diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp
index 245010beb0a45f830e49b3978d67ae63d7c41396..14fac84a7378d0ba81d004d9c4a8beddf941e013 100644
--- a/source/Lib/DecoderLib/VLCReader.cpp
+++ b/source/Lib/DecoderLib/VLCReader.cpp
@@ -1,35 +1,35 @@
 /* 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-2020, 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.
- */
+* 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-2020, 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     VLCWReader.cpp
  *  \brief    Reader for high level syntax
@@ -49,70 +49,70 @@
 
 #if ENABLE_TRACING
 
-void VLCReader::xReadCodeTr(uint32_t length, uint32_t &rValue, const char *pSymbolName)
+void  VLCReader::xReadCodeTr(uint32_t length, uint32_t& rValue, const char *pSymbolName)
 {
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-  xReadCode(length, rValue, pSymbolName);
+  xReadCode (length, rValue, pSymbolName);
 #else
-  xReadCode(length, rValue);
+  xReadCode (length, rValue);
 #endif
   if (length < 10)
   {
-    DTRACE(g_trace_ctx, D_HEADER, "%-50s u(%d)  : %u\n", pSymbolName, length, rValue);
+    DTRACE( g_trace_ctx, D_HEADER, "%-50s u(%d)  : %u\n", pSymbolName, length, rValue );
   }
   else
   {
-    DTRACE(g_trace_ctx, D_HEADER, "%-50s u(%d) : %u\n", pSymbolName, length, rValue);
+    DTRACE( g_trace_ctx, D_HEADER, "%-50s u(%d) : %u\n", pSymbolName, length, rValue );
   }
 }
 
-void VLCReader::xReadUvlcTr(uint32_t &rValue, const char *pSymbolName)
+void  VLCReader::xReadUvlcTr(uint32_t& rValue, const char *pSymbolName)
 {
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-  xReadUvlc(rValue, pSymbolName);
+  xReadUvlc (rValue, pSymbolName);
 #else
-  xReadUvlc(rValue);
+  xReadUvlc (rValue);
 #endif
-  DTRACE(g_trace_ctx, D_HEADER, "%-50s ue(v) : %u\n", pSymbolName, rValue);
+  DTRACE( g_trace_ctx, D_HEADER, "%-50s ue(v) : %u\n", pSymbolName, rValue );
 }
 
-void VLCReader::xReadSvlcTr(int &rValue, const char *pSymbolName)
+void  VLCReader::xReadSvlcTr(int& rValue, const char *pSymbolName)
 {
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-  xReadSvlc(rValue, pSymbolName);
+  xReadSvlc (rValue, pSymbolName);
 #else
-  xReadSvlc(rValue);
+  xReadSvlc (rValue);
 #endif
-  DTRACE(g_trace_ctx, D_HEADER, "%-50s se(v) : %d\n", pSymbolName, rValue);
+  DTRACE( g_trace_ctx, D_HEADER, "%-50s se(v) : %d\n", pSymbolName, rValue );
 }
 
-void VLCReader::xReadFlagTr(uint32_t &rValue, const char *pSymbolName)
+void  VLCReader::xReadFlagTr(uint32_t& rValue, const char *pSymbolName)
 {
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-  xReadFlag(rValue, pSymbolName);
+  xReadFlag (rValue, pSymbolName);
 #else
-  xReadFlag(rValue);
+  xReadFlag (rValue);
 #endif
-  DTRACE(g_trace_ctx, D_HEADER, "%-50s u(1)  : %d\n", pSymbolName, rValue);
+  DTRACE( g_trace_ctx, D_HEADER, "%-50s u(1)  : %d\n", pSymbolName, rValue );
 }
 
-void xTraceFillerData()
+void xTraceFillerData ()
 {
-  DTRACE(g_trace_ctx, D_HEADER, "=========== Filler Data ===========\n");
+  DTRACE( g_trace_ctx, D_HEADER, "=========== Filler Data ===========\n");
 }
 
 #endif
 
 #if RExt__DECODER_DEBUG_BIT_STATISTICS || ENABLE_TRACING
-void VLCReader::xReadSCode(uint32_t length, int &value, const char *pSymbolName)
+void VLCReader::xReadSCode (uint32_t length, int& value, const char *pSymbolName)
 #else
-void VLCReader::xReadSCode(uint32_t length, int &value)
+void VLCReader::xReadSCode (uint32_t length, int& value)
 #endif
 {
   uint32_t val;
-  assert(length > 0 && length <= 32);
-  m_pcBitstream->read(length, val);
-  value = length >= 32 ? int(val) : ((-int(val & (uint32_t(1) << (length - 1)))) | int(val));
+  assert ( length > 0 && length<=32);
+  m_pcBitstream->read (length, val);
+  value= length>=32 ? int(val) : ( (-int( val & (uint32_t(1)<<(length-1)))) | int(val) );
 
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
   CodingStatistics::IncrementStatisticEP(pSymbolName, length, value);
@@ -120,11 +120,11 @@ void VLCReader::xReadSCode(uint32_t length, int &value)
 #if ENABLE_TRACING
   if (length < 10)
   {
-    DTRACE(g_trace_ctx, D_HEADER, "%-50s i(%d)  : %d\n", pSymbolName, length, value);
+    DTRACE( g_trace_ctx, D_HEADER, "%-50s i(%d)  : %d\n", pSymbolName, length, value );
   }
   else
   {
-    DTRACE(g_trace_ctx, D_HEADER, "%-50s i(%d) : %d\n", pSymbolName, length, value);
+    DTRACE( g_trace_ctx, D_HEADER, "%-50s i(%d) : %d\n", pSymbolName, length, value );
   }
 #endif
 }
@@ -133,47 +133,47 @@ void VLCReader::xReadSCode(uint32_t length, int &value)
 // Protected member functions
 // ====================================================================================================================
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-void VLCReader::xReadCode(uint32_t uiLength, uint32_t &ruiCode, const char *pSymbolName)
+void VLCReader::xReadCode (uint32_t uiLength, uint32_t& ruiCode, const char *pSymbolName)
 #else
-void VLCReader::xReadCode(uint32_t uiLength, uint32_t &ruiCode)
+void VLCReader::xReadCode (uint32_t uiLength, uint32_t& ruiCode)
 #endif
 {
-  CHECK(uiLength == 0, "Reading a code of length '0'");
-  m_pcBitstream->read(uiLength, ruiCode);
+  CHECK( uiLength == 0, "Reading a code of length '0'" );
+  m_pcBitstream->read (uiLength, ruiCode);
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
   CodingStatistics::IncrementStatisticEP(pSymbolName, uiLength, ruiCode);
 #endif
 }
 
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-void VLCReader::xReadUvlc(uint32_t &ruiVal, const char *pSymbolName)
+void VLCReader::xReadUvlc( uint32_t& ruiVal, const char *pSymbolName)
 #else
-void VLCReader::xReadUvlc(uint32_t &ruiVal)
+void VLCReader::xReadUvlc( uint32_t& ruiVal)
 #endif
 {
-  uint32_t uiVal  = 0;
+  uint32_t uiVal = 0;
   uint32_t uiCode = 0;
   uint32_t uiLength;
-  m_pcBitstream->read(1, uiCode);
+  m_pcBitstream->read( 1, uiCode );
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-  uint32_t totalLen = 1;
+  uint32_t totalLen=1;
 #endif
 
-  if (0 == uiCode)
+  if( 0 == uiCode )
   {
     uiLength = 0;
 
-    while (!(uiCode & 1))
+    while( ! ( uiCode & 1 ))
     {
-      m_pcBitstream->read(1, uiCode);
+      m_pcBitstream->read( 1, uiCode );
       uiLength++;
     }
 
-    m_pcBitstream->read(uiLength, uiVal);
+    m_pcBitstream->read( uiLength, uiVal );
 
-    uiVal += (1 << uiLength) - 1;
+    uiVal += (1 << uiLength)-1;
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-    totalLen += uiLength + uiLength;
+    totalLen+=uiLength+uiLength;
 #endif
   }
 
@@ -184,32 +184,32 @@ void VLCReader::xReadUvlc(uint32_t &ruiVal)
 }
 
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-void VLCReader::xReadSvlc(int &riVal, const char *pSymbolName)
+void VLCReader::xReadSvlc( int& riVal, const char *pSymbolName)
 #else
-void VLCReader::xReadSvlc(int &riVal)
+void VLCReader::xReadSvlc( int& riVal)
 #endif
 {
   uint32_t uiBits = 0;
-  m_pcBitstream->read(1, uiBits);
+  m_pcBitstream->read( 1, uiBits );
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-  uint32_t totalLen = 1;
+  uint32_t totalLen=1;
 #endif
-  if (0 == uiBits)
+  if( 0 == uiBits )
   {
     uint32_t uiLength = 0;
 
-    while (!(uiBits & 1))
+    while( ! ( uiBits & 1 ))
     {
-      m_pcBitstream->read(1, uiBits);
+      m_pcBitstream->read( 1, uiBits );
       uiLength++;
     }
 
-    m_pcBitstream->read(uiLength, uiBits);
+    m_pcBitstream->read( uiLength, uiBits );
 
     uiBits += (1 << uiLength);
-    riVal = (uiBits & 1) ? -(int) (uiBits >> 1) : (int) (uiBits >> 1);
+    riVal = ( uiBits & 1) ? -(int)(uiBits>>1) : (int)(uiBits>>1);
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-    totalLen += uiLength + uiLength;
+    totalLen+=uiLength+uiLength;
 #endif
   }
   else
@@ -222,33 +222,33 @@ void VLCReader::xReadSvlc(int &riVal)
 }
 
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-void VLCReader::xReadFlag(uint32_t &ruiCode, const char *pSymbolName)
+void VLCReader::xReadFlag (uint32_t& ruiCode, const char *pSymbolName)
 #else
-void VLCReader::xReadFlag(uint32_t &ruiCode)
+void VLCReader::xReadFlag (uint32_t& ruiCode)
 #endif
 {
-  m_pcBitstream->read(1, ruiCode);
+  m_pcBitstream->read( 1, ruiCode );
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-  CodingStatistics::IncrementStatisticEP(pSymbolName, 1, int(/*ruiCode*/ 0));
+  CodingStatistics::IncrementStatisticEP(pSymbolName, 1, int(/*ruiCode*/0));
 #endif
 }
 
 void VLCReader::xReadRbspTrailingBits()
 {
   uint32_t bit;
-  READ_FLAG(bit, "rbsp_stop_one_bit");
-  CHECK(bit != 1, "Trailing bit not '1'");
+  READ_FLAG( bit, "rbsp_stop_one_bit");
+  CHECK(bit!=1, "Trailing bit not '1'");
   int cnt = 0;
   while (m_pcBitstream->getNumBitsUntilByteAligned())
   {
-    READ_FLAG(bit, "rbsp_alignment_zero_bit");
-    CHECK(bit != 0, "Alignment bit is not '0'");
+    READ_FLAG( bit, "rbsp_alignment_zero_bit");
+    CHECK(bit!=0, "Alignment bit is not '0'");
     cnt++;
   }
   CHECK(cnt >= 8, "Read more than '8' trailing bits");
 }
 
-void AUDReader::parseAccessUnitDelimiter(InputBitstream *bs, uint32_t &picType)
+void AUDReader::parseAccessUnitDelimiter(InputBitstream* bs, uint32_t &picType)
 {
   setBitstream(bs);
 
@@ -256,11 +256,11 @@ void AUDReader::parseAccessUnitDelimiter(InputBitstream *bs, uint32_t &picType)
   xTraceAccessUnitDelimiter();
 #endif
 
-  READ_CODE(3, picType, "pic_type");
+  READ_CODE (3, picType, "pic_type");
   xReadRbspTrailingBits();
 }
 
-void FDReader::parseFillerData(InputBitstream *bs, uint32_t &fdSize)
+void FDReader::parseFillerData(InputBitstream* bs, uint32_t &fdSize)
 {
   setBitstream(bs);
 #if ENABLE_TRACING
@@ -268,10 +268,10 @@ void FDReader::parseFillerData(InputBitstream *bs, uint32_t &fdSize)
 #endif
   uint32_t ffByte;
   fdSize = 0;
-  while (m_pcBitstream->getNumBitsLeft() > 8)
+  while( m_pcBitstream->getNumBitsLeft() >8 )
   {
-    READ_CODE(8, ffByte, "ff_byte");
-    CHECK(ffByte != 0xff, "Invalid filler data : not '0xff'");
+    READ_CODE (8, ffByte, "ff_byte");
+    CHECK(ffByte!=0xff, "Invalid filler data : not '0xff'");
     fdSize++;
   }
   xReadRbspTrailingBits();
@@ -281,45 +281,48 @@ void FDReader::parseFillerData(InputBitstream *bs, uint32_t &fdSize)
 // Constructor / destructor / create / destroy
 // ====================================================================================================================
 
-HLSyntaxReader::HLSyntaxReader() {}
+HLSyntaxReader::HLSyntaxReader()
+{
+}
+
+HLSyntaxReader::~HLSyntaxReader()
+{
 
-HLSyntaxReader::~HLSyntaxReader() {}
+}
 
 // ====================================================================================================================
 // Public member functions
 // ====================================================================================================================
 
-void HLSyntaxReader::copyRefPicList(SPS *sps, ReferencePictureList *source_rpl, ReferencePictureList *dest_rp)
+void HLSyntaxReader::copyRefPicList(SPS* sps, ReferencePictureList* source_rpl, ReferencePictureList* dest_rp)
 {
   dest_rp->setNumberOfShorttermPictures(source_rpl->getNumberOfShorttermPictures());
 
-  dest_rp->setNumberOfInterLayerPictures(sps->getInterLayerPresentFlag() ? dest_rp->getNumberOfInterLayerPictures()
-                                                                         : 0);
+  dest_rp->setNumberOfInterLayerPictures( sps->getInterLayerPresentFlag() ? dest_rp->getNumberOfInterLayerPictures() : 0 );
 
-  if (sps->getLongTermRefsPresent())
+  if( sps->getLongTermRefsPresent() )
   {
-    dest_rp->setNumberOfLongtermPictures(dest_rp->getNumberOfLongtermPictures());
+    dest_rp->setNumberOfLongtermPictures( dest_rp->getNumberOfLongtermPictures() );
   }
   else
     dest_rp->setNumberOfLongtermPictures(0);
 
   uint32_t numRefPic = dest_rp->getNumberOfShorttermPictures() + dest_rp->getNumberOfLongtermPictures();
 
-  for (int ii = 0; ii < numRefPic; ii++)
+  for( int ii = 0; ii < numRefPic; ii++ )
   {
-    dest_rp->setRefPicIdentifier(ii, source_rpl->getRefPicIdentifier(ii), source_rpl->isRefPicLongterm(ii),
-                                 source_rpl->isInterLayerRefPic(ii), source_rpl->getInterLayerRefPicIdx(ii));
+    dest_rp->setRefPicIdentifier( ii, source_rpl->getRefPicIdentifier( ii ), source_rpl->isRefPicLongterm( ii ), source_rpl->isInterLayerRefPic( ii ), source_rpl->getInterLayerRefPicIdx( ii ) );
   }
 }
 
-void HLSyntaxReader::parseRefPicList(SPS *sps, ReferencePictureList *rpl)
+void HLSyntaxReader::parseRefPicList(SPS* sps, ReferencePictureList* rpl)
 {
   uint32_t code;
   READ_UVLC(code, "num_ref_entries[ listIdx ][ rplsIdx ]");
   uint32_t numRefPic = code;
-  uint32_t numStrp   = 0;
-  uint32_t numLtrp   = 0;
-  uint32_t numIlrp   = 0;
+  uint32_t numStrp = 0;
+  uint32_t numLtrp = 0;
+  uint32_t numIlrp = 0;
 
   if (sps->getLongTermRefsPresent())
   {
@@ -328,329 +331,295 @@ void HLSyntaxReader::parseRefPicList(SPS *sps, ReferencePictureList *rpl)
   }
 
   bool isLongTerm;
-  int  prevDelta  = MAX_INT;
-  int  deltaValue = 0;
-  bool firstSTRP  = true;
+  int prevDelta = MAX_INT;
+  int deltaValue = 0;
+  bool firstSTRP = true;
 
-  rpl->setInterLayerPresentFlag(sps->getInterLayerPresentFlag());
+  rpl->setInterLayerPresentFlag( sps->getInterLayerPresentFlag() );
 
   for (int ii = 0; ii < numRefPic; ii++)
   {
     uint32_t isInterLayerRefPic = 0;
 
-    if (rpl->getInterLayerPresentFlag())
+    if( rpl->getInterLayerPresentFlag() )
     {
-      READ_FLAG(isInterLayerRefPic, "inter_layer_ref_pic_flag[ listIdx ][ rplsIdx ][ i ]");
+      READ_FLAG( isInterLayerRefPic, "inter_layer_ref_pic_flag[ listIdx ][ rplsIdx ][ i ]" );
 
-      if (isInterLayerRefPic)
+      if( isInterLayerRefPic )
       {
-        READ_UVLC(code, "ilrp_idx[ listIdx ][ rplsIdx ][ i ]");
-        rpl->setRefPicIdentifier(ii, 0, true, true, code);
+        READ_UVLC( code, "ilrp_idx[ listIdx ][ rplsIdx ][ i ]" );
+        rpl->setRefPicIdentifier( ii, 0, true, true, code );
         numIlrp++;
       }
     }
 
-    if (!isInterLayerRefPic)
+    if( !isInterLayerRefPic )
     {
+    isLongTerm = false;
+    if (sps->getLongTermRefsPresent())
+    {
+      READ_FLAG(code, "st_ref_pic_flag[ listIdx ][ rplsIdx ][ i ]");
+      isLongTerm = (code == 1) ? false : true;
+    }
+    else
       isLongTerm = false;
-      if (sps->getLongTermRefsPresent())
+
+    if (!isLongTerm)
+    {
+      READ_UVLC(code, "abs_delta_poc_st[ listIdx ][ rplsIdx ][ i ]");
+      if( !sps->getUseWP() && !sps->getUseWPBiPred() )
       {
-        READ_FLAG(code, "st_ref_pic_flag[ listIdx ][ rplsIdx ][ i ]");
-        isLongTerm = (code == 1) ? false : true;
+        code++;
       }
+      int readValue = code;
+      if (readValue > 0)
+        READ_FLAG(code, "strp_entry_sign_flag[ listIdx ][ rplsIdx ][ i ]");
       else
-        isLongTerm = false;
-
-      if (!isLongTerm)
+        code = 1;
+      readValue = (code) ? readValue : 0 - readValue; //true means positive delta POC -- false otherwise
+      if (firstSTRP)
       {
-        READ_UVLC(code, "abs_delta_poc_st[ listIdx ][ rplsIdx ][ i ]");
-        if (!sps->getUseWP() && !sps->getUseWPBiPred())
-        {
-          code++;
-        }
-        int readValue = code;
-        if (readValue > 0)
-          READ_FLAG(code, "strp_entry_sign_flag[ listIdx ][ rplsIdx ][ i ]");
-        else
-          code = 1;
-        readValue = (code) ? readValue : 0 - readValue;   // true means positive delta POC -- false otherwise
-        if (firstSTRP)
-        {
-          firstSTRP = false;
-          prevDelta = deltaValue = readValue;
-        }
-        else
-        {
-          deltaValue = prevDelta + readValue;
-          prevDelta  = deltaValue;
-        }
-
-        rpl->setRefPicIdentifier(ii, deltaValue, isLongTerm, false, 0);
-        numStrp++;
+        firstSTRP = false;
+        prevDelta = deltaValue = readValue;
       }
       else
       {
-        if (!rpl->getLtrpInSliceHeaderFlag())
-          READ_CODE(sps->getBitsForPOC(), code, "poc_lsb_lt[listIdx][rplsIdx][j]");
-        rpl->setRefPicIdentifier(ii, code, isLongTerm, false, 0);
-        numLtrp++;
+        deltaValue = prevDelta + readValue;
+        prevDelta = deltaValue;
       }
+
+      rpl->setRefPicIdentifier( ii, deltaValue, isLongTerm, false, 0 );
+      numStrp++;
+    }
+    else
+    {
+      if (!rpl->getLtrpInSliceHeaderFlag())
+        READ_CODE(sps->getBitsForPOC(), code, "poc_lsb_lt[listIdx][rplsIdx][j]");
+      rpl->setRefPicIdentifier( ii, code, isLongTerm, false, 0 );
+      numLtrp++;
+    }
     }
   }
   rpl->setNumberOfShorttermPictures(numStrp);
   rpl->setNumberOfLongtermPictures(numLtrp);
-  rpl->setNumberOfInterLayerPictures(numIlrp);
+  rpl->setNumberOfInterLayerPictures( numIlrp );
 }
 
-void HLSyntaxReader::parsePPS(PPS *pcPPS, ParameterSetManager *parameterSetManager)
+void HLSyntaxReader::parsePPS( PPS* pcPPS, ParameterSetManager *parameterSetManager )
 {
 #if ENABLE_TRACING
-  xTracePPSHeader();
+  xTracePPSHeader ();
 #endif
-  uint32_t uiCode;
+  uint32_t  uiCode;
 
-  int iCode;
+  int   iCode;
 
-  READ_UVLC(uiCode, "pps_pic_parameter_set_id");
+  READ_UVLC( uiCode, "pps_pic_parameter_set_id");
   CHECK(uiCode > 63, "PPS id exceeds boundary (63)");
-  pcPPS->setPPSId(uiCode);
+  pcPPS->setPPSId (uiCode);
 
   READ_CODE(4, uiCode, "pps_seq_parameter_set_id");
-  pcPPS->setSPSId(uiCode);
+  pcPPS->setSPSId (uiCode);
 
-  READ_UVLC(uiCode, "pic_width_in_luma_samples");
-  pcPPS->setPicWidthInLumaSamples(uiCode);
-  READ_UVLC(uiCode, "pic_height_in_luma_samples");
-  pcPPS->setPicHeightInLumaSamples(uiCode);
+  READ_UVLC( uiCode, "pic_width_in_luma_samples" );          pcPPS->setPicWidthInLumaSamples( uiCode );
+  READ_UVLC( uiCode, "pic_height_in_luma_samples" );         pcPPS->setPicHeightInLumaSamples( uiCode );
 
-  READ_FLAG(uiCode, "conformance_window_flag");
-  if (uiCode != 0)
+  READ_FLAG( uiCode, "conformance_window_flag" );
+  if( uiCode != 0 )
   {
     Window &conf = pcPPS->getConformanceWindow();
-    READ_UVLC(uiCode, "conf_win_left_offset");
-    conf.setWindowLeftOffset(uiCode);
-    READ_UVLC(uiCode, "conf_win_right_offset");
-    conf.setWindowRightOffset(uiCode);
-    READ_UVLC(uiCode, "conf_win_top_offset");
-    conf.setWindowTopOffset(uiCode);
-    READ_UVLC(uiCode, "conf_win_bottom_offset");
-    conf.setWindowBottomOffset(uiCode);
+    READ_UVLC( uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset( uiCode );
+    READ_UVLC( uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset( uiCode );
+    READ_UVLC( uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset( uiCode );
+    READ_UVLC( uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode );
   }
 
-  READ_FLAG(uiCode, "scaling_window_flag");
-  if (uiCode != 0)
+  READ_FLAG( uiCode, "scaling_window_flag" );
+  if( uiCode != 0 )
   {
     Window &scalingWindow = pcPPS->getScalingWindow();
-    READ_UVLC(uiCode, "scaling_win_left_offset");
-    scalingWindow.setWindowLeftOffset(uiCode);
-    READ_UVLC(uiCode, "scaling_win_right_offset");
-    scalingWindow.setWindowRightOffset(uiCode);
-    READ_UVLC(uiCode, "scaling_win_top_offset");
-    scalingWindow.setWindowTopOffset(uiCode);
-    READ_UVLC(uiCode, "scaling_win_bottom_offset");
-    scalingWindow.setWindowBottomOffset(uiCode);
+    READ_UVLC( uiCode, "scaling_win_left_offset" );               scalingWindow.setWindowLeftOffset( uiCode );
+    READ_UVLC( uiCode, "scaling_win_right_offset" );              scalingWindow.setWindowRightOffset( uiCode );
+    READ_UVLC( uiCode, "scaling_win_top_offset" );                scalingWindow.setWindowTopOffset( uiCode );
+    READ_UVLC( uiCode, "scaling_win_bottom_offset" );             scalingWindow.setWindowBottomOffset( uiCode );
   }
 
-  READ_FLAG(uiCode, "output_flag_present_flag");
-  pcPPS->setOutputFlagPresentFlag(uiCode == 1);
+  READ_FLAG( uiCode, "output_flag_present_flag" );                    pcPPS->setOutputFlagPresentFlag( uiCode==1 );
 
-  READ_FLAG(uiCode, "pps_subpic_id_signalling_present_flag");
-  pcPPS->setSubPicIdSignallingPresentFlag(uiCode != 0);
-  if (pcPPS->getSubPicIdSignallingPresentFlag())
+  READ_FLAG(uiCode, "pps_subpic_id_signalling_present_flag");              pcPPS->setSubPicIdSignallingPresentFlag( uiCode != 0 );
+  if( pcPPS->getSubPicIdSignallingPresentFlag() )
   {
-    READ_UVLC(uiCode, "pps_num_subpics_minus1");
-    pcPPS->setNumSubPics(uiCode + 1);
-    CHECK(uiCode > MAX_NUM_SUB_PICS - 1, "Number of sub-pictures exceeds limit");
+    READ_UVLC( uiCode, "pps_num_subpics_minus1" );                         pcPPS->setNumSubPics( uiCode + 1 );
+    CHECK( uiCode > MAX_NUM_SUB_PICS-1,  "Number of sub-pictures exceeds limit");
 
-    READ_UVLC(uiCode, "pps_subpic_id_len_minus1");
-    pcPPS->setSubPicIdLen(uiCode + 1);
-    CHECK(uiCode > 15, "Invalid pps_subpic_id_len_minus1 signalled");
+    READ_UVLC( uiCode, "pps_subpic_id_len_minus1" );                       pcPPS->setSubPicIdLen( uiCode + 1 );
+    CHECK( uiCode > 15, "Invalid pps_subpic_id_len_minus1 signalled");
 
 #if JVET_Q0169_SUBPIC_LEN_CONFORM
     CHECK((1 << pcPPS->getSubPicIdLen()) < pcPPS->getNumSubPics(), "pps_subpic_id_len exceeds valid range");
 #endif
-    for (int picIdx = 0; picIdx < pcPPS->getNumSubPics(); picIdx++)
+    for( int picIdx = 0; picIdx < pcPPS->getNumSubPics( ); picIdx++ )
     {
-      READ_CODE(pcPPS->getSubPicIdLen(), uiCode, "pps_subpic_id[i]");
-      pcPPS->setSubPicId(picIdx, uiCode);
+      READ_CODE( pcPPS->getSubPicIdLen( ), uiCode, "pps_subpic_id[i]" );   pcPPS->setSubPicId( picIdx, uiCode );
     }
   }
-  else
+  else 
   {
-    for (int picIdx = 0; picIdx < MAX_NUM_SUB_PICS; picIdx++)
+    for( int picIdx = 0; picIdx < MAX_NUM_SUB_PICS; picIdx++ )
     {
-      pcPPS->setSubPicId(picIdx, picIdx);
+      pcPPS->setSubPicId( picIdx, picIdx );
     }
 #if JVET_O1143_SUBPIC_BOUNDARY
     // set the value of pps_num_subpics_minus1 equal to sps_num_subpics_minus1
-    SPS *sps = parameterSetManager->getSPS(pcPPS->getSPSId());
+    SPS* sps = parameterSetManager->getSPS(pcPPS->getSPSId());
     pcPPS->setNumSubPics(sps->getNumSubPics());
 #endif
   }
 
-  READ_FLAG(uiCode, "no_pic_partition_flag");
-  pcPPS->setNoPicPartitionFlag(uiCode == 1);
-  if (!pcPPS->getNoPicPartitionFlag())
+
+  READ_FLAG( uiCode, "no_pic_partition_flag" );                       pcPPS->setNoPicPartitionFlag( uiCode == 1 );
+  if(!pcPPS->getNoPicPartitionFlag())
   {
     int colIdx, rowIdx;
     pcPPS->resetTileSliceInfo();
 
     // CTU size - required to match size in SPS
-    READ_CODE(2, uiCode, "pps_log2_ctu_size_minus5");
-    pcPPS->setLog2CtuSize(uiCode + 5);
+    READ_CODE(2, uiCode, "pps_log2_ctu_size_minus5");                 pcPPS->setLog2CtuSize(uiCode + 5);
     CHECK(uiCode > 2, "pps_log2_ctu_size_minus5 must be less than or equal to 2");
-
+    
     // number of explicit tile columns/rows
-    READ_UVLC(uiCode, "num_exp_tile_columns_minus1");
-    pcPPS->setNumExpTileColumns(uiCode + 1);
-    READ_UVLC(uiCode, "num_exp_tile_rows_minus1");
-    pcPPS->setNumExpTileRows(uiCode + 1);
-    CHECK(pcPPS->getNumExpTileColumns() > MAX_TILE_COLS, "Number of explicit tile columns exceeds valid range");
-    CHECK(pcPPS->getNumExpTileRows() > MAX_TILE_ROWS, "Number of explicit tile rows exceeds valid range");
-
+    READ_UVLC( uiCode, "num_exp_tile_columns_minus1" );               pcPPS->setNumExpTileColumns( uiCode + 1 );
+    READ_UVLC( uiCode, "num_exp_tile_rows_minus1" );                  pcPPS->setNumExpTileRows( uiCode + 1 );
+    CHECK(pcPPS->getNumExpTileColumns() > MAX_TILE_COLS,              "Number of explicit tile columns exceeds valid range");
+    CHECK(pcPPS->getNumExpTileRows() > MAX_TILE_ROWS,                 "Number of explicit tile rows exceeds valid range");
+    
     // tile sizes
-    for (colIdx = 0; colIdx < pcPPS->getNumExpTileColumns(); colIdx++)
+    for( colIdx = 0; colIdx < pcPPS->getNumExpTileColumns(); colIdx++ )
     {
-      READ_UVLC(uiCode, "tile_column_width_minus1[i]");
-      pcPPS->addTileColumnWidth(uiCode + 1);
+      READ_UVLC( uiCode, "tile_column_width_minus1[i]" );             pcPPS->addTileColumnWidth( uiCode + 1 );
     }
-    for (rowIdx = 0; rowIdx < pcPPS->getNumExpTileRows(); rowIdx++)
+    for( rowIdx = 0; rowIdx < pcPPS->getNumExpTileRows(); rowIdx++ )
     {
-      READ_UVLC(uiCode, "tile_row_height_minus1[i]");
-      pcPPS->addTileRowHeight(uiCode + 1);
+      READ_UVLC( uiCode, "tile_row_height_minus1[i]" );               pcPPS->addTileRowHeight( uiCode + 1 );
     }
     pcPPS->initTiles();
-
+     
     // rectangular slice signalling
-    READ_CODE(1, uiCode, "rect_slice_flag");
-    pcPPS->setRectSliceFlag(uiCode == 1);
-    if (pcPPS->getRectSliceFlag())
+    READ_CODE(1, uiCode, "rect_slice_flag");                          pcPPS->setRectSliceFlag( uiCode == 1 );
+    if (pcPPS->getRectSliceFlag()) 
     {
-      READ_FLAG(uiCode, "single_slice_per_subpic_flag");
-      pcPPS->setSingleSlicePerSubPicFlag(uiCode == 1);
+      READ_FLAG(uiCode, "single_slice_per_subpic_flag");            pcPPS->setSingleSlicePerSubPicFlag(uiCode == 1);
     }
     if (pcPPS->getRectSliceFlag() & !(pcPPS->getSingleSlicePerSubPicFlag()))
     {
       int32_t tileIdx = 0;
 
-      READ_UVLC(uiCode, "num_slices_in_pic_minus1");
-      pcPPS->setNumSlicesInPic(uiCode + 1);
-      CHECK(pcPPS->getNumSlicesInPic() > MAX_SLICES, "Number of slices in picture exceeds valid range");
-      READ_CODE(1, uiCode, "tile_idx_delta_present_flag");
-      pcPPS->setTileIdxDeltaPresentFlag(uiCode == 1);
+      READ_UVLC( uiCode, "num_slices_in_pic_minus1" );                pcPPS->setNumSlicesInPic( uiCode + 1 );
+      CHECK(pcPPS->getNumSlicesInPic() > MAX_SLICES,                  "Number of slices in picture exceeds valid range");
+      READ_CODE(1, uiCode, "tile_idx_delta_present_flag");            pcPPS->setTileIdxDeltaPresentFlag( uiCode == 1 );
       pcPPS->initRectSlices();
-
+      
       // read rectangular slice parameters
-      for (int i = 0; i < pcPPS->getNumSlicesInPic() - 1; i++)
+      for( int i = 0; i < pcPPS->getNumSlicesInPic()-1; i++ )
       {
-        pcPPS->setSliceTileIdx(i, tileIdx);
+        pcPPS->setSliceTileIdx( i, tileIdx );
 
         // complete tiles within a single slice
-        READ_UVLC(uiCode, "slice_width_in_tiles_minus1[i]");
-        pcPPS->setSliceWidthInTiles(i, uiCode + 1);
+        READ_UVLC( uiCode, "slice_width_in_tiles_minus1[i]" );        pcPPS->setSliceWidthInTiles ( i, uiCode + 1 );
 #if JVET_Q0480_RASTER_RECT_SLICES
-        if (pcPPS->getTileIdxDeltaPresentFlag() || ((tileIdx % pcPPS->getNumTileColumns()) == 0))
+        if( pcPPS->getTileIdxDeltaPresentFlag() || ( (tileIdx % pcPPS->getNumTileColumns()) == 0 ) )
         {
-          READ_UVLC(uiCode, "slice_height_in_tiles_minus1[i]");
-          pcPPS->setSliceHeightInTiles(i, uiCode + 1);
+          READ_UVLC( uiCode, "slice_height_in_tiles_minus1[i]" );     pcPPS->setSliceHeightInTiles( i, uiCode + 1 );
         }
-        else
+        else 
         {
-          pcPPS->setSliceHeightInTiles(i, pcPPS->getSliceHeightInTiles(i - 1));
+          pcPPS->setSliceHeightInTiles( i, pcPPS->getSliceHeightInTiles(i-1) );
         }
 #else
-        READ_UVLC(uiCode, "slice_height_in_tiles_minus1[i]");
-        pcPPS->setSliceHeightInTiles(i, uiCode + 1);
+        READ_UVLC( uiCode, "slice_height_in_tiles_minus1[i]" );       pcPPS->setSliceHeightInTiles( i, uiCode + 1 );
 #endif
 
         // multiple slices within a single tile special case
-        if (pcPPS->getSliceWidthInTiles(i) == 1 && pcPPS->getSliceHeightInTiles(i) == 1)
+        if( pcPPS->getSliceWidthInTiles( i ) == 1 && pcPPS->getSliceHeightInTiles( i ) == 1 ) 
         {
-          READ_UVLC(uiCode, "num_slices_in_tile_minus1[i]");
-          pcPPS->setNumSlicesInTile(i, uiCode + 1);
-          uint32_t numSlicesInTile = pcPPS->getNumSlicesInTile(i);
-          for (int j = 0; j < numSlicesInTile - 1; j++)
+          READ_UVLC( uiCode, "num_slices_in_tile_minus1[i]" );        pcPPS->setNumSlicesInTile( i, uiCode + 1 );
+          uint32_t numSlicesInTile = pcPPS->getNumSlicesInTile( i );
+          for( int j = 0; j < numSlicesInTile-1; j++ )
           {
-            READ_UVLC(uiCode, "slice_height_in_ctu_minus1[i]");
-            pcPPS->setSliceHeightInCtu(i, uiCode + 1);
+            READ_UVLC( uiCode, "slice_height_in_ctu_minus1[i]" );     pcPPS->setSliceHeightInCtu( i, uiCode + 1 );
             i++;
-            pcPPS->setSliceWidthInTiles(i, 1);
-            pcPPS->setSliceHeightInTiles(i, 1);
-            pcPPS->setNumSlicesInTile(i, numSlicesInTile);
-            pcPPS->setSliceTileIdx(i, tileIdx);
+            pcPPS->setSliceWidthInTiles ( i, 1 );
+            pcPPS->setSliceHeightInTiles( i, 1 );
+            pcPPS->setNumSlicesInTile   ( i, numSlicesInTile );
+            pcPPS->setSliceTileIdx      ( i, tileIdx );
           }
         }
 
         // tile index offset to start of next slice
-        if (i < pcPPS->getNumSlicesInPic() - 1)
+        if( i < pcPPS->getNumSlicesInPic()-1 )
         {
-          if (pcPPS->getTileIdxDeltaPresentFlag())
+          if( pcPPS->getTileIdxDeltaPresentFlag() ) 
           {
-            int32_t tileIdxDelta;
-            READ_SVLC(tileIdxDelta, "tile_idx_delta[i]");
+            int32_t  tileIdxDelta;
+            READ_SVLC( tileIdxDelta, "tile_idx_delta[i]" );
             tileIdx += tileIdxDelta;
-            CHECK(tileIdx < 0 || tileIdx >= pcPPS->getNumTiles(), "Invalid tile_idx_delta.");
+            CHECK( tileIdx < 0 || tileIdx >= pcPPS->getNumTiles(), "Invalid tile_idx_delta.");
           }
           else
           {
-            tileIdx += pcPPS->getSliceWidthInTiles(i);
-            if (tileIdx % pcPPS->getNumTileColumns() == 0)
+            tileIdx += pcPPS->getSliceWidthInTiles( i );
+            if( tileIdx % pcPPS->getNumTileColumns() == 0)
             {
-              tileIdx += (pcPPS->getSliceHeightInTiles(i) - 1) * pcPPS->getNumTileColumns();
+              tileIdx += (pcPPS->getSliceHeightInTiles( i ) - 1) * pcPPS->getNumTileColumns();
             }
           }
         }
       }
-      pcPPS->setSliceTileIdx(pcPPS->getNumSlicesInPic() - 1, tileIdx);
-
+      pcPPS->setSliceTileIdx(pcPPS->getNumSlicesInPic()-1, tileIdx );
+      
       // initialize mapping between rectangular slices and CTUs
       pcPPS->initRectSliceMap();
 #if JVET_O1143_SUBPIC_BOUNDARY
-      SPS *sps = parameterSetManager->getSPS(pcPPS->getSPSId());
+      SPS* sps = parameterSetManager->getSPS(pcPPS->getSPSId());
       CHECK(sps == 0, "Invalid SPS");
       pcPPS->initSubPic(*sps);
 #endif
     }
 
     // loop filtering across slice/tile controls
-    READ_CODE(1, uiCode, "loop_filter_across_tiles_enabled_flag");
-    pcPPS->setLoopFilterAcrossTilesEnabledFlag(uiCode == 1);
-    READ_CODE(1, uiCode, "loop_filter_across_slices_enabled_flag");
-    pcPPS->setLoopFilterAcrossSlicesEnabledFlag(uiCode == 1);
+    READ_CODE(1, uiCode, "loop_filter_across_tiles_enabled_flag");    pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode == 1 );
+    READ_CODE(1, uiCode, "loop_filter_across_slices_enabled_flag");   pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode == 1 );
   }
 
-  READ_FLAG(uiCode, "entropy_coding_sync_enabled_flag");
-  pcPPS->setEntropyCodingSyncEnabledFlag(uiCode == 1);
-  READ_FLAG(uiCode, "cabac_init_present_flag");
-  pcPPS->setCabacInitPresentFlag(uiCode ? true : false);
+  READ_FLAG(uiCode, "entropy_coding_sync_enabled_flag");       pcPPS->setEntropyCodingSyncEnabledFlag(uiCode == 1);
+  READ_FLAG( uiCode,   "cabac_init_present_flag" );            pcPPS->setCabacInitPresentFlag( uiCode ? true : false );
 
   READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1");
   CHECK(uiCode > 14, "Invalid code read");
-  pcPPS->setNumRefIdxL0DefaultActive(uiCode + 1);
+  pcPPS->setNumRefIdxL0DefaultActive(uiCode+1);
 
   READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1");
   CHECK(uiCode > 14, "Invalid code read");
-  pcPPS->setNumRefIdxL1DefaultActive(uiCode + 1);
+  pcPPS->setNumRefIdxL1DefaultActive(uiCode+1);
 
   READ_FLAG(uiCode, "rpl1_idx_present_flag");
   pcPPS->setRpl1IdxPresentFlag(uiCode);
 
-  READ_SVLC(iCode, "init_qp_minus26");
-  pcPPS->setPicInitQPMinus26(iCode);
+
+  READ_SVLC(iCode, "init_qp_minus26" );                            pcPPS->setPicInitQPMinus26(iCode);
   READ_UVLC(uiCode, "log2_transform_skip_max_size_minus2");
   pcPPS->setLog2MaxTransformSkipBlockSize(uiCode + 2);
 
-  READ_FLAG(uiCode, "cu_qp_delta_enabled_flag");
-  pcPPS->setUseDQP(uiCode ? true : false);
-  READ_SVLC(iCode, "pps_cb_qp_offset");
+  READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" );            pcPPS->setUseDQP( uiCode ? true : false );
+  READ_SVLC( iCode, "pps_cb_qp_offset");
   pcPPS->setQpOffset(COMPONENT_Cb, iCode);
-  CHECK(pcPPS->getQpOffset(COMPONENT_Cb) < -12, "Invalid Cb QP offset");
-  CHECK(pcPPS->getQpOffset(COMPONENT_Cb) > 12, "Invalid Cb QP offset");
+  CHECK( pcPPS->getQpOffset(COMPONENT_Cb) < -12, "Invalid Cb QP offset" );
+  CHECK( pcPPS->getQpOffset(COMPONENT_Cb) >  12, "Invalid Cb QP offset" );
 
-  READ_SVLC(iCode, "pps_cr_qp_offset");
+  READ_SVLC( iCode, "pps_cr_qp_offset");
   pcPPS->setQpOffset(COMPONENT_Cr, iCode);
-  CHECK(pcPPS->getQpOffset(COMPONENT_Cr) < -12, "Invalid Cr QP offset");
-  CHECK(pcPPS->getQpOffset(COMPONENT_Cr) > 12, "Invalid Cr QP offset");
+  CHECK( pcPPS->getQpOffset(COMPONENT_Cr) < -12, "Invalid Cr QP offset" );
+  CHECK( pcPPS->getQpOffset(COMPONENT_Cr) >  12, "Invalid Cr QP offset" );
 
   READ_FLAG(uiCode, "pps_joint_cbcr_qp_offset_present_flag");
   pcPPS->setJointCbCrQpOffsetPresentFlag(uiCode ? true : false);
@@ -665,15 +634,15 @@ void HLSyntaxReader::parsePPS(PPS *pcPPS, ParameterSetManager *parameterSetManag
   }
   pcPPS->setQpOffset(JOINT_CbCr, iCode);
 
-  CHECK(pcPPS->getQpOffset(JOINT_CbCr) < -12, "Invalid CbCr QP offset");
-  CHECK(pcPPS->getQpOffset(JOINT_CbCr) > 12, "Invalid CbCr QP offset");
+  CHECK( pcPPS->getQpOffset(JOINT_CbCr) < -12, "Invalid CbCr QP offset" );
+  CHECK( pcPPS->getQpOffset(JOINT_CbCr) >  12, "Invalid CbCr QP offset" );
 
-  CHECK(MAX_NUM_COMPONENT > 3, "Invalid maximal number of components");
+  CHECK(MAX_NUM_COMPONENT>3, "Invalid maximal number of components");
 
-  READ_FLAG(uiCode, "pps_slice_chroma_qp_offsets_present_flag");
-  pcPPS->setSliceChromaQpFlag(uiCode ? true : false);
+  READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" );
+  pcPPS->setSliceChromaQpFlag( uiCode ? true : false );
 
-  READ_FLAG(uiCode, "pps_cu_chroma_qp_offset_enabled_flag");
+  READ_FLAG( uiCode, "pps_cu_chroma_qp_offset_enabled_flag");
   if (uiCode == 0)
   {
     pcPPS->clearChromaQpOffsetList();
@@ -708,103 +677,77 @@ void HLSyntaxReader::parsePPS(PPS *pcPPS, ParameterSetManager *parameterSetManag
     CHECK(pcPPS->getChromaQpOffsetListLen() != tableSizeMinus1 + 1, "Invalid chroma QP offset list length");
   }
 
-  READ_FLAG(uiCode, "weighted_pred_flag");   // Use of Weighting Prediction (P_SLICE)
-  pcPPS->setUseWP(uiCode == 1);
-  READ_FLAG(uiCode, "weighted_bipred_flag");   // Use of Bi-Directional Weighting Prediction (B_SLICE)
-  pcPPS->setWPBiPred(uiCode == 1);
+  READ_FLAG( uiCode, "weighted_pred_flag" );          // Use of Weighting Prediction (P_SLICE)
+  pcPPS->setUseWP( uiCode==1 );
+  READ_FLAG( uiCode, "weighted_bipred_flag" );         // Use of Bi-Directional Weighting Prediction (B_SLICE)
+  pcPPS->setWPBiPred( uiCode==1 );
 
-  READ_FLAG(uiCode, "deblocking_filter_control_present_flag");
-  pcPPS->setDeblockingFilterControlPresentFlag(uiCode ? true : false);
-  if (pcPPS->getDeblockingFilterControlPresentFlag())
+  READ_FLAG( uiCode, "deblocking_filter_control_present_flag" );       pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false );
+  if(pcPPS->getDeblockingFilterControlPresentFlag())
   {
-    READ_FLAG(uiCode, "deblocking_filter_override_enabled_flag");
-    pcPPS->setDeblockingFilterOverrideEnabledFlag(uiCode ? true : false);
-    READ_FLAG(uiCode, "pps_deblocking_filter_disabled_flag");
-    pcPPS->setPPSDeblockingFilterDisabledFlag(uiCode ? true : false);
-    if (!pcPPS->getPPSDeblockingFilterDisabledFlag())
+    READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" );    pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false );
+    READ_FLAG( uiCode, "pps_deblocking_filter_disabled_flag" );        pcPPS->setPPSDeblockingFilterDisabledFlag(uiCode ? true : false );
+    if(!pcPPS->getPPSDeblockingFilterDisabledFlag())
     {
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-      READ_SVLC(iCode, "pps_beta_offset_div2");
-      pcPPS->setDeblockingFilterBetaOffsetDiv2(iCode);
-      CHECK(pcPPS->getDeblockingFilterBetaOffsetDiv2() < -12 || pcPPS->getDeblockingFilterBetaOffsetDiv2() > 12,
-            "Invalid deblocking filter configuration");
-
-      READ_SVLC(iCode, "pps_tc_offset_div2");
-      pcPPS->setDeblockingFilterTcOffsetDiv2(iCode);
-      CHECK(pcPPS->getDeblockingFilterTcOffsetDiv2() < -12 || pcPPS->getDeblockingFilterTcOffsetDiv2() > 12,
-            "Invalid deblocking filter configuration");
-
-      READ_SVLC(iCode, "pps_cb_beta_offset_div2");
-      pcPPS->setDeblockingFilterCbBetaOffsetDiv2(iCode);
-      CHECK(pcPPS->getDeblockingFilterCbBetaOffsetDiv2() < -12 || pcPPS->getDeblockingFilterCbBetaOffsetDiv2() > 12,
-            "Invalid deblocking filter configuration");
-
-      READ_SVLC(iCode, "pps_cb_tc_offset_div2");
-      pcPPS->setDeblockingFilterCbTcOffsetDiv2(iCode);
-      CHECK(pcPPS->getDeblockingFilterCbTcOffsetDiv2() < -12 || pcPPS->getDeblockingFilterCbTcOffsetDiv2() > 12,
-            "Invalid deblocking filter configuration");
-
-      READ_SVLC(iCode, "pps_cr_beta_offset_div2");
-      pcPPS->setDeblockingFilterCrBetaOffsetDiv2(iCode);
-      CHECK(pcPPS->getDeblockingFilterCrBetaOffsetDiv2() < -12 || pcPPS->getDeblockingFilterCrBetaOffsetDiv2() > 12,
-            "Invalid deblocking filter configuration");
-
-      READ_SVLC(iCode, "pps_cr_tc_offset_div2");
-      pcPPS->setDeblockingFilterCrTcOffsetDiv2(iCode);
-      CHECK(pcPPS->getDeblockingFilterCrTcOffsetDiv2() < -12 || pcPPS->getDeblockingFilterCrTcOffsetDiv2() > 12,
-            "Invalid deblocking filter configuration");
+      READ_SVLC( iCode, "pps_beta_offset_div2" );                    pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode );
+      CHECK(  pcPPS->getDeblockingFilterBetaOffsetDiv2() < -12 ||
+              pcPPS->getDeblockingFilterBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration" );
+
+      READ_SVLC( iCode, "pps_tc_offset_div2");                       pcPPS->setDeblockingFilterTcOffsetDiv2( iCode );
+      CHECK(  pcPPS->getDeblockingFilterTcOffsetDiv2() < -12 ||
+              pcPPS->getDeblockingFilterTcOffsetDiv2() > 12, "Invalid deblocking filter configuration" );
+
+      READ_SVLC( iCode, "pps_cb_beta_offset_div2");                   pcPPS->setDeblockingFilterCbBetaOffsetDiv2( iCode );
+      CHECK(  pcPPS->getDeblockingFilterCbBetaOffsetDiv2() < -12 ||
+              pcPPS->getDeblockingFilterCbBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration" );
+
+      READ_SVLC( iCode, "pps_cb_tc_offset_div2");                     pcPPS->setDeblockingFilterCbTcOffsetDiv2( iCode );
+      CHECK(  pcPPS->getDeblockingFilterCbTcOffsetDiv2() < -12 ||
+              pcPPS->getDeblockingFilterCbTcOffsetDiv2() > 12, "Invalid deblocking filter configuration" );
+
+      READ_SVLC( iCode, "pps_cr_beta_offset_div2");                   pcPPS->setDeblockingFilterCrBetaOffsetDiv2( iCode );
+      CHECK(  pcPPS->getDeblockingFilterCrBetaOffsetDiv2() < -12 ||
+              pcPPS->getDeblockingFilterCrBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration" );
+
+      READ_SVLC( iCode, "pps_cr_tc_offset_div2");                     pcPPS->setDeblockingFilterCrTcOffsetDiv2( iCode );
+      CHECK(  pcPPS->getDeblockingFilterCrTcOffsetDiv2() < -12 ||
+              pcPPS->getDeblockingFilterCrTcOffsetDiv2() > 12, "Invalid deblocking filter configuration" );
 #else
-      READ_SVLC(iCode, "pps_beta_offset_div2");
-      pcPPS->setDeblockingFilterBetaOffsetDiv2(iCode);
-      READ_SVLC(iCode, "pps_tc_offset_div2");
-      pcPPS->setDeblockingFilterTcOffsetDiv2(iCode);
+      READ_SVLC ( iCode, "pps_beta_offset_div2" );                     pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode );
+      READ_SVLC ( iCode, "pps_tc_offset_div2" );                       pcPPS->setDeblockingFilterTcOffsetDiv2( iCode );
 #endif
     }
   }
 
 #if JVET_Q0819_PH_CHANGES
-  READ_FLAG(uiCode, "rpl_info_in_ph_flag");
-  pcPPS->setRplInfoInPhFlag(uiCode ? true : false);
-  if (pcPPS->getDeblockingFilterOverrideEnabledFlag())
+  READ_FLAG(uiCode, "rpl_info_in_ph_flag");                    pcPPS->setRplInfoInPhFlag(uiCode ? true : false);
+  if( pcPPS->getDeblockingFilterOverrideEnabledFlag() )
   {
     READ_FLAG(uiCode, "dbf_info_in_ph_flag");
     pcPPS->setDbfInfoInPhFlag(uiCode ? true : false);
   }
-  READ_FLAG(uiCode, "sao_info_in_ph_flag");
-  pcPPS->setSaoInfoInPhFlag(uiCode ? true : false);
-  READ_FLAG(uiCode, "alf_info_in_ph_flag");
-  pcPPS->setAlfInfoInPhFlag(uiCode ? true : false);
+  READ_FLAG(uiCode, "sao_info_in_ph_flag");                    pcPPS->setSaoInfoInPhFlag(uiCode ? true : false);
+  READ_FLAG(uiCode, "alf_info_in_ph_flag");                    pcPPS->setAlfInfoInPhFlag(uiCode ? true : false);
   if ((pcPPS->getUseWP() || pcPPS->getWPBiPred()) && pcPPS->getRplInfoInPhFlag())
   {
-    READ_FLAG(uiCode, "wp_info_in_ph_flag");
-    pcPPS->setWpInfoInPhFlag(uiCode ? true : false);
+    READ_FLAG(uiCode, "wp_info_in_ph_flag");                   pcPPS->setWpInfoInPhFlag(uiCode ? true : false);
   }
-  READ_FLAG(uiCode, "qp_delta_info_in_ph_flag");
-  pcPPS->setQpDeltaInfoInPhFlag(uiCode ? true : false);
+  READ_FLAG(uiCode, "qp_delta_info_in_ph_flag");               pcPPS->setQpDeltaInfoInPhFlag(uiCode ? true : false);
 #endif
 
-  READ_FLAG(uiCode, "constant_slice_header_params_enabled_flag");
-  pcPPS->setConstantSliceHeaderParamsEnabledFlag(uiCode);
-  if (pcPPS->getConstantSliceHeaderParamsEnabledFlag())
-  {
-    READ_CODE(2, uiCode, "pps_dep_quant_enabled_idc");
-    pcPPS->setPPSDepQuantEnabledIdc(uiCode);
-    READ_CODE(2, uiCode, "pps_ref_pic_list_sps_idc[0]");
-    pcPPS->setPPSRefPicListSPSIdc0(uiCode);
-    READ_CODE(2, uiCode, "pps_ref_pic_list_sps_idc[1]");
-    pcPPS->setPPSRefPicListSPSIdc1(uiCode);
-    READ_CODE(2, uiCode, "pps_mvd_l1_zero_idc");
-    pcPPS->setPPSMvdL1ZeroIdc(uiCode);
-    READ_CODE(2, uiCode, "pps_collocated_from_l0_idc");
-    pcPPS->setPPSCollocatedFromL0Idc(uiCode);
-    READ_UVLC(uiCode, "pps_six_minus_max_num_merge_cand_plus1");
-    pcPPS->setPPSSixMinusMaxNumMergeCandPlus1(uiCode);
+  READ_FLAG( uiCode, "constant_slice_header_params_enabled_flag"); pcPPS->setConstantSliceHeaderParamsEnabledFlag(uiCode);
+  if ( pcPPS->getConstantSliceHeaderParamsEnabledFlag() ) {
+    READ_CODE( 2, uiCode, "pps_dep_quant_enabled_idc");        pcPPS->setPPSDepQuantEnabledIdc(uiCode);
+    READ_CODE( 2, uiCode, "pps_ref_pic_list_sps_idc[0]");      pcPPS->setPPSRefPicListSPSIdc0(uiCode);
+    READ_CODE( 2, uiCode, "pps_ref_pic_list_sps_idc[1]");      pcPPS->setPPSRefPicListSPSIdc1(uiCode);
+    READ_CODE( 2, uiCode, "pps_mvd_l1_zero_idc");              pcPPS->setPPSMvdL1ZeroIdc(uiCode);
+    READ_CODE( 2, uiCode, "pps_collocated_from_l0_idc");       pcPPS->setPPSCollocatedFromL0Idc(uiCode);
+    READ_UVLC( uiCode, "pps_six_minus_max_num_merge_cand_plus1"); pcPPS->setPPSSixMinusMaxNumMergeCandPlus1(uiCode);
 #if !JVET_Q0806
-    READ_UVLC(uiCode, "pps_max_num_merge_cand_minus_max_num_triangle_cand_plus1");
-    pcPPS->setPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1(uiCode);
+    READ_UVLC( uiCode, "pps_max_num_merge_cand_minus_max_num_triangle_cand_plus1");pcPPS->setPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1(uiCode);
 #else
-    READ_UVLC(uiCode, "pps_max_num_merge_cand_minus_max_num_gpm_cand_plus1");
-    pcPPS->setPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1(uiCode);
+    READ_UVLC(uiCode, "pps_max_num_merge_cand_minus_max_num_gpm_cand_plus1"); pcPPS->setPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1(uiCode);
 #endif
   }
   else
@@ -822,30 +765,36 @@ void HLSyntaxReader::parsePPS(PPS *pcPPS, ParameterSetManager *parameterSetManag
 #endif
   }
 
-  READ_FLAG(uiCode, "picture_header_extension_present_flag");
+
+  READ_FLAG( uiCode, "picture_header_extension_present_flag");
   pcPPS->setPictureHeaderExtensionPresentFlag(uiCode);
-  READ_FLAG(uiCode, "slice_header_extension_present_flag");
+  READ_FLAG( uiCode, "slice_header_extension_present_flag");
   pcPPS->setSliceHeaderExtensionPresentFlag(uiCode);
 
-  READ_FLAG(uiCode, "pps_extension_present_flag");
+
+  READ_FLAG( uiCode, "pps_extension_present_flag");
   if (uiCode)
   {
 #if ENABLE_TRACING || RExt__DECODER_DEBUG_BIT_STATISTICS
-    static const char *syntaxStrings[] = { "pps_range_extension_flag", "pps_multilayer_extension_flag",
-                                           "pps_extension_6bits[0]",   "pps_extension_6bits[1]",
-                                           "pps_extension_6bits[2]",   "pps_extension_6bits[3]",
-                                           "pps_extension_6bits[4]",   "pps_extension_6bits[5]" };
+    static const char *syntaxStrings[]={ "pps_range_extension_flag",
+      "pps_multilayer_extension_flag",
+      "pps_extension_6bits[0]",
+      "pps_extension_6bits[1]",
+      "pps_extension_6bits[2]",
+      "pps_extension_6bits[3]",
+      "pps_extension_6bits[4]",
+      "pps_extension_6bits[5]" };
 #endif
 
     bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS];
-    for (int i = 0; i < NUM_PPS_EXTENSION_FLAGS; i++)
+    for(int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++)
     {
-      READ_FLAG(uiCode, syntaxStrings[i]);
-      pps_extension_flags[i] = uiCode != 0;
+      READ_FLAG( uiCode, syntaxStrings[i] );
+      pps_extension_flags[i] = uiCode!=0;
     }
 
-    bool bSkipTrailingExtensionBits = false;
-    for (int i = 0; i < NUM_PPS_EXTENSION_FLAGS; i++)   // loop used so that the order is determined by the enum.
+    bool bSkipTrailingExtensionBits=false;
+    for(int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum.
     {
       if (pps_extension_flags[i])
       {
@@ -856,54 +805,56 @@ void HLSyntaxReader::parsePPS(PPS *pcPPS, ParameterSetManager *parameterSetManag
           PPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension();
           CHECK(bSkipTrailingExtensionBits, "Invalid state");
 
-          READ_FLAG(uiCode, "cross_component_prediction_enabled_flag");
+          READ_FLAG( uiCode, "cross_component_prediction_enabled_flag");
           ppsRangeExtension.setCrossComponentPredictionEnabledFlag(uiCode != 0);
 
-          READ_UVLC(uiCode, "log2_sao_offset_scale_luma");
+          READ_UVLC( uiCode, "log2_sao_offset_scale_luma");
           ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, uiCode);
-          READ_UVLC(uiCode, "log2_sao_offset_scale_chroma");
+          READ_UVLC( uiCode, "log2_sao_offset_scale_chroma");
           ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, uiCode);
         }
         break;
-        default: bSkipTrailingExtensionBits = true; break;
+        default:
+          bSkipTrailingExtensionBits=true;
+          break;
         }
       }
     }
     if (bSkipTrailingExtensionBits)
     {
-      while (xMoreRbspData())
+      while ( xMoreRbspData() )
       {
-        READ_FLAG(uiCode, "pps_extension_data_flag");
+        READ_FLAG( uiCode, "pps_extension_data_flag");
       }
     }
   }
   xReadRbspTrailingBits();
 }
 
-void HLSyntaxReader::parseAPS(APS *aps)
+void HLSyntaxReader::parseAPS( APS* aps )
 {
 #if ENABLE_TRACING
   xTraceAPSHeader();
 #endif
 
-  uint32_t code;
+  uint32_t  code;
 
   READ_CODE(5, code, "adaptation_parameter_set_id");
   aps->setAPSId(code);
 
   READ_CODE(3, code, "aps_params_type");
-  aps->setAPSType(ApsType(code));
-  if (code == ALF_APS)
+  aps->setAPSType( ApsType(code) );
+  if( code == ALF_APS )
   {
-    parseAlfAps(aps);
+    parseAlfAps( aps );
   }
-  else if (code == LMCS_APS)
+  else if( code == LMCS_APS )
   {
-    parseLmcsAps(aps);
+    parseLmcsAps( aps );
   }
-  else if (code == SCALING_LIST_APS)
+  else if( code == SCALING_LIST_APS )
   {
-    parseScalingListAps(aps);
+    parseScalingListAps( aps );
   }
   READ_FLAG(code, "aps_extension_flag");
   if (code)
@@ -916,9 +867,9 @@ void HLSyntaxReader::parseAPS(APS *aps)
   xReadRbspTrailingBits();
 }
 
-void HLSyntaxReader::parseAlfAps(APS *aps)
+void HLSyntaxReader::parseAlfAps( APS* aps )
 {
-  uint32_t code;
+  uint32_t  code;
 
   AlfParam param = aps->getAlfAPSParam();
   param.reset();
@@ -952,7 +903,7 @@ void HLSyntaxReader::parseAlfAps(APS *aps)
     param.numLumaFilters = code + 1;
     if (param.numLumaFilters > 1)
     {
-      const int length = ceilLog2(param.numLumaFilters);
+      const int length =  ceilLog2(param.numLumaFilters);
       for (int i = 0; i < MAX_NUM_ALF_CLASSES; i++)
       {
         READ_CODE(length, code, "alf_luma_coeff_delta_idx");
@@ -963,7 +914,7 @@ void HLSyntaxReader::parseAlfAps(APS *aps)
     {
       memset(param.filterCoeffDeltaIdx, 0, sizeof(param.filterCoeffDeltaIdx));
     }
-    alfFilter(param, false, 0);
+    alfFilter( param, false, 0 );
   }
   if (param.newFilterFlag[CHANNEL_TYPE_CHROMA])
   {
@@ -972,20 +923,20 @@ void HLSyntaxReader::parseAlfAps(APS *aps)
     param.nonLinearFlag[CHANNEL_TYPE_CHROMA] = code ? true : false;
 #endif
 
-    if (MAX_NUM_ALF_ALTERNATIVES_CHROMA > 1)
-      READ_UVLC(code, "alf_chroma_num_alts_minus1");
+    if( MAX_NUM_ALF_ALTERNATIVES_CHROMA > 1 )
+      READ_UVLC( code, "alf_chroma_num_alts_minus1" );
     else
       code = 0;
 
     param.numAlternativesChroma = code + 1;
 
-    for (int altIdx = 0; altIdx < param.numAlternativesChroma; ++altIdx)
+    for( int altIdx=0; altIdx < param.numAlternativesChroma; ++altIdx )
     {
 #if !JVET_Q0249_ALF_CHROMA_CLIPFLAG
       READ_FLAG(code, "alf_nonlinear_enable_flag_chroma");
       param.nonLinearFlag[CHANNEL_TYPE_CHROMA][altIdx] = code ? true : false;
 #endif
-      alfFilter(param, true, altIdx);
+      alfFilter( param, true, altIdx );
     }
   }
 
@@ -1047,18 +998,15 @@ void HLSyntaxReader::parseAlfAps(APS *aps)
   aps->setAlfAPSParam(param);
 }
 
-void HLSyntaxReader::parseLmcsAps(APS *aps)
+void HLSyntaxReader::parseLmcsAps( APS* aps )
 {
-  uint32_t code;
+  uint32_t  code;
 
-  SliceReshapeInfo &info = aps->getReshaperAPSInfo();
+  SliceReshapeInfo& info = aps->getReshaperAPSInfo();
   memset(info.reshaperModelBinCWDelta, 0, PIC_CODE_CW_BINS * sizeof(int));
-  READ_UVLC(code, "lmcs_min_bin_idx");
-  info.reshaperModelMinBinIdx = code;
-  READ_UVLC(code, "lmcs_delta_max_bin_idx");
-  info.reshaperModelMaxBinIdx = PIC_CODE_CW_BINS - 1 - code;
-  READ_UVLC(code, "lmcs_delta_cw_prec_minus1");
-  info.maxNbitsNeededDeltaCW = code + 1;
+  READ_UVLC(code, "lmcs_min_bin_idx");                             info.reshaperModelMinBinIdx = code;
+  READ_UVLC(code, "lmcs_delta_max_bin_idx");                       info.reshaperModelMaxBinIdx = PIC_CODE_CW_BINS - 1 - code;
+  READ_UVLC(code, "lmcs_delta_cw_prec_minus1");                    info.maxNbitsNeededDeltaCW = code + 1;
   assert(info.maxNbitsNeededDeltaCW > 0);
   for (uint32_t i = info.reshaperModelMinBinIdx; i <= info.reshaperModelMaxBinIdx; i++)
   {
@@ -1068,7 +1016,7 @@ void HLSyntaxReader::parseLmcsAps(APS *aps)
     {
       READ_CODE(1, code, "lmcs_delta_sign_cw_flag[ i ]");
     }
-    int signCW                      = code;
+    int signCW = code;
     info.reshaperModelBinCWDelta[i] = (1 - 2 * signCW) * absCW;
   }
   READ_CODE(3, code, "lmcs_delta_abs_crs");
@@ -1077,158 +1025,127 @@ void HLSyntaxReader::parseLmcsAps(APS *aps)
   {
     READ_CODE(1, code, "lmcs_delta_sign_crs_flag");
   }
-  int signCW               = code;
+  int signCW = code;
   info.chrResScalingOffset = (1 - 2 * signCW) * absCW;
 
   aps->setReshaperAPSInfo(info);
 }
 
-void HLSyntaxReader::parseScalingListAps(APS *aps)
+void HLSyntaxReader::parseScalingListAps( APS* aps )
 {
-  ScalingList &info = aps->getScalingList();
-  parseScalingList(&info);
+  ScalingList& info = aps->getScalingList();
+  parseScalingList( &info );
 }
 
-void HLSyntaxReader::parseVUI(VUI *pcVUI, SPS *pcSPS)
+void  HLSyntaxReader::parseVUI(VUI* pcVUI, SPS *pcSPS)
 {
 #if ENABLE_TRACING
-  DTRACE(g_trace_ctx, D_HEADER, "----------- vui_parameters -----------\n");
+  DTRACE( g_trace_ctx, D_HEADER, "----------- vui_parameters -----------\n");
 #endif
 
-  uint32_t symbol;
 
-  READ_FLAG(symbol, "aspect_ratio_info_present_flag");
-  pcVUI->setAspectRatioInfoPresentFlag(symbol);
+  uint32_t  symbol;
+
+  READ_FLAG( symbol, "aspect_ratio_info_present_flag");           pcVUI->setAspectRatioInfoPresentFlag(symbol);
   if (pcVUI->getAspectRatioInfoPresentFlag())
   {
-    READ_FLAG(symbol, "aspect_ratio_constant_flag");
-    pcVUI->setAspectRatioConstantFlag(symbol);
-    READ_CODE(8, symbol, "aspect_ratio_idc");
-    pcVUI->setAspectRatioIdc(symbol);
+    READ_FLAG( symbol, "aspect_ratio_constant_flag");           pcVUI->setAspectRatioConstantFlag(symbol);
+    READ_CODE(8, symbol, "aspect_ratio_idc");                         pcVUI->setAspectRatioIdc(symbol);
     if (pcVUI->getAspectRatioIdc() == 255)
     {
-      READ_CODE(16, symbol, "sar_width");
-      pcVUI->setSarWidth(symbol);
-      READ_CODE(16, symbol, "sar_height");
-      pcVUI->setSarHeight(symbol);
+      READ_CODE(16, symbol, "sar_width");                             pcVUI->setSarWidth(symbol);
+      READ_CODE(16, symbol, "sar_height");                            pcVUI->setSarHeight(symbol);
     }
   }
 
-  READ_FLAG(symbol, "colour_description_present_flag");
-  pcVUI->setColourDescriptionPresentFlag(symbol);
+  READ_FLAG(   symbol, "colour_description_present_flag");          pcVUI->setColourDescriptionPresentFlag(symbol);
   if (pcVUI->getColourDescriptionPresentFlag())
   {
-    READ_CODE(8, symbol, "colour_primaries");
-    pcVUI->setColourPrimaries(symbol);
-    READ_CODE(8, symbol, "transfer_characteristics");
-    pcVUI->setTransferCharacteristics(symbol);
-    READ_CODE(8, symbol, "matrix_coeffs");
-    pcVUI->setMatrixCoefficients(symbol);
-    READ_FLAG(symbol, "video_full_range_flag");
-    pcVUI->setVideoFullRangeFlag(symbol);
+    READ_CODE(8, symbol, "colour_primaries");                       pcVUI->setColourPrimaries(symbol);
+    READ_CODE(8, symbol, "transfer_characteristics");               pcVUI->setTransferCharacteristics(symbol);
+    READ_CODE(8, symbol, "matrix_coeffs");                          pcVUI->setMatrixCoefficients(symbol);
+    READ_FLAG(   symbol, "video_full_range_flag");                    pcVUI->setVideoFullRangeFlag(symbol);
   }
 
-  READ_FLAG(symbol, "field_seq_flag");
-  pcVUI->setFieldSeqFlag(symbol);
+  READ_FLAG(     symbol, "field_seq_flag");                           pcVUI->setFieldSeqFlag(symbol);
 
-  READ_FLAG(symbol, "chroma_loc_info_present_flag");
-  pcVUI->setChromaLocInfoPresentFlag(symbol);
+  READ_FLAG(     symbol, "chroma_loc_info_present_flag");             pcVUI->setChromaLocInfoPresentFlag(symbol);
   if (pcVUI->getChromaLocInfoPresentFlag())
   {
-    if (pcVUI->getFieldSeqFlag())
+    if(pcVUI->getFieldSeqFlag())
     {
-      READ_UVLC(symbol, "chroma_sample_loc_type_top_field");
-      pcVUI->setChromaSampleLocTypeTopField(symbol);
-      READ_UVLC(symbol, "chroma_sample_loc_type_bottom_field");
-      pcVUI->setChromaSampleLocTypeBottomField(symbol);
+      READ_UVLC(   symbol, "chroma_sample_loc_type_top_field" );        pcVUI->setChromaSampleLocTypeTopField(symbol);
+      READ_UVLC(   symbol, "chroma_sample_loc_type_bottom_field" );     pcVUI->setChromaSampleLocTypeBottomField(symbol);
     }
     else
     {
-      READ_UVLC(symbol, "chroma_sample_loc_type");
-      pcVUI->setChromaSampleLocType(symbol);
+      READ_UVLC(   symbol, "chroma_sample_loc_type" );        pcVUI->setChromaSampleLocType(symbol);
     }
   }
 
-  READ_FLAG(symbol, "overscan_info_present_flag");
-  pcVUI->setOverscanInfoPresentFlag(symbol);
+  READ_FLAG(     symbol, "overscan_info_present_flag");               pcVUI->setOverscanInfoPresentFlag(symbol);
   if (pcVUI->getOverscanInfoPresentFlag())
   {
-    READ_FLAG(symbol, "overscan_appropriate_flag");
-    pcVUI->setOverscanAppropriateFlag(symbol);
+    READ_FLAG(   symbol, "overscan_appropriate_flag");                pcVUI->setOverscanAppropriateFlag(symbol);
   }
 }
 
 void HLSyntaxReader::parseHrdParameters(HRDParameters *hrd, uint32_t firstSubLayer, uint32_t maxNumSubLayersMinus1)
 {
-  uint32_t symbol;
-  READ_FLAG(symbol, "general_nal_hrd_parameters_present_flag");
-  hrd->setNalHrdParametersPresentFlag(symbol == 1 ? true : false);
-  READ_FLAG(symbol, "general_vcl_hrd_parameters_present_flag");
-  hrd->setVclHrdParametersPresentFlag(symbol == 1 ? true : false);
-  READ_FLAG(symbol, "general_decoding_unit_hrd_params_present_flag");
-  hrd->setGeneralDecodingUnitHrdParamsPresentFlag(symbol == 1 ? true : false);
+  uint32_t  symbol;
+  READ_FLAG( symbol, "general_nal_hrd_parameters_present_flag" );           hrd->setNalHrdParametersPresentFlag( symbol == 1 ? true : false );
+  READ_FLAG( symbol, "general_vcl_hrd_parameters_present_flag" );           hrd->setVclHrdParametersPresentFlag( symbol == 1 ? true : false );
+  READ_FLAG( symbol, "general_decoding_unit_hrd_params_present_flag" );           hrd->setGeneralDecodingUnitHrdParamsPresentFlag( symbol == 1 ? true : false );
 
-  if (hrd->getGeneralDecodingUnitHrdParamsPresentFlag())
+  if( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() )
   {
-    READ_CODE(8, symbol, "tick_divisor_minus2");
-    hrd->setTickDivisorMinus2(symbol);
+    READ_CODE( 8, symbol, "tick_divisor_minus2" );                        hrd->setTickDivisorMinus2( symbol );
   }
-  READ_CODE(4, symbol, "bit_rate_scale");
-  hrd->setBitRateScale(symbol);
-  READ_CODE(4, symbol, "cpb_size_scale");
-  hrd->setCpbSizeScale(symbol);
-  if (hrd->getGeneralDecodingUnitHrdParamsPresentFlag())
+  READ_CODE( 4, symbol, "bit_rate_scale" );                       hrd->setBitRateScale( symbol );
+  READ_CODE( 4, symbol, "cpb_size_scale" );                       hrd->setCpbSizeScale( symbol );
+  if( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() )
   {
-    READ_CODE(4, symbol, "cpb_size_du_scale");
-    hrd->setCpbSizeDuScale(symbol);
+    READ_CODE( 4, symbol, "cpb_size_du_scale" );                  hrd->setCpbSizeDuScale( symbol );
   }
 
-  for (int i = firstSubLayer; i <= maxNumSubLayersMinus1; i++)
+  for( int i = firstSubLayer; i <= maxNumSubLayersMinus1; i ++ )
   {
-    READ_FLAG(symbol, "fixed_pic_rate_general_flag");
-    hrd->setFixedPicRateFlag(i, symbol == 1 ? true : false);
-    if (!hrd->getFixedPicRateFlag(i))
+    READ_FLAG( symbol, "fixed_pic_rate_general_flag" );                     hrd->setFixedPicRateFlag( i, symbol == 1 ? true : false  );
+    if( !hrd->getFixedPicRateFlag( i ) )
     {
-      READ_FLAG(symbol, "fixed_pic_rate_within_cvs_flag");
-      hrd->setFixedPicRateWithinCvsFlag(i, symbol == 1 ? true : false);
+      READ_FLAG( symbol, "fixed_pic_rate_within_cvs_flag" );                hrd->setFixedPicRateWithinCvsFlag( i, symbol == 1 ? true : false  );
     }
     else
     {
-      hrd->setFixedPicRateWithinCvsFlag(i, true);
+      hrd->setFixedPicRateWithinCvsFlag( i, true );
     }
 
-    hrd->setLowDelayHrdFlag(i, false);   // Inferred to be 0 when not present
-    hrd->setCpbCntMinus1(i, 0);          // Inferred to be 0 when not present
+    hrd->setLowDelayHrdFlag( i, false ); // Inferred to be 0 when not present
+    hrd->setCpbCntMinus1   ( i, 0 );     // Inferred to be 0 when not present
 
-    if (hrd->getFixedPicRateWithinCvsFlag(i))
+    if( hrd->getFixedPicRateWithinCvsFlag( i ) )
     {
-      READ_UVLC(symbol, "elemental_duration_in_tc_minus1");
-      hrd->setPicDurationInTcMinus1(i, symbol);
+      READ_UVLC( symbol, "elemental_duration_in_tc_minus1" );             hrd->setPicDurationInTcMinus1( i, symbol );
     }
     else
     {
-      READ_FLAG(symbol, "low_delay_hrd_flag");
-      hrd->setLowDelayHrdFlag(i, symbol == 1 ? true : false);
+      READ_FLAG( symbol, "low_delay_hrd_flag" );                      hrd->setLowDelayHrdFlag( i, symbol == 1 ? true : false  );
     }
-    if (!hrd->getLowDelayHrdFlag(i))
+    if (!hrd->getLowDelayHrdFlag( i ))
     {
-      READ_UVLC(symbol, "cpb_cnt_minus1");
-      hrd->setCpbCntMinus1(i, symbol);
+      READ_UVLC( symbol, "cpb_cnt_minus1" );                          hrd->setCpbCntMinus1( i, symbol );
     }
 
-    for (int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl++)
+    for( int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
     {
-      if (((nalOrVcl == 0) && (hrd->getNalHrdParametersPresentFlag()))
-          || ((nalOrVcl == 1) && (hrd->getVclHrdParametersPresentFlag())))
+      if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
+          ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
       {
-        for (int j = 0; j <= (hrd->getCpbCntMinus1(i)); j++)
+        for( int j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ )
         {
-          READ_UVLC(symbol, "bit_rate_value_minus1");
-          hrd->setBitRateValueMinus1(i, j, nalOrVcl, symbol);
-          READ_UVLC(symbol, "cpb_size_value_minus1");
-          hrd->setCpbSizeValueMinus1(i, j, nalOrVcl, symbol);
-          READ_FLAG(symbol, "cbr_flag");
-          hrd->setCbrFlag(i, j, nalOrVcl, symbol == 1 ? true : false);
+          READ_UVLC( symbol, "bit_rate_value_minus1" );             hrd->setBitRateValueMinus1( i, j, nalOrVcl, symbol );
+          READ_UVLC( symbol, "cpb_size_value_minus1" );             hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, symbol );
+          READ_FLAG( symbol, "cbr_flag" );                          hrd->setCbrFlag( i, j, nalOrVcl, symbol == 1 ? true : false  );
         }
       }
     }
@@ -1237,8 +1154,8 @@ void HLSyntaxReader::parseHrdParameters(HRDParameters *hrd, uint32_t firstSubLay
   {
     for (int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl++)
     {
-      if (((nalOrVcl == 0) && (hrd->getNalHrdParametersPresentFlag()))
-          || ((nalOrVcl == 1) && (hrd->getVclHrdParametersPresentFlag())))
+      if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
+          ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
       {
         for (int j = 0; j <= (hrd->getCpbCntMinus1(i)); j++)
         {
@@ -1254,19 +1171,17 @@ void HLSyntaxReader::parseHrdParameters(HRDParameters *hrd, uint32_t firstSubLay
   }
 }
 
-void HLSyntaxReader::parseSPS(SPS *pcSPS)
+
+void HLSyntaxReader::parseSPS(SPS* pcSPS)
 {
-  uint32_t uiCode;
+  uint32_t  uiCode;
 
 #if ENABLE_TRACING
-  xTraceSPSHeader();
+  xTraceSPSHeader ();
 #endif
-  READ_CODE(4, uiCode, "sps_decoding_parameter_set_id");
-  pcSPS->setDecodingParameterSetId(uiCode);
-  READ_CODE(4, uiCode, "sps_video_parameter_set_id");
-  pcSPS->setVPSId(uiCode);
-  READ_CODE(3, uiCode, "sps_max_sub_layers_minus1");
-  pcSPS->setMaxTLayers(uiCode + 1);
+  READ_CODE( 4,  uiCode, "sps_decoding_parameter_set_id");       pcSPS->setDecodingParameterSetId( uiCode );
+  READ_CODE( 4,  uiCode, "sps_video_parameter_set_id" );      pcSPS->setVPSId( uiCode );
+  READ_CODE(3, uiCode, "sps_max_sub_layers_minus1");          pcSPS->setMaxTLayers   (uiCode + 1);
   CHECK(uiCode > 6, "Invalid maximum number of T-layer signalled");
   READ_CODE(5, uiCode, "sps_reserved_zero_5bits");
   CHECK(uiCode != 0, "sps_reserved_zero_5bits not equal to zero");
@@ -1276,133 +1191,108 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
   READ_FLAG(uiCode, "gdr_enabled_flag");
   pcSPS->setGDREnabledFlag(uiCode);
 
-  READ_CODE(4, uiCode, "sps_seq_parameter_set_id");
-  pcSPS->setSPSId(uiCode);
+  READ_CODE(4, uiCode, "sps_seq_parameter_set_id");              pcSPS->setSPSId(uiCode);
 
-  READ_CODE(2, uiCode, "chroma_format_idc");
-  pcSPS->setChromaFormatIdc(ChromaFormat(uiCode));
+  READ_CODE(2, uiCode, "chroma_format_idc");                     pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) );
 
-  if (pcSPS->getChromaFormatIdc() == CHROMA_444)
+  if( pcSPS->getChromaFormatIdc() == CHROMA_444 )
   {
-    READ_FLAG(uiCode, "separate_colour_plane_flag");
-    CHECK(uiCode != 0, "Invalid code");
-    pcSPS->setSeparateColourPlaneFlag(uiCode != 0);
+    READ_FLAG(     uiCode, "separate_colour_plane_flag");        CHECK(uiCode != 0, "Invalid code");
+    pcSPS->setSeparateColourPlaneFlag( uiCode != 0 );
   }
 
 #if JVET_Q0043_RPR_and_Subpics
-  READ_FLAG(uiCode, "res_change_in_clvs_allowed_flag");
-  pcSPS->setRprEnabledFlag(uiCode);
+  READ_FLAG( uiCode, "res_change_in_clvs_allowed_flag" );        pcSPS->setRprEnabledFlag( uiCode );
 #else
-  READ_FLAG(uiCode, "ref_pic_resampling_enabled_flag");
-  pcSPS->setRprEnabledFlag(uiCode);
+  READ_FLAG( uiCode, "ref_pic_resampling_enabled_flag" );        pcSPS->setRprEnabledFlag( uiCode );
 #endif
 
-  READ_UVLC(uiCode, "pic_width_max_in_luma_samples");
-  pcSPS->setMaxPicWidthInLumaSamples(uiCode);
-  READ_UVLC(uiCode, "pic_height_max_in_luma_samples");
-  pcSPS->setMaxPicHeightInLumaSamples(uiCode);
+  READ_UVLC( uiCode, "pic_width_max_in_luma_samples" );          pcSPS->setMaxPicWidthInLumaSamples( uiCode );
+  READ_UVLC( uiCode, "pic_height_max_in_luma_samples" );         pcSPS->setMaxPicHeightInLumaSamples( uiCode );
 
-  READ_CODE(2, uiCode, "sps_log2_ctu_size_minus5");
-  pcSPS->setCTUSize(1 << (uiCode + 5));
+  READ_CODE(2, uiCode, "sps_log2_ctu_size_minus5");              pcSPS->setCTUSize(1 << (uiCode + 5));
   CHECK(uiCode > 2, "sps_log2_ctu_size_minus5 must be less than or equal to 2");
   unsigned ctbLog2SizeY = uiCode + 5;
-  pcSPS->setMaxCodingDepth(uiCode + 3);
-  pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode + 3);
+  pcSPS->setMaxCodingDepth(uiCode+3);
+  pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode+3);
   pcSPS->setMaxCUWidth(pcSPS->getCTUSize());
   pcSPS->setMaxCUHeight(pcSPS->getCTUSize());
 #if JVET_Q0043_RPR_and_Subpics
-  READ_FLAG(uiCode, "subpic_info_present_flag");
-  pcSPS->setSubPicPresentFlag(uiCode);
+  READ_FLAG( uiCode, "subpic_info_present_flag" );               pcSPS->setSubPicPresentFlag(uiCode);
 #else
-  READ_FLAG(uiCode, "subpics_present_flag");
-  pcSPS->setSubPicPresentFlag(uiCode);
+  READ_FLAG( uiCode, "subpics_present_flag" );                   pcSPS->setSubPicPresentFlag(uiCode);
 #endif
 
-  if (pcSPS->getSubPicPresentFlag())
+  if (pcSPS->getSubPicPresentFlag()) 
   {
-    READ_CODE(8, uiCode, "sps_num_subpics_minus1");
-    pcSPS->setNumSubPics(uiCode + 1);
+    READ_CODE(8, uiCode, "sps_num_subpics_minus1"); pcSPS->setNumSubPics(uiCode + 1);
 #if JVET_Q0816
-    if (pcSPS->getNumSubPics() == 1)
+    if( pcSPS->getNumSubPics() == 1 )
     {
-      pcSPS->setSubPicCtuTopLeftX(0, 0);
-      pcSPS->setSubPicCtuTopLeftY(0, 0);
-      pcSPS->setSubPicWidth(0, (pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                 >> floorLog2(pcSPS->getCTUSize()));
-      pcSPS->setSubPicHeight(0, (pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                  >> floorLog2(pcSPS->getCTUSize()));
-      pcSPS->setSubPicTreatedAsPicFlag(0, 0);
-      pcSPS->setLoopFilterAcrossSubpicEnabledFlag(0, 1);
+      pcSPS->setSubPicCtuTopLeftX( 0, 0 );
+      pcSPS->setSubPicCtuTopLeftY( 0, 0 );
+      pcSPS->setSubPicWidth( 0, ( pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1 ) >> floorLog2( pcSPS->getCTUSize() ) );
+      pcSPS->setSubPicHeight( 0, ( pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1 ) >> floorLog2( pcSPS->getCTUSize() ) );
+      pcSPS->setSubPicTreatedAsPicFlag( 0, 0 );
+      pcSPS->setLoopFilterAcrossSubpicEnabledFlag( 0, 1 );
     }
     else
     {
 #endif
-      for (int picIdx = 0; picIdx < pcSPS->getNumSubPics(); picIdx++)
-      {
+    for (int picIdx = 0; picIdx < pcSPS->getNumSubPics(); picIdx++)
+    {
 #if JVET_Q0787_SUBPIC
-        if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize())
-        {
-          READ_CODE(ceilLog2((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()),
-                    uiCode, "subpic_ctu_top_left_x[ i ]");
-          pcSPS->setSubPicCtuTopLeftX(picIdx, uiCode);
-        }
-        else
-        {
-          pcSPS->setSubPicCtuTopLeftX(picIdx, 0);
-        }
-        if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize())
-        {
-          READ_CODE(ceilLog2((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()),
-                    uiCode, "subpic_ctu_top_left_y[ i ]");
-          pcSPS->setSubPicCtuTopLeftY(picIdx, uiCode);
-        }
-        else
-        {
-          pcSPS->setSubPicCtuTopLeftY(picIdx, 0);
-        }
-        if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize())
-        {
-          READ_CODE(ceilLog2((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()),
-                    uiCode, "subpic_width_minus1[ i ]");
-          pcSPS->setSubPicWidth(picIdx, uiCode + 1);
-        }
-        else
-        {
-          pcSPS->setSubPicWidth(picIdx, 1);
-        }
-        if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize())
-        {
-          READ_CODE(ceilLog2((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()),
-                    uiCode, "subpic_height_minus1[ i ]");
-          pcSPS->setSubPicHeight(picIdx, uiCode + 1);
-        }
-        else
-        {
-          pcSPS->setSubPicHeight(picIdx, 1);
-        }
+      if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize())
+      {
+        READ_CODE(ceilLog2((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), uiCode, "subpic_ctu_top_left_x[ i ]");
+        pcSPS->setSubPicCtuTopLeftX(picIdx, uiCode);
+      }
+      else
+      {
+        pcSPS->setSubPicCtuTopLeftX(picIdx, 0);
+      }
+      if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize())
+      {
+        READ_CODE(ceilLog2((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), uiCode, "subpic_ctu_top_left_y[ i ]");
+        pcSPS->setSubPicCtuTopLeftY(picIdx, uiCode);
+      }
+      else
+      {
+        pcSPS->setSubPicCtuTopLeftY(picIdx, 0);
+      }
+      if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize())
+      {
+        READ_CODE(ceilLog2((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), uiCode, "subpic_width_minus1[ i ]");
+        pcSPS->setSubPicWidth(picIdx, uiCode + 1);
+      }
+      else
+      {
+        pcSPS->setSubPicWidth(picIdx, 1);
+      }
+      if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize())
+      {
+        READ_CODE(ceilLog2((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), uiCode, "subpic_height_minus1[ i ]");
+        pcSPS->setSubPicHeight(picIdx, uiCode + 1);
+      }
+      else
+      {
+        pcSPS->setSubPicHeight(picIdx, 1);
+      }
 #else
-      READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                      >> floorLog2(pcSPS->getCTUSize())))),
-                uiCode, "subpic_ctu_top_left_x[ i ]");
+      READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize())))), uiCode, "subpic_ctu_top_left_x[ i ]");
       pcSPS->setSubPicCtuTopLeftX(picIdx, uiCode);
-      READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                      >> floorLog2(pcSPS->getCTUSize())))),
-                uiCode, "subpic_ctu_top_left_y[ i ]");
+      READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize())))), uiCode, "subpic_ctu_top_left_y[ i ]");
       pcSPS->setSubPicCtuTopLeftY(picIdx, uiCode);
-      READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                      >> floorLog2(pcSPS->getCTUSize())))),
-                uiCode, "subpic_width_minus1[ i ]");
+      READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize())))), uiCode, "subpic_width_minus1[ i ]");
       pcSPS->setSubPicWidth(picIdx, uiCode + 1);
-      READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                      >> floorLog2(pcSPS->getCTUSize())))),
-                uiCode, "subpic_height_minus1[ i ]");
+      READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize())))), uiCode, "subpic_height_minus1[ i ]");
       pcSPS->setSubPicHeight(picIdx, uiCode + 1);
 #endif
-        READ_FLAG(uiCode, "subpic_treated_as_pic_flag[ i ]");
-        pcSPS->setSubPicTreatedAsPicFlag(picIdx, uiCode);
-        READ_FLAG(uiCode, "loop_filter_across_subpic_enabled_flag[ i ]");
-        pcSPS->setLoopFilterAcrossSubpicEnabledFlag(picIdx, uiCode);
-      }
+      READ_FLAG(uiCode, "subpic_treated_as_pic_flag[ i ]");
+      pcSPS->setSubPicTreatedAsPicFlag(picIdx, uiCode);
+      READ_FLAG(uiCode, "loop_filter_across_subpic_enabled_flag[ i ]");
+      pcSPS->setLoopFilterAcrossSubpicEnabledFlag(picIdx, uiCode);
+    }
 #if JVET_Q0816
     }
 #endif
@@ -1412,59 +1302,50 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
     pcSPS->setNumSubPics(1);
     pcSPS->setSubPicCtuTopLeftX(0, 0);
     pcSPS->setSubPicCtuTopLeftY(0, 0);
-    pcSPS->setSubPicWidth(0, (pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1)
-                               >> floorLog2(pcSPS->getCTUSize()));
-    pcSPS->setSubPicHeight(0, (pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                >> floorLog2(pcSPS->getCTUSize()));
+    pcSPS->setSubPicWidth(0, (pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize()));
+    pcSPS->setSubPicHeight(0, (pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize()));
   }
 
-  READ_FLAG(uiCode, "sps_subpic_id_present_flag");
-  pcSPS->setSubPicIdPresentFlag(uiCode != 0);
-  if (pcSPS->getSubPicIdPresentFlag())
+  READ_FLAG(uiCode, "sps_subpic_id_present_flag");                           pcSPS->setSubPicIdPresentFlag( uiCode != 0 );
+  if( pcSPS->getSubPicIdPresentFlag() )
   {
-    READ_FLAG(uiCode, "sps_subpic_id_signalling_present_flag");
-    pcSPS->setSubPicIdSignallingPresentFlag(uiCode != 0);
-    if (pcSPS->getSubPicIdSignallingPresentFlag())
+    READ_FLAG(uiCode, "sps_subpic_id_signalling_present_flag");              pcSPS->setSubPicIdSignallingPresentFlag( uiCode != 0 );
+    if( pcSPS->getSubPicIdSignallingPresentFlag() )
     {
-      READ_UVLC(uiCode, "sps_subpic_id_len_minus1");
-      pcSPS->setSubPicIdLen(uiCode + 1);
-      CHECK(uiCode > 15, "Invalid sps_subpic_id_len_minus1 signalled");
+      READ_UVLC( uiCode, "sps_subpic_id_len_minus1" );                       pcSPS->setSubPicIdLen( uiCode + 1 );
+      CHECK( uiCode > 15, "Invalid sps_subpic_id_len_minus1 signalled");
 #if JVET_Q0169_SUBPIC_LEN_CONFORM
       CHECK((1 << pcSPS->getSubPicIdLen()) < pcSPS->getNumSubPics(), "sps_subpic_id_len exceeds valid range");
 #endif
-      for (int picIdx = 0; picIdx < pcSPS->getNumSubPics(); picIdx++)
+      for( int picIdx = 0; picIdx < pcSPS->getNumSubPics( ); picIdx++ )
       {
-        READ_CODE(pcSPS->getSubPicIdLen(), uiCode, "sps_subpic_id[i]");
-        pcSPS->setSubPicId(picIdx, uiCode);
+        READ_CODE( pcSPS->getSubPicIdLen( ), uiCode, "sps_subpic_id[i]" );   pcSPS->setSubPicId( picIdx, uiCode );
       }
     }
   }
-  if (pcSPS->getSubPicIdPresentFlag() == false || pcSPS->getSubPicIdSignallingPresentFlag() == false)
+  if( pcSPS->getSubPicIdPresentFlag() == false || pcSPS->getSubPicIdSignallingPresentFlag() == false )
   {
-    for (int picIdx = 0; picIdx < pcSPS->getNumSubPics(); picIdx++)
+    for( int picIdx = 0; picIdx < pcSPS->getNumSubPics( ); picIdx++ )
     {
-      pcSPS->setSubPicId(picIdx, picIdx);
+      pcSPS->setSubPicId( picIdx, picIdx );
     }
   }
 
-  READ_UVLC(uiCode, "bit_depth_minus8");
+  READ_UVLC(     uiCode, "bit_depth_minus8" );
   CHECK(uiCode > 8, "Invalid bit depth signalled");
   pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode);
   pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode);
-  pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (int) (6 * uiCode));
-  pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (int) (6 * uiCode));
+  pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (int) (6*uiCode) );
+  pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (int) (6*uiCode) );
 
-  READ_UVLC(uiCode, "min_qp_prime_ts_minus4");
+  READ_UVLC(     uiCode, "min_qp_prime_ts_minus4" );
   pcSPS->setMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA, uiCode);
   CHECK(uiCode > 48, "Invalid min_qp_prime_ts_minus4 signalled");
   pcSPS->setMinQpPrimeTsMinus4(CHANNEL_TYPE_CHROMA, uiCode);
-  READ_FLAG(uiCode, "sps_weighted_pred_flag");
-  pcSPS->setUseWP(uiCode ? true : false);
-  READ_FLAG(uiCode, "sps_weighted_bipred_flag");
-  pcSPS->setUseWPBiPred(uiCode ? true : false);
+  READ_FLAG( uiCode, "sps_weighted_pred_flag" );                    pcSPS->setUseWP( uiCode ? true : false );
+  READ_FLAG( uiCode, "sps_weighted_bipred_flag" );                  pcSPS->setUseWPBiPred( uiCode ? true : false );
 
-  READ_CODE(4, uiCode, "log2_max_pic_order_cnt_lsb_minus4");
-  pcSPS->setBitsForPOC(4 + uiCode);
+  READ_CODE(4, uiCode, "log2_max_pic_order_cnt_lsb_minus4");     pcSPS->setBitsForPOC( 4 + uiCode );
   CHECK(uiCode > 12, "Invalid code");
   // KJS: Marakech decision: sub-layers added back
   uint32_t subLayerOrderingInfoPresentFlag;
@@ -1477,18 +1358,18 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
     subLayerOrderingInfoPresentFlag = 0;
   }
 
-  for (uint32_t i = 0; i <= pcSPS->getMaxTLayers() - 1; i++)
+  for(uint32_t i=0; i <= pcSPS->getMaxTLayers()-1; i++)
   {
-    READ_UVLC(uiCode, "sps_max_dec_pic_buffering_minus1[i]");
-    pcSPS->setMaxDecPicBuffering(uiCode + 1, i);
-    READ_UVLC(uiCode, "sps_max_num_reorder_pics[i]");
+    READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]");
+    pcSPS->setMaxDecPicBuffering( uiCode + 1, i);
+    READ_UVLC ( uiCode, "sps_max_num_reorder_pics[i]" );
     pcSPS->setNumReorderPics(uiCode, i);
-    READ_UVLC(uiCode, "sps_max_latency_increase_plus1[i]");
-    pcSPS->setMaxLatencyIncreasePlus1(uiCode, i);
+    READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]");
+    pcSPS->setMaxLatencyIncreasePlus1( uiCode, i );
 
     if (!subLayerOrderingInfoPresentFlag)
     {
-      for (i++; i <= pcSPS->getMaxTLayers() - 1; i++)
+      for (i++; i <= pcSPS->getMaxTLayers()-1; i++)
       {
         pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i);
         pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i);
@@ -1498,28 +1379,25 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
     }
   }
 
-  READ_FLAG(uiCode, "long_term_ref_pics_flag");
-  pcSPS->setLongTermRefsPresent(uiCode);
-  READ_FLAG(uiCode, "inter_layer_ref_pics_present_flag");
-  pcSPS->setInterLayerPresentFlag(uiCode);
-  READ_FLAG(uiCode, "sps_idr_rpl_present_flag");
-  pcSPS->setIDRRefParamListPresent((bool) uiCode);
+  READ_FLAG(uiCode, "long_term_ref_pics_flag");          pcSPS->setLongTermRefsPresent(uiCode);
+  READ_FLAG( uiCode, "inter_layer_ref_pics_present_flag" );  pcSPS->setInterLayerPresentFlag( uiCode );
+  READ_FLAG( uiCode, "sps_idr_rpl_present_flag" );       pcSPS->setIDRRefParamListPresent( (bool) uiCode );
   READ_FLAG(uiCode, "rpl1_copy_from_rpl0_flag");
   pcSPS->setRPL1CopyFromRPL0Flag(uiCode);
 
-  // Read candidate for List0
+  //Read candidate for List0
   READ_UVLC(uiCode, "num_ref_pic_lists_in_sps[0]");
   uint32_t numberOfRPL = uiCode;
   pcSPS->createRPLList0(numberOfRPL);
-  RPLList *             rplList = pcSPS->getRPLList0();
-  ReferencePictureList *rpl;
+  RPLList* rplList = pcSPS->getRPLList0();
+  ReferencePictureList* rpl;
   for (uint32_t ii = 0; ii < numberOfRPL; ii++)
   {
     rpl = rplList->getReferencePictureList(ii);
     parseRefPicList(pcSPS, rpl);
   }
 
-  // Read candidate for List1
+  //Read candidate for List1
   if (!pcSPS->getRPL1CopyFromRPL0Flag())
   {
     READ_UVLC(uiCode, "num_ref_pic_lists_in_sps[1]");
@@ -1536,21 +1414,20 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
   {
     numberOfRPL = pcSPS->getNumRPL0();
     pcSPS->createRPLList1(numberOfRPL);
-    RPLList *rplListSource = pcSPS->getRPLList0();
-    RPLList *rplListDest   = pcSPS->getRPLList1();
+    RPLList* rplListSource = pcSPS->getRPLList0();
+    RPLList* rplListDest = pcSPS->getRPLList1();
     for (uint32_t ii = 0; ii < numberOfRPL; ii++)
       copyRefPicList(pcSPS, rplListSource->getReferencePictureList(ii), rplListDest->getReferencePictureList(ii));
   }
 
-  unsigned minQT[3]  = { 0, 0, 0 };
-  unsigned maxBTD[3] = { 0, 0, 0 };
+  unsigned  minQT[3] = { 0, 0, 0 };
+  unsigned  maxBTD[3] = { 0, 0, 0 };
 
-  unsigned maxBTSize[3] = { 0, 0, 0 };
-  unsigned maxTTSize[3] = { 0, 0, 0 };
-  if (pcSPS->getChromaFormatIdc() != CHROMA_400)
+  unsigned  maxBTSize[3] = { 0, 0, 0 };
+  unsigned  maxTTSize[3] = { 0, 0, 0 };
+  if( pcSPS->getChromaFormatIdc() != CHROMA_400 ) 
   {
-    READ_FLAG(uiCode, "qtbtt_dual_tree_intra_flag");
-    pcSPS->setUseDualITree(uiCode);
+    READ_FLAG(uiCode, "qtbtt_dual_tree_intra_flag");           pcSPS->setUseDualITree(uiCode);
   }
   else
   {
@@ -1562,121 +1439,91 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
   pcSPS->setLog2MinCodingBlockSize(log2MinCUSize);
   CHECK(uiCode > ctbLog2SizeY - 2, "Invalid log2_min_luma_coding_block_size_minus2 signalled");
 
-  CHECK(log2MinCUSize > std::min(6, (int) (ctbLog2SizeY)),
-        "log2_min_luma_coding_block_size_minus2 shall be in the range of 0 to min (4, log2_ctu_size - 2)");
-  CHECK((pcSPS->getMaxPicWidthInLumaSamples()
-         % (std::max(8, int(pcSPS->getMaxCUWidth() >> (pcSPS->getMaxCodingDepth() - 1)))))
-          != 0,
-        "Coded frame width must be a multiple of Max(8, the minimum unit size)");
-  CHECK((pcSPS->getMaxPicHeightInLumaSamples()
-         % (std::max(8, int(pcSPS->getMaxCUHeight() >> (pcSPS->getMaxCodingDepth() - 1)))))
-          != 0,
-        "Coded frame height must be a multiple of Max(8, the minimum unit size)");
-
-  READ_FLAG(uiCode, "partition_constraints_override_enabled_flag");
-  pcSPS->setSplitConsOverrideEnabledFlag(uiCode);
+  CHECK(log2MinCUSize > std::min(6, (int)(ctbLog2SizeY)), "log2_min_luma_coding_block_size_minus2 shall be in the range of 0 to min (4, log2_ctu_size - 2)");
+  CHECK( ( pcSPS->getMaxPicWidthInLumaSamples() % ( std::max( 8, int( pcSPS->getMaxCUWidth() >> ( pcSPS->getMaxCodingDepth() - 1 ) ) ) ) ) != 0, "Coded frame width must be a multiple of Max(8, the minimum unit size)" );
+  CHECK( ( pcSPS->getMaxPicHeightInLumaSamples() % ( std::max( 8, int( pcSPS->getMaxCUHeight() >> ( pcSPS->getMaxCodingDepth() - 1 ) ) ) ) ) != 0, "Coded frame height must be a multiple of Max(8, the minimum unit size)" );
+
+  READ_FLAG(uiCode, "partition_constraints_override_enabled_flag"); pcSPS->setSplitConsOverrideEnabledFlag(uiCode);
   READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_intra_slice_luma");
   unsigned minQtLog2SizeIntraY = uiCode + pcSPS->getLog2MinCodingBlockSize();
-  minQT[0]                     = 1 << minQtLog2SizeIntraY;
+  minQT[0] = 1 << minQtLog2SizeIntraY;
 #if !JVET_Q0481_PARTITION_CONSTRAINTS_ORDER
   READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_inter_slice");
   unsigned minQtLog2SizeInterY = uiCode + pcSPS->getLog2MinCodingBlockSize();
-  minQT[1]                     = 1 << minQtLog2SizeInterY;
-  READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_inter_slice");
-  maxBTD[1] = uiCode;
-  CHECK(uiCode > 2 * (ctbLog2SizeY - log2MinCUSize),
-        "sps_max_mtt_hierarchy_depth_inter_slice shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");
+  minQT[1] = 1 << minQtLog2SizeInterY;
+  READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_inter_slice");     maxBTD[1] = uiCode;
+  CHECK(uiCode > 2*(ctbLog2SizeY - log2MinCUSize), "sps_max_mtt_hierarchy_depth_inter_slice shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");
 #endif
-  READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_intra_slice_luma");
-  maxBTD[0] = uiCode;
-  CHECK(uiCode > 2 * (ctbLog2SizeY - log2MinCUSize),
-        "sps_max_mtt_hierarchy_depth_intra_slice_luma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");
+  READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_intra_slice_luma");     maxBTD[0] = uiCode;
+  CHECK(uiCode > 2 * (ctbLog2SizeY - log2MinCUSize), "sps_max_mtt_hierarchy_depth_intra_slice_luma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");
 
   maxTTSize[0] = maxBTSize[0] = minQT[0];
   if (maxBTD[0] != 0)
   {
-    READ_UVLC(uiCode, "sps_log2_diff_max_bt_min_qt_intra_slice_luma");
-    maxBTSize[0] <<= uiCode;
+    READ_UVLC(uiCode, "sps_log2_diff_max_bt_min_qt_intra_slice_luma");     maxBTSize[0] <<= uiCode;
     CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "Invalid code");
-    READ_UVLC(uiCode, "sps_log2_diff_max_tt_min_qt_intra_slice_luma");
-    maxTTSize[0] <<= uiCode;
+    READ_UVLC(uiCode, "sps_log2_diff_max_tt_min_qt_intra_slice_luma");     maxTTSize[0] <<= uiCode;
     CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "Invalid code");
   }
 #if JVET_Q0481_PARTITION_CONSTRAINTS_ORDER
   READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_inter_slice");
   unsigned minQtLog2SizeInterY = uiCode + pcSPS->getLog2MinCodingBlockSize();
-  minQT[1]                     = 1 << minQtLog2SizeInterY;
-  READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_inter_slice");
-  maxBTD[1] = uiCode;
-  CHECK(uiCode > 2 * (ctbLog2SizeY - log2MinCUSize),
-        "sps_max_mtt_hierarchy_depth_inter_slice shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");
+  minQT[1] = 1 << minQtLog2SizeInterY;
+  READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_inter_slice");     maxBTD[1] = uiCode;
+  CHECK(uiCode > 2*(ctbLog2SizeY - log2MinCUSize), "sps_max_mtt_hierarchy_depth_inter_slice shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");
 #endif
   maxTTSize[1] = maxBTSize[1] = minQT[1];
   if (maxBTD[1] != 0)
   {
-    READ_UVLC(uiCode, "sps_log2_diff_max_bt_min_qt_inter_slice");
-    maxBTSize[1] <<= uiCode;
+    READ_UVLC(uiCode, "sps_log2_diff_max_bt_min_qt_inter_slice");     maxBTSize[1] <<= uiCode;
     CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code");
-    READ_UVLC(uiCode, "sps_log2_diff_max_tt_min_qt_inter_slice");
-    maxTTSize[1] <<= uiCode;
+    READ_UVLC(uiCode, "sps_log2_diff_max_tt_min_qt_inter_slice");     maxTTSize[1] <<= uiCode;
     CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code");
   }
   if (pcSPS->getUseDualITree())
   {
-    READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_intra_slice_chroma");
-    minQT[2] = 1 << (uiCode + pcSPS->getLog2MinCodingBlockSize());
-    READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_intra_slice_chroma");
-    maxBTD[2] = uiCode;
-    CHECK(uiCode > 2 * (ctbLog2SizeY - log2MinCUSize),
-          "sps_max_mtt_hierarchy_depth_intra_slice_chroma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");
+    READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_intra_slice_chroma"); minQT[2] = 1 << (uiCode + pcSPS->getLog2MinCodingBlockSize());
+    READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_intra_slice_chroma"); maxBTD[2] = uiCode;
+    CHECK(uiCode > 2 * (ctbLog2SizeY - log2MinCUSize), "sps_max_mtt_hierarchy_depth_intra_slice_chroma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)");
     maxTTSize[2] = maxBTSize[2] = minQT[2];
     if (maxBTD[2] != 0)
     {
-      READ_UVLC(uiCode, "sps_log2_diff_max_bt_min_qt_intra_slice_chroma");
-      maxBTSize[2] <<= uiCode;
-      READ_UVLC(uiCode, "sps_log2_diff_max_tt_min_qt_intra_slice_chroma");
-      maxTTSize[2] <<= uiCode;
+      READ_UVLC(uiCode, "sps_log2_diff_max_bt_min_qt_intra_slice_chroma");       maxBTSize[2] <<= uiCode;
+      READ_UVLC(uiCode, "sps_log2_diff_max_tt_min_qt_intra_slice_chroma");       maxTTSize[2] <<= uiCode;
     }
-  }
+}
 
   pcSPS->setMinQTSizes(minQT);
   pcSPS->setMaxMTTHierarchyDepth(maxBTD[1], maxBTD[0], maxBTD[2]);
   pcSPS->setMaxBTSize(maxBTSize[1], maxBTSize[0], maxBTSize[2]);
   pcSPS->setMaxTTSize(maxTTSize[1], maxTTSize[0], maxTTSize[2]);
 
-  READ_FLAG(uiCode, "sps_max_luma_transform_size_64_flag");
-  pcSPS->setLog2MaxTbSize((uiCode ? 1 : 0) + 5);
+
+  READ_FLAG( uiCode, "sps_max_luma_transform_size_64_flag");        pcSPS->setLog2MaxTbSize( (uiCode ? 1 : 0) + 5 );
 
 #if JVET_Q0147_JCCR_SIGNALLING
   if (pcSPS->getChromaFormatIdc() != CHROMA_400)
   {
-    READ_FLAG(uiCode, "sps_joint_cbcr_enabled_flag");
-    pcSPS->setJointCbCrEnabledFlag(uiCode ? true : false);
+    READ_FLAG(uiCode, "sps_joint_cbcr_enabled_flag");                pcSPS->setJointCbCrEnabledFlag(uiCode ? true : false);
 #else
-  READ_FLAG(uiCode, "sps_joint_cbcr_enabled_flag");
-  pcSPS->setJointCbCrEnabledFlag(uiCode ? true : false);
+  READ_FLAG(uiCode, "sps_joint_cbcr_enabled_flag");                pcSPS->setJointCbCrEnabledFlag(uiCode ? true : false);
   if (pcSPS->getChromaFormatIdc() != CHROMA_400)
   {
 #endif
     ChromaQpMappingTableParams chromaQpMappingTableParams;
-    READ_FLAG(uiCode, "same_qp_table_for_chroma");
-    chromaQpMappingTableParams.setSameCQPTableForAllChromaFlag(uiCode);
-    int numQpTables =
-      chromaQpMappingTableParams.getSameCQPTableForAllChromaFlag() ? 1 : (pcSPS->getJointCbCrEnabledFlag() ? 3 : 2);
+    READ_FLAG(uiCode, "same_qp_table_for_chroma");        chromaQpMappingTableParams.setSameCQPTableForAllChromaFlag(uiCode);
+    int numQpTables = chromaQpMappingTableParams.getSameCQPTableForAllChromaFlag() ? 1 : (pcSPS->getJointCbCrEnabledFlag() ? 3 : 2);
     chromaQpMappingTableParams.setNumQpTables(numQpTables);
     for (int i = 0; i < numQpTables; i++)
     {
       int32_t qpTableStart = 0;
-      READ_SVLC(qpTableStart, "qp_table_starts_minus26");
-      chromaQpMappingTableParams.setQpTableStartMinus26(i, qpTableStart);
-      READ_UVLC(uiCode, "num_points_in_qp_table_minus1");
-      chromaQpMappingTableParams.setNumPtsInCQPTableMinus1(i, uiCode);
+      READ_SVLC(qpTableStart, "qp_table_starts_minus26"); chromaQpMappingTableParams.setQpTableStartMinus26(i, qpTableStart);
+      READ_UVLC(uiCode, "num_points_in_qp_table_minus1"); chromaQpMappingTableParams.setNumPtsInCQPTableMinus1(i,uiCode);
       std::vector<int> deltaQpInValMinus1(chromaQpMappingTableParams.getNumPtsInCQPTableMinus1(i) + 1);
       std::vector<int> deltaQpOutVal(chromaQpMappingTableParams.getNumPtsInCQPTableMinus1(i) + 1);
       for (int j = 0; j <= chromaQpMappingTableParams.getNumPtsInCQPTableMinus1(i); j++)
       {
-        READ_UVLC(uiCode, "delta_qp_in_val_minus1");
-        deltaQpInValMinus1[j] = uiCode;
+        READ_UVLC(uiCode, "delta_qp_in_val_minus1");  deltaQpInValMinus1[j] = uiCode;
         READ_UVLC(uiCode, "delta_qp_diff_val");
         deltaQpOutVal[j] = uiCode ^ deltaQpInValMinus1[j];
       }
@@ -1687,15 +1534,13 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
     pcSPS->derivedChromaQPMappingTables();
   }
 
-  READ_FLAG(uiCode, "sps_sao_enabled_flag");
-  pcSPS->setSAOEnabledFlag(uiCode ? true : false);
-  READ_FLAG(uiCode, "sps_alf_enabled_flag");
-  pcSPS->setALFEnabledFlag(uiCode ? true : false);
+
+  READ_FLAG( uiCode, "sps_sao_enabled_flag" );                      pcSPS->setSAOEnabledFlag ( uiCode ? true : false );
+  READ_FLAG( uiCode, "sps_alf_enabled_flag" );                      pcSPS->setALFEnabledFlag ( uiCode ? true : false );
 #if JVET_Q0795_CCALF
   if (pcSPS->getALFEnabledFlag() && pcSPS->getChromaFormatIdc() != CHROMA_400)
   {
-    READ_FLAG(uiCode, "sps_ccalf_enabled_flag");
-    pcSPS->setCCALFEnabledFlag(uiCode ? true : false);
+    READ_FLAG( uiCode, "sps_ccalf_enabled_flag" );                      pcSPS->setCCALFEnabledFlag ( uiCode ? true : false );
   }
   else
   {
@@ -1703,138 +1548,107 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
   }
 #endif
 
-  READ_FLAG(uiCode, "sps_transform_skip_enabled_flag");
-  pcSPS->setTransformSkipEnabledFlag(uiCode ? true : false);
+  READ_FLAG(uiCode, "sps_transform_skip_enabled_flag"); pcSPS->setTransformSkipEnabledFlag(uiCode ? true : false);
   if (pcSPS->getTransformSkipEnabledFlag())
   {
 #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM
-    READ_FLAG(uiCode, "sps_bdpcm_enabled_flag");
-    pcSPS->setBDPCMEnabledFlag(uiCode ? true : false);
+    READ_FLAG(uiCode, "sps_bdpcm_enabled_flag"); pcSPS->setBDPCMEnabledFlag(uiCode ? true : false);
 #else
-    READ_FLAG(uiCode, "sps_bdpcm_enabled_flag");
+      READ_FLAG(uiCode, "sps_bdpcm_enabled_flag");
 #if JVET_Q0110_Q0785_CHROMA_BDPCM_420
-    if (uiCode)
+      if( uiCode )
 #else
-    if (uiCode && pcSPS->getChromaFormatIdc() == CHROMA_444)
+      if (uiCode && pcSPS->getChromaFormatIdc() == CHROMA_444 )
 #endif
-    {
-      READ_FLAG(uiCode, "sps_bdpcm_enabled_chroma_flag");
-      uiCode++;
-    }
-    pcSPS->setBDPCMEnabled(uiCode);
+      {
+          READ_FLAG(uiCode, "sps_bdpcm_enabled_chroma_flag");
+          uiCode++;
+      }
+      pcSPS->setBDPCMEnabled(uiCode);
 #endif
   }
 
-  READ_FLAG(uiCode, "sps_ref_wraparound_enabled_flag");
-  pcSPS->setWrapAroundEnabledFlag(uiCode ? true : false);
+  READ_FLAG(uiCode, "sps_ref_wraparound_enabled_flag");                  pcSPS->setWrapAroundEnabledFlag( uiCode ? true : false );
 
   if (pcSPS->getWrapAroundEnabledFlag())
   {
-    READ_UVLC(uiCode, "sps_ref_wraparound_offset_minus1");
-    pcSPS->setWrapAroundOffset((uiCode + 1) * (1 << pcSPS->getLog2MinCodingBlockSize()));
+    READ_UVLC(uiCode, "sps_ref_wraparound_offset_minus1");               pcSPS->setWrapAroundOffset( (uiCode+1)*(1 <<  pcSPS->getLog2MinCodingBlockSize()));
   }
 
-  READ_FLAG(uiCode, "sps_temporal_mvp_enabled_flag");
-  pcSPS->setSPSTemporalMVPEnabledFlag(uiCode);
+  READ_FLAG( uiCode, "sps_temporal_mvp_enabled_flag" );                  pcSPS->setSPSTemporalMVPEnabledFlag(uiCode);
 
-  if (pcSPS->getSPSTemporalMVPEnabledFlag())
+  if ( pcSPS->getSPSTemporalMVPEnabledFlag() )
   {
-    READ_FLAG(uiCode, "sps_sbtmvp_enabled_flag");
-    pcSPS->setSBTMVPEnabledFlag(uiCode != 0);
+    READ_FLAG( uiCode,    "sps_sbtmvp_enabled_flag" );                   pcSPS->setSBTMVPEnabledFlag      ( uiCode != 0 );
   }
   else
   {
     pcSPS->setSBTMVPEnabledFlag(false);
   }
 
-  READ_FLAG(uiCode, "sps_amvr_enabled_flag");
-  pcSPS->setAMVREnabledFlag(uiCode != 0);
+  READ_FLAG( uiCode,  "sps_amvr_enabled_flag" );                     pcSPS->setAMVREnabledFlag ( uiCode != 0 );
 
-  READ_FLAG(uiCode, "sps_bdof_enabled_flag");
-  pcSPS->setBDOFEnabledFlag(uiCode != 0);
+  READ_FLAG( uiCode, "sps_bdof_enabled_flag" );                      pcSPS->setBDOFEnabledFlag ( uiCode != 0 );
   if (pcSPS->getBDOFEnabledFlag())
   {
-    READ_FLAG(uiCode, "sps_bdof_pic_present_flag");
-    pcSPS->setBdofControlPresentFlag(uiCode != 0);
+    READ_FLAG(uiCode, "sps_bdof_pic_present_flag");                 pcSPS->setBdofControlPresentFlag( uiCode != 0 );
   }
-  else
-  {
-    pcSPS->setBdofControlPresentFlag(false);
+  else {
+    pcSPS->setBdofControlPresentFlag( false );
   }
-  READ_FLAG(uiCode, "sps_smvd_enabled_flag");
-  pcSPS->setUseSMVD(uiCode != 0);
-  READ_FLAG(uiCode, "sps_dmvr_enabled_flag");
-  pcSPS->setUseDMVR(uiCode != 0);
+  READ_FLAG(uiCode, "sps_smvd_enabled_flag");                       pcSPS->setUseSMVD( uiCode != 0 );
+  READ_FLAG(uiCode, "sps_dmvr_enabled_flag");                        pcSPS->setUseDMVR(uiCode != 0);
   if (pcSPS->getUseDMVR())
   {
-    READ_FLAG(uiCode, "sps_dmvr_pic_present_flag");
-    pcSPS->setDmvrControlPresentFlag(uiCode != 0);
+    READ_FLAG(uiCode, "sps_dmvr_pic_present_flag");                 pcSPS->setDmvrControlPresentFlag( uiCode != 0 );
   }
-  else
-  {
-    pcSPS->setDmvrControlPresentFlag(false);
+  else {
+    pcSPS->setDmvrControlPresentFlag( false );
   }
-  READ_FLAG(uiCode, "sps_mmvd_enabled_flag");
-  pcSPS->setUseMMVD(uiCode != 0);
-  READ_FLAG(uiCode, "sps_isp_enabled_flag");
-  pcSPS->setUseISP(uiCode != 0);
-  READ_FLAG(uiCode, "sps_mrl_enabled_flag");
-  pcSPS->setUseMRL(uiCode != 0);
-  READ_FLAG(uiCode, "sps_mip_enabled_flag");
-  pcSPS->setUseMIP(uiCode != 0);
-  if (pcSPS->getChromaFormatIdc() != CHROMA_400)
+  READ_FLAG(uiCode, "sps_mmvd_enabled_flag");                        pcSPS->setUseMMVD(uiCode != 0);
+  READ_FLAG(uiCode, "sps_isp_enabled_flag");                        pcSPS->setUseISP( uiCode != 0 );
+  READ_FLAG(uiCode, "sps_mrl_enabled_flag");                        pcSPS->setUseMRL( uiCode != 0 );
+  READ_FLAG(uiCode, "sps_mip_enabled_flag");                        pcSPS->setUseMIP( uiCode != 0 );
+  if( pcSPS->getChromaFormatIdc() != CHROMA_400) 
   {
-    READ_FLAG(uiCode, "sps_cclm_enabled_flag");
-    pcSPS->setUseLMChroma(uiCode != 0);
+    READ_FLAG( uiCode, "sps_cclm_enabled_flag" );                   pcSPS->setUseLMChroma( uiCode != 0 );
   }
   else
   {
     pcSPS->setUseLMChroma(0);
   }
-  if (pcSPS->getChromaFormatIdc() == CHROMA_420)
+  if( pcSPS->getChromaFormatIdc() == CHROMA_420 )
   {
-    READ_FLAG(uiCode, "sps_chroma_horizontal_collocated_flag");
-    pcSPS->setHorCollocatedChromaFlag(uiCode != 0);
-    READ_FLAG(uiCode, "sps_chroma_vertical_collocated_flag");
-    pcSPS->setVerCollocatedChromaFlag(uiCode != 0);
+    READ_FLAG( uiCode, "sps_chroma_horizontal_collocated_flag" );   pcSPS->setHorCollocatedChromaFlag( uiCode != 0 );
+    READ_FLAG( uiCode, "sps_chroma_vertical_collocated_flag" );     pcSPS->setVerCollocatedChromaFlag( uiCode != 0 );
   }
 
-  READ_FLAG(uiCode, "sps_mts_enabled_flag");
-  pcSPS->setUseMTS(uiCode != 0);
-  if (pcSPS->getUseMTS())
+  READ_FLAG( uiCode,    "sps_mts_enabled_flag" );                       pcSPS->setUseMTS                 ( uiCode != 0 );
+  if ( pcSPS->getUseMTS() )
   {
-    READ_FLAG(uiCode, "sps_explicit_mts_intra_enabled_flag");
-    pcSPS->setUseIntraMTS(uiCode != 0);
-    READ_FLAG(uiCode, "sps_explicit_mts_inter_enabled_flag");
-    pcSPS->setUseInterMTS(uiCode != 0);
+    READ_FLAG( uiCode,    "sps_explicit_mts_intra_enabled_flag" );               pcSPS->setUseIntraMTS            ( uiCode != 0 );
+    READ_FLAG( uiCode,    "sps_explicit_mts_inter_enabled_flag" );               pcSPS->setUseInterMTS            ( uiCode != 0 );
   }
-  READ_FLAG(uiCode, "sps_sbt_enabled_flag");
-  pcSPS->setUseSBT(uiCode != 0);
-  READ_FLAG(uiCode, "sps_affine_enabled_flag");
-  pcSPS->setUseAffine(uiCode != 0);
-  if (pcSPS->getUseAffine())
+  READ_FLAG(uiCode, "sps_sbt_enabled_flag");                        pcSPS->setUseSBT                 ( uiCode != 0 );
+  READ_FLAG( uiCode,    "sps_affine_enabled_flag" );                            pcSPS->setUseAffine              ( uiCode != 0 );
+  if ( pcSPS->getUseAffine() )
   {
-    READ_FLAG(uiCode, "sps_affine_type_flag");
-    pcSPS->setUseAffineType(uiCode != 0);
+    READ_FLAG( uiCode,  "sps_affine_type_flag" );                       pcSPS->setUseAffineType          ( uiCode != 0 );
 #if JVET_Q0444_AMVR_SIGNALLING
-    if (pcSPS->getAMVREnabledFlag())
+    if( pcSPS->getAMVREnabledFlag())
     {
 #endif
-      READ_FLAG(uiCode, "sps_affine_amvr_enabled_flag");
-      pcSPS->setAffineAmvrEnabledFlag(uiCode != 0);
+      READ_FLAG( uiCode, "sps_affine_amvr_enabled_flag" );            pcSPS->setAffineAmvrEnabledFlag  ( uiCode != 0 );
 #if JVET_Q0444_AMVR_SIGNALLING
     }
 #endif
-    READ_FLAG(uiCode, "sps_affine_prof_enabled_flag");
-    pcSPS->setUsePROF(uiCode != 0);
+    READ_FLAG( uiCode, "sps_affine_prof_enabled_flag" );            pcSPS->setUsePROF                ( uiCode != 0 );
     if (pcSPS->getUsePROF())
     {
-      READ_FLAG(uiCode, "sps_prof_pic_present_flag");
-      pcSPS->setProfControlPresentFlag(uiCode != 0);
+      READ_FLAG(uiCode, "sps_prof_pic_present_flag");               pcSPS->setProfControlPresentFlag ( uiCode != 0 );
     }
-    else
-    {
-      pcSPS->setProfControlPresentFlag(false);
+    else {
+      pcSPS->setProfControlPresentFlag( false );
     }
   }
   if (pcSPS->getChromaFormatIdc() == CHROMA_444)
@@ -1842,12 +1656,10 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
 #if JVET_Q0820_ACT
     if (pcSPS->getLog2MaxTbSize() != 6)
     {
-      READ_FLAG(uiCode, "sps_act_enabled_flag");
-      pcSPS->setUseColorTrans(uiCode != 0);
+      READ_FLAG(uiCode, "sps_act_enabled_flag");                                pcSPS->setUseColorTrans(uiCode != 0);
     }
 #else
-    READ_FLAG(uiCode, "sps_act_enabled_flag");
-    pcSPS->setUseColorTrans(uiCode != 0);
+    READ_FLAG(uiCode, "sps_act_enabled_flag");                                  pcSPS->setUseColorTrans(uiCode != 0);
 #endif
   }
   else
@@ -1855,61 +1667,47 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
     pcSPS->setUseColorTrans(false);
   }
 #if JVET_Q0504_PLT_NON444
-  READ_FLAG(uiCode, "sps_palette_enabled_flag");
-  pcSPS->setPLTMode(uiCode != 0);
+  READ_FLAG( uiCode,  "sps_palette_enabled_flag");                                pcSPS->setPLTMode                ( uiCode != 0 );
 #else
   if (pcSPS->getChromaFormatIdc() == CHROMA_444)
   {
-    READ_FLAG(uiCode, "sps_palette_enabled_flag");
-    pcSPS->setPLTMode(uiCode != 0);
+    READ_FLAG( uiCode,  "sps_palette_enabled_flag");                                pcSPS->setPLTMode                ( uiCode != 0 );
   }
   else
   {
     pcSPS->setPLTMode(false);
   }
 #endif
-  READ_FLAG(uiCode, "sps_bcw_enabled_flag");
-  pcSPS->setUseBcw(uiCode != 0);
-  READ_FLAG(uiCode, "sps_ibc_enabled_flag");
-  pcSPS->setIBCFlag(uiCode);
+  READ_FLAG( uiCode,    "sps_bcw_enabled_flag" );                   pcSPS->setUseBcw( uiCode != 0 );
+  READ_FLAG(uiCode, "sps_ibc_enabled_flag");                                    pcSPS->setIBCFlag(uiCode);
   // KJS: sps_ciip_enabled_flag
-  READ_FLAG(uiCode, "sps_ciip_enabled_flag");
-  pcSPS->setUseCiip(uiCode != 0);
+  READ_FLAG( uiCode,     "sps_ciip_enabled_flag" );                           pcSPS->setUseCiip             ( uiCode != 0 );
 
-  if (pcSPS->getUseMMVD())
+  if ( pcSPS->getUseMMVD() )
   {
-    READ_FLAG(uiCode, "sps_fpel_mmvd_enabled_flag");
-    pcSPS->setFpelMmvdEnabledFlag(uiCode != 0);
+    READ_FLAG( uiCode,  "sps_fpel_mmvd_enabled_flag" );             pcSPS->setFpelMmvdEnabledFlag ( uiCode != 0 );
   }
 
 #if !JVET_Q0806
-  READ_FLAG(uiCode, "triangle_flag");
-  pcSPS->setUseTriangle(uiCode != 0);
+  READ_FLAG( uiCode,    "triangle_flag" );                          pcSPS->setUseTriangle            ( uiCode != 0 );
 #else
-  READ_FLAG(uiCode, "sps_gpm_enabled_flag");
-  pcSPS->setUseGeo(uiCode != 0);
+  READ_FLAG( uiCode,    "sps_gpm_enabled_flag" );                               pcSPS->setUseGeo                 ( uiCode != 0 );
 #endif
 
-  READ_FLAG(uiCode, "sps_lmcs_enable_flag");
-  pcSPS->setUseLmcs(uiCode == 1);
-  READ_FLAG(uiCode, "sps_lfnst_enabled_flag");
-  pcSPS->setUseLFNST(uiCode != 0);
+  READ_FLAG(uiCode, "sps_lmcs_enable_flag");                   pcSPS->setUseLmcs(uiCode == 1);
+  READ_FLAG( uiCode, "sps_lfnst_enabled_flag" );                    pcSPS->setUseLFNST( uiCode != 0 );
 
 #if LUMA_ADAPTIVE_DEBLOCKING_FILTER_QP_OFFSET
-  READ_FLAG(uiCode, "sps_ladf_enabled_flag");
-  pcSPS->setLadfEnabled(uiCode != 0);
-  if (pcSPS->getLadfEnabled())
+  READ_FLAG( uiCode, "sps_ladf_enabled_flag" );                     pcSPS->setLadfEnabled( uiCode != 0 );
+  if ( pcSPS->getLadfEnabled() )
   {
     int signedSymbol = 0;
-    READ_CODE(2, uiCode, "sps_num_ladf_intervals_minus2");
-    pcSPS->setLadfNumIntervals(uiCode + 2);
-    READ_SVLC(signedSymbol, "sps_ladf_lowest_interval_qp_offset");
-    pcSPS->setLadfQpOffset(signedSymbol, 0);
-    for (int k = 1; k < pcSPS->getLadfNumIntervals(); k++)
-    {
-      READ_SVLC(signedSymbol, "sps_ladf_qp_offset");
-      pcSPS->setLadfQpOffset(signedSymbol, k);
-      READ_UVLC(uiCode, "sps_ladf_delta_threshold_minus1");
+    READ_CODE( 2, uiCode, "sps_num_ladf_intervals_minus2");         pcSPS->setLadfNumIntervals( uiCode + 2 );
+    READ_SVLC(signedSymbol, "sps_ladf_lowest_interval_qp_offset" );      pcSPS->setLadfQpOffset( signedSymbol, 0 );
+    for ( int k = 1; k < pcSPS->getLadfNumIntervals(); k++ )
+    {
+      READ_SVLC(signedSymbol, "sps_ladf_qp_offset" );                    pcSPS->setLadfQpOffset( signedSymbol, k );
+      READ_UVLC( uiCode, "sps_ladf_delta_threshold_minus1");
       pcSPS->setLadfIntervalLowerBound(uiCode + pcSPS->getLadfIntervalLowerBound(k - 1) + 1, k);
     }
   }
@@ -1925,46 +1723,36 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
   // KJS: not found in draft -> does not exist
 
   // KJS: remove scaling lists?
-  READ_FLAG(uiCode, "scaling_list_enabled_flag");
-  pcSPS->setScalingListFlag(uiCode);
+  READ_FLAG( uiCode, "scaling_list_enabled_flag" );                 pcSPS->setScalingListFlag ( uiCode );
 
-  READ_FLAG(uiCode, "sps_loop_filter_across_virtual_boundaries_disabled_present_flag");
-  pcSPS->setLoopFilterAcrossVirtualBoundariesDisabledFlag(uiCode != 0);
-  if (pcSPS->getLoopFilterAcrossVirtualBoundariesDisabledFlag())
+  READ_FLAG( uiCode, "sps_loop_filter_across_virtual_boundaries_disabled_present_flag" ); pcSPS->setLoopFilterAcrossVirtualBoundariesDisabledFlag( uiCode != 0 );
+  if( pcSPS->getLoopFilterAcrossVirtualBoundariesDisabledFlag() )
   {
-    READ_CODE(2, uiCode, "sps_num_ver_virtual_boundaries");
-    pcSPS->setNumVerVirtualBoundaries(uiCode);
-    for (unsigned i = 0; i < pcSPS->getNumVerVirtualBoundaries(); i++)
+    READ_CODE( 2, uiCode, "sps_num_ver_virtual_boundaries");        pcSPS->setNumVerVirtualBoundaries( uiCode );
+    for( unsigned i = 0; i < pcSPS->getNumVerVirtualBoundaries(); i++ )
     {
-      READ_CODE(13, uiCode, "sps_virtual_boundaries_pos_x");
-      pcSPS->setVirtualBoundariesPosX(uiCode << 3, i);
+      READ_CODE(13, uiCode, "sps_virtual_boundaries_pos_x");        pcSPS->setVirtualBoundariesPosX(uiCode << 3, i);
     }
-    READ_CODE(2, uiCode, "sps_num_hor_virtual_boundaries");
-    pcSPS->setNumHorVirtualBoundaries(uiCode);
-    for (unsigned i = 0; i < pcSPS->getNumHorVirtualBoundaries(); i++)
+    READ_CODE( 2, uiCode, "sps_num_hor_virtual_boundaries");        pcSPS->setNumHorVirtualBoundaries( uiCode );
+    for( unsigned i = 0; i < pcSPS->getNumHorVirtualBoundaries(); i++ )
     {
-      READ_CODE(13, uiCode, "sps_virtual_boundaries_pos_y");
-      pcSPS->setVirtualBoundariesPosY(uiCode << 3, i);
+      READ_CODE(13, uiCode, "sps_virtual_boundaries_pos_y");        pcSPS->setVirtualBoundariesPosY(uiCode << 3, i);
     }
   }
   else
   {
-    pcSPS->setNumVerVirtualBoundaries(0);
-    pcSPS->setNumHorVirtualBoundaries(0);
+    pcSPS->setNumVerVirtualBoundaries( 0 );
+    pcSPS->setNumHorVirtualBoundaries( 0 );
   }
 
   TimingInfo *timingInfo = pcSPS->getTimingInfo();
-  READ_FLAG(uiCode, "general_hrd_parameters_present_flag");
-  pcSPS->setHrdParametersPresentFlag(uiCode);
-  if (pcSPS->getHrdParametersPresentFlag())
+  READ_FLAG(     uiCode, "general_hrd_parameters_present_flag");        pcSPS->setHrdParametersPresentFlag(uiCode);
+  if( pcSPS->getHrdParametersPresentFlag() )
   {
-    READ_CODE(32, uiCode, "num_units_in_tick");
-    timingInfo->setNumUnitsInTick(uiCode);
-    READ_CODE(32, uiCode, "time_scale");
-    timingInfo->setTimeScale(uiCode);
+    READ_CODE( 32, uiCode, "num_units_in_tick");                timingInfo->setNumUnitsInTick             (uiCode);
+    READ_CODE( 32, uiCode, "time_scale");                       timingInfo->setTimeScale                  (uiCode);
 
-    READ_FLAG(uiCode, "sub_layer_cpb_parameters_present_flag");
-    pcSPS->setSubLayerParametersPresentFlag(uiCode);
+    READ_FLAG( uiCode, "sub_layer_cpb_parameters_present_flag");  pcSPS->setSubLayerParametersPresentFlag(uiCode);
     if (pcSPS->getSubLayerParametersPresentFlag())
     {
       parseHrdParameters(pcSPS->getHrdParameters(), 0, pcSPS->getMaxTLayers() - 1);
@@ -1975,8 +1763,7 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
     }
   }
 
-  READ_FLAG(uiCode, "vui_parameters_present_flag");
-  pcSPS->setVuiParametersPresentFlag(uiCode);
+  READ_FLAG( uiCode, "vui_parameters_present_flag" );             pcSPS->setVuiParametersPresentFlag(uiCode);
 
   if (pcSPS->getVuiParametersPresentFlag())
   {
@@ -1985,25 +1772,29 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
 
   // KJS: no SPS extensions defined yet
 
-  READ_FLAG(uiCode, "sps_extension_present_flag");
+  READ_FLAG( uiCode, "sps_extension_present_flag");
   if (uiCode)
   {
 #if ENABLE_TRACING || RExt__DECODER_DEBUG_BIT_STATISTICS
-    static const char *syntaxStrings[] = { "sps_range_extension_flag", "sps_multilayer_extension_flag",
-                                           "sps_extension_6bits[0]",   "sps_extension_6bits[1]",
-                                           "sps_extension_6bits[2]",   "sps_extension_6bits[3]",
-                                           "sps_extension_6bits[4]",   "sps_extension_6bits[5]" };
+    static const char *syntaxStrings[]={ "sps_range_extension_flag",
+      "sps_multilayer_extension_flag",
+      "sps_extension_6bits[0]",
+      "sps_extension_6bits[1]",
+      "sps_extension_6bits[2]",
+      "sps_extension_6bits[3]",
+      "sps_extension_6bits[4]",
+      "sps_extension_6bits[5]" };
 #endif
     bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS];
 
-    for (int i = 0; i < NUM_SPS_EXTENSION_FLAGS; i++)
+    for(int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++)
     {
-      READ_FLAG(uiCode, syntaxStrings[i]);
-      sps_extension_flags[i] = uiCode != 0;
+      READ_FLAG( uiCode, syntaxStrings[i] );
+      sps_extension_flags[i] = uiCode!=0;
     }
 
-    bool bSkipTrailingExtensionBits = false;
-    for (int i = 0; i < NUM_SPS_EXTENSION_FLAGS; i++)   // loop used so that the order is determined by the enum.
+    bool bSkipTrailingExtensionBits=false;
+    for(int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum.
     {
       if (sps_extension_flags[i])
       {
@@ -2013,114 +1804,99 @@ void HLSyntaxReader::parseSPS(SPS *pcSPS)
           CHECK(bSkipTrailingExtensionBits, "Skipping trailing extension bits not supported");
           {
             SPSRExt &spsRangeExtension = pcSPS->getSpsRangeExtension();
-            READ_FLAG(uiCode, "transform_skip_rotation_enabled_flag");
-            spsRangeExtension.setTransformSkipRotationEnabledFlag(uiCode != 0);
-            READ_FLAG(uiCode, "transform_skip_context_enabled_flag");
-            spsRangeExtension.setTransformSkipContextEnabledFlag(uiCode != 0);
-            READ_FLAG(uiCode, "implicit_rdpcm_enabled_flag");
-            spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0));
-            READ_FLAG(uiCode, "explicit_rdpcm_enabled_flag");
-            spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0));
-            READ_FLAG(uiCode, "extended_precision_processing_flag");
-            spsRangeExtension.setExtendedPrecisionProcessingFlag(uiCode != 0);
-            READ_FLAG(uiCode, "intra_smoothing_disabled_flag");
-            spsRangeExtension.setIntraSmoothingDisabledFlag(uiCode != 0);
-            READ_FLAG(uiCode, "high_precision_offsets_enabled_flag");
-            spsRangeExtension.setHighPrecisionOffsetsEnabledFlag(uiCode != 0);
-            READ_FLAG(uiCode, "persistent_rice_adaptation_enabled_flag");
-            spsRangeExtension.setPersistentRiceAdaptationEnabledFlag(uiCode != 0);
-            READ_FLAG(uiCode, "cabac_bypass_alignment_enabled_flag");
-            spsRangeExtension.setCabacBypassAlignmentEnabledFlag(uiCode != 0);
+            READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag");     spsRangeExtension.setTransformSkipRotationEnabledFlag(uiCode != 0);
+            READ_FLAG( uiCode, "transform_skip_context_enabled_flag");      spsRangeExtension.setTransformSkipContextEnabledFlag (uiCode != 0);
+            READ_FLAG( uiCode, "implicit_rdpcm_enabled_flag");              spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0));
+            READ_FLAG( uiCode, "explicit_rdpcm_enabled_flag");              spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0));
+            READ_FLAG( uiCode, "extended_precision_processing_flag");       spsRangeExtension.setExtendedPrecisionProcessingFlag (uiCode != 0);
+            READ_FLAG( uiCode, "intra_smoothing_disabled_flag");            spsRangeExtension.setIntraSmoothingDisabledFlag      (uiCode != 0);
+            READ_FLAG( uiCode, "high_precision_offsets_enabled_flag");      spsRangeExtension.setHighPrecisionOffsetsEnabledFlag (uiCode != 0);
+            READ_FLAG( uiCode, "persistent_rice_adaptation_enabled_flag");  spsRangeExtension.setPersistentRiceAdaptationEnabledFlag (uiCode != 0);
+            READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag");      spsRangeExtension.setCabacBypassAlignmentEnabledFlag  (uiCode != 0);
           }
           break;
-        default: bSkipTrailingExtensionBits = true; break;
+        default:
+          bSkipTrailingExtensionBits=true;
+          break;
         }
       }
     }
     if (bSkipTrailingExtensionBits)
     {
-      while (xMoreRbspData())
+      while ( xMoreRbspData() )
       {
-        READ_FLAG(uiCode, "sps_extension_data_flag");
+        READ_FLAG( uiCode, "sps_extension_data_flag");
       }
     }
   }
   xReadRbspTrailingBits();
 }
 
-void HLSyntaxReader::parseDPS(DPS *dps)
+void HLSyntaxReader::parseDPS(DPS* dps)
 {
 #if ENABLE_TRACING
-  xTraceDPSHeader();
+  xTraceDPSHeader ();
 #endif
-  uint32_t symbol;
+  uint32_t  symbol;
 
-  READ_CODE(4, symbol, "dps_decoding_parameter_set_id");
+  READ_CODE( 4,  symbol,  "dps_decoding_parameter_set_id" );
   CHECK(symbol == 0, "dps_decoding_parameter_set_id equal to zero is reserved and should not be use in a bitstream");
-  dps->setDecodingParameterSetId(symbol);
-
-  READ_CODE(3, symbol, "dps_max_sub_layers_minus1");
-  dps->setMaxSubLayersMinus1(symbol);
-  READ_CODE(5, symbol, "dps_reserved_zero_5bits");
-  CHECK(symbol != 0, "dps_reserved_zero_5bits must be equal to zero");
+  dps->setDecodingParameterSetId( symbol );
 
+  READ_CODE( 3,  symbol,  "dps_max_sub_layers_minus1" );          dps->setMaxSubLayersMinus1( symbol );
+  READ_CODE( 5, symbol,       "dps_reserved_zero_5bits" );              CHECK(symbol != 0, "dps_reserved_zero_5bits must be equal to zero");
+  
   uint32_t numPTLs;
-  READ_CODE(4, numPTLs, "dps_num_ptls_minus1");
+  READ_CODE( 4, numPTLs,       "dps_num_ptls_minus1" );
   numPTLs += 1;
 
   std::vector<ProfileTierLevel> ptls;
   ptls.resize(numPTLs);
-  for (int i = 0; i < numPTLs; i++)
+  for (int i=0; i<numPTLs; i++)
   {
-    parseProfileTierLevel(&ptls[i], dps->getMaxSubLayersMinus1());
+     parseProfileTierLevel(&ptls[i], dps->getMaxSubLayersMinus1());
   }
   dps->setProfileTierLevel(ptls);
 
-  READ_FLAG(symbol, "dps_extension_flag");
+  READ_FLAG( symbol,      "dps_extension_flag" );
   if (symbol)
   {
-    while (xMoreRbspData())
+    while ( xMoreRbspData() )
     {
-      READ_FLAG(symbol, "dps_extension_data_flag");
+      READ_FLAG( symbol, "dps_extension_data_flag");
     }
   }
   xReadRbspTrailingBits();
 }
 
-void HLSyntaxReader::parseVPS(VPS *pcVPS)
+void HLSyntaxReader::parseVPS(VPS* pcVPS)
 {
 #if ENABLE_TRACING
   xTraceVPSHeader();
 #endif
-  uint32_t uiCode;
+  uint32_t  uiCode;
 
-  READ_CODE(4, uiCode, "vps_video_parameter_set_id");
-  CHECK(uiCode == 0, "vps_video_parameter_set_id equal to zero is reserved and shall not be used in a bitstream");
+  READ_CODE(4, uiCode, "vps_video_parameter_set_id");         
+  CHECK( uiCode == 0, "vps_video_parameter_set_id equal to zero is reserved and shall not be used in a bitstream" );
   pcVPS->setVPSId(uiCode);
 
-  READ_CODE(6, uiCode, "vps_max_layers_minus1");
-  pcVPS->setMaxLayers(uiCode + 1);
-  CHECK(uiCode + 1 > MAX_VPS_LAYERS, "Invalid code");
+  READ_CODE(6, uiCode, "vps_max_layers_minus1");              pcVPS->setMaxLayers(uiCode + 1);    CHECK(uiCode + 1 > MAX_VPS_LAYERS, "Invalid code");
   if (pcVPS->getMaxLayers() - 1 == 0)
   {
     pcVPS->setEachLayerIsAnOlsFlag(1);
   }
-  READ_CODE(3, uiCode, "vps_max_sublayers_minus1");
-  pcVPS->setMaxSubLayers(uiCode + 1);
-  CHECK(uiCode + 1 > MAX_VPS_SUBLAYERS, "Invalid code");
-  if (pcVPS->getMaxLayers() > 1 && pcVPS->getMaxSubLayers() > 1)
+  READ_CODE(3, uiCode, "vps_max_sublayers_minus1");           pcVPS->setMaxSubLayers(uiCode + 1); CHECK(uiCode + 1 > MAX_VPS_SUBLAYERS, "Invalid code");
+  if( pcVPS->getMaxLayers() > 1 && pcVPS->getMaxSubLayers() > 1)
   {
-    READ_FLAG(uiCode, "vps_all_layers_same_num_sublayers_flag");
-    pcVPS->setAllLayersSameNumSublayersFlag(uiCode);
+    READ_FLAG(uiCode, "vps_all_layers_same_num_sublayers_flag"); pcVPS->setAllLayersSameNumSublayersFlag(uiCode);
   }
   else
   {
     pcVPS->setAllLayersSameNumSublayersFlag(1);
   }
-  if (pcVPS->getMaxLayers() > 1)
+  if( pcVPS->getMaxLayers() > 1 )
   {
-    READ_FLAG(uiCode, "vps_all_independent_layers_flag");
-    pcVPS->setAllIndependentLayersFlag(uiCode);
+    READ_FLAG(uiCode, "vps_all_independent_layers_flag");  pcVPS->setAllIndependentLayersFlag(uiCode);
     if (pcVPS->getAllIndependentLayersFlag() == 0)
     {
       pcVPS->setEachLayerIsAnOlsFlag(0);
@@ -2128,31 +1904,26 @@ void HLSyntaxReader::parseVPS(VPS *pcVPS)
   }
   for (uint32_t i = 0; i < pcVPS->getMaxLayers(); i++)
   {
-    READ_CODE(6, uiCode, "vps_layer_id");
-    pcVPS->setLayerId(i, uiCode);
+    READ_CODE(6, uiCode, "vps_layer_id");                     pcVPS->setLayerId(i, uiCode);
     pcVPS->setGeneralLayerIdx(uiCode, i);
 
     if (i > 0 && !pcVPS->getAllIndependentLayersFlag())
     {
-      READ_FLAG(uiCode, "vps_independent_layer_flag");
-      pcVPS->setIndependentLayerFlag(i, uiCode);
+      READ_FLAG(uiCode, "vps_independent_layer_flag");     pcVPS->setIndependentLayerFlag(i, uiCode);
       if (!pcVPS->getIndependentLayerFlag(i))
       {
         uint16_t sumUiCode = 0;
         for (int j = 0, k = 0; j < i; j++)
         {
-          READ_FLAG(uiCode, "vps_direct_dependency_flag");
-          pcVPS->setDirectRefLayerFlag(i, j, uiCode);
-          if (uiCode)
+          READ_FLAG(uiCode, "vps_direct_dependency_flag"); pcVPS->setDirectRefLayerFlag(i, j, uiCode);
+          if( uiCode )
           {
-            pcVPS->setInterLayerRefIdc(i, j, k);
-            pcVPS->setDirectRefLayerIdx(i, k++, j);
+            pcVPS->setInterLayerRefIdc( i, j, k );
+            pcVPS->setDirectRefLayerIdx( i, k++, j );
             sumUiCode++;
           }
         }
-        CHECK(sumUiCode == 0,
-              "There has to be at least one value of j such that the value of vps_direct_dependency_flag[ i ][ j ] is "
-              "equal to 1,when vps_independent_layer_flag[ i ] is equal to 0 ");
+        CHECK(sumUiCode == 0, "There has to be at least one value of j such that the value of vps_direct_dependency_flag[ i ][ j ] is equal to 1,when vps_independent_layer_flag[ i ] is equal to 0 ");
       }
     }
   }
@@ -2161,8 +1932,7 @@ void HLSyntaxReader::parseVPS(VPS *pcVPS)
   {
     if (pcVPS->getAllIndependentLayersFlag())
     {
-      READ_FLAG(uiCode, "vps_each_layer_is_an_ols_flag");
-      pcVPS->setEachLayerIsAnOlsFlag(uiCode);
+      READ_FLAG(uiCode, "vps_each_layer_is_an_ols_flag");  pcVPS->setEachLayerIsAnOlsFlag(uiCode);
       if (pcVPS->getEachLayerIsAnOlsFlag() == 0)
       {
         pcVPS->setOlsModeIdc(2);
@@ -2172,20 +1942,16 @@ void HLSyntaxReader::parseVPS(VPS *pcVPS)
     {
       if (!pcVPS->getAllIndependentLayersFlag())
       {
-        READ_CODE(2, uiCode, "vps_ols_mode_idc");
-        pcVPS->setOlsModeIdc(uiCode);
-        CHECK(uiCode > MAX_VPS_OLS_MODE_IDC, "Invalid code");
+        READ_CODE(2, uiCode, "vps_ols_mode_idc");             pcVPS->setOlsModeIdc(uiCode); CHECK(uiCode > MAX_VPS_OLS_MODE_IDC, "Invalid code");
       }
       if (pcVPS->getOlsModeIdc() == 2)
       {
-        READ_CODE(8, uiCode, "num_output_layer_sets_minus1");
-        pcVPS->setNumOutputLayerSets(uiCode + 1);
+        READ_CODE(8, uiCode, "num_output_layer_sets_minus1");   pcVPS->setNumOutputLayerSets(uiCode + 1);
         for (uint32_t i = 1; i <= pcVPS->getNumOutputLayerSets() - 1; i++)
         {
           for (uint32_t j = 0; j < pcVPS->getMaxLayers(); j++)
           {
-            READ_FLAG(uiCode, "vps_ols_output_layer_flag");
-            pcVPS->setOlsOutputLayerFlag(i, j, uiCode);
+            READ_FLAG(uiCode, "vps_ols_output_layer_flag");        pcVPS->setOlsOutputLayerFlag(i, j, uiCode);
           }
         }
       }
@@ -2204,200 +1970,182 @@ void HLSyntaxReader::parseVPS(VPS *pcVPS)
 }
 
 #if JVET_Q0775_PH_IN_SH
-void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManager *parameterSetManager,
-                                        bool readRbspTrailingBits)
+void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManager *parameterSetManager, bool readRbspTrailingBits )
 #else
-void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManager *parameterSetManager)
+void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManager *parameterSetManager )
 #endif
 {
-  uint32_t uiCode;
-  int      iCode;
-  PPS *    pps = NULL;
-  SPS *    sps = NULL;
-
+  uint32_t  uiCode; 
+  int       iCode;
+  PPS*      pps = NULL;
+  SPS*      sps = NULL;
+  
 #if ENABLE_TRACING
   xTracePictureHeader();
 #endif
 
 #if JVET_Q0819_PH_CHANGES
-  READ_FLAG(uiCode, "pic_inter_slice_allowed_flag");
-  picHeader->setPicInterSliceAllowedFlag(uiCode != 0);
+  READ_FLAG(uiCode, "pic_inter_slice_allowed_flag");       picHeader->setPicInterSliceAllowedFlag(uiCode != 0);
   if (picHeader->getPicInterSliceAllowedFlag())
   {
-    READ_FLAG(uiCode, "pic_intra_slice_allowed_flag");
-    picHeader->setPicIntraSliceAllowedFlag(uiCode != 0);
+    READ_FLAG(uiCode, "pic_intra_slice_allowed_flag");       picHeader->setPicIntraSliceAllowedFlag(uiCode != 0);
   }
   else
   {
     picHeader->setPicIntraSliceAllowedFlag(true);
   }
-  CHECK(picHeader->getPicInterSliceAllowedFlag() == 0 && picHeader->getPicIntraSliceAllowedFlag() == 0,
-        "Invalid picture without intra or inter slice");
+  CHECK(picHeader->getPicInterSliceAllowedFlag() == 0 && picHeader->getPicIntraSliceAllowedFlag() == 0, "Invalid picture without intra or inter slice");
 #endif
-  READ_FLAG(uiCode, "non_reference_picture_flag");
-  picHeader->setNonReferencePictureFlag(uiCode != 0);
-  READ_FLAG(uiCode, "gdr_pic_flag");
-  picHeader->setGdrPicFlag(uiCode != 0);
-  READ_FLAG(uiCode, "no_output_of_prior_pics_flag");
-  picHeader->setNoOutputOfPriorPicsFlag(uiCode != 0);
-  if (picHeader->getGdrPicFlag())
+  READ_FLAG(uiCode, "non_reference_picture_flag");       picHeader->setNonReferencePictureFlag( uiCode != 0 );
+  READ_FLAG(uiCode, "gdr_pic_flag");                     picHeader->setGdrPicFlag( uiCode != 0 );
+  READ_FLAG(uiCode, "no_output_of_prior_pics_flag");     picHeader->setNoOutputOfPriorPicsFlag( uiCode != 0 );
+  if( picHeader->getGdrPicFlag() ) 
   {
-    READ_UVLC(uiCode, "recovery_poc_cnt");
-    picHeader->setRecoveryPocCnt(uiCode);
+    READ_UVLC(uiCode, "recovery_poc_cnt");               picHeader->setRecoveryPocCnt( uiCode );
   }
-  else
+  else 
   {
-    picHeader->setRecoveryPocCnt(0);
+    picHeader->setRecoveryPocCnt( 0 );
   }
-
+  
   // parameter sets
   READ_UVLC(uiCode, "ph_pic_parameter_set_id");
-  picHeader->setPPSId(uiCode);
+  picHeader->setPPSId( uiCode );
   pps = parameterSetManager->getPPS(picHeader->getPPSId());
-  CHECK(pps == 0, "Invalid PPS");
-  picHeader->setSPSId(pps->getSPSId());
+  CHECK(pps==0, "Invalid PPS");  
+  picHeader->setSPSId( pps->getSPSId() );
   sps = parameterSetManager->getSPS(picHeader->getSPSId());
-  CHECK(sps == 0, "Invalid SPS");
+  CHECK(sps==0, "Invalid SPS");
 #if JVET_Q0819_PH_CHANGES
   READ_CODE(sps->getBitsForPOC(), uiCode, "ph_pic_order_cnt_lsb");
   picHeader->setPocLsb(uiCode);
 #endif
 
+  
   // initialize tile/slice info for no partitioning case
-  if (pps->getNoPicPartitionFlag())
+  if( pps->getNoPicPartitionFlag() )
   {
     pps->resetTileSliceInfo();
-    pps->setLog2CtuSize(ceilLog2(sps->getCTUSize()));
+    pps->setLog2CtuSize( ceilLog2(sps->getCTUSize()) );
     pps->setNumExpTileColumns(1);
     pps->setNumExpTileRows(1);
-    pps->addTileColumnWidth(pps->getPicWidthInCtu());
-    pps->addTileRowHeight(pps->getPicHeightInCtu());
+    pps->addTileColumnWidth( pps->getPicWidthInCtu( ) );
+    pps->addTileRowHeight( pps->getPicHeightInCtu( ) );
     pps->initTiles();
-    pps->setRectSliceFlag(1);
-    pps->setNumSlicesInPic(1);
-    pps->initRectSlices();
-    pps->setTileIdxDeltaPresentFlag(0);
-    pps->setSliceTileIdx(0, 0);
-    pps->initRectSliceMap();
+    pps->setRectSliceFlag( 1 );
+    pps->setNumSlicesInPic( 1 );
+    pps->initRectSlices( );
+    pps->setTileIdxDeltaPresentFlag( 0 );
+    pps->setSliceTileIdx( 0, 0 );
+    pps->initRectSliceMap( );
 #if JVET_O1143_SUBPIC_BOUNDARY
     // when no Pic partition, number of sub picture shall be less than 2
-    CHECK(pps->getNumSubPics() >= 2, "error, no picture partitions, but have equal to or more than 2 sub pictures");
+    CHECK(pps->getNumSubPics()>=2, "error, no picture partitions, but have equal to or more than 2 sub pictures");
 #endif
   }
-  else
+  else 
   {
     CHECK(pps->getCtuSize() != sps->getCTUSize(), "PPS CTU size does not match CTU size in SPS");
   }
 
   // sub-picture IDs
-  if (sps->getSubPicIdPresentFlag())
+  if( sps->getSubPicIdPresentFlag() ) 
   {
-    if (sps->getSubPicIdSignallingPresentFlag())
+    if( sps->getSubPicIdSignallingPresentFlag() ) 
     {
-      for (int picIdx = 0; picIdx < sps->getNumSubPics(); picIdx++)
+      for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ )
       {
-        picHeader->setSubPicId(picIdx, sps->getSubPicId(picIdx));
+        picHeader->setSubPicId( picIdx, sps->getSubPicId( picIdx ) );
       }
     }
-    else
+    else 
     {
-      READ_FLAG(uiCode, "ph_subpic_id_signalling_present_flag");
-      picHeader->setSubPicIdSignallingPresentFlag(uiCode != 0);
-      if (picHeader->getSubPicIdSignallingPresentFlag())
+      READ_FLAG(uiCode, "ph_subpic_id_signalling_present_flag");                 picHeader->setSubPicIdSignallingPresentFlag( uiCode != 0 );
+      if( picHeader->getSubPicIdSignallingPresentFlag() )
       {
-        READ_UVLC(uiCode, "ph_subpic_id_len_minus1");
-        picHeader->setSubPicIdLen(uiCode + 1);
-        CHECK(uiCode > 15, "Invalid ph_subpic_id_len_minus1 signalled");
+        READ_UVLC( uiCode, "ph_subpic_id_len_minus1" );                          picHeader->setSubPicIdLen( uiCode + 1 );
+        CHECK( uiCode > 15, "Invalid ph_subpic_id_len_minus1 signalled");
 #if JVET_Q0169_SUBPIC_LEN_CONFORM
         CHECK((1 << picHeader->getSubPicIdLen()) < sps->getNumSubPics(), "ph_subpic_id_len exceeds valid range");
 #endif
-        for (int picIdx = 0; picIdx < sps->getNumSubPics(); picIdx++)
+        for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ )
         {
-          READ_CODE(picHeader->getSubPicIdLen(), uiCode, "ph_subpic_id[i]");
-          picHeader->setSubPicId(picIdx, uiCode);
+          READ_CODE( picHeader->getSubPicIdLen( ), uiCode, "ph_subpic_id[i]" );   picHeader->setSubPicId( picIdx, uiCode );
         }
       }
-      else
+      else 
       {
-        for (int picIdx = 0; picIdx < sps->getNumSubPics(); picIdx++)
+        for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ )
         {
-          picHeader->setSubPicId(picIdx, pps->getSubPicId(picIdx));
+          picHeader->setSubPicId( picIdx, pps->getSubPicId( picIdx ) );
         }
       }
     }
   }
-  else
+  else 
   {
-    for (int picIdx = 0; picIdx < sps->getNumSubPics(); picIdx++)
+    for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ )
     {
-      picHeader->setSubPicId(picIdx, picIdx);
+      picHeader->setSubPicId( picIdx, picIdx );
     }
   }
 
   // virtual boundaries
-  if (!sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag())
+  if( !sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag() )
   {
-    READ_FLAG(uiCode, "ph_loop_filter_across_virtual_boundaries_disabled_present_flag");
-    picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag(uiCode != 0);
-    if (picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag())
+    READ_FLAG( uiCode, "ph_loop_filter_across_virtual_boundaries_disabled_present_flag" ); picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag( uiCode != 0 );
+    if( picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag() )
     {
-      READ_CODE(2, uiCode, "ph_num_ver_virtual_boundaries");
-      picHeader->setNumVerVirtualBoundaries(uiCode);
-      for (unsigned i = 0; i < picHeader->getNumVerVirtualBoundaries(); i++)
+      READ_CODE( 2, uiCode, "ph_num_ver_virtual_boundaries");        picHeader->setNumVerVirtualBoundaries( uiCode );
+      for( unsigned i = 0; i < picHeader->getNumVerVirtualBoundaries(); i++ )
       {
-        READ_CODE(13, uiCode, "ph_virtual_boundaries_pos_x");
-        picHeader->setVirtualBoundariesPosX(uiCode << 3, i);
+        READ_CODE(13, uiCode, "ph_virtual_boundaries_pos_x");        picHeader->setVirtualBoundariesPosX(uiCode << 3, i);
       }
-      READ_CODE(2, uiCode, "ph_num_hor_virtual_boundaries");
-      picHeader->setNumHorVirtualBoundaries(uiCode);
-      for (unsigned i = 0; i < picHeader->getNumHorVirtualBoundaries(); i++)
+      READ_CODE( 2, uiCode, "ph_num_hor_virtual_boundaries");        picHeader->setNumHorVirtualBoundaries( uiCode );
+      for( unsigned i = 0; i < picHeader->getNumHorVirtualBoundaries(); i++ )
       {
-        READ_CODE(13, uiCode, "ph_virtual_boundaries_pos_y");
-        picHeader->setVirtualBoundariesPosY(uiCode << 3, i);
+        READ_CODE(13, uiCode, "ph_virtual_boundaries_pos_y");        picHeader->setVirtualBoundariesPosY(uiCode << 3, i);
       }
     }
     else
     {
-      picHeader->setNumVerVirtualBoundaries(0);
-      picHeader->setNumHorVirtualBoundaries(0);
+      picHeader->setNumVerVirtualBoundaries( 0 );
+      picHeader->setNumHorVirtualBoundaries( 0 );
     }
   }
   else
   {
-    picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag(
-      sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag());
-    picHeader->setNumVerVirtualBoundaries(sps->getNumVerVirtualBoundaries());
-    picHeader->setNumHorVirtualBoundaries(sps->getNumHorVirtualBoundaries());
-    for (unsigned i = 0; i < 3; i++)
+    picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag( sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag() );
+    picHeader->setNumVerVirtualBoundaries( sps->getNumVerVirtualBoundaries() );
+    picHeader->setNumHorVirtualBoundaries( sps->getNumHorVirtualBoundaries() );
+    for( unsigned i = 0; i < 3; i++ ) 
     {
-      picHeader->setVirtualBoundariesPosX(sps->getVirtualBoundariesPosX(i), i);
-      picHeader->setVirtualBoundariesPosY(sps->getVirtualBoundariesPosY(i), i);
+      picHeader->setVirtualBoundariesPosX( sps->getVirtualBoundariesPosX(i), i );
+      picHeader->setVirtualBoundariesPosY( sps->getVirtualBoundariesPosY(i), i );
     }
   }
-
+  
 #if !JVET_Q0155_COLOUR_ID
   // 4:4:4 colour plane ID
-  if (sps->getSeparateColourPlaneFlag())
+  if( sps->getSeparateColourPlaneFlag() )
   {
-    READ_CODE(2, uiCode, "colour_plane_id");
-    picHeader->setColourPlaneId(uiCode);
+    READ_CODE( 2, uiCode, "colour_plane_id" ); picHeader->setColourPlaneId( uiCode );
     CHECK(uiCode > 2, "colour_plane_id exceeds valid range");
   }
-  else
+  else 
   {
-    picHeader->setColourPlaneId(0);
+    picHeader->setColourPlaneId( 0 );
   }
 #endif
 
   // picture output flag
-  if (pps->getOutputFlagPresentFlag())
+  if( pps->getOutputFlagPresentFlag() )
   {
-    READ_FLAG(uiCode, "pic_output_flag");
-    picHeader->setPicOutputFlag(uiCode != 0);
+    READ_FLAG( uiCode, "pic_output_flag" ); picHeader->setPicOutputFlag( uiCode != 0 );
   }
-  else
+  else 
   {
-    picHeader->setPicOutputFlag(true);
+    picHeader->setPicOutputFlag( true );
   }
 
   // reference picture lists
@@ -2406,12 +2154,12 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
 #else
   READ_FLAG(uiCode, "pic_rpl_present_flag");
   picHeader->setPicRplPresentFlag(uiCode != 0);
-  if (picHeader->getPicRplPresentFlag())
+  if( picHeader->getPicRplPresentFlag() )
 #endif
   {
     // List0 and List1
-    for (int listIdx = 0; listIdx < 2; listIdx++)
-    {
+    for(int listIdx = 0; listIdx < 2; listIdx++) 
+    {                 
       // copy L1 index from L0 index
       if (listIdx == 1 && !pps->getRpl1IdxPresentFlag())
       {
@@ -2419,76 +2167,72 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
         uiCode = (picHeader->getRPL0idx() != -1);
       }
       // RPL in picture header or SPS
-      else if (sps->getNumRPL(listIdx) == 0)
+      else if (sps->getNumRPL( listIdx ) == 0)
       {
         uiCode = 0;
       }
-      else if (!pps->getPPSRefPicListSPSIdc(listIdx))
+      else if (!pps->getPPSRefPicListSPSIdc( listIdx ))
       {
         READ_FLAG(uiCode, "pic_rpl_sps_flag[i]");
       }
       else
       {
-        uiCode = pps->getPPSRefPicListSPSIdc(listIdx) - 1;
+        uiCode = pps->getPPSRefPicListSPSIdc( listIdx ) - 1;
       }
 
       // explicit RPL in picture header
       if (!uiCode)
       {
-        ReferencePictureList *rpl = picHeader->getLocalRPL(listIdx);
-        (*rpl)                    = ReferencePictureList();
+        ReferencePictureList* rpl = picHeader->getLocalRPL( listIdx );
+        (*rpl) = ReferencePictureList();
         parseRefPicList(sps, rpl);
         picHeader->setRPLIdx(listIdx, -1);
         picHeader->setRPL(listIdx, rpl);
       }
       // use list from SPS
-      else
-      {
+      else 
+      { 
         if (listIdx == 1 && !pps->getRpl1IdxPresentFlag())
         {
-          picHeader->setRPL(listIdx, sps->getRPLList(listIdx)->getReferencePictureList(picHeader->getRPLIdx(listIdx)));
+          picHeader->setRPL( listIdx, sps->getRPLList( listIdx )->getReferencePictureList(picHeader->getRPLIdx( listIdx )));
         }
-        else if (sps->getNumRPL(listIdx) > 1)
+        else if (sps->getNumRPL( listIdx ) > 1)
         {
-          int numBits = ceilLog2(sps->getNumRPL(listIdx));
+          int numBits = ceilLog2(sps->getNumRPL( listIdx ));
           READ_CODE(numBits, uiCode, "pic_rpl_idx[i]");
-          picHeader->setRPLIdx(listIdx, uiCode);
-          picHeader->setRPL(listIdx, sps->getRPLList(listIdx)->getReferencePictureList(uiCode));
+          picHeader->setRPLIdx( listIdx, uiCode );
+          picHeader->setRPL( listIdx, sps->getRPLList( listIdx )->getReferencePictureList(uiCode));
         }
         else
         {
-          picHeader->setRPLIdx(listIdx, 0);
-          picHeader->setRPL(listIdx, sps->getRPLList(listIdx)->getReferencePictureList(0));
+          picHeader->setRPLIdx( listIdx, 0 );
+          picHeader->setRPL( listIdx, sps->getRPLList( listIdx )->getReferencePictureList(0));
         }
       }
 
       // POC MSB cycle signalling for LTRP
-      for (int i = 0; i < picHeader->getRPL(listIdx)->getNumberOfLongtermPictures()
-                            + picHeader->getRPL(listIdx)->getNumberOfShorttermPictures();
-           i++)
+      for (int i = 0; i < picHeader->getRPL( listIdx )->getNumberOfLongtermPictures() + picHeader->getRPL( listIdx )->getNumberOfShorttermPictures(); i++)
       {
-        picHeader->getLocalRPL(listIdx)->setDeltaPocMSBPresentFlag(i, false);
-        picHeader->getLocalRPL(listIdx)->setDeltaPocMSBCycleLT(i, 0);
+        picHeader->getLocalRPL( listIdx )->setDeltaPocMSBPresentFlag(i, false);
+        picHeader->getLocalRPL( listIdx )->setDeltaPocMSBCycleLT(i, 0);
       }
-      if (picHeader->getRPL(listIdx)->getNumberOfLongtermPictures())
+      if (picHeader->getRPL( listIdx )->getNumberOfLongtermPictures())
       {
-        for (int i = 0; i < picHeader->getRPL(listIdx)->getNumberOfLongtermPictures()
-                              + picHeader->getRPL(listIdx)->getNumberOfShorttermPictures();
-             i++)
+        for (int i = 0; i < picHeader->getRPL( listIdx )->getNumberOfLongtermPictures() + picHeader->getRPL( listIdx )->getNumberOfShorttermPictures(); i++)
         {
-          if (picHeader->getRPL(listIdx)->isRefPicLongterm(i))
+          if (picHeader->getRPL( listIdx )->isRefPicLongterm(i))
           {
-            if (picHeader->getRPL(listIdx)->getLtrpInSliceHeaderFlag())
+            if (picHeader->getRPL( listIdx )->getLtrpInSliceHeaderFlag())
             {
               READ_CODE(sps->getBitsForPOC(), uiCode, "pic_poc_lsb_lt[i][j]");
-              picHeader->getLocalRPL(listIdx)->setRefPicIdentifier(i, uiCode, true, false, 0);
+              picHeader->getLocalRPL( listIdx )->setRefPicIdentifier( i, uiCode, true, false, 0 );
             }
             READ_FLAG(uiCode, "pic_delta_poc_msb_present_flag[i][j]");
-            picHeader->getLocalRPL(listIdx)->setDeltaPocMSBPresentFlag(i, uiCode ? true : false);
+            picHeader->getLocalRPL( listIdx )->setDeltaPocMSBPresentFlag(i, uiCode ? true : false);
             if (uiCode)
             {
               READ_UVLC(uiCode, "pic_delta_poc_msb_cycle_lt[i][j]");
-              picHeader->getLocalRPL(listIdx)->setDeltaPocMSBCycleLT(i, uiCode);
+              picHeader->getLocalRPL( listIdx )->setDeltaPocMSBCycleLT(i, uiCode);
             }
           }
         }
@@ -2499,8 +2243,7 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
   // partitioning constraint overrides
   if (sps->getSplitConsOverrideEnabledFlag())
   {
-    READ_FLAG(uiCode, "partition_constraints_override_flag");
-    picHeader->setSplitConsOverrideFlag(uiCode != 0);
+    READ_FLAG(uiCode, "partition_constraints_override_flag");  picHeader->setSplitConsOverrideFlag( uiCode != 0 );
 #if JVET_Q0819_PH_CHANGES
   }
   else
@@ -2508,11 +2251,11 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
     picHeader->setSplitConsOverrideFlag(0);
   }
   // Q0781, two-flags
-  unsigned minQT[3]     = { 0, 0, 0 };
-  unsigned maxBTD[3]    = { 0, 0, 0 };
-  unsigned maxBTSize[3] = { 0, 0, 0 };
-  unsigned maxTTSize[3] = { 0, 0, 0 };
-  unsigned ctbLog2SizeY = floorLog2(sps->getCTUSize());
+  unsigned  minQT[3] = { 0, 0, 0 };
+  unsigned  maxBTD[3] = { 0, 0, 0 };
+  unsigned  maxBTSize[3] = { 0, 0, 0 };
+  unsigned  maxTTSize[3] = { 0, 0, 0 };
+  unsigned  ctbLog2SizeY = floorLog2(sps->getCTUSize());
 
   if (picHeader->getPicIntraSliceAllowedFlag())
   {
@@ -2520,33 +2263,29 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
     if (picHeader->getSplitConsOverrideFlag())
     {
 #if !JVET_Q0819_PH_CHANGES
-      unsigned minQT[3]     = { 0, 0, 0 };
-      unsigned maxBTD[3]    = { 0, 0, 0 };
-      unsigned maxBTSize[3] = { 0, 0, 0 };
-      unsigned maxTTSize[3] = { 0, 0, 0 };
-      unsigned ctbLog2SizeY = floorLog2(sps->getCTUSize());
+      unsigned  minQT[3]     = { 0, 0, 0 };
+      unsigned  maxBTD[3]    = { 0, 0, 0 };
+      unsigned  maxBTSize[3] = { 0, 0, 0 };
+      unsigned  maxTTSize[3] = { 0, 0, 0 };
+      unsigned  ctbLog2SizeY = floorLog2(sps->getCTUSize());
 #endif
       READ_UVLC(uiCode, "pic_log2_diff_min_qt_min_cb_intra_slice_luma");
       unsigned minQtLog2SizeIntraY = uiCode + sps->getLog2MinCodingBlockSize();
-      minQT[0]                     = 1 << minQtLog2SizeIntraY;
+      minQT[0] = 1 << minQtLog2SizeIntraY;
 #if !JVET_Q0819_PH_CHANGES
       READ_UVLC(uiCode, "pic_log2_diff_min_qt_min_cb_inter_slice");
       unsigned minQtLog2SizeInterY = uiCode + sps->getLog2MinCodingBlockSize();
-      minQT[1]                     = 1 << minQtLog2SizeInterY;
-      READ_UVLC(uiCode, "pic_max_mtt_hierarchy_depth_inter_slice");
-      maxBTD[1] = uiCode;
+      minQT[1] = 1 << minQtLog2SizeInterY;
+      READ_UVLC(uiCode, "pic_max_mtt_hierarchy_depth_inter_slice");              maxBTD[1] = uiCode;
 #endif
-      READ_UVLC(uiCode, "pic_max_mtt_hierarchy_depth_intra_slice_luma");
-      maxBTD[0] = uiCode;
+      READ_UVLC(uiCode, "pic_max_mtt_hierarchy_depth_intra_slice_luma");         maxBTD[0] = uiCode;
 
       maxTTSize[0] = maxBTSize[0] = minQT[0];
       if (maxBTD[0] != 0)
       {
-        READ_UVLC(uiCode, "pic_log2_diff_max_bt_min_qt_intra_slice_luma");
-        maxBTSize[0] <<= uiCode;
+        READ_UVLC(uiCode, "pic_log2_diff_max_bt_min_qt_intra_slice_luma");       maxBTSize[0] <<= uiCode;
         CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "Invalid code");
-        READ_UVLC(uiCode, "pic_log2_diff_max_tt_min_qt_intra_slice_luma");
-        maxTTSize[0] <<= uiCode;
+        READ_UVLC(uiCode, "pic_log2_diff_max_tt_min_qt_intra_slice_luma");       maxTTSize[0] <<= uiCode;
         CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "Invalid code");
       }
 
@@ -2554,27 +2293,21 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
       maxTTSize[1] = maxBTSize[1] = minQT[1];
       if (maxBTD[1] != 0)
       {
-        READ_UVLC(uiCode, "pic_log2_diff_max_bt_min_qt_inter_slice");
-        maxBTSize[1] <<= uiCode;
+        READ_UVLC(uiCode, "pic_log2_diff_max_bt_min_qt_inter_slice");            maxBTSize[1] <<= uiCode;
         CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code");
-        READ_UVLC(uiCode, "pic_log2_diff_max_tt_min_qt_inter_slice");
-        maxTTSize[1] <<= uiCode;
+        READ_UVLC(uiCode, "pic_log2_diff_max_tt_min_qt_inter_slice");            maxTTSize[1] <<= uiCode;
         CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code");
       }
 #endif
       if (sps->getUseDualITree())
       {
-        READ_UVLC(uiCode, "pic_log2_diff_min_qt_min_cb_intra_slice_chroma");
-        minQT[2] = 1 << (uiCode + sps->getLog2MinCodingBlockSize());
-        READ_UVLC(uiCode, "pic_max_mtt_hierarchy_depth_intra_slice_chroma");
-        maxBTD[2]    = uiCode;
+        READ_UVLC(uiCode, "pic_log2_diff_min_qt_min_cb_intra_slice_chroma");     minQT[2] = 1 << (uiCode + sps->getLog2MinCodingBlockSize());
+        READ_UVLC(uiCode, "pic_max_mtt_hierarchy_depth_intra_slice_chroma");     maxBTD[2] = uiCode;
         maxTTSize[2] = maxBTSize[2] = minQT[2];
         if (maxBTD[2] != 0)
         {
-          READ_UVLC(uiCode, "pic_log2_diff_max_bt_min_qt_intra_slice_chroma");
-          maxBTSize[2] <<= uiCode;
-          READ_UVLC(uiCode, "pic_log2_diff_max_tt_min_qt_intra_slice_chroma");
-          maxTTSize[2] <<= uiCode;
+          READ_UVLC(uiCode, "pic_log2_diff_max_bt_min_qt_intra_slice_chroma");   maxBTSize[2] <<= uiCode;
+          READ_UVLC(uiCode, "pic_log2_diff_max_tt_min_qt_intra_slice_chroma");   maxTTSize[2] <<= uiCode;
         }
       }
 #if !JVET_Q0819_PH_CHANGES
@@ -2594,7 +2327,7 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
 
 #if !JVET_Q0819_PH_CHANGES
   // inherit constraint values from SPS
-  if (!sps->getSplitConsOverrideEnabledFlag() || !picHeader->getSplitConsOverrideFlag())
+  if (!sps->getSplitConsOverrideEnabledFlag() || !picHeader->getSplitConsOverrideFlag()) 
   {
     picHeader->setMinQTSizes(sps->getMinQTSizes());
     picHeader->setMaxMTTHierarchyDepths(sps->getMaxMTTHierarchyDepths());
@@ -2607,68 +2340,61 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
   if (picHeader->getPicIntraSliceAllowedFlag())
   {
 #endif
-    // delta quantization and chrom and chroma offset
+  // delta quantization and chrom and chroma offset
     if (pps->getUseDQP())
     {
-      READ_UVLC(uiCode, "pic_cu_qp_delta_subdiv_intra_slice");
-      picHeader->setCuQpDeltaSubdivIntra(uiCode);
+      READ_UVLC( uiCode, "pic_cu_qp_delta_subdiv_intra_slice" );   picHeader->setCuQpDeltaSubdivIntra( uiCode );
 #if !JVET_Q0819_PH_CHANGES
-      READ_UVLC(uiCode, "pic_cu_qp_delta_subdiv_inter_slice");
-      picHeader->setCuQpDeltaSubdivInter(uiCode);
+      READ_UVLC( uiCode, "pic_cu_qp_delta_subdiv_inter_slice" );   picHeader->setCuQpDeltaSubdivInter( uiCode );
 #endif
     }
-    else
+    else 
     {
-      picHeader->setCuQpDeltaSubdivIntra(0);
+      picHeader->setCuQpDeltaSubdivIntra( 0 );
 #if !JVET_Q0819_PH_CHANGES
-      picHeader->setCuQpDeltaSubdivInter(0);
+      picHeader->setCuQpDeltaSubdivInter( 0 );
 #endif
     }
     if (pps->getCuChromaQpOffsetEnabledFlag())
     {
-      READ_UVLC(uiCode, "pic_cu_chroma_qp_offset_subdiv_intra_slice");
-      picHeader->setCuChromaQpOffsetSubdivIntra(uiCode);
+      READ_UVLC( uiCode, "pic_cu_chroma_qp_offset_subdiv_intra_slice" );   picHeader->setCuChromaQpOffsetSubdivIntra( uiCode );
 #if !JVET_Q0819_PH_CHANGES
-      READ_UVLC(uiCode, "pic_cu_chroma_qp_offset_subdiv_inter_slice");
-      picHeader->setCuChromaQpOffsetSubdivInter(uiCode);
+      READ_UVLC( uiCode, "pic_cu_chroma_qp_offset_subdiv_inter_slice" );   picHeader->setCuChromaQpOffsetSubdivInter( uiCode );
 #endif
     }
-    else
+    else 
     {
-      picHeader->setCuChromaQpOffsetSubdivIntra(0);
+      picHeader->setCuChromaQpOffsetSubdivIntra( 0 );
 #if !JVET_Q0819_PH_CHANGES
-      picHeader->setCuChromaQpOffsetSubdivInter(0);
+      picHeader->setCuChromaQpOffsetSubdivInter( 0 );
 #endif
     }
 #if JVET_Q0819_PH_CHANGES
   }
 
+
   if (picHeader->getPicInterSliceAllowedFlag())
   {
     if (picHeader->getSplitConsOverrideFlag())
     {
       READ_UVLC(uiCode, "pic_log2_diff_min_qt_min_cb_inter_slice");
       unsigned minQtLog2SizeInterY = uiCode + sps->getLog2MinCodingBlockSize();
-      minQT[1]                     = 1 << minQtLog2SizeInterY;
-      READ_UVLC(uiCode, "pic_max_mtt_hierarchy_depth_inter_slice");
-      maxBTD[1] = uiCode;
+      minQT[1] = 1 << minQtLog2SizeInterY;
+      READ_UVLC(uiCode, "pic_max_mtt_hierarchy_depth_inter_slice");              maxBTD[1] = uiCode;
 
       maxTTSize[1] = maxBTSize[1] = minQT[1];
       if (maxBTD[1] != 0)
       {
-        READ_UVLC(uiCode, "pic_log2_diff_max_bt_min_qt_inter_slice");
-        maxBTSize[1] <<= uiCode;
+        READ_UVLC(uiCode, "pic_log2_diff_max_bt_min_qt_inter_slice");            maxBTSize[1] <<= uiCode;
         CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code");
-        READ_UVLC(uiCode, "pic_log2_diff_max_tt_min_qt_inter_slice");
-        maxTTSize[1] <<= uiCode;
+        READ_UVLC(uiCode, "pic_log2_diff_max_tt_min_qt_inter_slice");            maxTTSize[1] <<= uiCode;
         CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code");
       }
     }
     // delta quantization and chrom and chroma offset
     if (pps->getUseDQP())
     {
-      READ_UVLC(uiCode, "pic_cu_qp_delta_subdiv_inter_slice");
-      picHeader->setCuQpDeltaSubdivInter(uiCode);
+      READ_UVLC(uiCode, "pic_cu_qp_delta_subdiv_inter_slice");   picHeader->setCuQpDeltaSubdivInter(uiCode);
     }
     else
     {
@@ -2676,27 +2402,26 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
     }
     if (pps->getCuChromaQpOffsetEnabledFlag())
     {
-      READ_UVLC(uiCode, "pic_cu_chroma_qp_offset_subdiv_inter_slice");
-      picHeader->setCuChromaQpOffsetSubdivInter(uiCode);
+      READ_UVLC(uiCode, "pic_cu_chroma_qp_offset_subdiv_inter_slice");   picHeader->setCuChromaQpOffsetSubdivInter(uiCode);
     }
     else
     {
       picHeader->setCuChromaQpOffsetSubdivInter(0);
     }
 
-#endif
-    // temporal motion vector prediction
+#endif  
+  // temporal motion vector prediction
     if (sps->getSPSTemporalMVPEnabledFlag())
     {
-      READ_FLAG(uiCode, "pic_temporal_mvp_enabled_flag");
-      picHeader->setEnableTMVPFlag(uiCode != 0);
+      READ_FLAG( uiCode, "pic_temporal_mvp_enabled_flag" );
+      picHeader->setEnableTMVPFlag( uiCode != 0 );
     }
     else
     {
       picHeader->setEnableTMVPFlag(false);
     }
 
-    // mvd L1 zero flag
+  // mvd L1 zero flag
     if (!pps->getPPSMvdL1ZeroIdc())
     {
       READ_FLAG(uiCode, "pic_mvd_l1_zero_flag");
@@ -2705,9 +2430,9 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
     {
       uiCode = pps->getPPSMvdL1ZeroIdc() - 1;
     }
-    picHeader->setMvdL1ZeroFlag(uiCode != 0);
-
-    // merge candidate list size
+    picHeader->setMvdL1ZeroFlag( uiCode != 0 );
+     
+  // merge candidate list size
     if (!pps->getPPSSixMinusMaxNumMergeCandPlus1())
     {
       READ_UVLC(uiCode, "pic_six_minus_max_num_merge_cand");
@@ -2719,56 +2444,53 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
     CHECK(MRG_MAX_NUM_CANDS <= uiCode, "Incorrrect max number of merge candidates!");
     picHeader->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
 
-    // subblock merge candidate list size
-    if (sps->getUseAffine())
+  // subblock merge candidate list size
+    if ( sps->getUseAffine() )
     {
       READ_UVLC(uiCode, "pic_five_minus_max_num_subblock_merge_cand");
       CHECK(AFFINE_MRG_MAX_NUM_CANDS < uiCode, "Incorrrect max number of affine merge candidates!");
-      picHeader->setMaxNumAffineMergeCand(AFFINE_MRG_MAX_NUM_CANDS - uiCode);
+      picHeader->setMaxNumAffineMergeCand( AFFINE_MRG_MAX_NUM_CANDS - uiCode );
     }
     else
     {
-      picHeader->setMaxNumAffineMergeCand(sps->getSBTMVPEnabledFlag() && picHeader->getEnableTMVPFlag());
+      picHeader->setMaxNumAffineMergeCand( sps->getSBTMVPEnabledFlag() && picHeader->getEnableTMVPFlag() );
     }
 
-    // full-pel MMVD flag
+  // full-pel MMVD flag
     if (sps->getFpelMmvdEnabledFlag())
     {
-      READ_FLAG(uiCode, "pic_fpel_mmvd_enabled_flag");
-      picHeader->setDisFracMMVD(uiCode != 0);
+      READ_FLAG( uiCode, "pic_fpel_mmvd_enabled_flag" );
+      picHeader->setDisFracMMVD( uiCode != 0 );
     }
     else
     {
       picHeader->setDisFracMMVD(false);
     }
-
-    // picture level BDOF disable flags
+  
+  // picture level BDOF disable flags
     if (sps->getBdofControlPresentFlag())
     {
-      READ_FLAG(uiCode, "pic_disable_bdof_flag");
-      picHeader->setDisBdofFlag(uiCode != 0);
+      READ_FLAG(uiCode, "pic_disable_bdof_flag");  picHeader->setDisBdofFlag(uiCode != 0);
     }
     else
     {
       picHeader->setDisBdofFlag(0);
     }
 
-    // picture level DMVR disable flags
+  // picture level DMVR disable flags
     if (sps->getDmvrControlPresentFlag())
     {
-      READ_FLAG(uiCode, "pic_disable_dmvr_flag");
-      picHeader->setDisDmvrFlag(uiCode != 0);
+      READ_FLAG(uiCode, "pic_disable_dmvr_flag");  picHeader->setDisDmvrFlag(uiCode != 0);
     }
     else
     {
       picHeader->setDisDmvrFlag(0);
     }
 
-    // picture level PROF disable flags
+  // picture level PROF disable flags
     if (sps->getProfControlPresentFlag())
     {
-      READ_FLAG(uiCode, "pic_disable_prof_flag");
-      picHeader->setDisProfFlag(uiCode != 0);
+      READ_FLAG(uiCode, "pic_disable_prof_flag");  picHeader->setDisProfFlag(uiCode != 0);
     }
     else
     {
@@ -2776,7 +2498,7 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
     }
 
 #if !JVET_Q0806
-    // triangle merge candidate list size
+  // triangle merge candidate list size
     if (sps->getUseTriangle() && picHeader->getMaxNumMergeCand() >= 2)
     {
       if (!pps->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1())
@@ -2796,23 +2518,23 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
     }
 #else
   // geometric merge candidate list size
-  if (sps->getUseGeo() && picHeader->getMaxNumMergeCand() >= 2)
-  {
-    if (!pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1())
+    if (sps->getUseGeo() && picHeader->getMaxNumMergeCand() >= 2)
     {
-      READ_UVLC(uiCode, "pic_max_num_merge_cand_minus_max_num_gpm_cand");
+      if (!pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1())
+      {
+        READ_UVLC(uiCode, "pic_max_num_merge_cand_minus_max_num_gpm_cand");
+      }
+      else
+      {
+        uiCode = pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1() - 1;
+      }
+      CHECK(picHeader->getMaxNumMergeCand() < uiCode, "Incorrrect max number of gpm candidates!");
+      picHeader->setMaxNumGeoCand((uint32_t)(picHeader->getMaxNumMergeCand() - uiCode));
     }
     else
     {
-      uiCode = pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1() - 1;
+      picHeader->setMaxNumGeoCand(0);
     }
-    CHECK(picHeader->getMaxNumMergeCand() < uiCode, "Incorrrect max number of gpm candidates!");
-    picHeader->setMaxNumGeoCand((uint32_t)(picHeader->getMaxNumMergeCand() - uiCode));
-  }
-  else
-  {
-    picHeader->setMaxNumGeoCand(0);
-  }
 #endif
 #if JVET_Q0819_PH_CHANGES
   }
@@ -2839,15 +2561,15 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
     CHECK(IBC_MRG_MAX_NUM_CANDS <= uiCode, "Incorrrect max number of IBC merge candidates!");
     picHeader->setMaxNumIBCMergeCand(IBC_MRG_MAX_NUM_CANDS - uiCode);
   }
-  else
-  {
+  else 
+   {
     picHeader->setMaxNumIBCMergeCand(0);
   }
 
 #if JVET_Q0819_PH_CHANGES
   if ((pps->getUseWP() || pps->getWPBiPred()) && pps->getWpInfoInPhFlag())
   {
-    parsePredWeightTable(NULL, picHeader, sps);
+    parsePredWeightTable(picHeader, sps);
   }
 #endif
 
@@ -2863,7 +2585,7 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
   // joint Cb/Cr sign flag
   if (sps->getJointCbCrEnabledFlag())
   {
-    READ_FLAG(uiCode, "pic_joint_cbcr_sign_flag");
+    READ_FLAG( uiCode, "pic_joint_cbcr_sign_flag" ); 
     picHeader->setJointCbCrSignFlag(uiCode != 0);
   }
   else
@@ -2872,21 +2594,21 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
   }
 
   // sao enable flags
-  if (sps->getSAOEnabledFlag())
+  if(sps->getSAOEnabledFlag())
   {
 #if JVET_Q0819_PH_CHANGES
     if (pps->getSaoInfoInPhFlag())
 #else
-    READ_FLAG(uiCode, "pic_sao_enabled_present_flag");
+    READ_FLAG(uiCode, "pic_sao_enabled_present_flag");  
     picHeader->setSaoEnabledPresentFlag(uiCode != 0);
 
     if (picHeader->getSaoEnabledPresentFlag())
 #endif
-    {
+    {    
 #if JVET_Q0819_PH_CHANGES
       READ_FLAG(uiCode, "ph_sao_luma_enabled_flag");
 #else
-      READ_FLAG(uiCode, "slice_sao_luma_flag");
+      READ_FLAG(uiCode, "slice_sao_luma_flag");  
 #endif
       picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, uiCode != 0);
 
@@ -2895,37 +2617,37 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
 #if JVET_Q0819_PH_CHANGES
         READ_FLAG(uiCode, "ph_sao_chroma_enabled_flag");
 #else
-        READ_FLAG(uiCode, "slice_sao_chroma_flag");
+        READ_FLAG(uiCode, "slice_sao_chroma_flag");  
 #endif
         picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, uiCode != 0);
       }
     }
-    else
+    else 
     {
-      picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, true);
+      picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA,   true);
       picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, sps->getChromaFormatIdc() != CHROMA_400);
     }
   }
-  else
+  else 
   {
-    picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, false);
+    picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA,   false);
     picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false);
   }
-
+  
   // alf enable flags and aps IDs
 #if JVET_Q0795_CCALF
   picHeader->setCcAlfEnabledFlag(COMPONENT_Cb, false);
   picHeader->setCcAlfEnabledFlag(COMPONENT_Cr, false);
 #endif
-  if (sps->getALFEnabledFlag())
+  if( sps->getALFEnabledFlag() )
   {
 #if JVET_Q0819_PH_CHANGES
     if (pps->getAlfInfoInPhFlag())
 #else
-    READ_FLAG(uiCode, "pic_alf_enabled_present_flag");
+    READ_FLAG(uiCode, "pic_alf_enabled_present_flag");  
     picHeader->setAlfEnabledPresentFlag(uiCode != 0);
 
-    if (picHeader->getAlfEnabledPresentFlag())
+    if (picHeader->getAlfEnabledPresentFlag()) 
 #endif
     {
       READ_FLAG(uiCode, "pic_alf_enabled_flag");
@@ -2992,16 +2714,16 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
       picHeader->setAlfEnabledFlag(COMPONENT_Cb, alfChromaIdc & 1);
       picHeader->setAlfEnabledFlag(COMPONENT_Cr, alfChromaIdc >> 1);
     }
-    else
+    else 
     {
-      picHeader->setAlfEnabledFlag(COMPONENT_Y, true);
+      picHeader->setAlfEnabledFlag(COMPONENT_Y,  true);
       picHeader->setAlfEnabledFlag(COMPONENT_Cb, true);
       picHeader->setAlfEnabledFlag(COMPONENT_Cr, true);
     }
   }
-  else
+  else 
   {
-    picHeader->setAlfEnabledFlag(COMPONENT_Y, false);
+    picHeader->setAlfEnabledFlag(COMPONENT_Y,  false);
     picHeader->setAlfEnabledFlag(COMPONENT_Cb, false);
     picHeader->setAlfEnabledFlag(COMPONENT_Cr, false);
   }
@@ -3015,13 +2737,13 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
   {
     uiCode = pps->getPPSDepQuantEnabledIdc() - 1;
   }
-  picHeader->setDepQuantEnabledFlag(uiCode != 0);
+  picHeader->setDepQuantEnabledFlag( uiCode != 0 );
 
   // sign data hiding
-  if (!picHeader->getDepQuantEnabledFlag())
+  if( !picHeader->getDepQuantEnabledFlag() )
   {
-    READ_FLAG(uiCode, "pic_sign_data_hiding_enabled_flag");
-    picHeader->setSignDataHidingEnabledFlag(uiCode != 0);
+    READ_FLAG( uiCode, "pic_sign_data_hiding_enabled_flag" );
+    picHeader->setSignDataHidingEnabledFlag( uiCode != 0 );
   }
   else
   {
@@ -3031,18 +2753,18 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
   // deblocking filter controls
   if (pps->getDeblockingFilterControlPresentFlag())
   {
-    if (pps->getDeblockingFilterOverrideEnabledFlag())
+    if(pps->getDeblockingFilterOverrideEnabledFlag())
     {
 #if JVET_Q0819_PH_CHANGES
       if (pps->getDbfInfoInPhFlag())
 #else
       READ_FLAG(uiCode, "pic_deblocking_filter_override_present_flag");
       picHeader->setDeblockingFilterOverridePresentFlag(uiCode != 0);
-
-      if (picHeader->getDeblockingFilterOverridePresentFlag())
+    
+      if( picHeader->getDeblockingFilterOverridePresentFlag() ) 
 #endif
       {
-        READ_FLAG(uiCode, "pic_deblocking_filter_override_flag");
+        READ_FLAG ( uiCode, "pic_deblocking_filter_override_flag" );
         picHeader->setDeblockingFilterOverrideFlag(uiCode != 0);
       }
       else
@@ -3058,86 +2780,81 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
       picHeader->setDeblockingFilterOverrideFlag(false);
     }
 
-    if (picHeader->getDeblockingFilterOverrideFlag())
+    if(picHeader->getDeblockingFilterOverrideFlag())
     {
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-      READ_FLAG(uiCode, "ph_deblocking_filter_disabled_flag");
+      READ_FLAG( uiCode, "ph_deblocking_filter_disabled_flag" );
       picHeader->setDeblockingFilterDisable(uiCode != 0);
       if (!picHeader->getDeblockingFilterDisable())
       {
-        READ_SVLC(iCode, "ph_beta_offset_div2");
+        READ_SVLC( iCode, "ph_beta_offset_div2" );
         picHeader->setDeblockingFilterBetaOffsetDiv2(iCode);
-        CHECK(picHeader->getDeblockingFilterBetaOffsetDiv2() < -12
-                || picHeader->getDeblockingFilterBetaOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
+        CHECK(  picHeader->getDeblockingFilterBetaOffsetDiv2() < -12 ||
+                picHeader->getDeblockingFilterBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration");
 
-        READ_SVLC(iCode, "ph_tc_offset_div2");
+        READ_SVLC( iCode, "ph_tc_offset_div2" );
         picHeader->setDeblockingFilterTcOffsetDiv2(iCode);
-        CHECK(picHeader->getDeblockingFilterTcOffsetDiv2() < -12 || picHeader->getDeblockingFilterTcOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
+        CHECK(  picHeader->getDeblockingFilterTcOffsetDiv2() < -12 ||
+                picHeader->getDeblockingFilterTcOffsetDiv2() > 12, "Invalid deblocking filter configuration");
 
-        READ_SVLC(iCode, "ph_cb_beta_offset_div2");
+        READ_SVLC( iCode, "ph_cb_beta_offset_div2" );
         picHeader->setDeblockingFilterCbBetaOffsetDiv2(iCode);
-        CHECK(picHeader->getDeblockingFilterCbBetaOffsetDiv2() < -12
-                || picHeader->getDeblockingFilterCbBetaOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
+        CHECK(  picHeader->getDeblockingFilterCbBetaOffsetDiv2() < -12 ||
+                picHeader->getDeblockingFilterCbBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration");
 
-        READ_SVLC(iCode, "ph_cb_tc_offset_div2");
+        READ_SVLC( iCode, "ph_cb_tc_offset_div2" );
         picHeader->setDeblockingFilterCbTcOffsetDiv2(iCode);
-        CHECK(picHeader->getDeblockingFilterCbTcOffsetDiv2() < -12
-                || picHeader->getDeblockingFilterCbTcOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
+        CHECK(  picHeader->getDeblockingFilterCbTcOffsetDiv2() < -12 ||
+                picHeader->getDeblockingFilterCbTcOffsetDiv2() > 12, "Invalid deblocking filter configuration");
 
-        READ_SVLC(iCode, "ph_cr_beta_offset_div2");
+        READ_SVLC( iCode, "ph_cr_beta_offset_div2" );
         picHeader->setDeblockingFilterCrBetaOffsetDiv2(iCode);
-        CHECK(picHeader->getDeblockingFilterCrBetaOffsetDiv2() < -12
-                || picHeader->getDeblockingFilterCrBetaOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
+        CHECK(  picHeader->getDeblockingFilterCrBetaOffsetDiv2() < -12 ||
+                picHeader->getDeblockingFilterCrBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration");
 
-        READ_SVLC(iCode, "ph_cr_tc_offset_div2");
+        READ_SVLC( iCode, "ph_cr_tc_offset_div2" );
         picHeader->setDeblockingFilterCrTcOffsetDiv2(iCode);
-        CHECK(picHeader->getDeblockingFilterCrTcOffsetDiv2() < -12
-                || picHeader->getDeblockingFilterCrTcOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
+        CHECK(  picHeader->getDeblockingFilterCrTcOffsetDiv2() < -12 ||
+                picHeader->getDeblockingFilterCrTcOffsetDiv2() > 12, "Invalid deblocking filter configuration");
       }
 #else
-      READ_FLAG(uiCode, "pic_deblocking_filter_disabled_flag");
+      READ_FLAG ( uiCode, "pic_deblocking_filter_disabled_flag" );
       picHeader->setDeblockingFilterDisable(uiCode != 0);
-      if (!picHeader->getDeblockingFilterDisable())
+      if(!picHeader->getDeblockingFilterDisable())
       {
-        READ_SVLC(iCode, "pic_beta_offset_div2");
+        READ_SVLC( iCode, "pic_beta_offset_div2" );
         picHeader->setDeblockingFilterBetaOffsetDiv2(iCode);
-        CHECK(picHeader->getDeblockingFilterBetaOffsetDiv2() < -6 && picHeader->getDeblockingFilterBetaOffsetDiv2() > 6,
-              "Invalid deblocking filter configuration");
+        CHECK(  picHeader->getDeblockingFilterBetaOffsetDiv2() < -6 &&
+                picHeader->getDeblockingFilterBetaOffsetDiv2() >  6, "Invalid deblocking filter configuration");
 
-        READ_SVLC(iCode, "pic_tc_offset_div2");
+        READ_SVLC( iCode, "pic_tc_offset_div2" );
         picHeader->setDeblockingFilterTcOffsetDiv2(iCode);
-        CHECK(picHeader->getDeblockingFilterTcOffsetDiv2() < -6 && picHeader->getDeblockingFilterTcOffsetDiv2() > 6,
-              "Invalid deblocking filter configuration");
+        CHECK  (picHeader->getDeblockingFilterTcOffsetDiv2() < -6 &&
+                picHeader->getDeblockingFilterTcOffsetDiv2() >  6, "Invalid deblocking filter configuration");
       }
 #endif
     }
     else
     {
-      picHeader->setDeblockingFilterDisable(pps->getPPSDeblockingFilterDisabledFlag());
-      picHeader->setDeblockingFilterBetaOffsetDiv2(pps->getDeblockingFilterBetaOffsetDiv2());
-      picHeader->setDeblockingFilterTcOffsetDiv2(pps->getDeblockingFilterTcOffsetDiv2());
+      picHeader->setDeblockingFilterDisable       ( pps->getPPSDeblockingFilterDisabledFlag() );
+      picHeader->setDeblockingFilterBetaOffsetDiv2( pps->getDeblockingFilterBetaOffsetDiv2() );
+      picHeader->setDeblockingFilterTcOffsetDiv2  ( pps->getDeblockingFilterTcOffsetDiv2() );
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-      picHeader->setDeblockingFilterCbBetaOffsetDiv2(pps->getDeblockingFilterCbBetaOffsetDiv2());
-      picHeader->setDeblockingFilterCbTcOffsetDiv2(pps->getDeblockingFilterCbTcOffsetDiv2());
-      picHeader->setDeblockingFilterCrBetaOffsetDiv2(pps->getDeblockingFilterCrBetaOffsetDiv2());
-      picHeader->setDeblockingFilterCrTcOffsetDiv2(pps->getDeblockingFilterCrTcOffsetDiv2());
+      picHeader->setDeblockingFilterCbBetaOffsetDiv2( pps->getDeblockingFilterCbBetaOffsetDiv2() );
+      picHeader->setDeblockingFilterCbTcOffsetDiv2  ( pps->getDeblockingFilterCbTcOffsetDiv2() );
+      picHeader->setDeblockingFilterCrBetaOffsetDiv2( pps->getDeblockingFilterCrBetaOffsetDiv2() );
+      picHeader->setDeblockingFilterCrTcOffsetDiv2  ( pps->getDeblockingFilterCrTcOffsetDiv2() );
 #endif
     }
   }
   else
   {
-    picHeader->setDeblockingFilterDisable(false);
-    picHeader->setDeblockingFilterBetaOffsetDiv2(0);
-    picHeader->setDeblockingFilterTcOffsetDiv2(0);
+    picHeader->setDeblockingFilterDisable       ( false );
+    picHeader->setDeblockingFilterBetaOffsetDiv2( 0 );
+    picHeader->setDeblockingFilterTcOffsetDiv2  ( 0 );
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-    picHeader->setDeblockingFilterCbBetaOffsetDiv2(0);
-    picHeader->setDeblockingFilterCbTcOffsetDiv2(0);
+    picHeader->setDeblockingFilterCbBetaOffsetDiv2( 0 );
+    picHeader->setDeblockingFilterCbTcOffsetDiv2  ( 0 );
     picHeader->setDeblockingFilterCrBetaOffsetDiv2(0);
     picHeader->setDeblockingFilterCrTcOffsetDiv2(0);
 #endif
@@ -3172,34 +2889,34 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
   }
 
   // quantization scaling lists
-  if (sps->getScalingListFlag())
+  if( sps->getScalingListFlag() )
   {
-    READ_FLAG(uiCode, "pic_scaling_list_present_flag");
-    picHeader->setScalingListPresentFlag(uiCode);
-    if (picHeader->getScalingListPresentFlag())
+    READ_FLAG( uiCode, "pic_scaling_list_present_flag" );
+    picHeader->setScalingListPresentFlag( uiCode );
+    if( picHeader->getScalingListPresentFlag() )
     {
-      READ_CODE(3, uiCode, "pic_scaling_list_aps_id");
-      picHeader->setScalingListAPSId(uiCode);
+      READ_CODE( 3, uiCode, "pic_scaling_list_aps_id" );
+      picHeader->setScalingListAPSId( uiCode );
     }
   }
-  else
+  else 
   {
-    picHeader->setScalingListPresentFlag(false);
+    picHeader->setScalingListPresentFlag( false );
   }
 
   // picture header extension
-  if (pps->getPictureHeaderExtensionPresentFlag())
+  if(pps->getPictureHeaderExtensionPresentFlag())
   {
-    READ_UVLC(uiCode, "pic_segment_header_extension_length");
-    for (int i = 0; i < uiCode; i++)
+    READ_UVLC(uiCode,"pic_segment_header_extension_length");
+    for(int i=0; i<uiCode; i++)
     {
       uint32_t ignore_;
-      READ_CODE(8, ignore_, "pic_segment_header_extension_data_byte");
+      READ_CODE(8,ignore_,"pic_segment_header_extension_data_byte");
     }
   }
 
 #if JVET_Q0775_PH_IN_SH
-  if (readRbspTrailingBits)
+  if( readRbspTrailingBits )
   {
     xReadRbspTrailingBits();
   }
@@ -3208,17 +2925,16 @@ void HLSyntaxReader::parsePictureHeader(PicHeader *picHeader, ParameterSetManage
 #endif
 }
 
-void HLSyntaxReader::parseSliceHeader(Slice *pcSlice, PicHeader *picHeader, ParameterSetManager *parameterSetManager,
-                                      const int prevTid0POC)
+void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC)
 {
-  uint32_t uiCode;
-  int      iCode;
+  uint32_t  uiCode;
+  int   iCode;
 
 #if ENABLE_TRACING
   xTraceSliceHeader();
 #endif
-  PPS *pps = NULL;
-  SPS *sps = NULL;
+  PPS* pps = NULL;
+  SPS* sps = NULL;
 #if JVET_Q0775_PH_IN_SH
   READ_FLAG(uiCode, "picture_header_in_slice_header_flag");
   if (uiCode)
@@ -3228,18 +2944,18 @@ void HLSyntaxReader::parseSliceHeader(Slice *pcSlice, PicHeader *picHeader, Para
     picHeader->setValid();
   }
 #endif
-  CHECK(picHeader == 0, "Invalid Picture Header");
-  CHECK(picHeader->isValid() == false, "Invalid Picture Header");
-  pps = parameterSetManager->getPPS(picHeader->getPPSId());
-  //! KS: need to add error handling code here, if PPS is not available
-  CHECK(pps == 0, "Invalid PPS");
+  CHECK(picHeader==0, "Invalid Picture Header");
+  CHECK(picHeader->isValid()==false, "Invalid Picture Header");
+  pps = parameterSetManager->getPPS( picHeader->getPPSId() );
+  //!KS: need to add error handling code here, if PPS is not available
+  CHECK(pps==0, "Invalid PPS");
   sps = parameterSetManager->getSPS(pps->getSPSId());
-  //! KS: need to add error handling code here, if SPS is not available
-  CHECK(sps == 0, "Invalid SPS");
+  //!KS: need to add error handling code here, if SPS is not available
+  CHECK(sps==0, "Invalid SPS");
 
-  const ChromaFormat chFmt        = sps->getChromaFormatIdc();
-  const uint32_t     numValidComp = getNumberValidComponents(chFmt);
-  const bool         bChroma      = (chFmt != CHROMA_400);
+  const ChromaFormat chFmt = sps->getChromaFormatIdc();
+  const uint32_t numValidComp=getNumberValidComponents(chFmt);
+  const bool bChroma=(chFmt!=CHROMA_400);
 
   // picture order count
 #if JVET_Q0819_PH_CHANGES
@@ -3253,17 +2969,17 @@ void HLSyntaxReader::parseSliceHeader(Slice *pcSlice, PicHeader *picHeader, Para
   }
   else
   {
-    int iPOClsb     = uiCode;
-    int iPrevPOC    = prevTid0POC;
-    int iMaxPOClsb  = 1 << sps->getBitsForPOC();
+    int iPOClsb = uiCode;
+    int iPrevPOC = prevTid0POC;
+    int iMaxPOClsb = 1 << sps->getBitsForPOC();
     int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1);
     int iPrevPOCmsb = iPrevPOC - iPrevPOClsb;
     int iPOCmsb;
-    if ((iPOClsb < iPrevPOClsb) && ((iPrevPOClsb - iPOClsb) >= (iMaxPOClsb / 2)))
+    if ((iPOClsb  <  iPrevPOClsb) && ((iPrevPOClsb - iPOClsb) >= (iMaxPOClsb / 2)))
     {
       iPOCmsb = iPrevPOCmsb + iMaxPOClsb;
     }
-    else if ((iPOClsb > iPrevPOClsb) && ((iPOClsb - iPrevPOClsb) > (iMaxPOClsb / 2)))
+    else if ((iPOClsb  >  iPrevPOClsb) && ((iPOClsb - iPrevPOClsb)  >  (iMaxPOClsb / 2)))
     {
       iPOCmsb = iPrevPOCmsb - iMaxPOClsb;
     }
@@ -3293,62 +3009,55 @@ void HLSyntaxReader::parseSliceHeader(Slice *pcSlice, PicHeader *picHeader, Para
     {
       bitsSubPicId = ceilLog2(sps->getNumSubPics());
     }
-    READ_CODE(bitsSubPicId, uiCode, "slice_subpic_id");
-    pcSlice->setSliceSubPicId(uiCode);
+    READ_CODE(bitsSubPicId, uiCode, "slice_subpic_id");    pcSlice->setSliceSubPicId(uiCode);
   }
 
   // raster scan slices
-  if (pps->getRectSliceFlag() == 0)
+  if(pps->getRectSliceFlag() == 0) 
   {
     uint32_t sliceAddr, numTilesInSlice;
 
     // slice address is the raster scan tile index of first tile in slice
-    if (pps->getNumTiles() > 1)
-    {
+    if( pps->getNumTiles() > 1 ) 
+    {      
       int bitsSliceAddress = ceilLog2(pps->getNumTiles());
-      READ_CODE(bitsSliceAddress, uiCode, "slice_address");
-      sliceAddr = uiCode;
-      READ_UVLC(uiCode, "num_tiles_in_slice_minus1");
-      numTilesInSlice = uiCode + 1;
+      READ_CODE(bitsSliceAddress, uiCode, "slice_address");  sliceAddr = uiCode;
+      READ_UVLC(uiCode, "num_tiles_in_slice_minus1");        numTilesInSlice = uiCode + 1;      
     }
-    else
-    {
-      sliceAddr       = 0;
+    else {
+      sliceAddr = 0;
       numTilesInSlice = 1;
     }
     CHECK(sliceAddr >= pps->getNumTiles(), "Invalid slice address");
     pcSlice->initSliceMap();
     pcSlice->setSliceID(sliceAddr);
-
-    for (uint32_t tileIdx = sliceAddr; tileIdx < sliceAddr + numTilesInSlice; tileIdx++)
+    
+    for( uint32_t tileIdx = sliceAddr; tileIdx < sliceAddr + numTilesInSlice; tileIdx++ )
     {
       uint32_t tileX = tileIdx % pps->getNumTileColumns();
       uint32_t tileY = tileIdx / pps->getNumTileColumns();
-      CHECK(tileY >= pps->getNumTileRows(),
-            "Number of tiles in slice exceeds the remaining number of tiles in picture");
+      CHECK(tileY >= pps->getNumTileRows(), "Number of tiles in slice exceeds the remaining number of tiles in picture");
 
-      pcSlice->addCtusToSlice(pps->getTileColumnBd(tileX), pps->getTileColumnBd(tileX + 1), pps->getTileRowBd(tileY),
-                              pps->getTileRowBd(tileY + 1), pps->getPicWidthInCtu());
-    }
+      pcSlice->addCtusToSlice(pps->getTileColumnBd(tileX), pps->getTileColumnBd(tileX + 1),
+                              pps->getTileRowBd(tileY), pps->getTileRowBd(tileY + 1), pps->getPicWidthInCtu());
+   }
   }
   // rectangular slices
-  else
+  else 
   {
     uint32_t sliceAddr;
 
     // slice address is the index of the slice within the current sub-picture
-    if (pps->getNumSlicesInPic() > 1)
+    if( pps->getNumSlicesInPic() > 1 ) 
     {
-      int bitsSliceAddress = ceilLog2(pps->getNumSlicesInPic());   // change to NumSlicesInSubPic when available
-      READ_CODE(bitsSliceAddress, uiCode, "slice_address");
-      sliceAddr = uiCode;
+      int bitsSliceAddress = ceilLog2(pps->getNumSlicesInPic());  // change to NumSlicesInSubPic when available
+      READ_CODE(bitsSliceAddress, uiCode, "slice_address");  sliceAddr = uiCode;
       CHECK(sliceAddr >= pps->getNumSlicesInPic(), "Invalid slice address");
     }
-    else
-    {
+    else {
       sliceAddr = 0;
     }
-    pcSlice->setSliceMap(pps->getSliceMap(sliceAddr));
+    pcSlice->setSliceMap( pps->getSliceMap(sliceAddr) );
     pcSlice->setSliceID(sliceAddr);
   }
 
@@ -3356,8 +3065,7 @@ void HLSyntaxReader::parseSliceHeader(Slice *pcSlice, PicHeader *picHeader, Para
   if (picHeader->getPicInterSliceAllowedFlag())
   {
 #endif
-    READ_UVLC(uiCode, "slice_type");
-    pcSlice->setSliceType((SliceType) uiCode);
+    READ_UVLC (    uiCode, "slice_type" );            pcSlice->setSliceType((SliceType)uiCode);
 #if JVET_Q0819_PH_CHANGES
   }
   else
@@ -3370,719 +3078,683 @@ void HLSyntaxReader::parseSliceHeader(Slice *pcSlice, PicHeader *picHeader, Para
   }
 #endif
 #if JVET_Q0155_COLOUR_ID
-  // 4:4:4 colour plane ID
-  if (sps->getSeparateColourPlaneFlag())
-  {
-    READ_CODE(2, uiCode, "colour_plane_id");
-    pcSlice->setColourPlaneId(uiCode);
-    CHECK(uiCode > 2, "colour_plane_id exceeds valid range");
-  }
-  else
-  {
-    pcSlice->setColourPlaneId(0);
-  }
+    // 4:4:4 colour plane ID
+    if( sps->getSeparateColourPlaneFlag() )
+    {
+      READ_CODE( 2, uiCode, "colour_plane_id" ); pcSlice->setColourPlaneId( uiCode );
+      CHECK( uiCode > 2, "colour_plane_id exceeds valid range" );
+    }
+    else
+    {
+      pcSlice->setColourPlaneId( 0 );
+    }
 #endif
 
-  // inherit values from picture header
-  //   set default values in case slice overrides are disabled
-  pcSlice->inheritFromPicHeader(picHeader, pps, sps);
+    // inherit values from picture header
+    //   set default values in case slice overrides are disabled
+    pcSlice->inheritFromPicHeader( picHeader, pps, sps );
 
 #if JVET_Q0819_PH_CHANGES
-  if (pps->getRplInfoInPhFlag())
+    if( pps->getRplInfoInPhFlag() )
 #else
-  if (picHeader->getPicRplPresentFlag())
+    if (picHeader->getPicRplPresentFlag())
 #endif
-  {
-    pcSlice->setRPL0(picHeader->getRPL0());
-    pcSlice->setRPL1(picHeader->getRPL1());
-    *pcSlice->getLocalRPL0() = *picHeader->getLocalRPL0();
-    *pcSlice->getLocalRPL1() = *picHeader->getLocalRPL1();
-  }
-  else if (pcSlice->getIdrPicFlag() && !(sps->getIDRRefParamListPresent()))
-  {
-    ReferencePictureList *rpl0 = pcSlice->getLocalRPL0();
-    (*rpl0)                    = ReferencePictureList();
-    pcSlice->setRPL0(rpl0);
-    ReferencePictureList *rpl1 = pcSlice->getLocalRPL1();
-    (*rpl1)                    = ReferencePictureList();
-    pcSlice->setRPL1(rpl1);
-  }
-  else
-  {
-    // Read L0 related syntax elements
-    if (sps->getNumRPL0() > 0)
-    {
-      if (!pps->getPPSRefPicListSPSIdc0())
-      {
-        READ_FLAG(uiCode, "ref_pic_list_sps_flag[0]");
-      }
-      else
-      {
-        uiCode = pps->getPPSRefPicListSPSIdc0() - 1;
-      }
-    }
-    else
     {
-      uiCode = 0;
+      pcSlice->setRPL0(picHeader->getRPL0());
+      pcSlice->setRPL1(picHeader->getRPL1());
+      *pcSlice->getLocalRPL0() = *picHeader->getLocalRPL0();
+      *pcSlice->getLocalRPL1() = *picHeader->getLocalRPL1();
     }
-
-    if (!uiCode)   // explicitly carried in this SH
+    else if( pcSlice->getIdrPicFlag() && !(sps->getIDRRefParamListPresent()) )
     {
-      ReferencePictureList *rpl0 = pcSlice->getLocalRPL0();
-      (*rpl0)                    = ReferencePictureList();
-      parseRefPicList(sps, rpl0);
-      pcSlice->setRPL0idx(-1);
+      ReferencePictureList* rpl0 = pcSlice->getLocalRPL0();
+      (*rpl0) = ReferencePictureList();
       pcSlice->setRPL0(rpl0);
-    }
-    else   // Refer to list in SPS
-    {
-      if (sps->getNumRPL0() > 1)
-      {
-        int numBits = ceilLog2(sps->getNumRPL0());
-        READ_CODE(numBits, uiCode, "ref_pic_list_idx[0]");
-        pcSlice->setRPL0idx(uiCode);
-        pcSlice->setRPL0(sps->getRPLList0()->getReferencePictureList(uiCode));
-      }
-      else
-      {
-        pcSlice->setRPL0idx(0);
-        pcSlice->setRPL0(sps->getRPLList0()->getReferencePictureList(0));
-      }
-    }
-    // Deal POC Msb cycle signalling for LTRP
-    for (int i = 0;
-         i < pcSlice->getRPL0()->getNumberOfLongtermPictures() + pcSlice->getRPL0()->getNumberOfShorttermPictures();
-         i++)
-    {
-      pcSlice->getLocalRPL0()->setDeltaPocMSBPresentFlag(i, false);
-      pcSlice->getLocalRPL0()->setDeltaPocMSBCycleLT(i, 0);
-    }
-    if (pcSlice->getRPL0()->getNumberOfLongtermPictures())
-    {
-      for (int i = 0;
-           i < pcSlice->getRPL0()->getNumberOfLongtermPictures() + pcSlice->getRPL0()->getNumberOfShorttermPictures();
-           i++)
-      {
-        if (pcSlice->getRPL0()->isRefPicLongterm(i))
-        {
-          if (pcSlice->getRPL0()->getLtrpInSliceHeaderFlag())
-          {
-            READ_CODE(sps->getBitsForPOC(), uiCode, "slice_poc_lsb_lt[i][j]");
-            pcSlice->getLocalRPL0()->setRefPicIdentifier(i, uiCode, true, false, 0);
-          }
-          READ_FLAG(uiCode, "delta_poc_msb_present_flag[i][j]");
-          pcSlice->getLocalRPL0()->setDeltaPocMSBPresentFlag(i, uiCode ? true : false);
-          if (uiCode)
-          {
-            READ_UVLC(uiCode, "slice_delta_poc_msb_cycle_lt[i][j]");
-            pcSlice->getLocalRPL0()->setDeltaPocMSBCycleLT(i, uiCode);
-          }
-        }
-      }
-    }
-
-    // Read L1 related syntax elements
-    if (!pps->getRpl1IdxPresentFlag())
-    {
-      pcSlice->setRPL1idx(pcSlice->getRPL0idx());
-      if (pcSlice->getRPL1idx() != -1)
-        pcSlice->setRPL1(sps->getRPLList1()->getReferencePictureList(pcSlice->getRPL0idx()));
+      ReferencePictureList* rpl1 = pcSlice->getLocalRPL1();
+      (*rpl1) = ReferencePictureList();
+      pcSlice->setRPL1(rpl1);
     }
     else
     {
-      if (sps->getNumRPL1() > 0)
+      //Read L0 related syntax elements
+      if (sps->getNumRPL0() > 0)
       {
-        if (!pps->getPPSRefPicListSPSIdc1())
+        if (!pps->getPPSRefPicListSPSIdc0())
         {
-          READ_FLAG(uiCode, "ref_pic_list_sps_flag[1]");
+          READ_FLAG(uiCode, "ref_pic_list_sps_flag[0]");
         }
         else
         {
-          uiCode = pps->getPPSRefPicListSPSIdc1() - 1;
+          uiCode = pps->getPPSRefPicListSPSIdc0() - 1;
         }
       }
       else
       {
         uiCode = 0;
       }
-      if (uiCode == 1)
+
+      if (!uiCode) //explicitly carried in this SH
+      {
+        ReferencePictureList* rpl0 = pcSlice->getLocalRPL0();
+        (*rpl0) = ReferencePictureList();
+        parseRefPicList(sps, rpl0);
+        pcSlice->setRPL0idx(-1);
+        pcSlice->setRPL0(rpl0);
+      }
+      else    //Refer to list in SPS
       {
-        if (sps->getNumRPL1() > 1)
+        if (sps->getNumRPL0() > 1)
         {
-          int numBits = ceilLog2(sps->getNumRPL1());
-          READ_CODE(numBits, uiCode, "ref_pic_list_idx[1]");
-          pcSlice->setRPL1idx(uiCode);
-          pcSlice->setRPL1(sps->getRPLList1()->getReferencePictureList(uiCode));
+          int numBits = ceilLog2(sps->getNumRPL0());
+          READ_CODE(numBits, uiCode, "ref_pic_list_idx[0]");
+          pcSlice->setRPL0idx(uiCode);
+          pcSlice->setRPL0(sps->getRPLList0()->getReferencePictureList(uiCode));
         }
         else
         {
-          pcSlice->setRPL1idx(0);
-          pcSlice->setRPL1(sps->getRPLList1()->getReferencePictureList(0));
+          pcSlice->setRPL0idx(0);
+          pcSlice->setRPL0(sps->getRPLList0()->getReferencePictureList(0));
         }
       }
-      else
+      //Deal POC Msb cycle signalling for LTRP
+      for (int i = 0; i < pcSlice->getRPL0()->getNumberOfLongtermPictures() + pcSlice->getRPL0()->getNumberOfShorttermPictures(); i++)
       {
-        pcSlice->setRPL1idx(-1);
+        pcSlice->getLocalRPL0()->setDeltaPocMSBPresentFlag(i, false);
+        pcSlice->getLocalRPL0()->setDeltaPocMSBCycleLT(i, 0);
       }
-    }
-    if (pcSlice->getRPL1idx() == -1)   // explicitly carried in this SH
-    {
-      ReferencePictureList *rpl1 = pcSlice->getLocalRPL1();
-      (*rpl1)                    = ReferencePictureList();
-      parseRefPicList(sps, rpl1);
-      pcSlice->setRPL1idx(-1);
-      pcSlice->setRPL1(rpl1);
-    }
-
-    // Deal POC Msb cycle signalling for LTRP
-    for (int i = 0;
-         i < pcSlice->getRPL1()->getNumberOfLongtermPictures() + pcSlice->getRPL1()->getNumberOfShorttermPictures();
-         i++)
-    {
-      pcSlice->getLocalRPL1()->setDeltaPocMSBPresentFlag(i, false);
-      pcSlice->getLocalRPL1()->setDeltaPocMSBCycleLT(i, 0);
-    }
-    if (pcSlice->getRPL1()->getNumberOfLongtermPictures())
-    {
-      for (int i = 0;
-           i < pcSlice->getRPL1()->getNumberOfLongtermPictures() + pcSlice->getRPL1()->getNumberOfShorttermPictures();
-           i++)
+      if (pcSlice->getRPL0()->getNumberOfLongtermPictures())
       {
-        if (pcSlice->getRPL1()->isRefPicLongterm(i))
+        for (int i = 0; i < pcSlice->getRPL0()->getNumberOfLongtermPictures() + pcSlice->getRPL0()->getNumberOfShorttermPictures(); i++)
         {
-          if (pcSlice->getRPL1()->getLtrpInSliceHeaderFlag())
-          {
-            READ_CODE(sps->getBitsForPOC(), uiCode, "slice_poc_lsb_lt[i][j]");
-            pcSlice->getLocalRPL1()->setRefPicIdentifier(i, uiCode, true, false, 0);
-          }
-          READ_FLAG(uiCode, "delta_poc_msb_present_flag[i][j]");
-          pcSlice->getLocalRPL1()->setDeltaPocMSBPresentFlag(i, uiCode ? true : false);
-          if (uiCode)
+          if (pcSlice->getRPL0()->isRefPicLongterm(i))
           {
-            READ_UVLC(uiCode, "slice_delta_poc_msb_cycle_lt[i][j]");
-            pcSlice->getLocalRPL1()->setDeltaPocMSBCycleLT(i, uiCode);
+            if (pcSlice->getRPL0()->getLtrpInSliceHeaderFlag())
+            {
+              READ_CODE(sps->getBitsForPOC(), uiCode, "slice_poc_lsb_lt[i][j]");
+              pcSlice->getLocalRPL0()->setRefPicIdentifier( i, uiCode, true, false, 0 );
+            }
+            READ_FLAG(uiCode, "delta_poc_msb_present_flag[i][j]");
+            pcSlice->getLocalRPL0()->setDeltaPocMSBPresentFlag(i, uiCode ? true : false);
+            if (uiCode)
+            {
+              READ_UVLC(uiCode, "slice_delta_poc_msb_cycle_lt[i][j]");
+              pcSlice->getLocalRPL0()->setDeltaPocMSBCycleLT(i, uiCode);
+            }
           }
         }
       }
-    }
-  }
-#if JVET_Q0819_PH_CHANGES
-  if (!pps->getRplInfoInPhFlag() && pcSlice->getIdrPicFlag() && !(sps->getIDRRefParamListPresent()))
-#else
-  if (!picHeader->getPicRplPresentFlag() && pcSlice->getIdrPicFlag() && !(sps->getIDRRefParamListPresent()))
-#endif
-  {
-    pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0);
-    pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
-  }
-  else
-  {
-    if ((!pcSlice->isIntra() && pcSlice->getRPL0()->getNumRefEntries() > 1)
-        || (pcSlice->isInterB() && pcSlice->getRPL1()->getNumRefEntries() > 1))
-    {
-      READ_FLAG(uiCode, "num_ref_idx_active_override_flag");
-      if (uiCode)
+
+      //Read L1 related syntax elements
+      if (!pps->getRpl1IdxPresentFlag())
       {
-        if (pcSlice->getRPL0()->getNumRefEntries() > 1)
+        pcSlice->setRPL1idx(pcSlice->getRPL0idx());
+        if (pcSlice->getRPL1idx() != -1)
+          pcSlice->setRPL1(sps->getRPLList1()->getReferencePictureList(pcSlice->getRPL0idx()));
+      }
+      else
+      {
+        if (sps->getNumRPL1() > 0)
         {
-          READ_UVLC(uiCode, "num_ref_idx_l0_active_minus1");
+          if (!pps->getPPSRefPicListSPSIdc1())
+          {
+            READ_FLAG(uiCode, "ref_pic_list_sps_flag[1]");
+          }
+          else
+          {
+            uiCode = pps->getPPSRefPicListSPSIdc1() - 1;
+          }
         }
         else
         {
           uiCode = 0;
         }
-        pcSlice->setNumRefIdx(REF_PIC_LIST_0, uiCode + 1);
-        if (pcSlice->isInterB())
+        if (uiCode == 1)
         {
-          if (pcSlice->getRPL1()->getNumRefEntries() > 1)
+          if (sps->getNumRPL1() > 1)
           {
-            READ_UVLC(uiCode, "num_ref_idx_l1_active_minus1");
+            int numBits = ceilLog2(sps->getNumRPL1());
+            READ_CODE(numBits, uiCode, "ref_pic_list_idx[1]");
+            pcSlice->setRPL1idx(uiCode);
+            pcSlice->setRPL1(sps->getRPLList1()->getReferencePictureList(uiCode));
           }
           else
           {
-            uiCode = 0;
+            pcSlice->setRPL1idx(0);
+            pcSlice->setRPL1(sps->getRPLList1()->getReferencePictureList(0));
           }
-          pcSlice->setNumRefIdx(REF_PIC_LIST_1, uiCode + 1);
         }
         else
         {
-          pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
+          pcSlice->setRPL1idx(-1);
         }
       }
-      else
+      if (pcSlice->getRPL1idx() == -1) //explicitly carried in this SH
       {
-        if (pcSlice->getRPL0()->getNumRefEntries() >= pps->getNumRefIdxL0DefaultActive())
-        {
-          pcSlice->setNumRefIdx(REF_PIC_LIST_0, pps->getNumRefIdxL0DefaultActive());
-        }
-        else
+        ReferencePictureList* rpl1 = pcSlice->getLocalRPL1();
+        (*rpl1) = ReferencePictureList();
+        parseRefPicList(sps, rpl1);
+        pcSlice->setRPL1idx(-1);
+        pcSlice->setRPL1(rpl1);
+      }
+
+      //Deal POC Msb cycle signalling for LTRP
+      for (int i = 0; i < pcSlice->getRPL1()->getNumberOfLongtermPictures() + pcSlice->getRPL1()->getNumberOfShorttermPictures(); i++)
+      {
+        pcSlice->getLocalRPL1()->setDeltaPocMSBPresentFlag(i, false);
+        pcSlice->getLocalRPL1()->setDeltaPocMSBCycleLT(i, 0);
+      }
+      if (pcSlice->getRPL1()->getNumberOfLongtermPictures())
+      {
+        for (int i = 0; i < pcSlice->getRPL1()->getNumberOfLongtermPictures() + pcSlice->getRPL1()->getNumberOfShorttermPictures(); i++)
         {
-          pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getRPL0()->getNumRefEntries());
+          if (pcSlice->getRPL1()->isRefPicLongterm(i))
+          {
+            if (pcSlice->getRPL1()->getLtrpInSliceHeaderFlag())
+            {
+              READ_CODE(sps->getBitsForPOC(), uiCode, "slice_poc_lsb_lt[i][j]");
+              pcSlice->getLocalRPL1()->setRefPicIdentifier( i, uiCode, true, false, 0 );
+            }
+            READ_FLAG(uiCode, "delta_poc_msb_present_flag[i][j]");
+            pcSlice->getLocalRPL1()->setDeltaPocMSBPresentFlag(i, uiCode ? true : false);
+            if (uiCode)
+            {
+              READ_UVLC(uiCode, "slice_delta_poc_msb_cycle_lt[i][j]");
+              pcSlice->getLocalRPL1()->setDeltaPocMSBCycleLT(i, uiCode);
+            }
+          }
         }
+      }
 
-        if (pcSlice->isInterB())
+    }
+#if JVET_Q0819_PH_CHANGES
+    if( !pps->getRplInfoInPhFlag() && pcSlice->getIdrPicFlag() && !(sps->getIDRRefParamListPresent()) )
+#else
+    if (!picHeader->getPicRplPresentFlag() && pcSlice->getIdrPicFlag() && !(sps->getIDRRefParamListPresent()))
+#endif
+    {
+      pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0);
+      pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
+    }
+    else
+    {
+      if ((!pcSlice->isIntra() && pcSlice->getRPL0()->getNumRefEntries() > 1) ||
+          (pcSlice->isInterB() && pcSlice->getRPL1()->getNumRefEntries() > 1) )
+      {
+        READ_FLAG( uiCode, "num_ref_idx_active_override_flag");
+        if (uiCode)
         {
-          if (pcSlice->getRPL1()->getNumRefEntries() >= pps->getNumRefIdxL1DefaultActive())
+          if(pcSlice->getRPL0()->getNumRefEntries() > 1)
+          {
+            READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" );
+          }
+          else
           {
-            pcSlice->setNumRefIdx(REF_PIC_LIST_1, pps->getNumRefIdxL1DefaultActive());
+            uiCode = 0;
+          }
+          pcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 );
+          if (pcSlice->isInterB())
+          {
+            if(pcSlice->getRPL1()->getNumRefEntries() > 1)
+            {
+              READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" );
+            }
+            else
+            {
+              uiCode = 0;
+            }
+            pcSlice->setNumRefIdx(REF_PIC_LIST_1, uiCode + 1);
           }
           else
           {
-            pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getRPL1()->getNumRefEntries());
+            pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
           }
         }
         else
         {
-          pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
+          if(pcSlice->getRPL0()->getNumRefEntries() >= pps->getNumRefIdxL0DefaultActive())
+          {
+            pcSlice->setNumRefIdx(REF_PIC_LIST_0, pps->getNumRefIdxL0DefaultActive());
+          }
+          else
+          {
+            pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getRPL0()->getNumRefEntries());
+          }
+
+          if (pcSlice->isInterB())
+          {
+            if(pcSlice->getRPL1()->getNumRefEntries() >= pps->getNumRefIdxL1DefaultActive())
+            {
+              pcSlice->setNumRefIdx(REF_PIC_LIST_1, pps->getNumRefIdxL1DefaultActive());
+            }
+            else
+            {
+              pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getRPL1()->getNumRefEntries());
+            }
+          }
+          else
+          {
+            pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
+          }
         }
       }
+      else
+      {
+        pcSlice->setNumRefIdx( REF_PIC_LIST_0, pcSlice->isIntra() ? 0 : 1 );
+        pcSlice->setNumRefIdx( REF_PIC_LIST_1, pcSlice->isInterB() ? 1 : 0 );
+      }
     }
-    else
+
+    if (pcSlice->isInterP() || pcSlice->isInterB())
     {
-      pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->isIntra() ? 0 : 1);
-      pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->isInterB() ? 1 : 0);
+      CHECK(pcSlice->getNumRefIdx(REF_PIC_LIST_0) == 0, "Number of active entries in RPL0 of P or B picture shall be greater than 0");
+      if (pcSlice->isInterB())
+        CHECK(pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0, "Number of active entries in RPL1 of B picture shall be greater than 0");
     }
-  }
 
-  if (pcSlice->isInterP() || pcSlice->isInterB())
-  {
-    CHECK(pcSlice->getNumRefIdx(REF_PIC_LIST_0) == 0,
-          "Number of active entries in RPL0 of P or B picture shall be greater than 0");
-    if (pcSlice->isInterB())
-      CHECK(pcSlice->getNumRefIdx(REF_PIC_LIST_1) == 0,
-            "Number of active entries in RPL1 of B picture shall be greater than 0");
-  }
 
-  pcSlice->setCabacInitFlag(false);   // default
-  if (pps->getCabacInitPresentFlag() && !pcSlice->isIntra())
-  {
-    READ_FLAG(uiCode, "cabac_init_flag");
-    pcSlice->setCabacInitFlag(uiCode ? true : false);
-    pcSlice->setEncCABACTableIdx(pcSlice->getSliceType() == B_SLICE ? (uiCode ? P_SLICE : B_SLICE)
-                                                                    : (uiCode ? B_SLICE : P_SLICE));
-  }
+    pcSlice->setCabacInitFlag( false ); // default
+    if(pps->getCabacInitPresentFlag() && !pcSlice->isIntra())
+    {
+      READ_FLAG(uiCode, "cabac_init_flag");
+      pcSlice->setCabacInitFlag( uiCode ? true : false );
+      pcSlice->setEncCABACTableIdx( pcSlice->getSliceType() == B_SLICE ? ( uiCode ? P_SLICE : B_SLICE ) : ( uiCode ? B_SLICE : P_SLICE ) );
+    }
 
-  if (pcSlice->getPicHeader()->getEnableTMVPFlag())
-  {
-    if (pcSlice->getSliceType() == B_SLICE)
+    if ( pcSlice->getPicHeader()->getEnableTMVPFlag() )
     {
-      if (!pps->getPPSCollocatedFromL0Idc())
+      if ( pcSlice->getSliceType() == B_SLICE )
       {
-        READ_FLAG(uiCode, "collocated_from_l0_flag");
+        if (!pps->getPPSCollocatedFromL0Idc())
+        {
+          READ_FLAG(uiCode, "collocated_from_l0_flag");
+        }
+        else
+        {
+          uiCode = pps->getPPSCollocatedFromL0Idc() - 1;
+        }
+        pcSlice->setColFromL0Flag(uiCode);
       }
       else
       {
-        uiCode = pps->getPPSCollocatedFromL0Idc() - 1;
+        pcSlice->setColFromL0Flag( 1 );
       }
-      pcSlice->setColFromL0Flag(uiCode);
-    }
-    else
-    {
-      pcSlice->setColFromL0Flag(1);
-    }
 
-    if (pcSlice->getSliceType() != I_SLICE
-        && ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)
-            || (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1)))
+      if ( pcSlice->getSliceType() != I_SLICE &&
+           ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)||
+           (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1)))
+      {
+        READ_UVLC( uiCode, "collocated_ref_idx" );
+        pcSlice->setColRefIdx(uiCode);
+      }
+      else
+      {
+        pcSlice->setColRefIdx(0);
+      }
+    }
+    if ( (pps->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) )
     {
-      READ_UVLC(uiCode, "collocated_ref_idx");
-      pcSlice->setColRefIdx(uiCode);
+#if JVET_Q0819_PH_CHANGES
+      if (pps->getWpInfoInPhFlag())
+      {
+        pcSlice->setWpScaling(picHeader->getWpScalingAll());
+      }
+      else
+      {
+        parsePredWeightTable(pcSlice, sps);
+      }
+#else
+      parsePredWeightTable(pcSlice, sps);
+#endif
+      pcSlice->initWpScaling(sps);
     }
     else
     {
-      pcSlice->setColRefIdx(0);
+      WPScalingParam *wp;
+      for ( int iNumRef=0 ; iNumRef<((pcSlice->getSliceType() == B_SLICE )?2:1); iNumRef++ )
+      {
+        RefPicList  eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
+        for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
+        {
+          pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
+          wp[0].bPresentFlag = false;
+          wp[1].bPresentFlag = false;
+          wp[2].bPresentFlag = false;
+        }
+      }
     }
-  }
-  if ((pps->getUseWP() && pcSlice->getSliceType() == P_SLICE)
-      || (pps->getWPBiPred() && pcSlice->getSliceType() == B_SLICE))
-  {
+
 #if JVET_Q0819_PH_CHANGES
-    if (pps->getWpInfoInPhFlag())
+    int qpDelta = 0;
+    if (pps->getQpDeltaInfoInPhFlag())
     {
-      pcSlice->setWpScaling(picHeader->getWpScalingAll());
+      qpDelta = picHeader->getQpDelta();
     }
     else
     {
-      parsePredWeightTable(pcSlice, NULL, sps);
+      READ_SVLC(iCode, "slice_qp_delta");
+      qpDelta = iCode;
     }
+    pcSlice->setSliceQp(26 + pps->getPicInitQPMinus26() + qpDelta);
 #else
-    parsePredWeightTable(pcSlice, sps);
+    READ_SVLC( iCode, "slice_qp_delta" );
+    pcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode);
 #endif
-    pcSlice->initWpScaling(sps);
-  }
-  else
-  {
-    WPScalingParam *wp;
-    for (int iNumRef = 0; iNumRef < ((pcSlice->getSliceType() == B_SLICE) ? 2 : 1); iNumRef++)
+    pcSlice->setSliceQpBase(pcSlice->getSliceQp());
+
+    CHECK( pcSlice->getSliceQp() < -sps->getQpBDOffset(CHANNEL_TYPE_LUMA), "Invalid slice QP delta" );
+    CHECK( pcSlice->getSliceQp() > MAX_QP, "Invalid slice QP" );
+
+    if (pps->getSliceChromaQpFlag())
     {
-      RefPicList eRefPicList = (iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
-      for (int iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(eRefPicList); iRefIdx++)
+      if (numValidComp>COMPONENT_Cb)
       {
-        pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
-        wp[0].bPresentFlag = false;
-        wp[1].bPresentFlag = false;
-        wp[2].bPresentFlag = false;
+        READ_SVLC( iCode, "slice_cb_qp_offset" );
+        pcSlice->setSliceChromaQpDelta(COMPONENT_Cb, iCode );
+        CHECK( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) < -12, "Invalid chroma QP offset" );
+        CHECK( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) >  12, "Invalid chroma QP offset" );
+        CHECK( (pps->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) < -12, "Invalid chroma QP offset" );
+        CHECK( (pps->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) >  12, "Invalid chroma QP offset" );
       }
-    }
-  }
-
-#if JVET_Q0819_PH_CHANGES
-  int qpDelta = 0;
-  if (pps->getQpDeltaInfoInPhFlag())
-  {
-    qpDelta = picHeader->getQpDelta();
-  }
-  else
-  {
-    READ_SVLC(iCode, "slice_qp_delta");
-    qpDelta = iCode;
-  }
-  pcSlice->setSliceQp(26 + pps->getPicInitQPMinus26() + qpDelta);
-#else
-  READ_SVLC(iCode, "slice_qp_delta");
-  pcSlice->setSliceQp(26 + pps->getPicInitQPMinus26() + iCode);
-#endif
-  pcSlice->setSliceQpBase(pcSlice->getSliceQp());
 
-  CHECK(pcSlice->getSliceQp() < -sps->getQpBDOffset(CHANNEL_TYPE_LUMA), "Invalid slice QP delta");
-  CHECK(pcSlice->getSliceQp() > MAX_QP, "Invalid slice QP");
+      if (numValidComp>COMPONENT_Cr)
+      {
+        READ_SVLC( iCode, "slice_cr_qp_offset" );
+        pcSlice->setSliceChromaQpDelta(COMPONENT_Cr, iCode );
+        CHECK( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) < -12, "Invalid chroma QP offset" );
+        CHECK( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) >  12, "Invalid chroma QP offset" );
+        CHECK( (pps->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) < -12, "Invalid chroma QP offset" );
+        CHECK( (pps->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) >  12, "Invalid chroma QP offset" );
+        if (sps->getJointCbCrEnabledFlag())
+        {
+          READ_SVLC(iCode, "slice_joint_cbcr_qp_offset" );
+          pcSlice->setSliceChromaQpDelta(JOINT_CbCr, iCode);
+          CHECK( pcSlice->getSliceChromaQpDelta(JOINT_CbCr) < -12, "Invalid chroma QP offset");
+          CHECK( pcSlice->getSliceChromaQpDelta(JOINT_CbCr) >  12, "Invalid chroma QP offset");
+          CHECK( (pps->getQpOffset(JOINT_CbCr) + pcSlice->getSliceChromaQpDelta(JOINT_CbCr)) < -12, "Invalid chroma QP offset");
+          CHECK( (pps->getQpOffset(JOINT_CbCr) + pcSlice->getSliceChromaQpDelta(JOINT_CbCr)) >  12, "Invalid chroma QP offset");
+        }
+      }
+    }
 
-  if (pps->getSliceChromaQpFlag())
-  {
-    if (numValidComp > COMPONENT_Cb)
+    if (pps->getCuChromaQpOffsetEnabledFlag())
     {
-      READ_SVLC(iCode, "slice_cb_qp_offset");
-      pcSlice->setSliceChromaQpDelta(COMPONENT_Cb, iCode);
-      CHECK(pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) < -12, "Invalid chroma QP offset");
-      CHECK(pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) > 12, "Invalid chroma QP offset");
-      CHECK((pps->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) < -12,
-            "Invalid chroma QP offset");
-      CHECK((pps->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) > 12,
-            "Invalid chroma QP offset");
+      READ_FLAG(uiCode, "cu_chroma_qp_offset_enabled_flag"); pcSlice->setUseChromaQpAdj(uiCode != 0);
     }
-
-    if (numValidComp > COMPONENT_Cr)
+    else
     {
-      READ_SVLC(iCode, "slice_cr_qp_offset");
-      pcSlice->setSliceChromaQpDelta(COMPONENT_Cr, iCode);
-      CHECK(pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) < -12, "Invalid chroma QP offset");
-      CHECK(pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) > 12, "Invalid chroma QP offset");
-      CHECK((pps->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) < -12,
-            "Invalid chroma QP offset");
-      CHECK((pps->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) > 12,
-            "Invalid chroma QP offset");
-      if (sps->getJointCbCrEnabledFlag())
-      {
-        READ_SVLC(iCode, "slice_joint_cbcr_qp_offset");
-        pcSlice->setSliceChromaQpDelta(JOINT_CbCr, iCode);
-        CHECK(pcSlice->getSliceChromaQpDelta(JOINT_CbCr) < -12, "Invalid chroma QP offset");
-        CHECK(pcSlice->getSliceChromaQpDelta(JOINT_CbCr) > 12, "Invalid chroma QP offset");
-        CHECK((pps->getQpOffset(JOINT_CbCr) + pcSlice->getSliceChromaQpDelta(JOINT_CbCr)) < -12,
-              "Invalid chroma QP offset");
-        CHECK((pps->getQpOffset(JOINT_CbCr) + pcSlice->getSliceChromaQpDelta(JOINT_CbCr)) > 12,
-              "Invalid chroma QP offset");
-      }
+      pcSlice->setUseChromaQpAdj(false);
     }
-  }
-
-  if (pps->getCuChromaQpOffsetEnabledFlag())
-  {
-    READ_FLAG(uiCode, "cu_chroma_qp_offset_enabled_flag");
-    pcSlice->setUseChromaQpAdj(uiCode != 0);
-  }
-  else
-  {
-    pcSlice->setUseChromaQpAdj(false);
-  }
 
 #if JVET_Q0819_PH_CHANGES
-  if (sps->getSAOEnabledFlag() && !pps->getSaoInfoInPhFlag())
+    if (sps->getSAOEnabledFlag() && !pps->getSaoInfoInPhFlag())
 #else
-  if (sps->getSAOEnabledFlag() && !picHeader->getSaoEnabledPresentFlag())
+    if (sps->getSAOEnabledFlag() && !picHeader->getSaoEnabledPresentFlag())
 #endif
-  {
-    READ_FLAG(uiCode, "slice_sao_luma_flag");
-    pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (bool) uiCode);
-
-    if (bChroma)
     {
-      READ_FLAG(uiCode, "slice_sao_chroma_flag");
-      pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, (bool) uiCode);
+      READ_FLAG(uiCode, "slice_sao_luma_flag");  pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (bool)uiCode);
+
+      if (bChroma)
+      {
+        READ_FLAG(uiCode, "slice_sao_chroma_flag");  pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, (bool)uiCode);
+      }
     }
-  }
 
 #if JVET_Q0819_PH_CHANGES
-  if (sps->getALFEnabledFlag() && !pps->getAlfInfoInPhFlag())
+    if (sps->getALFEnabledFlag() && !pps->getAlfInfoInPhFlag())
 #else
-  if (sps->getALFEnabledFlag() && !picHeader->getAlfEnabledPresentFlag())
+    if (sps->getALFEnabledFlag() && !picHeader->getAlfEnabledPresentFlag())
 #endif
-  {
-    READ_FLAG(uiCode, "slice_alf_enabled_flag");
-    pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Y, uiCode);
-    int alfChromaIdc = 0;
-    if (uiCode)
     {
-      READ_CODE(3, uiCode, "slice_num_alf_aps_ids_luma");
-      int numAps = uiCode;
-      pcSlice->setTileGroupNumAps(numAps);
-      std::vector<int> apsId(numAps, -1);
-      for (int i = 0; i < numAps; i++)
+      READ_FLAG(uiCode, "slice_alf_enabled_flag");
+      pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Y, uiCode);
+      int alfChromaIdc = 0;
+      if (uiCode)
       {
-        READ_CODE(3, uiCode, "slice_alf_aps_id_luma");
-        apsId[i]            = uiCode;
-        APS *APStoCheckLuma = parameterSetManager->getAPS(apsId[i], ALF_APS);
-        CHECK(APStoCheckLuma->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_LUMA] != 1,
-              "bitstream conformance error, alf_luma_filter_signal_flag shall be equal to 1");
-      }
+        READ_CODE(3, uiCode, "slice_num_alf_aps_ids_luma");
+        int numAps = uiCode;
+        pcSlice->setTileGroupNumAps(numAps);
+        std::vector<int> apsId(numAps, -1);
+        for (int i = 0; i < numAps; i++)
+        {
+          READ_CODE(3, uiCode, "slice_alf_aps_id_luma");
+          apsId[i] = uiCode;
+          APS* APStoCheckLuma = parameterSetManager->getAPS(apsId[i], ALF_APS);
+          CHECK(APStoCheckLuma->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_LUMA] != 1, "bitstream conformance error, alf_luma_filter_signal_flag shall be equal to 1");
+        }
 
-      pcSlice->setAlfAPSs(apsId);
-      if (bChroma)
-      {
-        READ_CODE(2, uiCode, "slice_alf_chroma_idc");
-        alfChromaIdc = uiCode;
+
+        pcSlice->setAlfAPSs(apsId);
+        if (bChroma)
+        {
+          READ_CODE(2, uiCode, "slice_alf_chroma_idc");   alfChromaIdc = uiCode;
+        }
+        else
+        {
+          alfChromaIdc = 0;
+        }
+        if (alfChromaIdc)
+        {
+          READ_CODE(3, uiCode, "slice_alf_aps_id_chroma");
+          pcSlice->setTileGroupApsIdChroma(uiCode);
+          APS* APStoCheckChroma = parameterSetManager->getAPS(uiCode, ALF_APS);
+          CHECK(APStoCheckChroma->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_CHROMA] != 1, "bitstream conformance error, alf_chroma_filter_signal_flag shall be equal to 1");
+        }
       }
       else
       {
-        alfChromaIdc = 0;
+        pcSlice->setTileGroupNumAps(0);
       }
-      if (alfChromaIdc)
-      {
-        READ_CODE(3, uiCode, "slice_alf_aps_id_chroma");
-        pcSlice->setTileGroupApsIdChroma(uiCode);
-        APS *APStoCheckChroma = parameterSetManager->getAPS(uiCode, ALF_APS);
-        CHECK(APStoCheckChroma->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_CHROMA] != 1,
-              "bitstream conformance error, alf_chroma_filter_signal_flag shall be equal to 1");
-      }
-    }
-    else
-    {
-      pcSlice->setTileGroupNumAps(0);
-    }
-    pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Cb, alfChromaIdc & 1);
-    pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Cr, alfChromaIdc >> 1);
+      pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Cb, alfChromaIdc & 1);
+      pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Cr, alfChromaIdc >> 1);
 
 #if JVET_Q0795_CCALF
-    CcAlfFilterParam &filterParam = pcSlice->m_ccAlfFilterParam;
-    if (sps->getCCALFEnabledFlag() && pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y))
-    {
-      READ_FLAG(uiCode, "slice_cc_alf_cb_enabled_flag");
-      pcSlice->setTileGroupCcAlfCbEnabledFlag(uiCode);
-      filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] = (uiCode == 1) ? true : false;
-      pcSlice->setTileGroupCcAlfCbApsId(-1);
-      if (filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1])
+      CcAlfFilterParam &filterParam = pcSlice->m_ccAlfFilterParam;
+      if (sps->getCCALFEnabledFlag() && pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y))
       {
-        // parse APS ID
-        READ_CODE(3, uiCode, "slice_cc_alf_cb_aps_id");
-        pcSlice->setTileGroupCcAlfCbApsId(uiCode);
+        READ_FLAG(uiCode, "slice_cc_alf_cb_enabled_flag");
+        pcSlice->setTileGroupCcAlfCbEnabledFlag(uiCode);
+        filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] = (uiCode == 1) ? true : false;
+        pcSlice->setTileGroupCcAlfCbApsId(-1);
+        if (filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1])
+        {
+          // parse APS ID
+          READ_CODE(3, uiCode, "slice_cc_alf_cb_aps_id");
+          pcSlice->setTileGroupCcAlfCbApsId(uiCode);
+        }
+        // Cr
+        READ_FLAG(uiCode, "slice_cc_alf_cr_enabled_flag");
+        pcSlice->setTileGroupCcAlfCrEnabledFlag(uiCode);
+        filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] = (uiCode == 1) ? true : false;
+        pcSlice->setTileGroupCcAlfCrApsId(-1);
+        if (filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1])
+        {
+          // parse APS ID
+          READ_CODE(3, uiCode, "slice_cc_alf_cr_aps_id");
+          pcSlice->setTileGroupCcAlfCrApsId(uiCode);
+        }
       }
-      // Cr
-      READ_FLAG(uiCode, "slice_cc_alf_cr_enabled_flag");
-      pcSlice->setTileGroupCcAlfCrEnabledFlag(uiCode);
-      filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] = (uiCode == 1) ? true : false;
-      pcSlice->setTileGroupCcAlfCrApsId(-1);
-      if (filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1])
+      else
       {
-        // parse APS ID
-        READ_CODE(3, uiCode, "slice_cc_alf_cr_aps_id");
-        pcSlice->setTileGroupCcAlfCrApsId(uiCode);
+        filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] = false;
+        filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] = false;
+        pcSlice->setTileGroupCcAlfCbApsId(-1);
+        pcSlice->setTileGroupCcAlfCrApsId(-1);
       }
-    }
-    else
-    {
-      filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] = false;
-      filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] = false;
-      pcSlice->setTileGroupCcAlfCbApsId(-1);
-      pcSlice->setTileGroupCcAlfCrApsId(-1);
-    }
 #endif
-  }
+    }
 
-  if (pps->getDeblockingFilterControlPresentFlag())
-  {
+    if (pps->getDeblockingFilterControlPresentFlag())
+    {
 #if JVET_Q0819_PH_CHANGES
-    if (pps->getDeblockingFilterOverrideEnabledFlag() && !pps->getDbfInfoInPhFlag())
+      if (pps->getDeblockingFilterOverrideEnabledFlag() && !pps->getDbfInfoInPhFlag())
 #else
-    if (pps->getDeblockingFilterOverrideEnabledFlag() && !picHeader->getDeblockingFilterOverridePresentFlag())
+      if (pps->getDeblockingFilterOverrideEnabledFlag() && !picHeader->getDeblockingFilterOverridePresentFlag())
 #endif
-    {
-      READ_FLAG(uiCode, "slice_deblocking_filter_override_flag");
-      pcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false);
-    }
-    else
-    {
-      pcSlice->setDeblockingFilterOverrideFlag(0);
-    }
-    if (pcSlice->getDeblockingFilterOverrideFlag())
-    {
-      READ_FLAG(uiCode, "slice_deblocking_filter_disabled_flag");
-      pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0);
-      if (!pcSlice->getDeblockingFilterDisable())
       {
+        READ_FLAG ( uiCode, "slice_deblocking_filter_override_flag" );        pcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false);
+      }
+      else
+      {
+        pcSlice->setDeblockingFilterOverrideFlag(0);
+      }
+      if(pcSlice->getDeblockingFilterOverrideFlag())
+      {
+        READ_FLAG ( uiCode, "slice_deblocking_filter_disabled_flag" );   pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0);
+        if(!pcSlice->getDeblockingFilterDisable())
+        {
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-        READ_SVLC(iCode, "slice_beta_offset_div2");
-        pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
-        CHECK(pcSlice->getDeblockingFilterBetaOffsetDiv2() < -12 || pcSlice->getDeblockingFilterBetaOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
-        READ_SVLC(iCode, "slice_tc_offset_div2");
-        pcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
-        CHECK(pcSlice->getDeblockingFilterTcOffsetDiv2() < -12 || pcSlice->getDeblockingFilterTcOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
-
-        READ_SVLC(iCode, "slice_cb_beta_offset_div2");
-        pcSlice->setDeblockingFilterCbBetaOffsetDiv2(iCode);
-        CHECK(pcSlice->getDeblockingFilterCbBetaOffsetDiv2() < -12
-                || pcSlice->getDeblockingFilterCbBetaOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
-        READ_SVLC(iCode, "slice_cb_tc_offset_div2");
-        pcSlice->setDeblockingFilterCbTcOffsetDiv2(iCode);
-        CHECK(pcSlice->getDeblockingFilterCbTcOffsetDiv2() < -12 || pcSlice->getDeblockingFilterCbTcOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
-
-        READ_SVLC(iCode, "slice_cr_beta_offset_div2");
-        pcSlice->setDeblockingFilterCrBetaOffsetDiv2(iCode);
-        CHECK(pcSlice->getDeblockingFilterCrBetaOffsetDiv2() < -12
-                || pcSlice->getDeblockingFilterCrBetaOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
-        READ_SVLC(iCode, "slice_cr_tc_offset_div2");
-        pcSlice->setDeblockingFilterCrTcOffsetDiv2(iCode);
-        CHECK(pcSlice->getDeblockingFilterCrTcOffsetDiv2() < -12 || pcSlice->getDeblockingFilterCrTcOffsetDiv2() > 12,
-              "Invalid deblocking filter configuration");
+          READ_SVLC( iCode, "slice_beta_offset_div2" );                     pcSlice->setDeblockingFilterBetaOffsetDiv2( iCode );
+          CHECK(  pcSlice->getDeblockingFilterBetaOffsetDiv2() < -12 ||
+                  pcSlice->getDeblockingFilterBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration");
+          READ_SVLC( iCode, "slice_tc_offset_div2" );                       pcSlice->setDeblockingFilterTcOffsetDiv2( iCode );
+          CHECK(  pcSlice->getDeblockingFilterTcOffsetDiv2() < -12 ||
+                  pcSlice->getDeblockingFilterTcOffsetDiv2() > 12, "Invalid deblocking filter configuration");
+
+          READ_SVLC( iCode, "slice_cb_beta_offset_div2" );                  pcSlice->setDeblockingFilterCbBetaOffsetDiv2( iCode );
+          CHECK(  pcSlice->getDeblockingFilterCbBetaOffsetDiv2() < -12 ||
+                  pcSlice->getDeblockingFilterCbBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration");
+          READ_SVLC( iCode, "slice_cb_tc_offset_div2" );                    pcSlice->setDeblockingFilterCbTcOffsetDiv2( iCode );
+          CHECK(  pcSlice->getDeblockingFilterCbTcOffsetDiv2() < -12 ||
+                  pcSlice->getDeblockingFilterCbTcOffsetDiv2() > 12, "Invalid deblocking filter configuration");
+
+          READ_SVLC( iCode, "slice_cr_beta_offset_div2" );                  pcSlice->setDeblockingFilterCrBetaOffsetDiv2( iCode );
+          CHECK(  pcSlice->getDeblockingFilterCrBetaOffsetDiv2() < -12 ||
+                  pcSlice->getDeblockingFilterCrBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration");
+          READ_SVLC( iCode, "slice_cr_tc_offset_div2" );                    pcSlice->setDeblockingFilterCrTcOffsetDiv2( iCode );
+          CHECK(  pcSlice->getDeblockingFilterCrTcOffsetDiv2() < -12 ||
+                  pcSlice->getDeblockingFilterCrTcOffsetDiv2() > 12, "Invalid deblocking filter configuration");
 #else
-        READ_SVLC(iCode, "slice_beta_offset_div2");
-        pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
-        CHECK(pcSlice->getDeblockingFilterBetaOffsetDiv2() < -6 && pcSlice->getDeblockingFilterBetaOffsetDiv2() > 6,
-              "Invalid deblocking filter configuration");
-        READ_SVLC(iCode, "slice_tc_offset_div2");
-        pcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
-        CHECK(pcSlice->getDeblockingFilterTcOffsetDiv2() < -6 && pcSlice->getDeblockingFilterTcOffsetDiv2() > 6,
-              "Invalid deblocking filter configuration");
+          READ_SVLC( iCode, "slice_beta_offset_div2" );                       pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
+          CHECK(  pcSlice->getDeblockingFilterBetaOffsetDiv2() < -6 &&
+                  pcSlice->getDeblockingFilterBetaOffsetDiv2() >  6, "Invalid deblocking filter configuration");
+          READ_SVLC( iCode, "slice_tc_offset_div2" );                         pcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
+          CHECK  (pcSlice->getDeblockingFilterTcOffsetDiv2() < -6 &&
+                  pcSlice->getDeblockingFilterTcOffsetDiv2() >  6, "Invalid deblocking filter configuration");
+#endif
+        }
+      }
+      else
+      {
+        pcSlice->setDeblockingFilterDisable       ( picHeader->getDeblockingFilterDisable() );
+        pcSlice->setDeblockingFilterBetaOffsetDiv2( picHeader->getDeblockingFilterBetaOffsetDiv2() );
+        pcSlice->setDeblockingFilterTcOffsetDiv2  ( picHeader->getDeblockingFilterTcOffsetDiv2() );
+#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
+        pcSlice->setDeblockingFilterCbBetaOffsetDiv2( picHeader->getDeblockingFilterCbBetaOffsetDiv2() );
+        pcSlice->setDeblockingFilterCbTcOffsetDiv2  ( picHeader->getDeblockingFilterCbTcOffsetDiv2() );
+        pcSlice->setDeblockingFilterCrBetaOffsetDiv2(picHeader->getDeblockingFilterCrBetaOffsetDiv2());
+        pcSlice->setDeblockingFilterCrTcOffsetDiv2(picHeader->getDeblockingFilterCrTcOffsetDiv2());
 #endif
       }
     }
     else
     {
-      pcSlice->setDeblockingFilterDisable(picHeader->getDeblockingFilterDisable());
-      pcSlice->setDeblockingFilterBetaOffsetDiv2(picHeader->getDeblockingFilterBetaOffsetDiv2());
-      pcSlice->setDeblockingFilterTcOffsetDiv2(picHeader->getDeblockingFilterTcOffsetDiv2());
+      pcSlice->setDeblockingFilterDisable       ( false );
+      pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
+      pcSlice->setDeblockingFilterTcOffsetDiv2  ( 0 );
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-      pcSlice->setDeblockingFilterCbBetaOffsetDiv2(picHeader->getDeblockingFilterCbBetaOffsetDiv2());
-      pcSlice->setDeblockingFilterCbTcOffsetDiv2(picHeader->getDeblockingFilterCbTcOffsetDiv2());
-      pcSlice->setDeblockingFilterCrBetaOffsetDiv2(picHeader->getDeblockingFilterCrBetaOffsetDiv2());
-      pcSlice->setDeblockingFilterCrTcOffsetDiv2(picHeader->getDeblockingFilterCrTcOffsetDiv2());
+      pcSlice->setDeblockingFilterCbBetaOffsetDiv2( 0 );
+      pcSlice->setDeblockingFilterCbTcOffsetDiv2  ( 0 );
+      pcSlice->setDeblockingFilterCrBetaOffsetDiv2( 0 );
+      pcSlice->setDeblockingFilterCrTcOffsetDiv2  ( 0 );
 #endif
     }
-  }
-  else
-  {
-    pcSlice->setDeblockingFilterDisable(false);
-    pcSlice->setDeblockingFilterBetaOffsetDiv2(0);
-    pcSlice->setDeblockingFilterTcOffsetDiv2(0);
-#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-    pcSlice->setDeblockingFilterCbBetaOffsetDiv2(0);
-    pcSlice->setDeblockingFilterCbTcOffsetDiv2(0);
-    pcSlice->setDeblockingFilterCrBetaOffsetDiv2(0);
-    pcSlice->setDeblockingFilterCrTcOffsetDiv2(0);
-#endif
-  }
 
 #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM
-  READ_FLAG(uiCode, "slice_ts_residual_coding_disabled_flag");
-  pcSlice->setTSResidualCodingDisabledFlag(uiCode != 0);
+	READ_FLAG(uiCode, "slice_ts_residual_coding_disabled_flag");
+	pcSlice->setTSResidualCodingDisabledFlag(uiCode != 0);
 #endif
 
-  if (pcSlice->getFirstCtuRsAddrInSlice() == 0)
+  if( pcSlice->getFirstCtuRsAddrInSlice() == 0 )
   {
-    pcSlice->setDefaultClpRng(*sps);
+    pcSlice->setDefaultClpRng( *sps );
+
   }
 
-  if (pps->getSliceHeaderExtensionPresentFlag())
+  if(pps->getSliceHeaderExtensionPresentFlag())
   {
-    READ_UVLC(uiCode, "slice_segment_header_extension_length");
-    for (int i = 0; i < uiCode; i++)
+    READ_UVLC(uiCode,"slice_segment_header_extension_length");
+    for(int i=0; i<uiCode; i++)
     {
       uint32_t ignore_;
-      READ_CODE(8, ignore_, "slice_segment_header_extension_data_byte");
+      READ_CODE(8,ignore_,"slice_segment_header_extension_data_byte");
     }
   }
 
   std::vector<uint32_t> entryPointOffset;
 
-  pcSlice->setNumEntryPoints(pps);
-  if (pcSlice->getNumEntryPoints() > 0)
+  pcSlice->setNumEntryPoints( pps );
+  if( pcSlice->getNumEntryPoints() > 0 )
   {
     uint32_t offsetLenMinus1;
-    READ_UVLC(offsetLenMinus1, "offset_len_minus1");
-    entryPointOffset.resize(pcSlice->getNumEntryPoints());
-    for (uint32_t idx = 0; idx < pcSlice->getNumEntryPoints(); idx++)
+    READ_UVLC( offsetLenMinus1, "offset_len_minus1" );
+    entryPointOffset.resize( pcSlice->getNumEntryPoints() );
+    for( uint32_t idx = 0; idx < pcSlice->getNumEntryPoints(); idx++ )
     {
-      READ_CODE(offsetLenMinus1 + 1, uiCode, "entry_point_offset_minus1");
+      READ_CODE( offsetLenMinus1 + 1, uiCode, "entry_point_offset_minus1" );
       entryPointOffset[idx] = uiCode + 1;
     }
   }
 
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-  CodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS, m_pcBitstream->readByteAlignment(), 0);
+  CodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,m_pcBitstream->readByteAlignment(),0);
 #else
   m_pcBitstream->readByteAlignment();
 #endif
 
   pcSlice->clearSubstreamSizes();
 
-  if (pcSlice->getNumEntryPoints() > 0)
+  if( pcSlice->getNumEntryPoints() > 0 )
   {
     int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();
 
     // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header
-    for (uint32_t curByteIdx = 0; curByteIdx < m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++)
+    for ( uint32_t curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
     {
-      if (m_pcBitstream->getEmulationPreventionByteLocation(curByteIdx) < endOfSliceHeaderLocation)
+      if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation )
       {
         endOfSliceHeaderLocation++;
       }
     }
 
-    int curEntryPointOffset  = 0;
-    int prevEntryPointOffset = 0;
-    for (uint32_t idx = 0; idx < entryPointOffset.size(); idx++)
+    int  curEntryPointOffset     = 0;
+    int  prevEntryPointOffset    = 0;
+    for (uint32_t idx=0; idx<entryPointOffset.size(); idx++)
     {
-      curEntryPointOffset += entryPointOffset[idx];
+      curEntryPointOffset += entryPointOffset[ idx ];
 
       int emulationPreventionByteCount = 0;
-      for (uint32_t curByteIdx = 0; curByteIdx < m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++)
+      for ( uint32_t curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
       {
-        if (m_pcBitstream->getEmulationPreventionByteLocation(curByteIdx)
-              >= (prevEntryPointOffset + endOfSliceHeaderLocation)
-            && m_pcBitstream->getEmulationPreventionByteLocation(curByteIdx)
-                 < (curEntryPointOffset + endOfSliceHeaderLocation))
+        if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) &&
+             m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) <  ( curEntryPointOffset  + endOfSliceHeaderLocation ) )
         {
           emulationPreventionByteCount++;
         }
       }
 
-      entryPointOffset[idx] -= emulationPreventionByteCount;
+      entryPointOffset[ idx ] -= emulationPreventionByteCount;
       prevEntryPointOffset = curEntryPointOffset;
-      pcSlice->addSubstreamSize(entryPointOffset[idx]);
+      pcSlice->addSubstreamSize(entryPointOffset [ idx ] );
     }
   }
   return;
 }
 
-void HLSyntaxReader::parseSliceHeaderToPoc(Slice *pcSlice, PicHeader *picHeader,
-                                           ParameterSetManager *parameterSetManager, const int prevTid0POC)
+void HLSyntaxReader::parseSliceHeaderToPoc (Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC)
 {
-  uint32_t uiCode;
-  PPS *    pps = NULL;
-  SPS *    sps = NULL;
-
-  CHECK(picHeader == 0, "Invalid Picture Header");
-  CHECK(picHeader->isValid() == false, "Invalid Picture Header");
-  pps = parameterSetManager->getPPS(picHeader->getPPSId());
-  //! KS: need to add error handling code here, if PPS is not available
-  CHECK(pps == 0, "Invalid PPS");
+  uint32_t  uiCode;
+  PPS* pps = NULL;
+  SPS* sps = NULL;
+
+  CHECK(picHeader==0, "Invalid Picture Header");
+  CHECK(picHeader->isValid()==false, "Invalid Picture Header");
+  pps = parameterSetManager->getPPS( picHeader->getPPSId() );
+  //!KS: need to add error handling code here, if PPS is not available
+  CHECK(pps==0, "Invalid PPS");
   sps = parameterSetManager->getSPS(pps->getSPSId());
-  //! KS: need to add error handling code here, if SPS is not available
-  CHECK(sps == 0, "Invalid SPS");
-
+  //!KS: need to add error handling code here, if SPS is not available
+  CHECK(sps==0, "Invalid SPS");
+  
   // picture order count
   READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb");
   if (pcSlice->getIdrPicFlag())
@@ -4091,17 +3763,17 @@ void HLSyntaxReader::parseSliceHeaderToPoc(Slice *pcSlice, PicHeader *picHeader,
   }
   else
   {
-    int iPOClsb     = uiCode;
-    int iPrevPOC    = prevTid0POC;
-    int iMaxPOClsb  = 1 << sps->getBitsForPOC();
+    int iPOClsb = uiCode;
+    int iPrevPOC = prevTid0POC;
+    int iMaxPOClsb = 1 << sps->getBitsForPOC();
     int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1);
     int iPrevPOCmsb = iPrevPOC - iPrevPOClsb;
     int iPOCmsb;
-    if ((iPOClsb < iPrevPOClsb) && ((iPrevPOClsb - iPOClsb) >= (iMaxPOClsb / 2)))
+    if ((iPOClsb  <  iPrevPOClsb) && ((iPrevPOClsb - iPOClsb) >= (iMaxPOClsb / 2)))
     {
       iPOCmsb = iPrevPOCmsb + iMaxPOClsb;
     }
-    else if ((iPOClsb > iPrevPOClsb) && ((iPOClsb - iPrevPOClsb) > (iMaxPOClsb / 2)))
+    else if ((iPOClsb  >  iPrevPOClsb) && ((iPOClsb - iPrevPOClsb)  >  (iMaxPOClsb / 2)))
     {
       iPOCmsb = iPrevPOCmsb - iMaxPOClsb;
     }
@@ -4116,218 +3788,281 @@ void HLSyntaxReader::parseSliceHeaderToPoc(Slice *pcSlice, PicHeader *picHeader,
 void HLSyntaxReader::parseConstraintInfo(ConstraintInfo *cinfo)
 {
   uint32_t symbol;
-  READ_FLAG(symbol, "general_progressive_source_flag");
-  cinfo->setProgressiveSourceFlag(symbol ? true : false);
-  READ_FLAG(symbol, "general_interlaced_source_flag");
-  cinfo->setInterlacedSourceFlag(symbol ? true : false);
-  READ_FLAG(symbol, "general_non_packed_constraint_flag");
-  cinfo->setNonPackedConstraintFlag(symbol ? true : false);
-  READ_FLAG(symbol, "general_frame_only_constraint_flag");
-  cinfo->setFrameOnlyConstraintFlag(symbol ? true : false);
-  READ_FLAG(symbol, "intra_only_constraint_flag");
-  cinfo->setIntraOnlyConstraintFlag(symbol ? true : false);
-
-  READ_CODE(4, symbol, "max_bitdepth_constraint_idc");
-  cinfo->setMaxBitDepthConstraintIdc(symbol);
-  READ_CODE(2, symbol, "max_chroma_format_constraint_idc");
-  cinfo->setMaxChromaFormatConstraintIdc((ChromaFormat) symbol);
-
-  READ_FLAG(symbol, "no_qtbtt_dual_tree_intra_constraint_flag");
-  cinfo->setNoQtbttDualTreeIntraConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_partition_constraints_override_constraint_flag");
-  cinfo->setNoPartitionConstraintsOverrideConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_sao_constraint_flag");
-  cinfo->setNoSaoConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_alf_constraint_flag");
-  cinfo->setNoAlfConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol,  "general_progressive_source_flag"          ); cinfo->setProgressiveSourceFlag(symbol ? true : false);
+  READ_FLAG(symbol,  "general_interlaced_source_flag"           ); cinfo->setInterlacedSourceFlag(symbol ? true : false);
+  READ_FLAG(symbol,  "general_non_packed_constraint_flag"       ); cinfo->setNonPackedConstraintFlag(symbol ? true : false);
+  READ_FLAG(symbol,  "general_frame_only_constraint_flag"       ); cinfo->setFrameOnlyConstraintFlag(symbol ? true : false);
+  READ_FLAG(symbol,  "intra_only_constraint_flag"               ); cinfo->setIntraOnlyConstraintFlag(symbol ? true : false);
+
+  READ_CODE(4, symbol,  "max_bitdepth_constraint_idc"              ); cinfo->setMaxBitDepthConstraintIdc(symbol);
+  READ_CODE(2, symbol,  "max_chroma_format_constraint_idc"         ); cinfo->setMaxChromaFormatConstraintIdc((ChromaFormat)symbol);
+
+  READ_FLAG(symbol,  "no_qtbtt_dual_tree_intra_constraint_flag" ); cinfo->setNoQtbttDualTreeIntraConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_partition_constraints_override_constraint_flag"); cinfo->setNoPartitionConstraintsOverrideConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol,  "no_sao_constraint_flag");                    cinfo->setNoSaoConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol,  "no_alf_constraint_flag");                    cinfo->setNoAlfConstraintFlag(symbol > 0 ? true : false);
 #if JVET_Q0795_CCALF
-  READ_FLAG(symbol, "no_ccalf_constraint_flag");
-  cinfo->setNoCCAlfConstraintFlag(symbol > 0 ? true : false);
-#endif
-  READ_FLAG(symbol, "no_joint_cbcr_constraint_flag");
-  cinfo->setNoJointCbCrConstraintFlag(symbol > 0 ? true : false);
-
-  READ_FLAG(symbol, "no_ref_wraparound_constraint_flag");
-  cinfo->setNoRefWraparoundConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_temporal_mvp_constraint_flag");
-  cinfo->setNoTemporalMvpConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_sbtmvp_constraint_flag");
-  cinfo->setNoSbtmvpConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_amvr_constraint_flag");
-  cinfo->setNoAmvrConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_bdof_constraint_flag");
-  cinfo->setNoBdofConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_dmvr_constraint_flag");
-  cinfo->setNoDmvrConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_cclm_constraint_flag");
-  cinfo->setNoCclmConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_mts_constraint_flag");
-  cinfo->setNoMtsConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_sbt_constraint_flag");
-  cinfo->setNoSbtConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_affine_motion_constraint_flag");
-  cinfo->setNoAffineMotionConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_bcw_constraint_flag");
-  cinfo->setNoBcwConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_ibc_constraint_flag");
-  cinfo->setNoIbcConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_ciip_constraint_flag");
-  cinfo->setNoCiipConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_fpel_mmvd_constraint_flag");
-  cinfo->setNoFPelMmvdConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol,  "no_ccalf_constraint_flag");                  cinfo->setNoCCAlfConstraintFlag(symbol > 0 ? true : false);
+#endif
+  READ_FLAG(symbol,  "no_joint_cbcr_constraint_flag");             cinfo->setNoJointCbCrConstraintFlag(symbol > 0 ? true : false);
+
+  READ_FLAG(symbol,  "no_ref_wraparound_constraint_flag");         cinfo->setNoRefWraparoundConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol,  "no_temporal_mvp_constraint_flag");           cinfo->setNoTemporalMvpConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol,  "no_sbtmvp_constraint_flag");                 cinfo->setNoSbtmvpConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol,  "no_amvr_constraint_flag");                   cinfo->setNoAmvrConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol,  "no_bdof_constraint_flag");                   cinfo->setNoBdofConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_dmvr_constraint_flag");                    cinfo->setNoDmvrConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_cclm_constraint_flag");                    cinfo->setNoCclmConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_mts_constraint_flag");                     cinfo->setNoMtsConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_sbt_constraint_flag");                     cinfo->setNoSbtConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_affine_motion_constraint_flag");           cinfo->setNoAffineMotionConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_bcw_constraint_flag");                     cinfo->setNoBcwConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_ibc_constraint_flag");                     cinfo->setNoIbcConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_ciip_constraint_flag");                    cinfo->setNoCiipConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_fpel_mmvd_constraint_flag");               cinfo->setNoFPelMmvdConstraintFlag(symbol > 0 ? true : false);
 #if !JVET_Q0806
-  READ_FLAG(symbol, "no_triangle_constraint_flag");
-  cinfo->setNoTriangleConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_triangle_constraint_flag");                cinfo->setNoTriangleConstraintFlag(symbol > 0 ? true : false);
 #else
-  READ_FLAG(symbol, "no_gpm_constraint_flag");
-  cinfo->setNoGeoConstraintFlag(symbol > 0 ? true : false);
-#endif
-  READ_FLAG(symbol, "no_ladf_constraint_flag");
-  cinfo->setNoLadfConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_transform_skip_constraint_flag");
-  cinfo->setNoTransformSkipConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_bdpcm_constraint_flag");
-  cinfo->setNoBDPCMConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_qp_delta_constraint_flag");
-  cinfo->setNoQpDeltaConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_dep_quant_constraint_flag");
-  cinfo->setNoDepQuantConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_sign_data_hiding_constraint_flag");
-  cinfo->setNoSignDataHidingConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_trail_constraint_flag");
-  cinfo->setNoTrailConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_stsa_constraint_flag");
-  cinfo->setNoStsaConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_rasl_constraint_flag");
-  cinfo->setNoRaslConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_radl_constraint_flag");
-  cinfo->setNoRadlConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_idr_constraint_flag");
-  cinfo->setNoIdrConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_cra_constraint_flag");
-  cinfo->setNoCraConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_gdr_constraint_flag");
-  cinfo->setNoGdrConstraintFlag(symbol > 0 ? true : false);
-  READ_FLAG(symbol, "no_aps_constraint_flag");
-  cinfo->setNoApsConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_gpm_constraint_flag");                     cinfo->setNoGeoConstraintFlag(symbol > 0 ? true : false);
+#endif
+  READ_FLAG(symbol, "no_ladf_constraint_flag");                    cinfo->setNoLadfConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_transform_skip_constraint_flag");          cinfo->setNoTransformSkipConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_bdpcm_constraint_flag");                   cinfo->setNoBDPCMConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_qp_delta_constraint_flag");                cinfo->setNoQpDeltaConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_dep_quant_constraint_flag");               cinfo->setNoDepQuantConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_sign_data_hiding_constraint_flag");        cinfo->setNoSignDataHidingConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_trail_constraint_flag");                   cinfo->setNoTrailConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_stsa_constraint_flag");                    cinfo->setNoStsaConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_rasl_constraint_flag");                    cinfo->setNoRaslConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_radl_constraint_flag");                    cinfo->setNoRadlConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_idr_constraint_flag");                     cinfo->setNoIdrConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_cra_constraint_flag");                     cinfo->setNoCraConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_gdr_constraint_flag");                     cinfo->setNoGdrConstraintFlag(symbol > 0 ? true : false);
+  READ_FLAG(symbol, "no_aps_constraint_flag");                     cinfo->setNoApsConstraintFlag(symbol > 0 ? true : false);
 }
 
+
 void HLSyntaxReader::parseProfileTierLevel(ProfileTierLevel *ptl, int maxNumSubLayersMinus1)
 {
   uint32_t symbol;
-  READ_CODE(7, symbol, "general_profile_idc");
-  ptl->setProfileIdc(Profile::Name(symbol));
-  READ_FLAG(symbol, "general_tier_flag");
-  ptl->setTierFlag(symbol ? Level::HIGH : Level::MAIN);
+  READ_CODE(7 , symbol,   "general_profile_idc"              ); ptl->setProfileIdc  (Profile::Name(symbol));
+  READ_FLAG(    symbol,   "general_tier_flag"                ); ptl->setTierFlag    (symbol ? Level::HIGH : Level::MAIN);
 
-  parseConstraintInfo(ptl->getConstraintInfo());
+  parseConstraintInfo( ptl->getConstraintInfo() );
 
-  READ_CODE(8, symbol, "general_level_idc");
-  ptl->setLevelIdc(Level::Name(symbol));
+  READ_CODE( 8, symbol, "general_level_idc" ); ptl->setLevelIdc( Level::Name( symbol ) );
 
   READ_CODE(8, symbol, "num_sub_profiles");
   uint8_t numSubProfiles = symbol;
-  ptl->setNumSubProfile(numSubProfiles);
+  ptl->setNumSubProfile( numSubProfiles );
   for (int i = 0; i < numSubProfiles; i++)
   {
-    READ_CODE(32, symbol, "general_sub_profile_idc[i]");
-    ptl->setSubProfileIdc(i, symbol);
+    READ_CODE(32, symbol, "general_sub_profile_idc[i]"); ptl->setSubProfileIdc(i, symbol);
   }
 
+
   for (int i = 0; i < maxNumSubLayersMinus1; i++)
   {
-    READ_FLAG(symbol, "sub_layer_level_present_flag[i]");
-    ptl->setSubLayerLevelPresentFlag(i, symbol);
+    READ_FLAG( symbol, "sub_layer_level_present_flag[i]"   ); ptl->setSubLayerLevelPresentFlag  (i, symbol);
   }
 
   while (!isByteAligned())
   {
-    READ_FLAG(symbol, "ptl_alignment_zero_bit");
-    CHECK(symbol != 0, "ptl_alignment_zero_bit not equal to zero");
+    READ_FLAG(    symbol,   "ptl_alignment_zero_bit"        ); CHECK (symbol != 0, "ptl_alignment_zero_bit not equal to zero");
   }
 
   for (int i = 0; i < maxNumSubLayersMinus1; i++)
   {
     if (ptl->getSubLayerLevelPresentFlag(i))
     {
-      READ_CODE(8, symbol, "sub_layer_level_idc");
-      ptl->setSubLayerLevelIdc(i, Level::Name(symbol));
+      READ_CODE(8 , symbol,   "sub_layer_level_idc"                ); ptl->setSubLayerLevelIdc    (i, Level::Name(symbol));
     }
   }
   ptl->setSubLayerLevelIdc(maxNumSubLayersMinus1, ptl->getLevelIdc());
-  for (int i = maxNumSubLayersMinus1 - 1; i >= 0; i--)
+  for( int i = maxNumSubLayersMinus1 - 1; i >= 0; i-- )
   {
-    if (!ptl->getSubLayerLevelPresentFlag(i))
+    if( !ptl->getSubLayerLevelPresentFlag( i ) )
     {
-      ptl->setSubLayerLevelIdc(i, ptl->getSubLayerLevelIdc(i + 1));
+      ptl->setSubLayerLevelIdc( i, ptl->getSubLayerLevelIdc( i + 1 ) );
     }
   }
 }
 
-void HLSyntaxReader::parseTerminatingBit(uint32_t &ruiBit)
+
+
+void HLSyntaxReader::parseTerminatingBit( uint32_t& ruiBit )
 {
-  ruiBit        = false;
+  ruiBit = false;
   int iBitsLeft = m_pcBitstream->getNumBitsLeft();
-  if (iBitsLeft <= 8)
+  if(iBitsLeft <= 8)
   {
     uint32_t uiPeekValue = m_pcBitstream->peekBits(iBitsLeft);
-    if (uiPeekValue == (1 << (iBitsLeft - 1)))
+    if (uiPeekValue == (1<<(iBitsLeft-1)))
     {
       ruiBit = true;
     }
   }
 }
 
-void HLSyntaxReader::parseRemainingBytes(bool noTrailingBytesExpected)
+void HLSyntaxReader::parseRemainingBytes( bool noTrailingBytesExpected )
 {
   if (noTrailingBytesExpected)
   {
-    CHECK(0 != m_pcBitstream->getNumBitsLeft(), "Bits left although no bits expected");
+    CHECK( 0 != m_pcBitstream->getNumBitsLeft(), "Bits left although no bits expected" );
   }
   else
   {
     while (m_pcBitstream->getNumBitsLeft())
     {
-      uint32_t trailingNullByte = m_pcBitstream->readByte();
-      if (trailingNullByte != 0)
+      uint32_t trailingNullByte=m_pcBitstream->readByte();
+      if (trailingNullByte!=0)
       {
-        msg(ERROR, "Trailing byte should be 0, but has value %02x\n", trailingNullByte);
+        msg( ERROR, "Trailing byte should be 0, but has value %02x\n", trailingNullByte);
         THROW("Invalid trailing '0' byte");
       }
     }
   }
 }
 
+
+
+
 // ====================================================================================================================
 // Protected member functions
 // ====================================================================================================================
 
 //! parse explicit wp tables
+void HLSyntaxReader::parsePredWeightTable( Slice* pcSlice, const SPS *sps )
+{
+  WPScalingParam *wp;
+  const ChromaFormat    chFmt        = sps->getChromaFormatIdc();
+  const int             numValidComp = int(getNumberValidComponents(chFmt));
+  const bool            bChroma      = (chFmt!=CHROMA_400);
+  const SliceType       eSliceType   = pcSlice->getSliceType();
+  const int             iNbRef       = (eSliceType == B_SLICE ) ? (2) : (1);
+  uint32_t            uiLog2WeightDenomLuma=0, uiLog2WeightDenomChroma=0;
+  uint32_t            uiTotalSignalledWeightFlags = 0;
+
+  int iDeltaDenom;
+  // decode delta_luma_log2_weight_denom :
+  READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" );
+  CHECK( uiLog2WeightDenomLuma > 7, "Invalid code" );
+  if( bChroma )
+  {
+    READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );
+    CHECK((iDeltaDenom + (int)uiLog2WeightDenomLuma)<0, "Invalid code");
+    CHECK((iDeltaDenom + (int)uiLog2WeightDenomLuma)>7, "Invalid code");
+    uiLog2WeightDenomChroma = (uint32_t)(iDeltaDenom + uiLog2WeightDenomLuma);
+  }
+
+  for ( int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) // loop over l0 and l1 syntax elements
+  {
+    RefPicList  eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
+    for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
+    {
+      pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
+
+      wp[COMPONENT_Y].uiLog2WeightDenom = uiLog2WeightDenomLuma;
+      for(int j=1; j<numValidComp; j++)
+      {
+        wp[j].uiLog2WeightDenom = uiLog2WeightDenomChroma;
+      }
+
+      uint32_t  uiCode;
+      READ_FLAG( uiCode, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" );
+      wp[COMPONENT_Y].bPresentFlag = ( uiCode == 1 );
+      uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag;
+    }
+    if ( bChroma )
+    {
+      uint32_t  uiCode;
+      for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
+      {
+        pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
+        READ_FLAG( uiCode, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" );
+        for(int j=1; j<numValidComp; j++)
+        {
+          wp[j].bPresentFlag = ( uiCode == 1 );
+        }
+        uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag;
+      }
+    }
+    for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
+    {
+      pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
+      if ( wp[COMPONENT_Y].bPresentFlag )
+      {
+        int iDeltaWeight;
+        READ_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" );
+        CHECK( iDeltaWeight < -128, "Invalid code" );
+        CHECK( iDeltaWeight >  127, "Invalid code" );
+        wp[COMPONENT_Y].iWeight = (iDeltaWeight + (1<<wp[COMPONENT_Y].uiLog2WeightDenom));
+        READ_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" );
+        const int range=sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<sps->getBitDepth(CHANNEL_TYPE_LUMA))/2 : 128;
+        if( wp[0].iOffset < -range ) { THROW("Offset out of range"); }
+        if( wp[0].iOffset >= range ) { THROW("Offset out of range"); }
+      }
+      else
+      {
+        wp[COMPONENT_Y].iWeight = (1 << wp[COMPONENT_Y].uiLog2WeightDenom);
+        wp[COMPONENT_Y].iOffset = 0;
+      }
+      if ( bChroma )
+      {
+        if ( wp[COMPONENT_Cb].bPresentFlag )
+        {
+          int range=sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<sps->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128;
+          for ( int j=1 ; j<numValidComp ; j++ )
+          {
+            int iDeltaWeight;
+            READ_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" );
+            CHECK( iDeltaWeight < -128, "Invalid code" );
+            CHECK( iDeltaWeight >  127, "Invalid code" );
+            wp[j].iWeight = (iDeltaWeight + (1<<wp[j].uiLog2WeightDenom));
+
+            int iDeltaChroma;
+            READ_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" );
+            CHECK( iDeltaChroma <  -4*range, "Invalid code" );
+            CHECK( iDeltaChroma >=  4*range, "Invalid code" );
+            int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
+            wp[j].iOffset = Clip3(-range, range-1, (iDeltaChroma + pred) );
+          }
+        }
+        else
+        {
+          for ( int j=1 ; j<numValidComp ; j++ )
+          {
+            wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom);
+            wp[j].iOffset = 0;
+          }
+        }
+      }
+    }
+
+    for ( int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ )
+    {
+      pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
+
+      wp[0].bPresentFlag = false;
+      wp[1].bPresentFlag = false;
+      wp[2].bPresentFlag = false;
+    }
+  }
+  CHECK(uiTotalSignalledWeightFlags>24, "Too many weight flag signalled");
+}
+
 #if JVET_Q0819_PH_CHANGES
-void HLSyntaxReader::parsePredWeightTable(Slice *pcSlice, PicHeader *picHeader, const SPS *sps)
-#else
-void HLSyntaxReader::parsePredWeightTable(Slice *pcSlice, const SPS *sps)
-#endif
+void HLSyntaxReader::parsePredWeightTable(PicHeader *picHeader, const SPS *sps)
 {
   WPScalingParam *   wp;
-  const ChromaFormat chFmt                       = sps->getChromaFormatIdc();
-  const int          numValidComp                = int(getNumberValidComponents(chFmt));
-  const bool         chroma                      = (chFmt != CHROMA_400);
-#if JVET_Q0819_PH_CHANGES
-  bool               sliceLevelWp                = (pcSlice != NULL) ? 1 : 0;
-  const SliceType    sliceType                   = (sliceLevelWp) ? pcSlice->getSliceType() : B_SLICE;
-  const int          nbRef                       = (sliceLevelWp) ? ((sliceType == B_SLICE) ? (2) : (1)) : 0;
-  uint32_t           log2WeightDenomLuma         = 0;
-  uint32_t           log2WeightDenomChroma       = 0;
-#else
-  const SliceType    sliceType                   = pcSlice->getSliceType();
-  const int          nbRef                       = (sliceType == B_SLICE) ? (2) : (1);
-  uint32_t           log2WeightDenomLuma         = 0, log2WeightDenomChroma = 0;
-#endif
-  uint32_t           totalSignalledWeightFlags   = 0;
+  const ChromaFormat chFmt                     = sps->getChromaFormatIdc();
+  const int          numValidComp              = int(getNumberValidComponents(chFmt));
+  const bool         chroma                    = (chFmt != CHROMA_400);
+  uint32_t           log2WeightDenomLuma       = 0;
+  uint32_t           log2WeightDenomChroma     = 0;
+  uint32_t           totalSignalledWeightFlags = 0;
 
   int deltaDenom;
-  // decode delta_luma_log2_weight_denom :
   READ_UVLC(log2WeightDenomLuma, "luma_log2_weight_denom");
   CHECK(log2WeightDenomLuma > 7, "Invalid code");
   if (chroma)
@@ -4337,39 +4072,18 @@ void HLSyntaxReader::parsePredWeightTable(Slice *pcSlice, const SPS *sps)
     CHECK((deltaDenom + (int) log2WeightDenomLuma) > 7, "Invalid code");
     log2WeightDenomChroma = (uint32_t)(deltaDenom + log2WeightDenomLuma);
   }
-#if JVET_Q0819_PH_CHANGES
+
   uint32_t numLxWeights;
-  if (!sliceLevelWp)
-  {
-    READ_UVLC(numLxWeights, "num_l0_weights");
-  }
+  READ_UVLC(numLxWeights, "num_l0_weights");
 
   bool moreSyntaxToBeParsed = true;
-  for (int numRef = 0; numRef < NUM_REF_PIC_LIST_01 && moreSyntaxToBeParsed; numRef++)   // loop over l0 and l1 syntax elements
+  for (int numRef = 0; numRef < NUM_REF_PIC_LIST_01 && moreSyntaxToBeParsed; numRef++)
   {
     RefPicList refPicList = (numRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
-    if (sliceLevelWp)
-    {
-      numLxWeights = pcSlice->getNumRefIdx(refPicList);
-    }
     for (int refIdx = 0; refIdx < numLxWeights; refIdx++)
     {
-      if (sliceLevelWp)
-      {
-        pcSlice->getWpScaling(refPicList, refIdx, wp);
-      }
-      else
-      {
-        picHeader->getWpScaling(refPicList, refIdx, wp);
-      }
-#else
-  for (int numRef = 0; numRef < nbRef; numRef++)   // loop over l0 and l1 syntax elements
-  {
-    RefPicList refPicList = (numRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
-    for (int refIdx = 0; refIdx < pcSlice->getNumRefIdx(refPicList); iRefIdx++)
-    {
-      pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
-#endif
+      picHeader->getWpScaling(refPicList, refIdx, wp);
+
       wp[COMPONENT_Y].uiLog2WeightDenom = log2WeightDenomLuma;
       for (int j = 1; j < numValidComp; j++)
       {
@@ -4384,20 +4098,9 @@ void HLSyntaxReader::parsePredWeightTable(Slice *pcSlice, const SPS *sps)
     if (chroma)
     {
       uint32_t uiCode;
-#if JVET_Q0819_PH_CHANGES
-      for (int iRefIdx = 0; iRefIdx < numLxWeights; iRefIdx++)
-#else
-      for (int iRefIdx = 0; iRefIdx < pcSlice->getNumRefIdx(eRefPicList); iRefIdx++)
-#endif
+      for (int refIdx = 0; refIdx < numLxWeights; refIdx++)
       {
-        if (sliceLevelWp)
-        {
-          pcSlice->getWpScaling(refPicList, iRefIdx, wp);
-        }
-        else
-        {
-          picHeader->getWpScaling(refPicList, iRefIdx, wp);
-        }
+        picHeader->getWpScaling(refPicList, refIdx, wp);
         READ_FLAG(uiCode, numRef == 0 ? "chroma_weight_l0_flag[i]" : "chroma_weight_l1_flag[i]");
         for (int j = 1; j < numValidComp; j++)
         {
@@ -4406,20 +4109,9 @@ void HLSyntaxReader::parsePredWeightTable(Slice *pcSlice, const SPS *sps)
         totalSignalledWeightFlags += 2 * wp[COMPONENT_Cb].bPresentFlag;
       }
     }
-#if JVET_Q0819_PH_CHANGES
     for (int refIdx = 0; refIdx < numLxWeights; refIdx++)
-#else
-    for (int refIdx = 0; refIdx < pcSlice->getNumRefIdx(refPicList); refIdx++)
-#endif
     {
-      if (sliceLevelWp)
-      {
-        pcSlice->getWpScaling(refPicList, refIdx, wp);
-      }
-      else
-      {
-        picHeader->getWpScaling(refPicList, refIdx, wp);
-      }
+      picHeader->getWpScaling(refPicList, refIdx, wp);
       if (wp[COMPONENT_Y].bPresentFlag)
       {
         int deltaWeight;
@@ -4475,45 +4167,33 @@ void HLSyntaxReader::parsePredWeightTable(Slice *pcSlice, const SPS *sps)
       }
     }
 
-#if JVET_Q0819_PH_CHANGES
     for (int refIdx = numLxWeights; refIdx < MAX_NUM_REF; refIdx++)
-#else
-    for (int refIdx = pcSlice->getNumRefIdx(eRefPicList); refIdx < MAX_NUM_REF; refIdx++)
-#endif
     {
-      pcSlice->getWpScaling(refPicList, refIdx, wp);
+      picHeader->getWpScaling(refPicList, refIdx, wp);
 
       wp[0].bPresentFlag = false;
       wp[1].bPresentFlag = false;
       wp[2].bPresentFlag = false;
     }
-#if JVET_Q0819_PH_CHANGES
-    if( sliceLevelWp )
-    {
-      moreSyntaxToBeParsed = (numRef < nbRef) ? true : false;
-    }
-    else
+
+    if (numRef == 0)
     {
-      if (numRef == 0)
-      {
-        READ_UVLC(numLxWeights, "num_l1_weights");
-        moreSyntaxToBeParsed = (numLxWeights == 0) ? false : true;
-      }
+      READ_UVLC(numLxWeights, "num_l1_weights");
+      moreSyntaxToBeParsed = (numLxWeights == 0) ? false : true;
     }
-#endif
   }
   CHECK(totalSignalledWeightFlags > 24, "Too many weight flag signalled");
 }
+#endif
 
 /** decode quantization matrix
- * \param scalingList quantization matrix information
- */
-void HLSyntaxReader::parseScalingList(ScalingList *scalingList)
+* \param scalingList quantization matrix information
+*/
+void HLSyntaxReader::parseScalingList(ScalingList* scalingList)
 {
-  uint32_t code;
-  bool     scalingListCopyModeFlag;
-  READ_FLAG(code, "scaling_matrix_for_lfnst_disabled_flag");
-  scalingList->setDisableScalingMatrixForLfnstBlks(code ? true : false);
+  uint32_t  code;
+  bool scalingListCopyModeFlag;
+  READ_FLAG(code, "scaling_matrix_for_lfnst_disabled_flag"); scalingList->setDisableScalingMatrixForLfnstBlks(code ? true : false);
   for (int scalingListId = 0; scalingListId < 28; scalingListId++)
   {
     READ_FLAG(code, "scaling_list_copy_mode_flag");
@@ -4527,27 +4207,22 @@ void HLSyntaxReader::parseScalingList(ScalingList *scalingList)
       scalingList->setScalingListPreditorModeFlag(scalingListId, code);
     }
 
-    if ((scalingListCopyModeFlag || scalingList->getScalingListPreditorModeFlag(scalingListId))
-        && scalingListId != SCALING_LIST_1D_START_2x2 && scalingListId != SCALING_LIST_1D_START_4x4
-        && scalingListId != SCALING_LIST_1D_START_8x8)   // Copy Mode
+    if ((scalingListCopyModeFlag || scalingList->getScalingListPreditorModeFlag(scalingListId)) && scalingListId!= SCALING_LIST_1D_START_2x2 && scalingListId!= SCALING_LIST_1D_START_4x4 && scalingListId!= SCALING_LIST_1D_START_8x8) //Copy Mode
     {
       READ_UVLC(code, "scaling_list_pred_matrix_id_delta");
-      scalingList->setRefMatrixId(scalingListId, (uint32_t)((int) (scalingListId) - (code)));
-    }
+      scalingList->setRefMatrixId(scalingListId, (uint32_t)((int)(scalingListId)-(code)));
+    }    
     else if (scalingListCopyModeFlag || scalingList->getScalingListPreditorModeFlag(scalingListId))
     {
-      scalingList->setRefMatrixId(scalingListId, (uint32_t)((int) (scalingListId)));
+      scalingList->setRefMatrixId(scalingListId, (uint32_t)((int)(scalingListId)));
     }
-    if (scalingListCopyModeFlag)   // copy
+    if (scalingListCopyModeFlag)//copy
     {
       if (scalingListId >= SCALING_LIST_1D_START_16x16)
       {
-        scalingList->setScalingListDC(
-          scalingListId, ((scalingListId == scalingList->getRefMatrixId(scalingListId))
-                            ? 16
-                            : (scalingList->getRefMatrixId(scalingListId) < SCALING_LIST_1D_START_16x16)
-                                ? scalingList->getScalingListAddress(scalingList->getRefMatrixId(scalingListId))[0]
-                                : scalingList->getScalingListDC(scalingList->getRefMatrixId(scalingListId))));
+        scalingList->setScalingListDC(scalingListId,
+          ((scalingListId == scalingList->getRefMatrixId(scalingListId)) ? 16
+            : (scalingList->getRefMatrixId(scalingListId) < SCALING_LIST_1D_START_16x16) ? scalingList->getScalingListAddress(scalingList->getRefMatrixId(scalingListId))[0] : scalingList->getScalingListDC(scalingList->getRefMatrixId(scalingListId))));
       }
       scalingList->processRefMatrix(scalingListId, scalingList->getRefMatrixId(scalingListId));
     }
@@ -4561,29 +4236,24 @@ void HLSyntaxReader::parseScalingList(ScalingList *scalingList)
 }
 
 /** decode DPCM
- * \param scalingList  quantization matrix information
- * \param sizeId size index
- * \param listId list index
- */
+* \param scalingList  quantization matrix information
+* \param sizeId size index
+* \param listId list index
+*/
 void HLSyntaxReader::decodeScalingList(ScalingList *scalingList, uint32_t scalingListId, bool isPredictor)
 {
-  int matrixSize =
-    (scalingListId < SCALING_LIST_1D_START_4x4) ? 2 : (scalingListId < SCALING_LIST_1D_START_8x8) ? 4 : 8;
-  int          i, coefNum = matrixSize * matrixSize;
-  int          data;
-  int          scalingListDcCoefMinus8 = 0;
-  int          nextCoef                = (isPredictor) ? 0 : SCALING_LIST_START_VALUE;
-  ScanElement *scan =
-    g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][gp_sizeIdxInfo->idxFrom(matrixSize)][gp_sizeIdxInfo->idxFrom(matrixSize)];
+  int matrixSize = (scalingListId < SCALING_LIST_1D_START_4x4) ? 2 : (scalingListId < SCALING_LIST_1D_START_8x8) ? 4 : 8;
+  int i, coefNum = matrixSize * matrixSize;
+  int data;
+  int scalingListDcCoefMinus8 = 0;
+  int nextCoef = (isPredictor) ? 0 : SCALING_LIST_START_VALUE;
+  ScanElement *scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][gp_sizeIdxInfo->idxFrom(matrixSize)][gp_sizeIdxInfo->idxFrom(matrixSize)];
   int *dst = scalingList->getScalingListAddress(scalingListId);
 
   int PredListId = scalingList->getRefMatrixId(scalingListId);
   CHECK(isPredictor && PredListId > scalingListId, "Scaling List error predictor!");
-  const int *srcPred = (isPredictor)
-                         ? ((scalingListId == PredListId) ? scalingList->getScalingListDefaultAddress(scalingListId)
-                                                          : scalingList->getScalingListAddress(PredListId))
-                         : NULL;
-  if (isPredictor && scalingListId == PredListId)
+  const int *srcPred = (isPredictor) ? ((scalingListId == PredListId) ? scalingList->getScalingListDefaultAddress(scalingListId) : scalingList->getScalingListAddress(PredListId)) : NULL;
+  if(isPredictor && scalingListId == PredListId)
     scalingList->setScalingListDC(PredListId, SCALING_LIST_DC);
   int predCoef = 0;
 
@@ -4598,16 +4268,16 @@ void HLSyntaxReader::decodeScalingList(ScalingList *scalingList, uint32_t scalin
     scalingList->setScalingListDC(scalingListId, (nextCoef + predCoef + 256) & 255);
   }
 
-  for (i = 0; i < coefNum; i++)
+  for(i = 0; i < coefNum; i++)
   {
     if (scalingListId >= SCALING_LIST_1D_START_64x64 && scan[i].x >= 4 && scan[i].y >= 4)
     {
       dst[scan[i].idx] = 0;
       continue;
     }
-    READ_SVLC(data, "scaling_list_delta_coef");
-    nextCoef += data;
-    predCoef         = (isPredictor) ? srcPred[scan[i].idx] : 0;
+    READ_SVLC( data, "scaling_list_delta_coef");
+    nextCoef += data;  
+    predCoef = (isPredictor) ? srcPred[scan[i].idx] : 0;
     dst[scan[i].idx] = (nextCoef + predCoef + 256) & 255;
   }
 }
@@ -4623,10 +4293,10 @@ bool HLSyntaxReader::xMoreRbspData()
   }
 
   uint8_t lastByte = m_pcBitstream->peekBits(bitsLeft);
-  int     cnt      = bitsLeft;
+  int cnt = bitsLeft;
 
   // remove trailing bits equal to zero
-  while ((cnt > 0) && ((lastByte & 1) == 0))
+  while ((cnt>0) && ((lastByte & 1) == 0))
   {
     lastByte >>= 1;
     cnt--;
@@ -4635,78 +4305,82 @@ bool HLSyntaxReader::xMoreRbspData()
   cnt--;
 
   // we should not have a negative number of bits
-  CHECK(cnt < 0, "Negative number of bits");
+  CHECK (cnt<0, "Negative number of bits");
 
   // we have more data, if cnt is not zero
-  return (cnt > 0);
+  return (cnt>0);
 }
 
-int HLSyntaxReader::alfGolombDecode(const int k, const bool signed_val)
+int HLSyntaxReader::alfGolombDecode( const int k, const bool signed_val )
 {
-  int      numLeadingBits = -1;
-  uint32_t b              = 0;
+  int numLeadingBits = -1;
+  uint32_t b = 0;
   for (; !b; numLeadingBits++)
   {
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-    xReadFlag(b, "");
+    xReadFlag( b, "" );
 #else
-    READ_FLAG(b, "alf_coeff_abs_prefix");
+    READ_FLAG( b, "alf_coeff_abs_prefix");
 #endif
   }
 
-  int symbol = ((1 << numLeadingBits) - 1) << k;
-  if (numLeadingBits + k > 0)
+  int symbol = ( ( 1 << numLeadingBits ) - 1 ) << k;
+  if ( numLeadingBits + k > 0)
   {
     uint32_t bins;
-    READ_CODE(numLeadingBits + k, bins, "alf_coeff_abs_suffix");
+    READ_CODE( numLeadingBits + k, bins, "alf_coeff_abs_suffix" );
     symbol += bins;
   }
 
-  if (signed_val && symbol != 0)
+  if ( signed_val && symbol != 0 )
   {
 #if RExt__DECODER_DEBUG_BIT_STATISTICS
-    xReadFlag(b, "");
+    xReadFlag( b, "" );
 #else
-    READ_FLAG(b, "alf_coeff_sign");
+    READ_FLAG( b, "alf_coeff_sign" );
 #endif
-    symbol = (b) ? -symbol : symbol;
+    symbol = ( b ) ? -symbol : symbol;
   }
   return symbol;
 }
 
-void HLSyntaxReader::alfFilter(AlfParam &alfParam, const bool isChroma, const int altIdx)
+void HLSyntaxReader::alfFilter( AlfParam& alfParam, const bool isChroma, const int altIdx )
 {
   uint32_t code;
 
   // derive maxGolombIdx
-  AlfFilterShape alfShape(isChroma ? 5 : 7);
-  const int      numFilters = isChroma ? 1 : alfParam.numLumaFilters;
-  short *        coeff      = isChroma ? alfParam.chromaCoeff[altIdx] : alfParam.lumaCoeff;
-  short *        clipp      = isChroma ? alfParam.chromaClipp[altIdx] : alfParam.lumaClipp;
+  AlfFilterShape alfShape( isChroma ? 5 : 7 );
+  const int numFilters = isChroma ? 1 : alfParam.numLumaFilters;
+  short* coeff = isChroma ? alfParam.chromaCoeff[altIdx] : alfParam.lumaCoeff;
+  short* clipp = isChroma ? alfParam.chromaClipp[altIdx] : alfParam.lumaClipp;
+
 
   // Filter coefficients
-  for (int ind = 0; ind < numFilters; ++ind)
+  for( int ind = 0; ind < numFilters; ++ind )
   {
-    for (int i = 0; i < alfShape.numCoeff - 1; i++)
+
+    for( int i = 0; i < alfShape.numCoeff - 1; i++ )
     {
-      coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] = alfGolombDecode(3);
-      CHECK(isChroma
-              && (coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] > 127 || coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] < -127),
-            "AlfCoeffC shall be in the range of -127 to 127, inclusive");
+      coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] = alfGolombDecode( 3 );
+      CHECK( isChroma &&
+             ( coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] > 127 || coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] < -127 )
+             , "AlfCoeffC shall be in the range of -127 to 127, inclusive" );
     }
   }
 
   // Clipping values coding
 #if JVET_Q0249_ALF_CHROMA_CLIPFLAG
-  if (alfParam.nonLinearFlag[isChroma])
+  if ( alfParam.nonLinearFlag[isChroma] )
 #else
-  if (alfParam.nonLinearFlag[isChroma][altIdx])
+  if ( alfParam.nonLinearFlag[isChroma][altIdx] )
 #endif
   {
+
     // Filter coefficients
-    for (int ind = 0; ind < numFilters; ++ind)
+    for( int ind = 0; ind < numFilters; ++ind )
     {
-      for (int i = 0; i < alfShape.numCoeff - 1; i++)
+
+      for( int i = 0; i < alfShape.numCoeff - 1; i++ )
       {
         READ_CODE(2, code, "alf_clipping_index");
         clipp[ind * MAX_NUM_ALF_LUMA_COEFF + i] = code;
@@ -4715,11 +4389,13 @@ void HLSyntaxReader::alfFilter(AlfParam &alfParam, const bool isChroma, const in
   }
   else
   {
-    for (int ind = 0; ind < numFilters; ++ind)
+    for( int ind = 0; ind < numFilters; ++ind )
     {
-      std::fill_n(clipp + ind * MAX_NUM_ALF_LUMA_COEFF, alfShape.numCoeff, 0);
+      std::fill_n( clipp + ind * MAX_NUM_ALF_LUMA_COEFF, alfShape.numCoeff, 0 );
     }
   }
 }
 
+
 //! \}
+
diff --git a/source/Lib/DecoderLib/VLCReader.h b/source/Lib/DecoderLib/VLCReader.h
index b78f0fb9418869241ca94d9904c0e6030b5e1703..f629806051bc27f4fbd4d4871b31a044269c6cff 100644
--- a/source/Lib/DecoderLib/VLCReader.h
+++ b/source/Lib/DecoderLib/VLCReader.h
@@ -177,12 +177,11 @@ public:
   void  parseTerminatingBit ( uint32_t& ruiBit );
   void  parseRemainingBytes ( bool noTrailingBytesExpected );
 
-#if JVET_Q0819_PH_CHANGES //Hendry
-  void parsePredWeightTable( Slice *pcSlice, PicHeader *picHeader, const SPS *sps );
-#else
   void  parsePredWeightTable( Slice* pcSlice, const SPS *sps );
+#if JVET_Q0819_PH_CHANGES
+  void parsePredWeightTable ( PicHeader *picHeader, const SPS *sps );
 #endif
-  void parseScalingList(ScalingList *scalingList);
+  void  parseScalingList    ( ScalingList* scalingList );
   void  decodeScalingList   ( ScalingList *scalingList, uint32_t scalingListId, bool isPredictor);
   void parseReshaper        ( SliceReshapeInfo& sliceReshaperInfo, const SPS* pcSPS, const bool isIntra );
   void alfFilter( AlfParam& alfParam, const bool isChroma, const int altIdx );
diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp
index 111d0651e4793c0faa22d51eed707468db1db71c..ea223350ce5a77eca7bd2091c95fb37085b00f0d 100644
--- a/source/Lib/EncoderLib/VLCWriter.cpp
+++ b/source/Lib/EncoderLib/VLCWriter.cpp
@@ -1,35 +1,35 @@
 /* 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-2020, 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.
- */
+* 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-2020, 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     VLCWriter.cpp
  *  \brief    Writer for high level syntax
@@ -40,7 +40,7 @@
 
 #include "CommonLib/CommonDef.h"
 #include "CommonLib/Unit.h"
-#include "CommonLib/Picture.h"   // th remove this
+#include "CommonLib/Picture.h" // th remove this
 #include "CommonLib/dtrace_next.h"
 #include "EncAdaptiveLoopFilter.h"
 #include "CommonLib/AdaptiveLoopFilter.h"
@@ -50,63 +50,63 @@
 
 #if ENABLE_TRACING
 
-void VLCWriter::xWriteSCodeTr(int value, uint32_t length, const char *pSymbolName)
+void  VLCWriter::xWriteSCodeTr (int value, uint32_t  length, const char *pSymbolName)
 {
-  xWriteSCode(value, length);
-  if (g_HLSTraceEnable)
+  xWriteSCode (value,length);
+  if( g_HLSTraceEnable )
   {
-    if (length < 10)
+    if( length<10 )
     {
-      DTRACE(g_trace_ctx, D_HEADER, "%-50s u(%d)  : %d\n", pSymbolName, length, value);
+      DTRACE( g_trace_ctx, D_HEADER, "%-50s u(%d)  : %d\n", pSymbolName, length, value );
     }
     else
     {
-      DTRACE(g_trace_ctx, D_HEADER, "%-50s u(%d) : %d\n", pSymbolName, length, value);
+      DTRACE( g_trace_ctx, D_HEADER, "%-50s u(%d) : %d\n", pSymbolName, length, value );
     }
   }
 }
 
-void VLCWriter::xWriteCodeTr(uint32_t value, uint32_t length, const char *pSymbolName)
+void  VLCWriter::xWriteCodeTr (uint32_t value, uint32_t  length, const char *pSymbolName)
 {
-  xWriteCode(value, length);
+  xWriteCode (value,length);
 
-  if (g_HLSTraceEnable)
+  if( g_HLSTraceEnable )
   {
-    if (length < 10)
+    if( length < 10 )
     {
-      DTRACE(g_trace_ctx, D_HEADER, "%-50s u(%d)  : %d\n", pSymbolName, length, value);
+      DTRACE( g_trace_ctx, D_HEADER, "%-50s u(%d)  : %d\n", pSymbolName, length, value );
     }
     else
     {
-      DTRACE(g_trace_ctx, D_HEADER, "%-50s u(%d) : %d\n", pSymbolName, length, value);
+      DTRACE( g_trace_ctx, D_HEADER, "%-50s u(%d) : %d\n", pSymbolName, length, value );
     }
   }
 }
 
-void VLCWriter::xWriteUvlcTr(uint32_t value, const char *pSymbolName)
+void  VLCWriter::xWriteUvlcTr (uint32_t value, const char *pSymbolName)
 {
-  xWriteUvlc(value);
-  if (g_HLSTraceEnable)
+  xWriteUvlc (value);
+  if( g_HLSTraceEnable )
   {
-    DTRACE(g_trace_ctx, D_HEADER, "%-50s ue(v) : %d\n", pSymbolName, value);
+    DTRACE( g_trace_ctx, D_HEADER, "%-50s ue(v) : %d\n", pSymbolName, value );
   }
 }
 
-void VLCWriter::xWriteSvlcTr(int value, const char *pSymbolName)
+void  VLCWriter::xWriteSvlcTr (int value, const char *pSymbolName)
 {
   xWriteSvlc(value);
-  if (g_HLSTraceEnable)
+  if( g_HLSTraceEnable )
   {
-    DTRACE(g_trace_ctx, D_HEADER, "%-50s se(v) : %d\n", pSymbolName, value);
+    DTRACE( g_trace_ctx, D_HEADER, "%-50s se(v) : %d\n", pSymbolName, value );
   }
 }
 
-void VLCWriter::xWriteFlagTr(uint32_t value, const char *pSymbolName)
+void  VLCWriter::xWriteFlagTr(uint32_t value, const char *pSymbolName)
 {
   xWriteFlag(value);
-  if (g_HLSTraceEnable)
+  if( g_HLSTraceEnable )
   {
-    DTRACE(g_trace_ctx, D_HEADER, "%-50s u(1)  : %d\n", pSymbolName, value);
+    DTRACE( g_trace_ctx, D_HEADER, "%-50s u(1)  : %d\n", pSymbolName, value );
   }
 }
 
@@ -114,60 +114,60 @@ bool g_HLSTraceEnable = true;
 
 #endif
 
-void VLCWriter::xWriteSCode(int code, uint32_t length)
+void VLCWriter::xWriteSCode    ( int code, uint32_t length )
 {
-  assert(length > 0 && length <= 32);
-  assert(length == 32 || (code >= -(1 << (length - 1)) && code < (1 << (length - 1))));
-  m_pcBitIf->write(length == 32 ? uint32_t(code) : (uint32_t(code) & ((1 << length) - 1)), length);
+  assert ( length > 0 && length<=32 );
+  assert( length==32 || (code>=-(1<<(length-1)) && code<(1<<(length-1))) );
+  m_pcBitIf->write( length==32 ? uint32_t(code) : ( uint32_t(code)&((1<<length)-1) ), length );
 }
 
-void VLCWriter::xWriteCode(uint32_t uiCode, uint32_t uiLength)
+void VLCWriter::xWriteCode     ( uint32_t uiCode, uint32_t uiLength )
 {
-  CHECK(uiLength == 0, "Code of length '0' not supported");
-  m_pcBitIf->write(uiCode, uiLength);
+  CHECK( uiLength == 0, "Code of length '0' not supported" );
+  m_pcBitIf->write( uiCode, uiLength );
 }
 
-void VLCWriter::xWriteUvlc(uint32_t uiCode)
+void VLCWriter::xWriteUvlc     ( uint32_t uiCode )
 {
   uint32_t uiLength = 1;
-  uint32_t uiTemp   = ++uiCode;
+  uint32_t uiTemp = ++uiCode;
 
-  CHECK(!uiTemp, "Integer overflow");
+  CHECK( !uiTemp, "Integer overflow" );
 
-  while (1 != uiTemp)
+  while( 1 != uiTemp )
   {
     uiTemp >>= 1;
     uiLength += 2;
   }
   // Take care of cases where uiLength > 32
-  m_pcBitIf->write(0, uiLength >> 1);
-  m_pcBitIf->write(uiCode, (uiLength + 1) >> 1);
+  m_pcBitIf->write( 0, uiLength >> 1);
+  m_pcBitIf->write( uiCode, (uiLength+1) >> 1);
 }
 
-void VLCWriter::xWriteSvlc(int iCode)
+void VLCWriter::xWriteSvlc     ( int iCode )
 {
-  uint32_t uiCode = uint32_t(iCode <= 0 ? (-iCode) << 1 : (iCode << 1) - 1);
-  xWriteUvlc(uiCode);
+  uint32_t uiCode = uint32_t( iCode <= 0 ? (-iCode)<<1 : (iCode<<1)-1);
+  xWriteUvlc( uiCode );
 }
 
-void VLCWriter::xWriteFlag(uint32_t uiCode)
+void VLCWriter::xWriteFlag( uint32_t uiCode )
 {
-  m_pcBitIf->write(uiCode, 1);
+  m_pcBitIf->write( uiCode, 1 );
 }
 
 void VLCWriter::xWriteRbspTrailingBits()
 {
-  WRITE_FLAG(1, "rbsp_stop_one_bit");
+  WRITE_FLAG( 1, "rbsp_stop_one_bit");
   int cnt = 0;
   while (m_pcBitIf->getNumBitsUntilByteAligned())
   {
-    WRITE_FLAG(0, "rbsp_alignment_zero_bit");
+    WRITE_FLAG( 0, "rbsp_alignment_zero_bit");
     cnt++;
   }
-  CHECK(cnt >= 8, "More than '8' alignment bytes read");
+  CHECK(cnt>=8, "More than '8' alignment bytes read");
 }
 
-void AUDWriter::codeAUD(OutputBitstream &bs, const int pictureType)
+void AUDWriter::codeAUD(OutputBitstream& bs, const int pictureType)
 {
 #if ENABLE_TRACING
   xTraceAccessUnitDelimiter();
@@ -179,210 +179,207 @@ void AUDWriter::codeAUD(OutputBitstream &bs, const int pictureType)
   xWriteRbspTrailingBits();
 }
 
-void HLSWriter::xCodeRefPicList(const ReferencePictureList *rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount,
-                                const bool isForbiddenZeroDeltaPoc)
+void HLSWriter::xCodeRefPicList( const ReferencePictureList* rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount, const bool isForbiddenZeroDeltaPoc )
 {
-  uint32_t numRefPic =
-    rpl->getNumberOfShorttermPictures() + rpl->getNumberOfLongtermPictures() + rpl->getNumberOfInterLayerPictures();
-  WRITE_UVLC(numRefPic, "num_ref_entries[ listIdx ][ rplsIdx ]");
+  uint32_t numRefPic = rpl->getNumberOfShorttermPictures() + rpl->getNumberOfLongtermPictures() + rpl->getNumberOfInterLayerPictures();
+  WRITE_UVLC( numRefPic, "num_ref_entries[ listIdx ][ rplsIdx ]" );
 
   if (isLongTermPresent)
   {
     WRITE_FLAG(rpl->getLtrpInSliceHeaderFlag(), "ltrp_in_slice_header_flag[ listIdx ][ rplsIdx ]");
   }
-  int  prevDelta  = MAX_INT;
-  int  deltaValue = 0;
-  bool firstSTRP  = true;
+  int prevDelta = MAX_INT;
+  int deltaValue = 0;
+  bool firstSTRP = true;
   for (int ii = 0; ii < numRefPic; ii++)
   {
-    if (rpl->getInterLayerPresentFlag())
+    if( rpl->getInterLayerPresentFlag() )
     {
-      WRITE_FLAG(rpl->isInterLayerRefPic(ii), "inter_layer_ref_pic_flag[ listIdx ][ rplsIdx ][ i ]");
+      WRITE_FLAG( rpl->isInterLayerRefPic( ii ), "inter_layer_ref_pic_flag[ listIdx ][ rplsIdx ][ i ]" );
 
-      if (rpl->isInterLayerRefPic(ii))
+      if( rpl->isInterLayerRefPic( ii ) )
       {
-        CHECK(rpl->getInterLayerRefPicIdx(ii) < 0, "Wrong inter-layer reference index");
-        WRITE_UVLC(rpl->getInterLayerRefPicIdx(ii), "ilrp_idx[ listIdx ][ rplsIdx ][ i ]");
+        CHECK( rpl->getInterLayerRefPicIdx( ii ) < 0, "Wrong inter-layer reference index" );
+        WRITE_UVLC( rpl->getInterLayerRefPicIdx( ii ), "ilrp_idx[ listIdx ][ rplsIdx ][ i ]" );
       }
     }
 
-    if (!rpl->isInterLayerRefPic(ii))
+    if( !rpl->isInterLayerRefPic( ii ) )
+    {
+    if( isLongTermPresent )
     {
-      if (isLongTermPresent)
+      WRITE_FLAG( !rpl->isRefPicLongterm( ii ), "st_ref_pic_flag[ listIdx ][ rplsIdx ][ i ]" );
+    }
+
+    if (!rpl->isRefPicLongterm(ii))
+    {
+      if (firstSTRP)
       {
-        WRITE_FLAG(!rpl->isRefPicLongterm(ii), "st_ref_pic_flag[ listIdx ][ rplsIdx ][ i ]");
+        firstSTRP = false;
+        deltaValue = prevDelta = rpl->getRefPicIdentifier(ii);
       }
-
-      if (!rpl->isRefPicLongterm(ii))
+      else
       {
-        if (firstSTRP)
-        {
-          firstSTRP  = false;
-          deltaValue = prevDelta = rpl->getRefPicIdentifier(ii);
-        }
-        else
-        {
-          deltaValue = rpl->getRefPicIdentifier(ii) - prevDelta;
-          prevDelta  = rpl->getRefPicIdentifier(ii);
-        }
-        unsigned int absDeltaValue = (deltaValue < 0) ? 0 - deltaValue : deltaValue;
-        if (isForbiddenZeroDeltaPoc)
-        {
-          CHECK(!absDeltaValue, "Zero delta POC is not used without WP");
-          WRITE_UVLC(absDeltaValue - 1, "abs_delta_poc_st[ listIdx ][ rplsIdx ][ i ]");
-        }
-        else
-          WRITE_UVLC(absDeltaValue, "abs_delta_poc_st[ listIdx ][ rplsIdx ][ i ]");
-        if (absDeltaValue > 0)
-          WRITE_FLAG(
-            (deltaValue < 0) ? 0 : 1,
-            "strp_entry_sign_flag[ listIdx ][ rplsIdx ][ i ]");   // 0  means negative delta POC : 1 means positive
+        deltaValue = rpl->getRefPicIdentifier(ii) - prevDelta;
+        prevDelta = rpl->getRefPicIdentifier(ii);
       }
-      else if (!rpl->getLtrpInSliceHeaderFlag())
+      unsigned int absDeltaValue = (deltaValue < 0) ? 0 - deltaValue : deltaValue;
+      if( isForbiddenZeroDeltaPoc )
       {
-        WRITE_CODE(rpl->getRefPicIdentifier(ii), ltLsbBitsCount, "poc_lsb_lt[listIdx][rplsIdx][i]");
+        CHECK( !absDeltaValue, "Zero delta POC is not used without WP" );
+        WRITE_UVLC( absDeltaValue - 1, "abs_delta_poc_st[ listIdx ][ rplsIdx ][ i ]" );
       }
+      else
+      WRITE_UVLC(absDeltaValue, "abs_delta_poc_st[ listIdx ][ rplsIdx ][ i ]");
+      if (absDeltaValue > 0)
+        WRITE_FLAG((deltaValue < 0) ? 0 : 1, "strp_entry_sign_flag[ listIdx ][ rplsIdx ][ i ]");  //0  means negative delta POC : 1 means positive
+    }
+    else if (!rpl->getLtrpInSliceHeaderFlag())
+    {
+      WRITE_CODE(rpl->getRefPicIdentifier(ii), ltLsbBitsCount, "poc_lsb_lt[listIdx][rplsIdx][i]");
+    }
     }
   }
 }
 
-void HLSWriter::codePPS(const PPS *pcPPS, const SPS *pcSPS)
+void HLSWriter::codePPS( const PPS* pcPPS, const SPS* pcSPS )
 {
 #if ENABLE_TRACING
-  xTracePPSHeader();
+  xTracePPSHeader ();
 #endif
 
-  WRITE_UVLC(pcPPS->getPPSId(), "pps_pic_parameter_set_id");
-  WRITE_CODE(pcPPS->getSPSId(), 4, "pps_seq_parameter_set_id");
+  WRITE_UVLC( pcPPS->getPPSId(),                             "pps_pic_parameter_set_id" );
+  WRITE_CODE( pcPPS->getSPSId(), 4,                          "pps_seq_parameter_set_id" );
 
-  WRITE_UVLC(pcPPS->getPicWidthInLumaSamples(), "pic_width_in_luma_samples");
-  WRITE_UVLC(pcPPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples");
+  WRITE_UVLC( pcPPS->getPicWidthInLumaSamples(), "pic_width_in_luma_samples" );
+  WRITE_UVLC( pcPPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" );
   Window conf = pcPPS->getConformanceWindow();
 
-  WRITE_FLAG(conf.getWindowEnabledFlag(), "conformance_window_flag");
-  if (conf.getWindowEnabledFlag())
+  WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_flag" );
+  if( conf.getWindowEnabledFlag() )
   {
-    WRITE_UVLC(conf.getWindowLeftOffset(), "conf_win_left_offset");
-    WRITE_UVLC(conf.getWindowRightOffset(), "conf_win_right_offset");
-    WRITE_UVLC(conf.getWindowTopOffset(), "conf_win_top_offset");
-    WRITE_UVLC(conf.getWindowBottomOffset(), "conf_win_bottom_offset");
+    WRITE_UVLC( conf.getWindowLeftOffset(),   "conf_win_left_offset" );
+    WRITE_UVLC( conf.getWindowRightOffset(),  "conf_win_right_offset" );
+    WRITE_UVLC( conf.getWindowTopOffset(),    "conf_win_top_offset" );
+    WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" );
   }
   Window scalingWindow = pcPPS->getScalingWindow();
 
-  WRITE_FLAG(scalingWindow.getWindowEnabledFlag(), "scaling_window_flag");
-  if (scalingWindow.getWindowEnabledFlag())
+  WRITE_FLAG( scalingWindow.getWindowEnabledFlag(), "scaling_window_flag" );
+  if( scalingWindow.getWindowEnabledFlag() )
   {
-    WRITE_UVLC(scalingWindow.getWindowLeftOffset(), "scaling_win_left_offset");
-    WRITE_UVLC(scalingWindow.getWindowRightOffset(), "scaling_win_right_offset");
-    WRITE_UVLC(scalingWindow.getWindowTopOffset(), "scaling_win_top_offset");
-    WRITE_UVLC(scalingWindow.getWindowBottomOffset(), "scaling_win_bottom_offset");
+    WRITE_UVLC( scalingWindow.getWindowLeftOffset(), "scaling_win_left_offset" );
+    WRITE_UVLC( scalingWindow.getWindowRightOffset(), "scaling_win_right_offset" );
+    WRITE_UVLC( scalingWindow.getWindowTopOffset(), "scaling_win_top_offset" );
+    WRITE_UVLC( scalingWindow.getWindowBottomOffset(), "scaling_win_bottom_offset" );
   }
 
-  WRITE_FLAG(pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag");
+  WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0,     "output_flag_present_flag" );
   WRITE_FLAG(pcPPS->getSubPicIdSignallingPresentFlag(), "pps_subpic_id_signalling_present_flag");
-  if (pcPPS->getSubPicIdSignallingPresentFlag())
+  if( pcPPS->getSubPicIdSignallingPresentFlag() )
   {
-    WRITE_UVLC(pcPPS->getNumSubPics() - 1, "pps_num_subpics_minus1");
+    WRITE_UVLC( pcPPS->getNumSubPics() - 1, "pps_num_subpics_minus1" );
 
-    WRITE_UVLC(pcPPS->getSubPicIdLen() - 1, "pps_subpic_id_len_minus1");
+    WRITE_UVLC( pcPPS->getSubPicIdLen() - 1, "pps_subpic_id_len_minus1" );
 
-#if JVET_Q0169_SUBPIC_LEN_CONFORM
+#if JVET_Q0169_SUBPIC_LEN_CONFORM    
     CHECK((1 << pcPPS->getSubPicIdLen()) < pcPPS->getNumSubPics(), "pps_subpic_id_len exceeds valid range");
 #endif
-    for (int picIdx = 0; picIdx < pcPPS->getNumSubPics(); picIdx++)
+    for( int picIdx = 0; picIdx < pcPPS->getNumSubPics( ); picIdx++ )
     {
-      WRITE_CODE(pcPPS->getSubPicId(picIdx), pcPPS->getSubPicIdLen(), "pps_subpic_id[i]");
+      WRITE_CODE( pcPPS->getSubPicId(picIdx), pcPPS->getSubPicIdLen( ), "pps_subpic_id[i]" );
     }
   }
 
-  WRITE_FLAG(pcPPS->getNoPicPartitionFlag() ? 1 : 0, "no_pic_partition_flag");
-  if (!pcPPS->getNoPicPartitionFlag())
+  WRITE_FLAG( pcPPS->getNoPicPartitionFlag( ) ? 1 : 0, "no_pic_partition_flag" );
+  if( !pcPPS->getNoPicPartitionFlag() )
   {
     int colIdx, rowIdx;
 
     // CTU size - required to match size in SPS
-    WRITE_CODE(pcPPS->getLog2CtuSize() - 5, 2, "pps_log2_ctu_size_minus5");
-
+    WRITE_CODE( pcPPS->getLog2CtuSize() - 5, 2, "pps_log2_ctu_size_minus5" );
+    
     // number of explicit tile columns/rows
-    WRITE_UVLC(pcPPS->getNumExpTileColumns() - 1, "num_exp_tile_columns_minus1");
-    WRITE_UVLC(pcPPS->getNumExpTileRows() - 1, "num_exp_tile_rows_minus1");
-
+    WRITE_UVLC( pcPPS->getNumExpTileColumns() - 1, "num_exp_tile_columns_minus1" );
+    WRITE_UVLC( pcPPS->getNumExpTileRows() - 1,    "num_exp_tile_rows_minus1" );
+        
     // tile sizes
-    for (colIdx = 0; colIdx < pcPPS->getNumExpTileColumns(); colIdx++)
+    for( colIdx = 0; colIdx < pcPPS->getNumExpTileColumns(); colIdx++ )
     {
-      WRITE_UVLC(pcPPS->getTileColumnWidth(colIdx) - 1, "tile_column_width_minus1[i]");
+      WRITE_UVLC( pcPPS->getTileColumnWidth( colIdx ) - 1, "tile_column_width_minus1[i]" );
     }
-    for (rowIdx = 0; rowIdx < pcPPS->getNumExpTileRows(); rowIdx++)
+    for( rowIdx = 0; rowIdx < pcPPS->getNumExpTileRows(); rowIdx++ )
     {
-      WRITE_UVLC(pcPPS->getTileRowHeight(rowIdx) - 1, "tile_row_height_minus1[i]");
+      WRITE_UVLC( pcPPS->getTileRowHeight( rowIdx ) - 1, "tile_row_height_minus1[i]" );
     }
-
+     
     // rectangular slice signalling
-    WRITE_FLAG(pcPPS->getRectSliceFlag() ? 1 : 0, "rect_slice_flag");
+    WRITE_FLAG( pcPPS->getRectSliceFlag( ) ? 1 : 0, "rect_slice_flag");
     if (pcPPS->getRectSliceFlag())
     {
-      WRITE_FLAG(pcPPS->getSingleSlicePerSubPicFlag() ? 1 : 0, "single_slice_per_subpic_flag");
+      WRITE_FLAG(pcPPS->getSingleSlicePerSubPicFlag( ) ? 1 : 0, "single_slice_per_subpic_flag");
     }
     if (pcPPS->getRectSliceFlag() & !(pcPPS->getSingleSlicePerSubPicFlag()))
-    {
-      WRITE_UVLC(pcPPS->getNumSlicesInPic() - 1, "num_slices_in_pic_minus1");
-      WRITE_FLAG(pcPPS->getTileIdxDeltaPresentFlag() ? 1 : 0, "tile_idx_delta_present_flag");
-
+    {      
+      WRITE_UVLC( pcPPS->getNumSlicesInPic( ) - 1, "num_slices_in_pic_minus1" );
+      WRITE_FLAG( pcPPS->getTileIdxDeltaPresentFlag( ) ? 1 : 0, "tile_idx_delta_present_flag");
+      
       // write rectangular slice parameters
-      for (int i = 0; i < pcPPS->getNumSlicesInPic() - 1; i++)
+      for( int i = 0; i < pcPPS->getNumSlicesInPic()-1; i++ )
       {
         // complete tiles within a single slice
-        WRITE_UVLC(pcPPS->getSliceWidthInTiles(i) - 1, "slice_width_in_tiles_minus1[i]");
+        WRITE_UVLC( pcPPS->getSliceWidthInTiles( i ) - 1,  "slice_width_in_tiles_minus1[i]" );
 #if JVET_Q0480_RASTER_RECT_SLICES
-        if (pcPPS->getTileIdxDeltaPresentFlag() || ((pcPPS->getSliceTileIdx(i) % pcPPS->getNumTileColumns()) == 0))
+        if( pcPPS->getTileIdxDeltaPresentFlag() || ( (pcPPS->getSliceTileIdx( i ) % pcPPS->getNumTileColumns()) == 0 ) )
         {
-          WRITE_UVLC(pcPPS->getSliceHeightInTiles(i) - 1, "slice_height_in_tiles_minus1[i]");
+          WRITE_UVLC( pcPPS->getSliceHeightInTiles( i ) - 1, "slice_height_in_tiles_minus1[i]" );
         }
 #else
-        WRITE_UVLC(pcPPS->getSliceHeightInTiles(i) - 1, "slice_height_in_tiles_minus1[i]");
+        WRITE_UVLC( pcPPS->getSliceHeightInTiles( i ) - 1, "slice_height_in_tiles_minus1[i]" );
 #endif
 
         // multiple slices within a single tile special case
-        if (pcPPS->getSliceWidthInTiles(i) == 1 && pcPPS->getSliceHeightInTiles(i) == 1)
+        if( pcPPS->getSliceWidthInTiles( i ) == 1 && pcPPS->getSliceHeightInTiles( i ) == 1 ) 
         {
-          WRITE_UVLC(pcPPS->getNumSlicesInTile(i) - 1, "num_slices_in_tile_minus1[i]");
-          uint32_t numSlicesInTile = pcPPS->getNumSlicesInTile(i);
-          for (int j = 0; j < numSlicesInTile - 1; j++)
+          WRITE_UVLC( pcPPS->getNumSlicesInTile( i ) - 1,  "num_slices_in_tile_minus1[i]" );
+          uint32_t numSlicesInTile = pcPPS->getNumSlicesInTile( i );
+          for( int j = 0; j < numSlicesInTile-1; j++ )
           {
-            WRITE_UVLC(pcPPS->getSliceHeightInCtu(i) - 1, "slice_height_in_ctu_minus1[i]");
+            WRITE_UVLC( pcPPS->getSliceHeightInCtu( i ) - 1,  "slice_height_in_ctu_minus1[i]" );
             i++;
           }
         }
 
         // tile index offset to start of next slice
-        if (i < pcPPS->getNumSlicesInPic() - 1)
+        if( i < pcPPS->getNumSlicesInPic()-1 ) 
         {
-          if (pcPPS->getTileIdxDeltaPresentFlag())
+          if( pcPPS->getTileIdxDeltaPresentFlag() ) 
           {
-            int32_t tileIdxDelta = pcPPS->getSliceTileIdx(i + 1) - pcPPS->getSliceTileIdx(i);
-            WRITE_SVLC(tileIdxDelta, "tile_idx_delta[i]");
+            int32_t  tileIdxDelta = pcPPS->getSliceTileIdx( i + 1 ) - pcPPS->getSliceTileIdx( i );
+            WRITE_SVLC( tileIdxDelta,  "tile_idx_delta[i]" );
           }
         }
       }
     }
 
     // loop filtering across slice/tile controls
-    WRITE_FLAG(pcPPS->getLoopFilterAcrossTilesEnabledFlag(), "loop_filter_across_tiles_enabled_flag");
-    WRITE_FLAG(pcPPS->getLoopFilterAcrossSlicesEnabledFlag(), "loop_filter_across_slices_enabled_flag");
+    WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag(), "loop_filter_across_tiles_enabled_flag");
+    WRITE_FLAG( pcPPS->getLoopFilterAcrossSlicesEnabledFlag(), "loop_filter_across_slices_enabled_flag");
   }
 
-  WRITE_FLAG(pcPPS->getEntropyCodingSyncEnabledFlag() ? 1 : 0, "entropy_coding_sync_enabled_flag");
-  WRITE_FLAG(pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag");
-  WRITE_UVLC(pcPPS->getNumRefIdxL0DefaultActive() - 1, "num_ref_idx_l0_default_active_minus1");
-  WRITE_UVLC(pcPPS->getNumRefIdxL1DefaultActive() - 1, "num_ref_idx_l1_default_active_minus1");
+  WRITE_FLAG( pcPPS->getEntropyCodingSyncEnabledFlag() ? 1 : 0, "entropy_coding_sync_enabled_flag" );
+  WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0,   "cabac_init_present_flag" );
+  WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive()-1,     "num_ref_idx_l0_default_active_minus1");
+  WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1,     "num_ref_idx_l1_default_active_minus1");
   WRITE_FLAG(pcPPS->getRpl1IdxPresentFlag() ? 1 : 0, "rpl1IdxPresentFlag");
 
-  WRITE_SVLC(pcPPS->getPicInitQPMinus26(), "init_qp_minus26");
-  WRITE_UVLC(pcPPS->getLog2MaxTransformSkipBlockSize() - 2, "log2_transform_skip_max_size_minus2");
-  WRITE_FLAG(pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag");
 
-  WRITE_SVLC(pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset");
-  WRITE_SVLC(pcPPS->getQpOffset(COMPONENT_Cr), "pps_cr_qp_offset");
+  WRITE_SVLC( pcPPS->getPicInitQPMinus26(),                  "init_qp_minus26");
+  WRITE_UVLC( pcPPS->getLog2MaxTransformSkipBlockSize() - 2, "log2_transform_skip_max_size_minus2");
+  WRITE_FLAG( pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag" );
+
+  WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset" );
+  WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cr), "pps_cr_qp_offset" );
   if (pcSPS->getJointCbCrEnabledFlag() == false || pcSPS->getChromaFormatIdc() == CHROMA_400)
   {
     CHECK(pcPPS->getJointCbCrQpOffsetPresentFlag(), "pps_jcbcr_qp_offset_present_flag should be false");
@@ -393,42 +390,41 @@ void HLSWriter::codePPS(const PPS *pcPPS, const SPS *pcSPS)
     WRITE_SVLC(pcPPS->getQpOffset(JOINT_CbCr), "pps_joint_cbcr_qp_offset_value");
   }
 
-  WRITE_FLAG(pcPPS->getSliceChromaQpFlag() ? 1 : 0, "pps_slice_chroma_qp_offsets_present_flag");
+  WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0,          "pps_slice_chroma_qp_offsets_present_flag" );
 
-  WRITE_FLAG(uint32_t(pcPPS->getCuChromaQpOffsetEnabledFlag()), "cu_chroma_qp_offset_enabled_flag");
+  WRITE_FLAG(uint32_t(pcPPS->getCuChromaQpOffsetEnabledFlag()),         "cu_chroma_qp_offset_enabled_flag" );
   if (pcPPS->getCuChromaQpOffsetEnabledFlag())
   {
-    WRITE_UVLC(pcPPS->getChromaQpOffsetListLen() - 1, "chroma_qp_offset_list_len_minus1");
+    WRITE_UVLC(pcPPS->getChromaQpOffsetListLen() - 1,                   "chroma_qp_offset_list_len_minus1");
     /* skip zero index */
     for (int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < pcPPS->getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++)
     {
-      WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1).u.comp.CbOffset, "cb_qp_offset_list[i]");
-      WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1).u.comp.CrOffset, "cr_qp_offset_list[i]");
+      WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset,     "cb_qp_offset_list[i]");
+      WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset,     "cr_qp_offset_list[i]");
       if (pcPPS->getJointCbCrQpOffsetPresentFlag())
       {
-        WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1).u.comp.JointCbCrOffset,
-                   "joint_cbcr_qp_offset_list[i]");
+        WRITE_SVLC(pcPPS->getChromaQpOffsetListEntry(cuChromaQpOffsetIdx + 1).u.comp.JointCbCrOffset, "joint_cbcr_qp_offset_list[i]");
       }
     }
   }
 
-  WRITE_FLAG(pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag");        // Use of Weighting Prediction (P_SLICE)
-  WRITE_FLAG(pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag");   // Use of Weighting Bi-Prediction (B_SLICE)
+  WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0,  "weighted_pred_flag" );   // Use of Weighting Prediction (P_SLICE)
+  WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" );  // Use of Weighting Bi-Prediction (B_SLICE)
 
-  WRITE_FLAG(pcPPS->getDeblockingFilterControlPresentFlag() ? 1 : 0, "deblocking_filter_control_present_flag");
-  if (pcPPS->getDeblockingFilterControlPresentFlag())
+  WRITE_FLAG( pcPPS->getDeblockingFilterControlPresentFlag()?1 : 0,       "deblocking_filter_control_present_flag");
+  if(pcPPS->getDeblockingFilterControlPresentFlag())
   {
-    WRITE_FLAG(pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0, "deblocking_filter_override_enabled_flag");
-    WRITE_FLAG(pcPPS->getPPSDeblockingFilterDisabledFlag() ? 1 : 0, "pps_deblocking_filter_disabled_flag");
-    if (!pcPPS->getPPSDeblockingFilterDisabledFlag())
+    WRITE_FLAG( pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0,  "deblocking_filter_override_enabled_flag" );
+    WRITE_FLAG( pcPPS->getPPSDeblockingFilterDisabledFlag() ? 1 : 0,      "pps_deblocking_filter_disabled_flag" );
+    if(!pcPPS->getPPSDeblockingFilterDisabledFlag())
     {
-      WRITE_SVLC(pcPPS->getDeblockingFilterBetaOffsetDiv2(), "pps_beta_offset_div2");
-      WRITE_SVLC(pcPPS->getDeblockingFilterTcOffsetDiv2(), "pps_tc_offset_div2");
+      WRITE_SVLC( pcPPS->getDeblockingFilterBetaOffsetDiv2(),             "pps_beta_offset_div2" );
+      WRITE_SVLC( pcPPS->getDeblockingFilterTcOffsetDiv2(),               "pps_tc_offset_div2" );
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-      WRITE_SVLC(pcPPS->getDeblockingFilterCbBetaOffsetDiv2(), "pps_cb_beta_offset_div2");
-      WRITE_SVLC(pcPPS->getDeblockingFilterCbTcOffsetDiv2(), "pps_cb_tc_offset_div2");
-      WRITE_SVLC(pcPPS->getDeblockingFilterCrBetaOffsetDiv2(), "pps_cr_beta_offset_div2");
-      WRITE_SVLC(pcPPS->getDeblockingFilterCrTcOffsetDiv2(), "pps_cr_tc_offset_div2");
+      WRITE_SVLC( pcPPS->getDeblockingFilterCbBetaOffsetDiv2(),           "pps_cb_beta_offset_div2" );
+      WRITE_SVLC( pcPPS->getDeblockingFilterCbTcOffsetDiv2(),             "pps_cb_tc_offset_div2" );
+      WRITE_SVLC( pcPPS->getDeblockingFilterCrBetaOffsetDiv2(),           "pps_cr_beta_offset_div2" );
+      WRITE_SVLC( pcPPS->getDeblockingFilterCrTcOffsetDiv2(),             "pps_cr_tc_offset_div2" );
 #endif
     }
   }
@@ -448,47 +444,49 @@ void HLSWriter::codePPS(const PPS *pcPPS, const SPS *pcSPS)
   WRITE_FLAG(pcPPS->getQpDeltaInfoInPhFlag() ? 1 : 0, "qp_delta_info_in_ph_flag");
 #endif
 
-  WRITE_FLAG(pcPPS->getConstantSliceHeaderParamsEnabledFlag(), "constant_slice_header_params_enabled_flag");
-  if (pcPPS->getConstantSliceHeaderParamsEnabledFlag())
-  {
-    WRITE_CODE(pcPPS->getPPSDepQuantEnabledIdc(), 2, "pps_dep_quant_enabled_idc");
-    WRITE_CODE(pcPPS->getPPSRefPicListSPSIdc0(), 2, "pps_ref_pic_list_sps_idc[0]");
-    WRITE_CODE(pcPPS->getPPSRefPicListSPSIdc1(), 2, "pps_ref_pic_list_sps_idc[1]");
-    WRITE_CODE(pcPPS->getPPSMvdL1ZeroIdc(), 2, "pps_mvd_l1_zero_idc");
-    WRITE_CODE(pcPPS->getPPSCollocatedFromL0Idc(), 2, "pps_collocated_from_l0_idc");
-    WRITE_UVLC(pcPPS->getPPSSixMinusMaxNumMergeCandPlus1(), "pps_six_minus_max_num_merge_cand_plus1");
+  WRITE_FLAG( pcPPS->getConstantSliceHeaderParamsEnabledFlag(),              "constant_slice_header_params_enabled_flag");
+  if ( pcPPS->getConstantSliceHeaderParamsEnabledFlag() ) {
+    WRITE_CODE( pcPPS->getPPSDepQuantEnabledIdc(), 2,                        "pps_dep_quant_enabled_idc");
+    WRITE_CODE( pcPPS->getPPSRefPicListSPSIdc0(), 2,                         "pps_ref_pic_list_sps_idc[0]");
+    WRITE_CODE( pcPPS->getPPSRefPicListSPSIdc1(), 2,                         "pps_ref_pic_list_sps_idc[1]");
+    WRITE_CODE( pcPPS->getPPSMvdL1ZeroIdc(), 2,                              "pps_mvd_l1_zero_idc");
+    WRITE_CODE( pcPPS->getPPSCollocatedFromL0Idc(), 2,                       "pps_collocated_from_l0_idc");
+    WRITE_UVLC( pcPPS->getPPSSixMinusMaxNumMergeCandPlus1(),                 "pps_six_minus_max_num_merge_cand_plus1");
 #if !JVET_Q0806
-    WRITE_UVLC(pcPPS->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1(),
-               "pps_max_num_merge_cand_minus_max_num_triangle_cand_plus1");
+    WRITE_UVLC( pcPPS->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1(),  "pps_max_num_merge_cand_minus_max_num_triangle_cand_plus1");
 #else
-    WRITE_UVLC(pcPPS->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1(),
-               "pps_max_num_merge_cand_minus_max_num_gpm_cand_plus1");
+    WRITE_UVLC(pcPPS->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1(), "pps_max_num_merge_cand_minus_max_num_gpm_cand_plus1");
 #endif
   }
 
-  WRITE_FLAG(pcPPS->getPictureHeaderExtensionPresentFlag() ? 1 : 0, "picture_header_extension_present_flag");
-  WRITE_FLAG(pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_header_extension_present_flag");
 
-  bool pps_extension_present_flag                   = false;
-  bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS] = { false };
+  WRITE_FLAG( pcPPS->getPictureHeaderExtensionPresentFlag() ? 1 : 0, "picture_header_extension_present_flag");
+  WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_header_extension_present_flag");
 
-  WRITE_FLAG((pps_extension_present_flag ? 1 : 0), "pps_extension_present_flag");
+  bool pps_extension_present_flag=false;
+  bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]={false};
+
+  WRITE_FLAG( (pps_extension_present_flag?1:0), "pps_extension_present_flag" );
 
   if (pps_extension_present_flag)
   {
 #if ENABLE_TRACING /*|| RExt__DECODER_DEBUG_BIT_STATISTICS*/
-    static const char *syntaxStrings[] = { "pps_range_extension_flag", "pps_multilayer_extension_flag",
-                                           "pps_extension_6bits[0]",   "pps_extension_6bits[1]",
-                                           "pps_extension_6bits[2]",   "pps_extension_6bits[3]",
-                                           "pps_extension_6bits[4]",   "pps_extension_6bits[5]" };
+    static const char *syntaxStrings[]={ "pps_range_extension_flag",
+      "pps_multilayer_extension_flag",
+      "pps_extension_6bits[0]",
+      "pps_extension_6bits[1]",
+      "pps_extension_6bits[2]",
+      "pps_extension_6bits[3]",
+      "pps_extension_6bits[4]",
+      "pps_extension_6bits[5]" };
 #endif
 
-    for (int i = 0; i < NUM_PPS_EXTENSION_FLAGS; i++)
+    for(int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++)
     {
-      WRITE_FLAG(pps_extension_flags[i] ? 1 : 0, syntaxStrings[i]);
+      WRITE_FLAG( pps_extension_flags[i]?1:0, syntaxStrings[i] );
     }
 
-    for (int i = 0; i < NUM_PPS_EXTENSION_FLAGS; i++)   // loop used so that the order is determined by the enum.
+    for(int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum.
     {
       if (pps_extension_flags[i])
       {
@@ -498,32 +496,30 @@ void HLSWriter::codePPS(const PPS *pcPPS, const SPS *pcSPS)
         {
           const PPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension();
 
-          WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0),
-                     "cross_component_prediction_enabled_flag");
+          WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" );
 
-          WRITE_UVLC(ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), "log2_sao_offset_scale_luma");
-          WRITE_UVLC(ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA), "log2_sao_offset_scale_chroma");
+          WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA),           "log2_sao_offset_scale_luma"   );
+          WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA),         "log2_sao_offset_scale_chroma" );
         }
         break;
         default:
-          CHECK(pps_extension_flags[i] == false,
-                "Unknown PPS extension signalled");   // Should never get here with an active PPS extension flag.
+          CHECK(pps_extension_flags[i]==false, "Unknown PPS extension signalled"); // Should never get here with an active PPS extension flag.
           break;
-        }   // switch
-      }     // if flag present
-    }       // loop over PPS flags
-  }         // pps_extension_present_flag is non-zero
+        } // switch
+      } // if flag present
+    } // loop over PPS flags
+  } // pps_extension_present_flag is non-zero
   xWriteRbspTrailingBits();
 }
 
-void HLSWriter::codeAPS(APS *pcAPS)
+void HLSWriter::codeAPS( APS* pcAPS )
 {
 #if ENABLE_TRACING
   xTraceAPSHeader();
 #endif
 
   WRITE_CODE(pcAPS->getAPSId(), 5, "adaptation_parameter_set_id");
-  WRITE_CODE((int) pcAPS->getAPSType(), 3, "aps_params_type");
+  WRITE_CODE( (int)pcAPS->getAPSType(), 3, "aps_params_type" );
 
   if (pcAPS->getAPSType() == ALF_APS)
   {
@@ -531,18 +527,17 @@ void HLSWriter::codeAPS(APS *pcAPS)
   }
   else if (pcAPS->getAPSType() == LMCS_APS)
   {
-    codeLmcsAps(pcAPS);
+    codeLmcsAps (pcAPS);
   }
-  else if (pcAPS->getAPSType() == SCALING_LIST_APS)
+  else if( pcAPS->getAPSType() == SCALING_LIST_APS )
   {
-    codeScalingListAps(pcAPS);
+    codeScalingListAps( pcAPS );
   }
-  WRITE_FLAG(0, "aps_extension_flag");   // Implementation when this flag is equal to 1 should be added when it is
-                                         // needed. Currently in the spec we don't have case when this flag is equal to 1
+  WRITE_FLAG(0, "aps_extension_flag");   //Implementation when this flag is equal to 1 should be added when it is needed. Currently in the spec we don't have case when this flag is equal to 1
   xWriteRbspTrailingBits();
 }
 
-void HLSWriter::codeAlfAps(APS *pcAPS)
+void HLSWriter::codeAlfAps( APS* pcAPS )
 {
   AlfParam param = pcAPS->getAlfAPSParam();
 
@@ -558,33 +553,34 @@ void HLSWriter::codeAlfAps(APS *pcAPS)
   if (param.newFilterFlag[CHANNEL_TYPE_LUMA])
   {
 #if JVET_Q0249_ALF_CHROMA_CLIPFLAG
-    WRITE_FLAG(param.nonLinearFlag[CHANNEL_TYPE_LUMA], "alf_luma_clip");
+    WRITE_FLAG( param.nonLinearFlag[CHANNEL_TYPE_LUMA], "alf_luma_clip" );
 #else
-    WRITE_FLAG(param.nonLinearFlag[CHANNEL_TYPE_LUMA][0], "alf_luma_clip");
+    WRITE_FLAG( param.nonLinearFlag[CHANNEL_TYPE_LUMA][0], "alf_luma_clip" );
 #endif
 
     WRITE_UVLC(param.numLumaFilters - 1, "alf_luma_num_filters_signalled_minus1");
     if (param.numLumaFilters > 1)
     {
-      const int length = ceilLog2(param.numLumaFilters);
+      const int length =  ceilLog2( param.numLumaFilters);
       for (int i = 0; i < MAX_NUM_ALF_CLASSES; i++)
       {
-        WRITE_CODE(param.filterCoeffDeltaIdx[i], length, "alf_luma_coeff_delta_idx");
+        WRITE_CODE(param.filterCoeffDeltaIdx[i], length, "alf_luma_coeff_delta_idx" );
       }
     }
     alfFilter(param, false, 0);
+
   }
   if (param.newFilterFlag[CHANNEL_TYPE_CHROMA])
   {
 #if JVET_Q0249_ALF_CHROMA_CLIPFLAG
     WRITE_FLAG(param.nonLinearFlag[CHANNEL_TYPE_CHROMA], "alf_nonlinear_enable_flag_chroma");
 #endif
-    if (MAX_NUM_ALF_ALTERNATIVES_CHROMA > 1)
-      WRITE_UVLC(param.numAlternativesChroma - 1, "alf_chroma_num_alts_minus1");
-    for (int altIdx = 0; altIdx < param.numAlternativesChroma; ++altIdx)
+    if( MAX_NUM_ALF_ALTERNATIVES_CHROMA > 1 )
+      WRITE_UVLC( param.numAlternativesChroma - 1, "alf_chroma_num_alts_minus1" );
+    for( int altIdx=0; altIdx < param.numAlternativesChroma; ++altIdx )
     {
 #if !JVET_Q0249_ALF_CHROMA_CLIPFLAG
-      WRITE_FLAG(param.nonLinearFlag[CHANNEL_TYPE_CHROMA][altIdx], "alf_nonlinear_enable_flag_chroma");
+      WRITE_FLAG( param.nonLinearFlag[CHANNEL_TYPE_CHROMA][altIdx], "alf_nonlinear_enable_flag_chroma" );
 #endif
       alfFilter(param, true, altIdx);
     }
@@ -637,7 +633,7 @@ void HLSWriter::codeAlfAps(APS *pcAPS)
 #endif
 }
 
-void HLSWriter::codeLmcsAps(APS *pcAPS)
+void HLSWriter::codeLmcsAps( APS* pcAPS )
 {
   SliceReshapeInfo param = pcAPS->getReshaperAPSInfo();
   WRITE_UVLC(param.reshaperModelMinBinIdx, "lmcs_min_bin_idx");
@@ -648,8 +644,8 @@ void HLSWriter::codeLmcsAps(APS *pcAPS)
   for (int i = param.reshaperModelMinBinIdx; i <= param.reshaperModelMaxBinIdx; i++)
   {
     int deltaCW = param.reshaperModelBinCWDelta[i];
-    int signCW  = (deltaCW < 0) ? 1 : 0;
-    int absCW   = (deltaCW < 0) ? (-deltaCW) : deltaCW;
+    int signCW = (deltaCW < 0) ? 1 : 0;
+    int absCW = (deltaCW < 0) ? (-deltaCW) : deltaCW;
     WRITE_CODE(absCW, param.maxNbitsNeededDeltaCW, "lmcs_delta_abs_cw[ i ]");
     if (absCW > 0)
     {
@@ -657,8 +653,8 @@ void HLSWriter::codeLmcsAps(APS *pcAPS)
     }
   }
   int deltaCRS = param.chrResScalingOffset;
-  int signCRS  = (deltaCRS < 0) ? 1 : 0;
-  int absCRS   = (deltaCRS < 0) ? (-deltaCRS) : deltaCRS;
+  int signCRS = (deltaCRS < 0) ? 1 : 0;
+  int absCRS = (deltaCRS < 0) ? (-deltaCRS) : deltaCRS;
   WRITE_CODE(absCRS, 3, "lmcs_delta_crs_val");
   if (absCRS > 0)
   {
@@ -666,147 +662,147 @@ void HLSWriter::codeLmcsAps(APS *pcAPS)
   }
 }
 
-void HLSWriter::codeScalingListAps(APS *pcAPS)
+void HLSWriter::codeScalingListAps( APS* pcAPS )
 {
   ScalingList param = pcAPS->getScalingList();
-  codeScalingList(param);
+  codeScalingList( param );
 }
 
-void HLSWriter::codeVUI(const VUI *pcVUI, const SPS *pcSPS)
+void HLSWriter::codeVUI( const VUI *pcVUI, const SPS* pcSPS )
 {
 #if ENABLE_TRACING
-  DTRACE(g_trace_ctx, D_HEADER, "----------- vui_parameters -----------\n");
+  DTRACE( g_trace_ctx, D_HEADER, "----------- vui_parameters -----------\n");
 #endif
 
-  WRITE_FLAG(pcVUI->getAspectRatioInfoPresentFlag(), "aspect_ratio_info_present_flag");
+
+  WRITE_FLAG(pcVUI->getAspectRatioInfoPresentFlag(),            "aspect_ratio_info_present_flag");
   if (pcVUI->getAspectRatioInfoPresentFlag())
   {
-    WRITE_FLAG(pcVUI->getAspectRatioConstantFlag(), "aspect_ratio_constant_flag");
-    WRITE_CODE(pcVUI->getAspectRatioIdc(), 8, "aspect_ratio_idc");
+    WRITE_FLAG(pcVUI->getAspectRatioConstantFlag(),             "aspect_ratio_constant_flag");
+    WRITE_CODE(pcVUI->getAspectRatioIdc(), 8,                   "aspect_ratio_idc" );
     if (pcVUI->getAspectRatioIdc() == 255)
     {
-      WRITE_CODE(pcVUI->getSarWidth(), 16, "sar_width");
-      WRITE_CODE(pcVUI->getSarHeight(), 16, "sar_height");
+      WRITE_CODE(pcVUI->getSarWidth(), 16,                      "sar_width");
+      WRITE_CODE(pcVUI->getSarHeight(), 16,                     "sar_height");
     }
   }
-  WRITE_FLAG(pcVUI->getColourDescriptionPresentFlag(), "colour_description_present_flag");
+  WRITE_FLAG(pcVUI->getColourDescriptionPresentFlag(),        "colour_description_present_flag");
   if (pcVUI->getColourDescriptionPresentFlag())
   {
-    WRITE_CODE(pcVUI->getColourPrimaries(), 8, "colour_primaries");
-    WRITE_CODE(pcVUI->getTransferCharacteristics(), 8, "transfer_characteristics");
-    WRITE_CODE(pcVUI->getMatrixCoefficients(), 8, "matrix_coeffs");
-    WRITE_FLAG(pcVUI->getVideoFullRangeFlag(), "video_full_range_flag");
+    WRITE_CODE(pcVUI->getColourPrimaries(), 8,                "colour_primaries");
+    WRITE_CODE(pcVUI->getTransferCharacteristics(), 8,        "transfer_characteristics");
+    WRITE_CODE(pcVUI->getMatrixCoefficients(), 8,             "matrix_coeffs");
+    WRITE_FLAG(pcVUI->getVideoFullRangeFlag(),                "video_full_range_flag");
   }
-  WRITE_FLAG(pcVUI->getFieldSeqFlag(), "field_seq_flag");
-  WRITE_FLAG(pcVUI->getChromaLocInfoPresentFlag(), "chroma_loc_info_present_flag");
+  WRITE_FLAG(pcVUI->getFieldSeqFlag(),                          "field_seq_flag");
+  WRITE_FLAG(pcVUI->getChromaLocInfoPresentFlag(),              "chroma_loc_info_present_flag");
   if (pcVUI->getChromaLocInfoPresentFlag())
   {
-    if (pcVUI->getFieldSeqFlag())
+    if(pcVUI->getFieldSeqFlag())
     {
-      WRITE_UVLC(pcVUI->getChromaSampleLocTypeTopField(), "chroma_sample_loc_type_top_field");
-      WRITE_UVLC(pcVUI->getChromaSampleLocTypeBottomField(), "chroma_sample_loc_type_bottom_field");
+      WRITE_UVLC(pcVUI->getChromaSampleLocTypeTopField(),         "chroma_sample_loc_type_top_field");
+      WRITE_UVLC(pcVUI->getChromaSampleLocTypeBottomField(),      "chroma_sample_loc_type_bottom_field");
     }
     else
     {
-      WRITE_UVLC(pcVUI->getChromaSampleLocType(), "chroma_sample_loc_type");
+      WRITE_UVLC(pcVUI->getChromaSampleLocType(),         "chroma_sample_loc_type");
     }
   }
-  WRITE_FLAG(pcVUI->getOverscanInfoPresentFlag(), "overscan_info_present_flag");
+  WRITE_FLAG(pcVUI->getOverscanInfoPresentFlag(),               "overscan_info_present_flag");
   if (pcVUI->getOverscanInfoPresentFlag())
   {
-    WRITE_FLAG(pcVUI->getOverscanAppropriateFlag(), "overscan_appropriate_flag");
+    WRITE_FLAG(pcVUI->getOverscanAppropriateFlag(),             "overscan_appropriate_flag");
   }
 }
 
-void HLSWriter::codeHrdParameters(const HRDParameters *hrd, const uint32_t firstSubLayer,
-                                  const uint32_t maxNumSubLayersMinus1)
+void HLSWriter::codeHrdParameters( const HRDParameters *hrd, const uint32_t firstSubLayer, const uint32_t maxNumSubLayersMinus1)
 {
-  WRITE_FLAG(hrd->getNalHrdParametersPresentFlag() ? 1 : 0, "general_nal_hrd_parameters_present_flag");
-  WRITE_FLAG(hrd->getVclHrdParametersPresentFlag() ? 1 : 0, "general_vcl_hrd_parameters_present_flag");
-  WRITE_FLAG(hrd->getGeneralDecodingUnitHrdParamsPresentFlag() ? 1 : 0,
-             "general_decoding_unit_hrd_params_present_flag");
-  if (hrd->getGeneralDecodingUnitHrdParamsPresentFlag())
+  WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 ,  "general_nal_hrd_parameters_present_flag" );
+  WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 ,  "general_vcl_hrd_parameters_present_flag" );
+  WRITE_FLAG( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() ? 1 : 0,  "general_decoding_unit_hrd_params_present_flag" );
+  if( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() )
   {
-    WRITE_CODE(hrd->getTickDivisorMinus2(), 8, "tick_divisor_minus2");
+    WRITE_CODE( hrd->getTickDivisorMinus2(), 8,            "tick_divisor_minus2" );
   }
-  WRITE_CODE(hrd->getBitRateScale(), 4, "bit_rate_scale");
-  WRITE_CODE(hrd->getCpbSizeScale(), 4, "cpb_size_scale");
-  if (hrd->getGeneralDecodingUnitHrdParamsPresentFlag())
+  WRITE_CODE( hrd->getBitRateScale(), 4,                     "bit_rate_scale" );
+  WRITE_CODE( hrd->getCpbSizeScale(), 4,                     "cpb_size_scale" );
+  if( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() )
   {
-    WRITE_CODE(hrd->getCpbSizeDuScale(), 4, "cpb_size_du_scale");
+    WRITE_CODE( hrd->getCpbSizeDuScale(), 4,               "cpb_size_du_scale" );
   }
 
-  for (int i = firstSubLayer; i <= maxNumSubLayersMinus1; i++)
+  for( int i = firstSubLayer; i <= maxNumSubLayersMinus1; i ++ )
   {
-    WRITE_FLAG(hrd->getFixedPicRateFlag(i) ? 1 : 0, "fixed_pic_rate_general_flag");
+    WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0,          "fixed_pic_rate_general_flag");
     bool fixedPixRateWithinCvsFlag = true;
-    if (!hrd->getFixedPicRateFlag(i))
+    if( !hrd->getFixedPicRateFlag( i ) )
     {
-      fixedPixRateWithinCvsFlag = hrd->getFixedPicRateWithinCvsFlag(i);
-      WRITE_FLAG(hrd->getFixedPicRateWithinCvsFlag(i) ? 1 : 0, "fixed_pic_rate_within_cvs_flag");
+      fixedPixRateWithinCvsFlag = hrd->getFixedPicRateWithinCvsFlag( i );
+      WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag");
     }
-    if (fixedPixRateWithinCvsFlag)
+    if( fixedPixRateWithinCvsFlag )
     {
-      WRITE_UVLC(hrd->getPicDurationInTcMinus1(i), "elemental_duration_in_tc_minus1");
+      WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ),           "elemental_duration_in_tc_minus1");
     }
     else
     {
-      WRITE_FLAG(hrd->getLowDelayHrdFlag(i) ? 1 : 0, "low_delay_hrd_flag");
+      WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0,           "low_delay_hrd_flag");
     }
-    if (!hrd->getLowDelayHrdFlag(i))
+    if (!hrd->getLowDelayHrdFlag( i ))
     {
-      WRITE_UVLC(hrd->getCpbCntMinus1(i), "cpb_cnt_minus1");
+      WRITE_UVLC( hrd->getCpbCntMinus1( i ),                      "cpb_cnt_minus1");
     }
 
-    for (int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl++)
+    for( int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ )
     {
-      if (((nalOrVcl == 0) && (hrd->getNalHrdParametersPresentFlag()))
-          || ((nalOrVcl == 1) && (hrd->getVclHrdParametersPresentFlag())))
+      if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
+          ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
       {
-        for (int j = 0; j <= (hrd->getCpbCntMinus1(i)); j++)
+        for( int j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ )
         {
-          WRITE_UVLC(hrd->getBitRateValueMinus1(i, j, nalOrVcl), "bit_rate_value_minus1");
-          WRITE_UVLC(hrd->getCpbSizeValueMinus1(i, j, nalOrVcl), "cpb_size_value_minus1");
-          WRITE_FLAG(hrd->getCbrFlag(i, j, nalOrVcl) ? 1 : 0, "cbr_flag");
+          WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1");
+          WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1");
+          WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag");
         }
       }
     }
   }
 }
 
-void HLSWriter::codeSPS(const SPS *pcSPS)
+
+void HLSWriter::codeSPS( const SPS* pcSPS )
 {
 #if ENABLE_TRACING
-  xTraceSPSHeader();
+  xTraceSPSHeader ();
 #endif
-  WRITE_CODE(pcSPS->getDecodingParameterSetId(), 4, "sps_decoding_parameter_set_id");
-  WRITE_CODE(pcSPS->getVPSId(), 4, "sps_video_parameter_set_id");
+  WRITE_CODE( pcSPS->getDecodingParameterSetId (), 4,       "sps_decoding_parameter_set_id" );
+  WRITE_CODE( pcSPS->getVPSId(), 4, "sps_video_parameter_set_id" );
   CHECK(pcSPS->getMaxTLayers() == 0, "Maximum number of temporal sub-layers is '0'");
 
   WRITE_CODE(pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1");
-  WRITE_CODE(0, 5, "sps_reserved_zero_5bits");
+  WRITE_CODE(0,                          5, "sps_reserved_zero_5bits");
 
-  codeProfileTierLevel(pcSPS->getProfileTierLevel(), pcSPS->getMaxTLayers() - 1);
+  codeProfileTierLevel( pcSPS->getProfileTierLevel(), pcSPS->getMaxTLayers() - 1 );
   WRITE_FLAG(pcSPS->getGDREnabledFlag(), "gdr_enabled_flag");
 
-  WRITE_CODE(pcSPS->getSPSId(), 4, "sps_seq_parameter_set_id");
+  WRITE_CODE( pcSPS->getSPSId (), 4, "sps_seq_parameter_set_id" );
 
-  WRITE_CODE(int(pcSPS->getChromaFormatIdc()), 2, "chroma_format_idc");
+  WRITE_CODE(int(pcSPS->getChromaFormatIdc ()), 2, "chroma_format_idc");
 
-  const ChromaFormat format = pcSPS->getChromaFormatIdc();
-  if (format == CHROMA_444)
+  const ChromaFormat format                = pcSPS->getChromaFormatIdc();
+  if( format == CHROMA_444 )
   {
-    WRITE_FLAG(0, "separate_colour_plane_flag");
+    WRITE_FLAG( 0,                                  "separate_colour_plane_flag");
   }
 
 #if JVET_Q0043_RPR_and_Subpics
-  WRITE_FLAG(pcSPS->getRprEnabledFlag(), "res_change_in_clvs_allowed_flag");
+  WRITE_FLAG( pcSPS->getRprEnabledFlag(), "res_change_in_clvs_allowed_flag" );
 #else
-  WRITE_FLAG(pcSPS->getRprEnabledFlag(), "ref_pic_resampling_enabled_flag");
+  WRITE_FLAG( pcSPS->getRprEnabledFlag(), "ref_pic_resampling_enabled_flag" );
 #endif
 
-  WRITE_UVLC(pcSPS->getMaxPicWidthInLumaSamples(), "pic_width_max_in_luma_samples");
-  WRITE_UVLC(pcSPS->getMaxPicHeightInLumaSamples(), "pic_height_max_in_luma_samples");
+  WRITE_UVLC( pcSPS->getMaxPicWidthInLumaSamples(), "pic_width_max_in_luma_samples" );
+  WRITE_UVLC( pcSPS->getMaxPicHeightInLumaSamples(), "pic_height_max_in_luma_samples" );
   WRITE_CODE(floorLog2(pcSPS->getCTUSize()) - 5, 2, "sps_log2_ctu_size_minus5");
 
 #if JVET_Q0043_RPR_and_Subpics
@@ -814,186 +810,154 @@ void HLSWriter::codeSPS(const SPS *pcSPS)
 #else
   WRITE_FLAG(pcSPS->getSubPicPresentFlag(), "subpics_present_flag");
 #endif
-  if (pcSPS->getSubPicPresentFlag())
+  if(pcSPS->getSubPicPresentFlag())
   {
     WRITE_CODE(pcSPS->getNumSubPics() - 1, 8, "sps_num_subpics_minus1");
 #if JVET_Q0816
-    if (pcSPS->getNumSubPics() > 1)
+    if( pcSPS->getNumSubPics() > 1 )
     {
 #endif
-      for (int picIdx = 0; picIdx < pcSPS->getNumSubPics(); picIdx++)
-      {
+    for (int picIdx = 0; picIdx < pcSPS->getNumSubPics(); picIdx++)
+    {
 #if JVET_Q0787_SUBPIC
-        if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize())
-        {
-          WRITE_CODE(pcSPS->getSubPicCtuTopLeftX(picIdx),
-                     ceilLog2((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()),
-                     "subpic_ctu_top_left_x[ i ]");
-        }
-        if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize())
-        {
-          WRITE_CODE(pcSPS->getSubPicCtuTopLeftY(picIdx),
-                     ceilLog2((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()),
-                     "subpic_ctu_top_left_y[ i ]");
-        }
-        if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize())
-        {
-          WRITE_CODE(pcSPS->getSubPicWidth(picIdx) - 1,
-                     ceilLog2((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()),
-                     "subpic_width_minus1[ i ]");
-        }
-        if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize())
-        {
-          WRITE_CODE(pcSPS->getSubPicHeight(picIdx) - 1,
-                     ceilLog2((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()),
-                     "subpic_height_minus1[ i ]");
-        }
-#else
-      WRITE_CODE(pcSPS->getSubPicCtuTopLeftX(picIdx),
-                 std::max(1, ceilLog2(((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                       >> floorLog2(pcSPS->getCTUSize())))),
-                 "subpic_ctu_top_left_x[ i ]");
-      WRITE_CODE(pcSPS->getSubPicCtuTopLeftY(picIdx),
-                 std::max(1, ceilLog2(((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                       >> floorLog2(pcSPS->getCTUSize())))),
-                 "subpic_ctu_top_left_y[ i ]");
-      WRITE_CODE(pcSPS->getSubPicWidth(picIdx) - 1,
-                 std::max(1, ceilLog2(((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                       >> floorLog2(pcSPS->getCTUSize())))),
-                 "subpic_width_minus1[ i ]");
-      WRITE_CODE(pcSPS->getSubPicHeight(picIdx) - 1,
-                 std::max(1, ceilLog2(((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1)
-                                       >> floorLog2(pcSPS->getCTUSize())))),
-                 "subpic_height_minus1[ i ]");
-#endif
-        WRITE_FLAG(pcSPS->getSubPicTreatedAsPicFlag(picIdx), "subpic_treated_as_pic_flag[ i ]");
-        WRITE_FLAG(pcSPS->getLoopFilterAcrossSubpicEnabledFlag(picIdx), "loop_filter_across_subpic_enabled_flag[ i ]");
+      if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize())
+      {
+        WRITE_CODE( pcSPS->getSubPicCtuTopLeftX(picIdx), ceilLog2(( pcSPS->getMaxPicWidthInLumaSamples()  +  pcSPS->getCTUSize() - 1)  / pcSPS->getCTUSize()), "subpic_ctu_top_left_x[ i ]"  );
+      }
+      if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize())
+      {
+        WRITE_CODE( pcSPS->getSubPicCtuTopLeftY(picIdx), ceilLog2(( pcSPS->getMaxPicHeightInLumaSamples() +  pcSPS->getCTUSize() - 1)  / pcSPS->getCTUSize()), "subpic_ctu_top_left_y[ i ]"  );
+      }
+      if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize())
+      {
+        WRITE_CODE( pcSPS->getSubPicWidth(picIdx) - 1,   ceilLog2(( pcSPS->getMaxPicWidthInLumaSamples()  +  pcSPS->getCTUSize() - 1)  / pcSPS->getCTUSize()), "subpic_width_minus1[ i ]"    );
       }
+      if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize())
+      {
+        WRITE_CODE( pcSPS->getSubPicHeight(picIdx) - 1,  ceilLog2(( pcSPS->getMaxPicHeightInLumaSamples() +  pcSPS->getCTUSize() - 1)  / pcSPS->getCTUSize()), "subpic_height_minus1[ i ]"   );
+      }
+#else
+      WRITE_CODE( pcSPS->getSubPicCtuTopLeftX(picIdx), std::max(1, ceilLog2((( pcSPS->getMaxPicWidthInLumaSamples()  +  pcSPS->getCTUSize() - 1)  >> floorLog2( pcSPS->getCTUSize())))), "subpic_ctu_top_left_x[ i ]"  );
+      WRITE_CODE( pcSPS->getSubPicCtuTopLeftY(picIdx), std::max(1, ceilLog2((( pcSPS->getMaxPicHeightInLumaSamples() +  pcSPS->getCTUSize() - 1)  >> floorLog2( pcSPS->getCTUSize())))), "subpic_ctu_top_left_y[ i ]"  );
+      WRITE_CODE( pcSPS->getSubPicWidth(picIdx) - 1,   std::max(1, ceilLog2((( pcSPS->getMaxPicWidthInLumaSamples()  +  pcSPS->getCTUSize() - 1)  >> floorLog2( pcSPS->getCTUSize())))), "subpic_width_minus1[ i ]"    );
+      WRITE_CODE( pcSPS->getSubPicHeight(picIdx) - 1,  std::max(1, ceilLog2((( pcSPS->getMaxPicHeightInLumaSamples() +  pcSPS->getCTUSize() - 1)  >> floorLog2( pcSPS->getCTUSize())))), "subpic_height_minus1[ i ]"   );
+#endif
+      WRITE_FLAG( pcSPS->getSubPicTreatedAsPicFlag(picIdx),  "subpic_treated_as_pic_flag[ i ]" );
+      WRITE_FLAG( pcSPS->getLoopFilterAcrossSubpicEnabledFlag(picIdx),  "loop_filter_across_subpic_enabled_flag[ i ]" );
+    }
 #if JVET_Q0816
     }
 #endif
   }
 
-  WRITE_FLAG(pcSPS->getSubPicIdPresentFlag(), "sps_subpic_id_present_flag");
-  if (pcSPS->getSubPicIdPresentFlag())
+  WRITE_FLAG( pcSPS->getSubPicIdPresentFlag(), "sps_subpic_id_present_flag");
+  if( pcSPS->getSubPicIdPresentFlag() )
   {
     WRITE_FLAG(pcSPS->getSubPicIdSignallingPresentFlag(), "sps_subpic_id_signalling_present_flag");
-    if (pcSPS->getSubPicIdSignallingPresentFlag())
+    if( pcSPS->getSubPicIdSignallingPresentFlag() )
     {
-      WRITE_UVLC(pcSPS->getSubPicIdLen() - 1, "sps_subpic_id_len_minus1");
+      WRITE_UVLC( pcSPS->getSubPicIdLen( ) - 1, "sps_subpic_id_len_minus1" );
 #if JVET_Q0169_SUBPIC_LEN_CONFORM
       CHECK((1 << pcSPS->getSubPicIdLen()) < pcSPS->getNumSubPics(), "sps_subpic_id_len exceeds valid range");
 #endif
-      for (int picIdx = 0; picIdx < pcSPS->getNumSubPics(); picIdx++)
+      for( int picIdx = 0; picIdx < pcSPS->getNumSubPics( ); picIdx++ )
       {
-        WRITE_CODE(pcSPS->getSubPicId(picIdx), pcSPS->getSubPicIdLen(), "sps_subpic_id[i]");
+        WRITE_CODE( pcSPS->getSubPicId(picIdx), pcSPS->getSubPicIdLen( ), "sps_subpic_id[i]" );
       }
     }
   }
 
-  WRITE_UVLC(pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) - 8, "bit_depth_minus8");
+  WRITE_UVLC( pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) - 8,                      "bit_depth_minus8" );
 
-  WRITE_UVLC(pcSPS->getMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA), "min_qp_prime_ts_minus4");
+  WRITE_UVLC( pcSPS->getMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA),                      "min_qp_prime_ts_minus4" );
+  
+  WRITE_FLAG( pcSPS->getUseWP() ? 1 : 0, "sps_weighted_pred_flag" );   // Use of Weighting Prediction (P_SLICE)
+  WRITE_FLAG( pcSPS->getUseWPBiPred() ? 1 : 0, "sps_weighted_bipred_flag" );  // Use of Weighting Bi-Prediction (B_SLICE)
 
-  WRITE_FLAG(pcSPS->getUseWP() ? 1 : 0, "sps_weighted_pred_flag");           // Use of Weighting Prediction (P_SLICE)
-  WRITE_FLAG(pcSPS->getUseWPBiPred() ? 1 : 0, "sps_weighted_bipred_flag");   // Use of Weighting Bi-Prediction (B_SLICE)
-
-  WRITE_CODE(pcSPS->getBitsForPOC() - 4, 4, "log2_max_pic_order_cnt_lsb_minus4");
+  WRITE_CODE(pcSPS->getBitsForPOC()-4, 4, "log2_max_pic_order_cnt_lsb_minus4");
   // KJS: Marakech decision: sub-layers added back
   const bool subLayerOrderingInfoPresentFlag = 1;
   if (pcSPS->getMaxTLayers() > 1)
   {
-    WRITE_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag");
+    WRITE_FLAG(subLayerOrderingInfoPresentFlag,       "sps_sub_layer_ordering_info_present_flag");
   }
-  for (uint32_t i = 0; i <= pcSPS->getMaxTLayers() - 1; i++)
+  for(uint32_t i=0; i <= pcSPS->getMaxTLayers()-1; i++)
   {
-    WRITE_UVLC(pcSPS->getMaxDecPicBuffering(i) - 1, "sps_max_dec_pic_buffering_minus1[i]");
-    WRITE_UVLC(pcSPS->getNumReorderPics(i), "sps_max_num_reorder_pics[i]");
-    WRITE_UVLC(pcSPS->getMaxLatencyIncreasePlus1(i), "sps_max_latency_increase_plus1[i]");
+    WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1,       "sps_max_dec_pic_buffering_minus1[i]" );
+    WRITE_UVLC( pcSPS->getNumReorderPics(i),               "sps_max_num_reorder_pics[i]" );
+    WRITE_UVLC( pcSPS->getMaxLatencyIncreasePlus1(i),      "sps_max_latency_increase_plus1[i]" );
     if (!subLayerOrderingInfoPresentFlag)
     {
       break;
     }
   }
-  CHECK(pcSPS->getMaxCUWidth() != pcSPS->getMaxCUHeight(), "Rectangular CTUs not supported");
+  CHECK( pcSPS->getMaxCUWidth() != pcSPS->getMaxCUHeight(),                          "Rectangular CTUs not supported" );
   WRITE_FLAG(pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_flag");
-  WRITE_FLAG(pcSPS->getInterLayerPresentFlag() ? 1 : 0, "inter_layer_ref_pics_present_flag");
-  WRITE_FLAG(pcSPS->getIDRRefParamListPresent() ? 1 : 0, "sps_idr_rpl_present_flag");
+  WRITE_FLAG( pcSPS->getInterLayerPresentFlag() ? 1 : 0, "inter_layer_ref_pics_present_flag" );
+  WRITE_FLAG(pcSPS->getIDRRefParamListPresent() ? 1 : 0, "sps_idr_rpl_present_flag" );
   WRITE_FLAG(pcSPS->getRPL1CopyFromRPL0Flag() ? 1 : 0, "rpl1_copy_from_rpl0_flag");
 
-  const RPLList *rplList0 = pcSPS->getRPLList0();
-  const RPLList *rplList1 = pcSPS->getRPLList1();
+  const RPLList* rplList0 = pcSPS->getRPLList0();
+  const RPLList* rplList1 = pcSPS->getRPLList1();
 
-  // Write candidate for List0
+  //Write candidate for List0
   uint32_t numberOfRPL = pcSPS->getNumRPL0();
   WRITE_UVLC(numberOfRPL, "num_ref_pic_lists_in_sps[0]");
   for (int ii = 0; ii < numberOfRPL; ii++)
   {
-    const ReferencePictureList *rpl = rplList0->getReferencePictureList(ii);
-    xCodeRefPicList(rpl, pcSPS->getLongTermRefsPresent(), pcSPS->getBitsForPOC(),
-                    !pcSPS->getUseWP() && !pcSPS->getUseWPBiPred());
+    const ReferencePictureList* rpl = rplList0->getReferencePictureList(ii);
+    xCodeRefPicList( rpl, pcSPS->getLongTermRefsPresent(), pcSPS->getBitsForPOC(), !pcSPS->getUseWP() && !pcSPS->getUseWPBiPred() );
   }
 
-  // Write candidate for List1
+  //Write candidate for List1
   if (!pcSPS->getRPL1CopyFromRPL0Flag())
   {
     numberOfRPL = pcSPS->getNumRPL1();
     WRITE_UVLC(numberOfRPL, "num_ref_pic_lists_in_sps[1]");
     for (int ii = 0; ii < numberOfRPL; ii++)
     {
-      const ReferencePictureList *rpl = rplList1->getReferencePictureList(ii);
-      xCodeRefPicList(rpl, pcSPS->getLongTermRefsPresent(), pcSPS->getBitsForPOC(),
-                      !pcSPS->getUseWP() && !pcSPS->getUseWPBiPred());
+      const ReferencePictureList* rpl = rplList1->getReferencePictureList(ii);
+      xCodeRefPicList( rpl, pcSPS->getLongTermRefsPresent(), pcSPS->getBitsForPOC(), !pcSPS->getUseWP() && !pcSPS->getUseWPBiPred() );
     }
   }
-  if (pcSPS->getChromaFormatIdc() != CHROMA_400)
+  if( pcSPS->getChromaFormatIdc() != CHROMA_400 ) 
   {
     WRITE_FLAG(pcSPS->getUseDualITree(), "qtbtt_dual_tree_intra_flag");
   }
   WRITE_UVLC(pcSPS->getLog2MinCodingBlockSize() - 2, "log2_min_luma_coding_block_size_minus2");
   WRITE_FLAG(pcSPS->getSplitConsOverrideEnabledFlag(), "partition_constraints_override_enabled_flag");
-  WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(I_SLICE)) - pcSPS->getLog2MinCodingBlockSize(),
-             "sps_log2_diff_min_qt_min_cb_intra_slice_luma");
+  WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(I_SLICE)) - pcSPS->getLog2MinCodingBlockSize(), "sps_log2_diff_min_qt_min_cb_intra_slice_luma");
 #if !JVET_Q0481_PARTITION_CONSTRAINTS_ORDER
-  WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(B_SLICE)) - pcSPS->getLog2MinCodingBlockSize(),
-             "sps_log2_diff_min_qt_min_cb_inter_slice");
+  WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(B_SLICE)) - pcSPS->getLog2MinCodingBlockSize(), "sps_log2_diff_min_qt_min_cb_inter_slice");
   WRITE_UVLC(pcSPS->getMaxMTTHierarchyDepth(), "sps_max_mtt_hierarchy_depth_inter_slice");
 #endif
   WRITE_UVLC(pcSPS->getMaxMTTHierarchyDepthI(), "sps_max_mtt_hierarchy_depth_intra_slice_luma");
   if (pcSPS->getMaxMTTHierarchyDepthI() != 0)
   {
-    WRITE_UVLC(floorLog2(pcSPS->getMaxBTSizeI()) - floorLog2(pcSPS->getMinQTSize(I_SLICE)),
-               "sps_log2_diff_max_bt_min_qt_intra_slice_luma");
-    WRITE_UVLC(floorLog2(pcSPS->getMaxTTSizeI()) - floorLog2(pcSPS->getMinQTSize(I_SLICE)),
-               "sps_log2_diff_max_tt_min_qt_intra_slice_luma");
+    WRITE_UVLC(floorLog2(pcSPS->getMaxBTSizeI()) - floorLog2(pcSPS->getMinQTSize(I_SLICE)), "sps_log2_diff_max_bt_min_qt_intra_slice_luma");
+    WRITE_UVLC(floorLog2(pcSPS->getMaxTTSizeI()) - floorLog2(pcSPS->getMinQTSize(I_SLICE)), "sps_log2_diff_max_tt_min_qt_intra_slice_luma");
   }
 #if JVET_Q0481_PARTITION_CONSTRAINTS_ORDER
-  WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(B_SLICE)) - pcSPS->getLog2MinCodingBlockSize(),
-             "sps_log2_diff_min_qt_min_cb_inter_slice");
+  WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(B_SLICE)) - pcSPS->getLog2MinCodingBlockSize(), "sps_log2_diff_min_qt_min_cb_inter_slice");
   WRITE_UVLC(pcSPS->getMaxMTTHierarchyDepth(), "sps_max_mtt_hierarchy_depth_inter_slice");
 #endif
   if (pcSPS->getMaxMTTHierarchyDepth() != 0)
   {
-    WRITE_UVLC(floorLog2(pcSPS->getMaxBTSize()) - floorLog2(pcSPS->getMinQTSize(B_SLICE)),
-               "sps_log2_diff_max_bt_min_qt_inter_slice");
-    WRITE_UVLC(floorLog2(pcSPS->getMaxTTSize()) - floorLog2(pcSPS->getMinQTSize(B_SLICE)),
-               "sps_log2_diff_max_tt_min_qt_inter_slice");
+    WRITE_UVLC(floorLog2(pcSPS->getMaxBTSize()) - floorLog2(pcSPS->getMinQTSize(B_SLICE)), "sps_log2_diff_max_bt_min_qt_inter_slice");
+    WRITE_UVLC(floorLog2(pcSPS->getMaxTTSize()) - floorLog2(pcSPS->getMinQTSize(B_SLICE)), "sps_log2_diff_max_tt_min_qt_inter_slice");
   }
   if (pcSPS->getUseDualITree())
   {
-    WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)) - pcSPS->getLog2MinCodingBlockSize(),
-               "sps_log2_diff_min_qt_min_cb_intra_slice_chroma");
+    WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)) - pcSPS->getLog2MinCodingBlockSize(), "sps_log2_diff_min_qt_min_cb_intra_slice_chroma");
     WRITE_UVLC(pcSPS->getMaxMTTHierarchyDepthIChroma(), "sps_max_mtt_hierarchy_depth_intra_slice_chroma");
     if (pcSPS->getMaxMTTHierarchyDepthIChroma() != 0)
     {
-      WRITE_UVLC(floorLog2(pcSPS->getMaxBTSizeIChroma()) - floorLog2(pcSPS->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)),
-                 "sps_log2_diff_max_bt_min_qt_intra_slice_chroma");
-      WRITE_UVLC(floorLog2(pcSPS->getMaxTTSizeIChroma()) - floorLog2(pcSPS->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)),
-                 "sps_log2_diff_max_tt_min_qt_intra_slice_chroma");
+      WRITE_UVLC(floorLog2(pcSPS->getMaxBTSizeIChroma()) - floorLog2(pcSPS->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)), "sps_log2_diff_max_bt_min_qt_intra_slice_chroma");
+      WRITE_UVLC(floorLog2(pcSPS->getMaxTTSizeIChroma()) - floorLog2(pcSPS->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)), "sps_log2_diff_max_tt_min_qt_intra_slice_chroma");
     }
   }
 
-  WRITE_FLAG((pcSPS->getLog2MaxTbSize() - 5) ? 1 : 0, "sps_max_luma_transform_size_64_flag");
+  WRITE_FLAG( (pcSPS->getLog2MaxTbSize() - 5) ? 1 : 0,                       "sps_max_luma_transform_size_64_flag" );
 
 #if JVET_Q0147_JCCR_SIGNALLING
   if (pcSPS->getChromaFormatIdc() != CHROMA_400)
@@ -1004,10 +968,9 @@ void HLSWriter::codeSPS(const SPS *pcSPS)
   if (pcSPS->getChromaFormatIdc() != CHROMA_400)
   {
 #endif
-    const ChromaQpMappingTable &chromaQpMappingTable = pcSPS->getChromaQpMappingTable();
+    const ChromaQpMappingTable& chromaQpMappingTable = pcSPS->getChromaQpMappingTable();
     WRITE_FLAG(chromaQpMappingTable.getSameCQPTableForAllChromaFlag(), "same_qp_table_for_chroma");
-    int numQpTables =
-      chromaQpMappingTable.getSameCQPTableForAllChromaFlag() ? 1 : (pcSPS->getJointCbCrEnabledFlag() ? 3 : 2);
+    int numQpTables = chromaQpMappingTable.getSameCQPTableForAllChromaFlag() ? 1 : (pcSPS->getJointCbCrEnabledFlag() ? 3 : 2);
     CHECK(numQpTables != chromaQpMappingTable.getNumQpTables(), " numQpTables does not match at encoder side ");
     for (int i = 0; i < numQpTables; i++)
     {
@@ -1016,19 +979,19 @@ void HLSWriter::codeSPS(const SPS *pcSPS)
 
       for (int j = 0; j <= chromaQpMappingTable.getNumPtsInCQPTableMinus1(i); j++)
       {
-        WRITE_UVLC(chromaQpMappingTable.getDeltaQpInValMinus1(i, j), "delta_qp_in_val_minus1");
+        WRITE_UVLC(chromaQpMappingTable.getDeltaQpInValMinus1(i,j),  "delta_qp_in_val_minus1");
         WRITE_UVLC(chromaQpMappingTable.getDeltaQpOutVal(i, j) ^ chromaQpMappingTable.getDeltaQpInValMinus1(i, j),
                    "delta_qp_diff_val");
       }
     }
   }
 
-  WRITE_FLAG(pcSPS->getSAOEnabledFlag(), "sps_sao_enabled_flag");
-  WRITE_FLAG(pcSPS->getALFEnabledFlag(), "sps_alf_enabled_flag");
+  WRITE_FLAG( pcSPS->getSAOEnabledFlag(),                                            "sps_sao_enabled_flag");
+  WRITE_FLAG( pcSPS->getALFEnabledFlag(),                                            "sps_alf_enabled_flag" );
 #if JVET_Q0795_CCALF
   if (pcSPS->getALFEnabledFlag() && pcSPS->getChromaFormatIdc() != CHROMA_400)
   {
-    WRITE_FLAG(pcSPS->getCCALFEnabledFlag(), "sps_ccalf_enabled_flag");
+    WRITE_FLAG( pcSPS->getCCALFEnabledFlag(),                                            "sps_ccalf_enabled_flag" );
   }
 #endif
 
@@ -1038,20 +1001,20 @@ void HLSWriter::codeSPS(const SPS *pcSPS)
 #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM
     WRITE_FLAG(pcSPS->getBDPCMEnabledFlag() ? 1 : 0, "sps_bdpcm_enabled_flag");
 #else
-    WRITE_FLAG(pcSPS->getBDPCMEnabled() ? 1 : 0, "sps_bdpcm_enabled_flag");
+      WRITE_FLAG(pcSPS->getBDPCMEnabled() ? 1 : 0, "sps_bdpcm_enabled_flag");
 #if JVET_Q0110_Q0785_CHROMA_BDPCM_420
-    if (pcSPS->getBDPCMEnabled())
+      if( pcSPS->getBDPCMEnabled() )
 #else
-    if (pcSPS->getBDPCMEnabled() && pcSPS->getChromaFormatIdc() == CHROMA_444)
+      if (pcSPS->getBDPCMEnabled() && pcSPS->getChromaFormatIdc() == CHROMA_444)
 #endif
-    {
-      WRITE_FLAG(pcSPS->getBDPCMEnabled() == BDPCM_LUMACHROMA ? 1 : 0, "sps_bdpcm_enabled_chroma_flag");
-    }
+      {
+          WRITE_FLAG(pcSPS->getBDPCMEnabled() == BDPCM_LUMACHROMA ? 1 : 0, "sps_bdpcm_enabled_chroma_flag");
+      }
 #if !JVET_Q0110_Q0785_CHROMA_BDPCM_420
-    else
-    {
-      CHECK(pcSPS->getBDPCMEnabled() == BDPCM_LUMACHROMA, "BDPCM for chroma can be used for 444 only.")
-    }
+      else 
+      {
+        CHECK(pcSPS->getBDPCMEnabled() == BDPCM_LUMACHROMA, "BDPCM for chroma can be used for 444 only.")
+      }
 #endif
 #endif
   }
@@ -1060,74 +1023,73 @@ void HLSWriter::codeSPS(const SPS *pcSPS)
 #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM
     CHECK(pcSPS->getBDPCMEnabledFlag(), "BDPCM cannot be used when transform skip is disabled");
 #else
-    CHECK(pcSPS->getBDPCMEnabled() != 0, "BDPCM cannot be used when transform skip is disabled");
+    CHECK(pcSPS->getBDPCMEnabled()!=0, "BDPCM cannot be used when transform skip is disabled");
 #endif
   }
 
-  WRITE_FLAG(pcSPS->getWrapAroundEnabledFlag() ? 1 : 0, "sps_ref_wraparound_enabled_flag");
-  if (pcSPS->getWrapAroundEnabledFlag())
+  WRITE_FLAG( pcSPS->getWrapAroundEnabledFlag() ? 1 : 0,                              "sps_ref_wraparound_enabled_flag" );
+  if( pcSPS->getWrapAroundEnabledFlag() )
   {
-    WRITE_UVLC((pcSPS->getWrapAroundOffset() / (1 << pcSPS->getLog2MinCodingBlockSize())) - 1,
-               "sps_ref_wraparound_offset_minus1");
+    WRITE_UVLC( (pcSPS->getWrapAroundOffset()/(1 <<  pcSPS->getLog2MinCodingBlockSize()))-1,  "sps_ref_wraparound_offset_minus1" );
   }
 
-  WRITE_FLAG(pcSPS->getSPSTemporalMVPEnabledFlag() ? 1 : 0, "sps_temporal_mvp_enabled_flag");
+  WRITE_FLAG( pcSPS->getSPSTemporalMVPEnabledFlag()  ? 1 : 0,                        "sps_temporal_mvp_enabled_flag" );
 
-  if (pcSPS->getSPSTemporalMVPEnabledFlag())
+  if ( pcSPS->getSPSTemporalMVPEnabledFlag() )
   {
-    WRITE_FLAG(pcSPS->getSBTMVPEnabledFlag() ? 1 : 0, "sps_sbtmvp_enabled_flag");
+    WRITE_FLAG( pcSPS->getSBTMVPEnabledFlag() ? 1 : 0,                               "sps_sbtmvp_enabled_flag");
   }
 
-  WRITE_FLAG(pcSPS->getAMVREnabledFlag() ? 1 : 0, "sps_amvr_enabled_flag");
+  WRITE_FLAG( pcSPS->getAMVREnabledFlag() ? 1 : 0,                                   "sps_amvr_enabled_flag" );
 
-  WRITE_FLAG(pcSPS->getBDOFEnabledFlag() ? 1 : 0, "sps_bdof_enabled_flag");
+  WRITE_FLAG( pcSPS->getBDOFEnabledFlag() ? 1 : 0,                                   "sps_bdof_enabled_flag" );
   if (pcSPS->getBDOFEnabledFlag())
   {
-    WRITE_FLAG(pcSPS->getBdofControlPresentFlag() ? 1 : 0, "sps_bdof_pic_present_flag");
+    WRITE_FLAG(pcSPS->getBdofControlPresentFlag() ? 1 : 0,                           "sps_bdof_pic_present_flag");
   }
-  WRITE_FLAG(pcSPS->getUseSMVD() ? 1 : 0, "sps_smvd_enabled_flag");
-  WRITE_FLAG(pcSPS->getUseDMVR() ? 1 : 0, "sps_dmvr_enabled_flag");
+  WRITE_FLAG( pcSPS->getUseSMVD() ? 1 : 0,                                            "sps_smvd_enabled_flag" );
+  WRITE_FLAG( pcSPS->getUseDMVR() ? 1 : 0,                                            "sps_dmvr_enabled_flag" );
   if (pcSPS->getUseDMVR())
   {
-    WRITE_FLAG(pcSPS->getDmvrControlPresentFlag() ? 1 : 0, "sps_dmvr_pic_present_flag");
+    WRITE_FLAG(pcSPS->getDmvrControlPresentFlag() ? 1 : 0,                            "sps_dmvr_pic_present_flag");
   }
-  WRITE_FLAG(pcSPS->getUseMMVD() ? 1 : 0, "sps_mmvd_enabled_flag");
-  WRITE_FLAG(pcSPS->getUseISP() ? 1 : 0, "sps_isp_enabled_flag");
-  WRITE_FLAG(pcSPS->getUseMRL() ? 1 : 0, "sps_mrl_enabled_flag");
-  WRITE_FLAG(pcSPS->getUseMIP() ? 1 : 0, "sps_mip_enabled_flag");
-  if (pcSPS->getChromaFormatIdc() != CHROMA_400)
+  WRITE_FLAG(pcSPS->getUseMMVD() ? 1 : 0,                                             "sps_mmvd_enabled_flag");
+  WRITE_FLAG( pcSPS->getUseISP() ? 1 : 0,                                             "sps_isp_enabled_flag");
+  WRITE_FLAG( pcSPS->getUseMRL() ? 1 : 0,                                             "sps_mrl_enabled_flag");
+  WRITE_FLAG( pcSPS->getUseMIP() ? 1 : 0,                                             "sps_mip_enabled_flag");
+  if( pcSPS->getChromaFormatIdc() != CHROMA_400) 
   {
-    WRITE_FLAG(pcSPS->getUseLMChroma() ? 1 : 0, "sps_cclm_enabled_flag");
+    WRITE_FLAG( pcSPS->getUseLMChroma() ? 1 : 0,                                      "sps_cclm_enabled_flag");
   }
-  if (pcSPS->getChromaFormatIdc() == CHROMA_420)
+  if( pcSPS->getChromaFormatIdc() == CHROMA_420 )
   {
-    WRITE_FLAG(pcSPS->getHorCollocatedChromaFlag() ? 1 : 0, "sps_chroma_horizontal_collocated_flag");
-    WRITE_FLAG(pcSPS->getVerCollocatedChromaFlag() ? 1 : 0, "sps_chroma_vertical_collocated_flag");
+    WRITE_FLAG( pcSPS->getHorCollocatedChromaFlag() ? 1 : 0, "sps_chroma_horizontal_collocated_flag" );
+    WRITE_FLAG( pcSPS->getVerCollocatedChromaFlag() ? 1 : 0, "sps_chroma_vertical_collocated_flag" );
   }
 
-  WRITE_FLAG(pcSPS->getUseMTS() ? 1 : 0, "sps_mts_enabled_flag");
-  if (pcSPS->getUseMTS())
+  WRITE_FLAG( pcSPS->getUseMTS() ? 1 : 0,                                                      "sps_mts_enabled_flag" );
+  if ( pcSPS->getUseMTS() )
   {
-    WRITE_FLAG(pcSPS->getUseIntraMTS() ? 1 : 0, "sps_explicit_mts_intra_enabled_flag");
-    WRITE_FLAG(pcSPS->getUseInterMTS() ? 1 : 0, "sps_explicit_mts_inter_enabled_flag");
+    WRITE_FLAG( pcSPS->getUseIntraMTS() ? 1 : 0,                                               "sps_explicit_mts_intra_enabled_flag" );
+    WRITE_FLAG( pcSPS->getUseInterMTS() ? 1 : 0,                                               "sps_explicit_mts_inter_enabled_flag" );
   }
-  WRITE_FLAG(pcSPS->getUseSBT() ? 1 : 0, "sps_sbt_enabled_flag");
-  WRITE_FLAG(pcSPS->getUseAffine() ? 1 : 0, "sps_affine_enabled_flag");
-  if (pcSPS->getUseAffine())
+  WRITE_FLAG( pcSPS->getUseSBT() ? 1 : 0,                                                      "sps_sbt_enabled_flag");
+  WRITE_FLAG( pcSPS->getUseAffine() ? 1 : 0,                                                   "sps_affine_enabled_flag" );
+  if ( pcSPS->getUseAffine() )
   {
-    WRITE_FLAG(pcSPS->getUseAffineType() ? 1 : 0, "sps_affine_type_flag");
+    WRITE_FLAG( pcSPS->getUseAffineType() ? 1 : 0,                                             "sps_affine_type_flag" );
 #if JVET_Q0444_AMVR_SIGNALLING
     if (pcSPS->getAMVREnabledFlag())
     {
 #endif
-      WRITE_FLAG(pcSPS->getAffineAmvrEnabledFlag() ? 1 : 0, "sps_affine_amvr_enabled_flag");
+      WRITE_FLAG( pcSPS->getAffineAmvrEnabledFlag() ? 1 : 0,                                     "sps_affine_amvr_enabled_flag" );
 #if JVET_Q0444_AMVR_SIGNALLING
     }
 #endif
-    WRITE_FLAG(pcSPS->getUsePROF() ? 1 : 0, "sps_affine_prof_enabled_flag");
+    WRITE_FLAG( pcSPS->getUsePROF() ? 1 : 0,                                                   "sps_affine_prof_enabled_flag" );
     if (pcSPS->getUsePROF())
     {
-      WRITE_FLAG(pcSPS->getProfControlPresentFlag() ? 1 : 0, "sps_prof_pic_present_flag");
+      WRITE_FLAG(pcSPS->getProfControlPresentFlag() ? 1 : 0,                                   "sps_prof_pic_present_flag" );
     }
   }
   if (pcSPS->getChromaFormatIdc() == CHROMA_444)
@@ -1142,44 +1104,43 @@ void HLSWriter::codeSPS(const SPS *pcSPS)
 #endif
   }
 #if JVET_Q0504_PLT_NON444
-  WRITE_FLAG(pcSPS->getPLTMode() ? 1 : 0, "sps_palette_enabled_flag");
+  WRITE_FLAG(pcSPS->getPLTMode() ? 1 : 0,                                                    "sps_palette_enabled_flag" );
 #else
   if (pcSPS->getChromaFormatIdc() == CHROMA_444)
   {
-    WRITE_FLAG(pcSPS->getPLTMode() ? 1 : 0, "sps_palette_enabled_flag");
+    WRITE_FLAG(pcSPS->getPLTMode() ? 1 : 0,                                                    "sps_palette_enabled_flag" );
   }
 #endif
-  WRITE_FLAG(pcSPS->getUseBcw() ? 1 : 0, "sps_bcw_enabled_flag");
-  WRITE_FLAG(pcSPS->getIBCFlag() ? 1 : 0, "sps_ibc_enabled_flag");
+  WRITE_FLAG( pcSPS->getUseBcw() ? 1 : 0,                                                      "sps_bcw_enabled_flag" );
+  WRITE_FLAG(pcSPS->getIBCFlag() ? 1 : 0,                                                      "sps_ibc_enabled_flag");
 
   // KJS: sps_ciip_enabled_flag
-  WRITE_FLAG(pcSPS->getUseCiip() ? 1 : 0, "sps_ciip_enabled_flag");
+  WRITE_FLAG( pcSPS->getUseCiip() ? 1 : 0,                                                  "sps_ciip_enabled_flag" );
 
-  if (pcSPS->getUseMMVD())
+  if ( pcSPS->getUseMMVD() )
   {
-    WRITE_FLAG(pcSPS->getFpelMmvdEnabledFlag() ? 1 : 0, "sps_fpel_mmvd_enabled_flag");
+    WRITE_FLAG( pcSPS->getFpelMmvdEnabledFlag() ? 1 : 0,                            "sps_fpel_mmvd_enabled_flag" );
   }
 
 #if !JVET_Q0806
-  WRITE_FLAG(pcSPS->getUseTriangle() ? 1 : 0, "sps_triangle_enabled_flag");
+  WRITE_FLAG( pcSPS->getUseTriangle() ? 1: 0,                                                  "sps_triangle_enabled_flag" );
 #else
-  WRITE_FLAG(pcSPS->getUseGeo() ? 1 : 0, "sps_gpm_enabled_flag");
+  WRITE_FLAG( pcSPS->getUseGeo() ? 1: 0,                                                       "sps_gpm_enabled_flag" );
 #endif
 
   WRITE_FLAG(pcSPS->getUseLmcs() ? 1 : 0, "sps_lmcs_enable_flag");
-  WRITE_FLAG(pcSPS->getUseLFNST() ? 1 : 0, "sps_lfnst_enabled_flag");
+  WRITE_FLAG( pcSPS->getUseLFNST() ? 1 : 0,                                                    "sps_lfnst_enabled_flag" );
 
 #if LUMA_ADAPTIVE_DEBLOCKING_FILTER_QP_OFFSET
-  WRITE_FLAG(pcSPS->getLadfEnabled() ? 1 : 0, "sps_ladf_enabled_flag");
-  if (pcSPS->getLadfEnabled())
+  WRITE_FLAG( pcSPS->getLadfEnabled() ? 1 : 0,                                                 "sps_ladf_enabled_flag" );
+  if ( pcSPS->getLadfEnabled() )
   {
-    WRITE_CODE(pcSPS->getLadfNumIntervals() - 2, 2, "sps_num_ladf_intervals_minus2");
-    WRITE_SVLC(pcSPS->getLadfQpOffset(0), "sps_ladf_lowest_interval_qp_offset");
-    for (int k = 1; k < pcSPS->getLadfNumIntervals(); k++)
+    WRITE_CODE( pcSPS->getLadfNumIntervals() - 2, 2,                                           "sps_num_ladf_intervals_minus2" );
+    WRITE_SVLC( pcSPS->getLadfQpOffset( 0 ),                                                   "sps_ladf_lowest_interval_qp_offset");
+    for ( int k = 1; k< pcSPS->getLadfNumIntervals(); k++ )
     {
-      WRITE_SVLC(pcSPS->getLadfQpOffset(k), "sps_ladf_qp_offset");
-      WRITE_UVLC(pcSPS->getLadfIntervalLowerBound(k) - pcSPS->getLadfIntervalLowerBound(k - 1) - 1,
-                 "sps_ladf_delta_threshold_minus1");
+      WRITE_SVLC( pcSPS->getLadfQpOffset( k ),                                                 "sps_ladf_qp_offset" );
+      WRITE_UVLC( pcSPS->getLadfIntervalLowerBound( k ) - pcSPS->getLadfIntervalLowerBound( k - 1 ) - 1, "sps_ladf_delta_threshold_minus1" );
     }
   }
 #endif
@@ -1189,31 +1150,31 @@ void HLSWriter::codeSPS(const SPS *pcSPS)
 
   // KJS: reference picture sets to be replaced
 
+
   // KJS: remove scaling lists?
-  WRITE_FLAG(pcSPS->getScalingListFlag() ? 1 : 0, "sps_scaling_list_enabled_flag");
+  WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0,                                   "sps_scaling_list_enabled_flag" );
 
-  WRITE_FLAG(pcSPS->getLoopFilterAcrossVirtualBoundariesDisabledFlag(),
-             "sps_loop_filter_across_virtual_boundaries_disabled_present_flag");
-  if (pcSPS->getLoopFilterAcrossVirtualBoundariesDisabledFlag())
+  WRITE_FLAG( pcSPS->getLoopFilterAcrossVirtualBoundariesDisabledFlag(), "sps_loop_filter_across_virtual_boundaries_disabled_present_flag" );
+  if( pcSPS->getLoopFilterAcrossVirtualBoundariesDisabledFlag() )
   {
-    WRITE_CODE(pcSPS->getNumVerVirtualBoundaries(), 2, "sps_num_ver_virtual_boundaries");
-    for (unsigned i = 0; i < pcSPS->getNumVerVirtualBoundaries(); i++)
+    WRITE_CODE( pcSPS->getNumVerVirtualBoundaries(), 2, "sps_num_ver_virtual_boundaries");
+    for( unsigned i = 0; i < pcSPS->getNumVerVirtualBoundaries(); i++ )
     {
-      WRITE_CODE((pcSPS->getVirtualBoundariesPosX(i) >> 3), 13, "sps_virtual_boundaries_pos_x");
+      WRITE_CODE((pcSPS->getVirtualBoundariesPosX(i)>>3), 13, "sps_virtual_boundaries_pos_x");
     }
     WRITE_CODE(pcSPS->getNumHorVirtualBoundaries(), 2, "sps_num_hor_virtual_boundaries");
-    for (unsigned i = 0; i < pcSPS->getNumHorVirtualBoundaries(); i++)
+    for( unsigned i = 0; i < pcSPS->getNumHorVirtualBoundaries(); i++ )
     {
-      WRITE_CODE((pcSPS->getVirtualBoundariesPosY(i) >> 3), 13, "sps_virtual_boundaries_pos_y");
+      WRITE_CODE((pcSPS->getVirtualBoundariesPosY(i)>>3), 13, "sps_virtual_boundaries_pos_y");
     }
   }
 
   const TimingInfo *timingInfo = pcSPS->getTimingInfo();
-  WRITE_FLAG(pcSPS->getHrdParametersPresentFlag(), "general_hrd_parameters_present_flag");
-  if (pcSPS->getHrdParametersPresentFlag())
+  WRITE_FLAG(pcSPS->getHrdParametersPresentFlag(),          "general_hrd_parameters_present_flag");
+    if( pcSPS->getHrdParametersPresentFlag() )
   {
-    WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "num_units_in_tick");
-    WRITE_CODE(timingInfo->getTimeScale(), 32, "time_scale");
+    WRITE_CODE(timingInfo->getNumUnitsInTick(), 32,           "num_units_in_tick");
+    WRITE_CODE(timingInfo->getTimeScale(),      32,           "time_scale");
     WRITE_FLAG(pcSPS->getSubLayerParametersPresentFlag(), "sub_layer_cpb_parameters_present_flag");
     if (pcSPS->getSubLayerParametersPresentFlag())
     {
@@ -1225,41 +1186,45 @@ void HLSWriter::codeSPS(const SPS *pcSPS)
     }
   }
 
-  WRITE_FLAG(pcSPS->getVuiParametersPresentFlag(), "vui_parameters_present_flag");
+  WRITE_FLAG( pcSPS->getVuiParametersPresentFlag(),            "vui_parameters_present_flag" );
   if (pcSPS->getVuiParametersPresentFlag())
   {
     codeVUI(pcSPS->getVuiParameters(), pcSPS);
   }
 
-  bool sps_extension_present_flag                   = false;
-  bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS] = { false };
+  bool sps_extension_present_flag=false;
+  bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]={false};
 
   sps_extension_flags[SPS_EXT__REXT] = pcSPS->getSpsRangeExtension().settingsDifferFromDefaults();
 
   // Other SPS extension flags checked here.
 
-  for (int i = 0; i < NUM_SPS_EXTENSION_FLAGS; i++)
+  for(int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++)
   {
-    sps_extension_present_flag |= sps_extension_flags[i];
+    sps_extension_present_flag|=sps_extension_flags[i];
   }
 
-  WRITE_FLAG((sps_extension_present_flag ? 1 : 0), "sps_extension_present_flag");
+  WRITE_FLAG( (sps_extension_present_flag?1:0), "sps_extension_present_flag" );
 
   if (sps_extension_present_flag)
   {
 #if ENABLE_TRACING /*|| RExt__DECODER_DEBUG_BIT_STATISTICS*/
-    static const char *syntaxStrings[] = { "sps_range_extension_flag", "sps_multilayer_extension_flag",
-                                           "sps_extension_6bits[0]",   "sps_extension_6bits[1]",
-                                           "sps_extension_6bits[2]",   "sps_extension_6bits[3]",
-                                           "sps_extension_6bits[4]",   "sps_extension_6bits[5]" };
+    static const char *syntaxStrings[]={ "sps_range_extension_flag",
+      "sps_multilayer_extension_flag",
+      "sps_extension_6bits[0]",
+      "sps_extension_6bits[1]",
+      "sps_extension_6bits[2]",
+      "sps_extension_6bits[3]",
+      "sps_extension_6bits[4]",
+      "sps_extension_6bits[5]" };
 #endif
 
-    for (int i = 0; i < NUM_SPS_EXTENSION_FLAGS; i++)
+    for(int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++)
     {
-      WRITE_FLAG(sps_extension_flags[i] ? 1 : 0, syntaxStrings[i]);
+      WRITE_FLAG( sps_extension_flags[i]?1:0, syntaxStrings[i] );
     }
 
-    for (int i = 0; i < NUM_SPS_EXTENSION_FLAGS; i++)   // loop used so that the order is determined by the enum.
+    for(int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum.
     {
       if (sps_extension_flags[i])
       {
@@ -1267,30 +1232,21 @@ void HLSWriter::codeSPS(const SPS *pcSPS)
         {
         case SPS_EXT__REXT:
         {
-          const SPSRExt &spsRangeExtension = pcSPS->getSpsRangeExtension();
-
-          WRITE_FLAG((spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0),
-                     "transform_skip_rotation_enabled_flag");
-          WRITE_FLAG((spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0),
-                     "transform_skip_context_enabled_flag");
-          WRITE_FLAG((spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0),
-                     "implicit_rdpcm_enabled_flag");
-          WRITE_FLAG((spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0),
-                     "explicit_rdpcm_enabled_flag");
-          WRITE_FLAG((spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0),
-                     "extended_precision_processing_flag");
-          WRITE_FLAG((spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0), "intra_smoothing_disabled_flag");
-          WRITE_FLAG((spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0),
-                     "high_precision_offsets_enabled_flag");
-          WRITE_FLAG((spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0),
-                     "persistent_rice_adaptation_enabled_flag");
-          WRITE_FLAG((spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0),
-                     "cabac_bypass_alignment_enabled_flag");
+          const SPSRExt &spsRangeExtension=pcSPS->getSpsRangeExtension();
+
+          WRITE_FLAG( (spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0),      "transform_skip_rotation_enabled_flag");
+          WRITE_FLAG( (spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0),       "transform_skip_context_enabled_flag");
+          WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" );
+          WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" );
+          WRITE_FLAG( (spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0),       "extended_precision_processing_flag" );
+          WRITE_FLAG( (spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0),            "intra_smoothing_disabled_flag" );
+          WRITE_FLAG( (spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0),       "high_precision_offsets_enabled_flag" );
+          WRITE_FLAG( (spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0),   "persistent_rice_adaptation_enabled_flag" );
+          WRITE_FLAG( (spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0),       "cabac_bypass_alignment_enabled_flag" );
           break;
         }
         default:
-          CHECK(sps_extension_flags[i] != false,
-                "Unknown PPS extension signalled");   // Should never get here with an active SPS extension flag.
+          CHECK(sps_extension_flags[i]!=false, "Unknown PPS extension signalled"); // Should never get here with an active SPS extension flag.
           break;
         }
       }
@@ -1299,29 +1255,29 @@ void HLSWriter::codeSPS(const SPS *pcSPS)
   xWriteRbspTrailingBits();
 }
 
-void HLSWriter::codeDPS(const DPS *dps)
+void HLSWriter::codeDPS( const DPS* dps )
 {
 #if ENABLE_TRACING
   xTraceDPSHeader();
 #endif
-  WRITE_CODE(dps->getDecodingParameterSetId(), 4, "dps_decoding_parameter_set_id");
-  WRITE_CODE(dps->getMaxSubLayersMinus1(), 3, "dps_max_sub_layers_minus1");
-  WRITE_CODE(0, 5, "dps_reserved_zero_5bits");
+  WRITE_CODE( dps->getDecodingParameterSetId(),     4,        "dps_decoding_parameter_set_id" );
+  WRITE_CODE( dps->getMaxSubLayersMinus1(),         3,        "dps_max_sub_layers_minus1" );
+  WRITE_CODE( 0,                                    5,         "dps_reserved_zero_5bits" );
   uint32_t numPTLs = (uint32_t) dps->getNumPTLs();
-  CHECK(numPTLs < 1, "At least one PTL must be available in DPS");
+  CHECK (numPTLs<1, "At least one PTL must be available in DPS");
 
-  WRITE_CODE(numPTLs - 1, 4, "dps_num_ptls_minus1");
+  WRITE_CODE( numPTLs - 1,                          4,         "dps_num_ptls_minus1" );
 
-  for (int i = 0; i < numPTLs; i++)
+  for (int i=0; i< numPTLs; i++)
   {
     ProfileTierLevel ptl = dps->getProfileTierLevel(i);
-    codeProfileTierLevel(&ptl, dps->getMaxSubLayersMinus1());
+    codeProfileTierLevel( &ptl, dps->getMaxSubLayersMinus1() );
   }
-  WRITE_FLAG(0, "dps_extension_flag");
+  WRITE_FLAG( 0,                                              "dps_extension_flag" );
   xWriteRbspTrailingBits();
 }
 
-void HLSWriter::codeVPS(const VPS *pcVPS)
+void HLSWriter::codeVPS(const VPS* pcVPS)
 {
 #if ENABLE_TRACING
   xTraceVPSHeader();
@@ -1329,7 +1285,7 @@ void HLSWriter::codeVPS(const VPS *pcVPS)
   WRITE_CODE(pcVPS->getVPSId(), 4, "vps_video_parameter_set_id");
   WRITE_CODE(pcVPS->getMaxLayers() - 1, 6, "vps_max_layers_minus1");
   WRITE_CODE(pcVPS->getMaxSubLayers() - 1, 3, "vps_max_sublayers_minus1");
-  if (pcVPS->getMaxLayers() > 1 && pcVPS->getMaxSubLayers() > 1)
+  if (pcVPS->getMaxLayers() > 1 && pcVPS->getMaxSubLayers() > 1) 
   {
     WRITE_FLAG(pcVPS->getAllLayersSameNumSublayersFlag(), "vps_all_layers_same_num_sublayers_flag");
   }
@@ -1352,16 +1308,15 @@ void HLSWriter::codeVPS(const VPS *pcVPS)
       }
     }
   }
-  if (pcVPS->getMaxLayers() > 1)
+  if( pcVPS->getMaxLayers() > 1 )
   {
-    if (pcVPS->getAllIndependentLayersFlag())
+    if (pcVPS->getAllIndependentLayersFlag()) 
     {
       WRITE_FLAG(pcVPS->getEachLayerIsAnOlsFlag(), "vps_each_layer_is_an_ols_flag");
     }
-    if (!pcVPS->getEachLayerIsAnOlsFlag())
+    if (!pcVPS->getEachLayerIsAnOlsFlag()) 
     {
-      if (!pcVPS->getAllIndependentLayersFlag())
-      {
+      if (!pcVPS->getAllIndependentLayersFlag()) {
         WRITE_CODE(pcVPS->getOlsModeIdc(), 2, "vps_ols_mode_idc");
       }
       if (pcVPS->getOlsModeIdc() == 2)
@@ -1379,24 +1334,24 @@ void HLSWriter::codeVPS(const VPS *pcVPS)
   }
   WRITE_FLAG(0, "vps_extension_flag");
 
-  // future extensions here..
+  //future extensions here..
   xWriteRbspTrailingBits();
 }
 
 #if JVET_Q0775_PH_IN_SH
-void HLSWriter::codePictureHeader(PicHeader *picHeader, bool writeRbspTrailingBits)
+void HLSWriter::codePictureHeader( PicHeader* picHeader, bool writeRbspTrailingBits )
 #else
-void HLSWriter::codePictureHeader(PicHeader *picHeader)
+void HLSWriter::codePictureHeader( PicHeader* picHeader )
 #endif
 {
-  const PPS *pps = NULL;
-  const SPS *sps = NULL;
-
+  const PPS*  pps = NULL;
+  const SPS*  sps = NULL;
+  
 #if ENABLE_TRACING
-  xTracePictureHeader();
+  xTracePictureHeader ();
 #endif
 
-  CodingStructure &cs = *picHeader->getPic()->cs;
+  CodingStructure& cs = *picHeader->getPic()->cs;
 #if JVET_Q0819_PH_CHANGES
   // Q0781, two-flags
   WRITE_FLAG(picHeader->getPicInterSliceAllowedFlag(), "pic_inter_slice_allowed_flag");
@@ -1408,124 +1363,123 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
   WRITE_FLAG(picHeader->getNonReferencePictureFlag(), "non_reference_picture_flag");
   WRITE_FLAG(picHeader->getGdrPicFlag(), "gdr_pic_flag");
   WRITE_FLAG(picHeader->getNoOutputOfPriorPicsFlag(), "no_output_of_prior_pics_flag");
-  if (picHeader->getGdrPicFlag())
+  if( picHeader->getGdrPicFlag() ) 
   {
     WRITE_UVLC(picHeader->getRecoveryPocCnt(), "recovery_poc_cnt");
   }
-  else
+  else 
   {
-    picHeader->setRecoveryPocCnt(0);
+    picHeader->setRecoveryPocCnt( 0 );
   }
 
   // parameter sets
   WRITE_UVLC(picHeader->getPPSId(), "ph_pic_parameter_set_id");
   pps = cs.slice->getPPS();
-  CHECK(pps == 0, "Invalid PPS");
+  CHECK(pps==0, "Invalid PPS");  
   sps = cs.slice->getSPS();
-  CHECK(sps == 0, "Invalid SPS");
+  CHECK(sps==0, "Invalid SPS");
 #if JVET_Q0819_PH_CHANGES
   int pocBits = cs.slice->getSPS()->getBitsForPOC();
   int pocMask = (1 << pocBits) - 1;
   WRITE_CODE(cs.slice->getPOC() & pocMask, pocBits, "ph_pic_order_cnt_lsb");
 #endif
 
+  
   // sub-picture IDs
-  if (sps->getSubPicIdPresentFlag())
+  if( sps->getSubPicIdPresentFlag() ) 
   {
-    if (sps->getSubPicIdSignallingPresentFlag())
+    if( sps->getSubPicIdSignallingPresentFlag() ) 
     {
-      for (int picIdx = 0; picIdx < sps->getNumSubPics(); picIdx++)
+      for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ )
       {
-        picHeader->setSubPicId(picIdx, sps->getSubPicId(picIdx));
+        picHeader->setSubPicId( picIdx, sps->getSubPicId( picIdx ) );
       }
     }
-    else
+    else 
     {
       WRITE_FLAG(picHeader->getSubPicIdSignallingPresentFlag(), "ph_subpic_id_signalling_present_flag");
-      if (picHeader->getSubPicIdSignallingPresentFlag())
+      if( picHeader->getSubPicIdSignallingPresentFlag() )
       {
-        WRITE_UVLC(picHeader->getSubPicIdLen() - 1, "ph_subpic_id_len_minus1");
+        WRITE_UVLC( picHeader->getSubPicIdLen() - 1, "ph_subpic_id_len_minus1" );
 #if JVET_Q0169_SUBPIC_LEN_CONFORM
         CHECK((1 << picHeader->getSubPicIdLen()) < sps->getNumSubPics(), "ph_subpic_id_len exceeds valid range");
 #endif
-        for (int picIdx = 0; picIdx < sps->getNumSubPics(); picIdx++)
+        for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ )
         {
-          WRITE_CODE(picHeader->getSubPicId(picIdx), picHeader->getSubPicIdLen(), "ph_subpic_id[i]");
+          WRITE_CODE(picHeader->getSubPicId(picIdx), picHeader->getSubPicIdLen( ), "ph_subpic_id[i]" );
         }
       }
-      else
+      else 
       {
-        for (int picIdx = 0; picIdx < pps->getNumSubPics(); picIdx++)
+        for( int picIdx = 0; picIdx < pps->getNumSubPics( ); picIdx++ )
         {
-          picHeader->setSubPicId(picIdx, pps->getSubPicId(picIdx));
+          picHeader->setSubPicId( picIdx, pps->getSubPicId( picIdx ) );
         }
       }
     }
   }
-  else
+  else 
   {
-    for (int picIdx = 0; picIdx < sps->getNumSubPics(); picIdx++)
+    for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ )
     {
-      picHeader->setSubPicId(picIdx, picIdx);
+      picHeader->setSubPicId( picIdx, picIdx );
     }
   }
 
   // virtual boundaries
-  if (!sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag())
+  if( !sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag() )
   {
-    WRITE_FLAG(picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag(),
-               "ph_loop_filter_across_virtual_boundaries_disabled_present_flag");
-    if (picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag())
+    WRITE_FLAG( picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag(), "ph_loop_filter_across_virtual_boundaries_disabled_present_flag" );
+    if( picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag() )
     {
       WRITE_CODE(picHeader->getNumVerVirtualBoundaries(), 2, "ph_num_ver_virtual_boundaries");
-      for (unsigned i = 0; i < picHeader->getNumVerVirtualBoundaries(); i++)
+      for( unsigned i = 0; i < picHeader->getNumVerVirtualBoundaries(); i++ )
       {
         WRITE_CODE(picHeader->getVirtualBoundariesPosX(i) >> 3, 13, "ph_virtual_boundaries_pos_x");
       }
       WRITE_CODE(picHeader->getNumHorVirtualBoundaries(), 2, "ph_num_hor_virtual_boundaries");
-      for (unsigned i = 0; i < picHeader->getNumHorVirtualBoundaries(); i++)
+      for( unsigned i = 0; i < picHeader->getNumHorVirtualBoundaries(); i++ )
       {
-        WRITE_CODE(picHeader->getVirtualBoundariesPosY(i) >> 3, 13, "ph_virtual_boundaries_pos_y");
+        WRITE_CODE(picHeader->getVirtualBoundariesPosY(i)>>3, 13, "ph_virtual_boundaries_pos_y");
       }
     }
     else
     {
-      picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag(0);
-      picHeader->setNumVerVirtualBoundaries(0);
-      picHeader->setNumHorVirtualBoundaries(0);
+      picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag( 0 );
+      picHeader->setNumVerVirtualBoundaries( 0 );
+      picHeader->setNumHorVirtualBoundaries( 0 );
     }
   }
   else
   {
-    picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag(
-      sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag());
-    picHeader->setNumVerVirtualBoundaries(sps->getNumVerVirtualBoundaries());
-    picHeader->setNumHorVirtualBoundaries(sps->getNumHorVirtualBoundaries());
-    for (unsigned i = 0; i < 3; i++)
+    picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag( sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag() );
+    picHeader->setNumVerVirtualBoundaries( sps->getNumVerVirtualBoundaries() );
+    picHeader->setNumHorVirtualBoundaries( sps->getNumHorVirtualBoundaries() );
+    for( unsigned i = 0; i < 3; i++ ) 
     {
-      picHeader->setVirtualBoundariesPosX(sps->getVirtualBoundariesPosX(i), i);
-      picHeader->setVirtualBoundariesPosY(sps->getVirtualBoundariesPosY(i), i);
+      picHeader->setVirtualBoundariesPosX( sps->getVirtualBoundariesPosX(i), i );
+      picHeader->setVirtualBoundariesPosY( sps->getVirtualBoundariesPosY(i), i );
     }
   }
-
+  
 #if !JVET_Q0155_COLOUR_ID
   // 4:4:4 colour plane ID
-  if (sps->getSeparateColourPlaneFlag())
+  if( sps->getSeparateColourPlaneFlag() )
   {
-    WRITE_CODE(picHeader->getColourPlaneId(), 2, "colour_plane_id");
+    WRITE_CODE( picHeader->getColourPlaneId(), 2, "colour_plane_id" );
   }
-  else
+  else 
   {
-    picHeader->setColourPlaneId(0);
+    picHeader->setColourPlaneId( 0 );
   }
 #endif
-
+  
   // picture output flag
-  if (pps->getOutputFlagPresentFlag())
+  if( pps->getOutputFlagPresentFlag() )
   {
-    WRITE_FLAG(picHeader->getPicOutputFlag(), "pic_output_flag");
+    WRITE_FLAG( picHeader->getPicOutputFlag(), "pic_output_flag" );
   }
-  else
+  else 
   {
     picHeader->setPicOutputFlag(true);
   }
@@ -1534,18 +1488,18 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
 #if JVET_Q0819_PH_CHANGES
   if (pps->getRplInfoInPhFlag())
 #else
-  WRITE_FLAG(picHeader->getPicRplPresentFlag(), "pic_rpl_present_flag");
-  if (picHeader->getPicRplPresentFlag())
+  WRITE_FLAG(picHeader->getPicRplPresentFlag(), "pic_rpl_present_flag"); 
+  if( picHeader->getPicRplPresentFlag() )
 #endif
   {
     // List0 and List1
-    for (int listIdx = 0; listIdx < 2; listIdx++)
-    {
+    for(int listIdx = 0; listIdx < 2; listIdx++) 
+    {                 
       // copy L1 index from L0 index
       if (listIdx == 1 && !pps->getRpl1IdxPresentFlag())
       {
         picHeader->setRPL1idx(picHeader->getRPL0idx());
-      }
+      }      
       // RPL in picture header or SPS
       else if (sps->getNumRPL(listIdx) > 0)
       {
@@ -1553,54 +1507,52 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
         {
           WRITE_FLAG(picHeader->getRPLIdx(listIdx) != -1 ? 1 : 0, "pic_rpl_sps_flag[i]");
         }
-        else if (pps->getPPSRefPicListSPSIdc(listIdx) == 1)
+        else if (pps->getPPSRefPicListSPSIdc( listIdx ) == 1)
         {
-          picHeader->setRPLIdx(listIdx, -1);
+          picHeader->setRPLIdx( listIdx, -1);
         }
       }
-      else
+      else 
       {
-        picHeader->setRPLIdx(listIdx, -1);
+          picHeader->setRPLIdx( listIdx, -1 );
       }
 
       // use list from SPS
       if (picHeader->getRPLIdx(listIdx) != -1)
       {
-        if (listIdx == 1 && !pps->getRpl1IdxPresentFlag()) {}
-        else if (sps->getNumRPL(listIdx) > 1)
+        if (listIdx == 1 && !pps->getRpl1IdxPresentFlag())
+        {
+        }
+        else if (sps->getNumRPL( listIdx ) > 1)
         {
-          int numBits = ceilLog2(sps->getNumRPL(listIdx));
+          int numBits = ceilLog2(sps->getNumRPL( listIdx ));
           WRITE_CODE(picHeader->getRPLIdx(listIdx), numBits, "pic_rpl_idx[i]");
         }
         else
         {
-          picHeader->setRPLIdx(listIdx, 0);
+          picHeader->setRPLIdx( listIdx, 0 );
         }
-        picHeader->setRPL(listIdx, sps->getRPLList(listIdx)->getReferencePictureList(picHeader->getRPLIdx(listIdx)));
+        picHeader->setRPL( listIdx, sps->getRPLList( listIdx )->getReferencePictureList(picHeader->getRPLIdx(listIdx)));
       }
       // explicit RPL in picture header
       else
       {
-        xCodeRefPicList(picHeader->getRPL(listIdx), sps->getLongTermRefsPresent(), sps->getBitsForPOC(),
-                        !sps->getUseWP() && !sps->getUseWPBiPred());
+        xCodeRefPicList( picHeader->getRPL(listIdx), sps->getLongTermRefsPresent(), sps->getBitsForPOC(), !sps->getUseWP() && !sps->getUseWPBiPred() );
       }
 
       // POC MSB cycle signalling for LTRP
       if (picHeader->getRPL(listIdx)->getNumberOfLongtermPictures())
       {
-        for (int i = 0; i < picHeader->getRPL(listIdx)->getNumberOfLongtermPictures()
-                              + picHeader->getRPL(listIdx)->getNumberOfShorttermPictures();
-             i++)
+        for (int i = 0; i < picHeader->getRPL(listIdx)->getNumberOfLongtermPictures() + picHeader->getRPL(listIdx)->getNumberOfShorttermPictures(); i++)
         {
           if (picHeader->getRPL(listIdx)->isRefPicLongterm(i))
           {
             if (picHeader->getRPL(listIdx)->getLtrpInSliceHeaderFlag())
-            {
+            { 
               WRITE_CODE(picHeader->getRPL(listIdx)->getRefPicIdentifier(i), sps->getBitsForPOC(),
                          "pic_poc_lsb_lt[listIdx][rplsIdx][j]");
             }
-            WRITE_FLAG(picHeader->getLocalRPL(listIdx)->getDeltaPocMSBPresentFlag(i) ? 1 : 0,
-                       "pic_delta_poc_msb_present_flag[i][j]");
+            WRITE_FLAG(picHeader->getLocalRPL(listIdx)->getDeltaPocMSBPresentFlag(i) ? 1 : 0, "pic_delta_poc_msb_present_flag[i][j]");
             if (picHeader->getLocalRPL(listIdx)->getDeltaPocMSBPresentFlag(i))
             {
               WRITE_UVLC(picHeader->getLocalRPL(listIdx)->getDeltaPocMSBCycleLT(i), "pic_delta_poc_msb_cycle_lt[i][j]");
@@ -1627,113 +1579,99 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
 #endif
     if (picHeader->getSplitConsOverrideFlag())
     {
-      WRITE_UVLC(floorLog2(picHeader->getMinQTSize(I_SLICE)) - sps->getLog2MinCodingBlockSize(),
-                 "pic_log2_diff_min_qt_min_cb_intra_slice_luma");
+      WRITE_UVLC(floorLog2(picHeader->getMinQTSize(I_SLICE)) - sps->getLog2MinCodingBlockSize(), "pic_log2_diff_min_qt_min_cb_intra_slice_luma");
 #if !JVET_Q0819_PH_CHANGES
-      WRITE_UVLC(floorLog2(picHeader->getMinQTSize(P_SLICE)) - sps->getLog2MinCodingBlockSize(),
-                 "pic_log2_diff_min_qt_min_cb_inter_slice");
-      WRITE_UVLC(picHeader->getMaxMTTHierarchyDepth(P_SLICE), "pic_max_mtt_hierarchy_depth_inter_slice");
+      WRITE_UVLC(floorLog2(picHeader->getMinQTSize(P_SLICE)) - sps->getLog2MinCodingBlockSize(), "pic_log2_diff_min_qt_min_cb_inter_slice");
+      WRITE_UVLC(picHeader->getMaxMTTHierarchyDepth(P_SLICE),  "pic_max_mtt_hierarchy_depth_inter_slice");
 #endif
       WRITE_UVLC(picHeader->getMaxMTTHierarchyDepth(I_SLICE), "pic_max_mtt_hierarchy_depth_intra_slice_luma");
       if (picHeader->getMaxMTTHierarchyDepth(I_SLICE) != 0)
       {
-        WRITE_UVLC(floorLog2(picHeader->getMaxBTSize(I_SLICE)) - floorLog2(picHeader->getMinQTSize(I_SLICE)),
-                   "pic_log2_diff_max_bt_min_qt_intra_slice_luma");
-        WRITE_UVLC(floorLog2(picHeader->getMaxTTSize(I_SLICE)) - floorLog2(picHeader->getMinQTSize(I_SLICE)),
-                   "pic_log2_diff_max_tt_min_qt_intra_slice_luma");
+        WRITE_UVLC(floorLog2(picHeader->getMaxBTSize(I_SLICE)) - floorLog2(picHeader->getMinQTSize(I_SLICE)), "pic_log2_diff_max_bt_min_qt_intra_slice_luma");
+        WRITE_UVLC(floorLog2(picHeader->getMaxTTSize(I_SLICE)) - floorLog2(picHeader->getMinQTSize(I_SLICE)), "pic_log2_diff_max_tt_min_qt_intra_slice_luma");
       }
 
 #if !JVET_Q0819_PH_CHANGES
       if (picHeader->getMaxMTTHierarchyDepth(P_SLICE) != 0)
       {
-        WRITE_UVLC(floorLog2(picHeader->getMaxBTSize(P_SLICE)) - floorLog2(picHeader->getMinQTSize(P_SLICE)),
-                   "pic_log2_diff_max_bt_min_qt_inter_slice");
-        WRITE_UVLC(floorLog2(picHeader->getMaxTTSize(P_SLICE)) - floorLog2(picHeader->getMinQTSize(P_SLICE)),
-                   "pic_log2_diff_max_tt_min_qt_inter_slice");
+        WRITE_UVLC(floorLog2(picHeader->getMaxBTSize(P_SLICE)) - floorLog2(picHeader->getMinQTSize(P_SLICE)), "pic_log2_diff_max_bt_min_qt_inter_slice");
+        WRITE_UVLC(floorLog2(picHeader->getMaxTTSize(P_SLICE)) - floorLog2(picHeader->getMinQTSize(P_SLICE)), "pic_log2_diff_max_tt_min_qt_inter_slice");
       }
 #endif
       if (sps->getUseDualITree())
       {
-        WRITE_UVLC(floorLog2(picHeader->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)) - sps->getLog2MinCodingBlockSize(),
-                   "pic_log2_diff_min_qt_min_cb_intra_slice_chroma");
-        WRITE_UVLC(picHeader->getMaxMTTHierarchyDepth(I_SLICE, CHANNEL_TYPE_CHROMA),
-                   "pic_max_mtt_hierarchy_depth_intra_slice_chroma");
+        WRITE_UVLC(floorLog2(picHeader->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)) - sps->getLog2MinCodingBlockSize(), "pic_log2_diff_min_qt_min_cb_intra_slice_chroma");
+        WRITE_UVLC(picHeader->getMaxMTTHierarchyDepth(I_SLICE, CHANNEL_TYPE_CHROMA), "pic_max_mtt_hierarchy_depth_intra_slice_chroma");
         if (picHeader->getMaxMTTHierarchyDepth(I_SLICE, CHANNEL_TYPE_CHROMA) != 0)
         {
-          WRITE_UVLC(floorLog2(picHeader->getMaxBTSize(I_SLICE, CHANNEL_TYPE_CHROMA))
-                       - floorLog2(picHeader->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)),
-                     "pic_log2_diff_max_bt_min_qt_intra_slice_chroma");
-          WRITE_UVLC(floorLog2(picHeader->getMaxTTSize(I_SLICE, CHANNEL_TYPE_CHROMA))
-                       - floorLog2(picHeader->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)),
-                     "pic_log2_diff_max_tt_min_qt_intra_slice_chroma");
+          WRITE_UVLC(floorLog2(picHeader->getMaxBTSize(I_SLICE, CHANNEL_TYPE_CHROMA)) - floorLog2(picHeader->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)), "pic_log2_diff_max_bt_min_qt_intra_slice_chroma");
+          WRITE_UVLC(floorLog2(picHeader->getMaxTTSize(I_SLICE, CHANNEL_TYPE_CHROMA)) - floorLog2(picHeader->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)), "pic_log2_diff_max_tt_min_qt_intra_slice_chroma");
         }
       }
     }
   }
 #if !JVET_Q0819_PH_CHANGES
-  else
+  else 
   {
     picHeader->setSplitConsOverrideFlag(0);
   }
 
   // inherit constraint values from SPS
-  if (!sps->getSplitConsOverrideEnabledFlag() || !picHeader->getSplitConsOverrideFlag())
+  if (!sps->getSplitConsOverrideEnabledFlag() || !picHeader->getSplitConsOverrideFlag()) 
   {
-    picHeader->setMinQTSizes(sps->getMinQTSizes());
-    picHeader->setMaxMTTHierarchyDepths(sps->getMaxMTTHierarchyDepths());
-    picHeader->setMaxBTSizes(sps->getMaxBTSizes());
-    picHeader->setMaxTTSizes(sps->getMaxTTSizes());
+      picHeader->setMinQTSizes(sps->getMinQTSizes());
+      picHeader->setMaxMTTHierarchyDepths(sps->getMaxMTTHierarchyDepths());
+      picHeader->setMaxBTSizes(sps->getMaxBTSizes());
+      picHeader->setMaxTTSizes(sps->getMaxTTSizes());
   }
 #endif
 #if JVET_Q0819_PH_CHANGES
   if (picHeader->getPicIntraSliceAllowedFlag())
   {
 #endif
-    // delta quantization and chrom and chroma offset
+  // delta quantization and chrom and chroma offset
     if (pps->getUseDQP())
     {
-      WRITE_UVLC(picHeader->getCuQpDeltaSubdivIntra(), "pic_cu_qp_delta_subdiv_intra_slice");
+      WRITE_UVLC( picHeader->getCuQpDeltaSubdivIntra(), "pic_cu_qp_delta_subdiv_intra_slice" );
 #if !JVET_Q0819_PH_CHANGES
-      WRITE_UVLC(picHeader->getCuQpDeltaSubdivInter(), "pic_cu_qp_delta_subdiv_inter_slice");
+      WRITE_UVLC( picHeader->getCuQpDeltaSubdivInter(), "pic_cu_qp_delta_subdiv_inter_slice" );
 #endif
     }
-    else
+    else 
     {
-      picHeader->setCuQpDeltaSubdivIntra(0);
+      picHeader->setCuQpDeltaSubdivIntra( 0 );
 #if !JVET_Q0819_PH_CHANGES
-      picHeader->setCuQpDeltaSubdivInter(0);
+      picHeader->setCuQpDeltaSubdivInter( 0 );
 #endif
     }
     if (pps->getCuChromaQpOffsetEnabledFlag())
     {
-      WRITE_UVLC(picHeader->getCuChromaQpOffsetSubdivIntra(), "pic_cu_chroma_qp_offset_subdiv_intra_slice");
+      WRITE_UVLC( picHeader->getCuChromaQpOffsetSubdivIntra(), "pic_cu_chroma_qp_offset_subdiv_intra_slice" );
 #if !JVET_Q0819_PH_CHANGES
-      WRITE_UVLC(picHeader->getCuChromaQpOffsetSubdivInter(), "pic_cu_chroma_qp_offset_subdiv_inter_slice");
+      WRITE_UVLC( picHeader->getCuChromaQpOffsetSubdivInter(), "pic_cu_chroma_qp_offset_subdiv_inter_slice" );
 #endif
     }
-    else
+    else 
     {
-      picHeader->setCuChromaQpOffsetSubdivIntra(0);
+      picHeader->setCuChromaQpOffsetSubdivIntra( 0 );
 #if !JVET_Q0819_PH_CHANGES
-      picHeader->setCuChromaQpOffsetSubdivInter(0);
+      picHeader->setCuChromaQpOffsetSubdivInter( 0 );
 #endif
     }
 #if JVET_Q0819_PH_CHANGES
   }
 
+
   if (picHeader->getPicInterSliceAllowedFlag())
   {
     if (picHeader->getSplitConsOverrideFlag())
     {
-      WRITE_UVLC(floorLog2(picHeader->getMinQTSize(P_SLICE)) - sps->getLog2MinCodingBlockSize(),
-                 "pic_log2_diff_min_qt_min_cb_inter_slice");
+      WRITE_UVLC(floorLog2(picHeader->getMinQTSize(P_SLICE)) - sps->getLog2MinCodingBlockSize(), "pic_log2_diff_min_qt_min_cb_inter_slice");
       WRITE_UVLC(picHeader->getMaxMTTHierarchyDepth(P_SLICE), "pic_max_mtt_hierarchy_depth_inter_slice");
       if (picHeader->getMaxMTTHierarchyDepth(P_SLICE) != 0)
       {
-        WRITE_UVLC(floorLog2(picHeader->getMaxBTSize(P_SLICE)) - floorLog2(picHeader->getMinQTSize(P_SLICE)),
-                   "pic_log2_diff_max_bt_min_qt_inter_slice");
-        WRITE_UVLC(floorLog2(picHeader->getMaxTTSize(P_SLICE)) - floorLog2(picHeader->getMinQTSize(P_SLICE)),
-                   "pic_log2_diff_max_tt_min_qt_inter_slice");
+        WRITE_UVLC(floorLog2(picHeader->getMaxBTSize(P_SLICE)) - floorLog2(picHeader->getMinQTSize(P_SLICE)), "pic_log2_diff_max_bt_min_qt_inter_slice");
+        WRITE_UVLC(floorLog2(picHeader->getMaxTTSize(P_SLICE)) - floorLog2(picHeader->getMinQTSize(P_SLICE)), "pic_log2_diff_max_tt_min_qt_inter_slice");
       }
     }
 
@@ -1755,27 +1693,27 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
       picHeader->setCuChromaQpOffsetSubdivInter(0);
     }
 #endif
-    // temporal motion vector prediction
+  // temporal motion vector prediction
     if (sps->getSPSTemporalMVPEnabledFlag())
     {
-      WRITE_FLAG(picHeader->getEnableTMVPFlag(), "pic_temporal_mvp_enabled_flag");
+      WRITE_FLAG( picHeader->getEnableTMVPFlag(), "pic_temporal_mvp_enabled_flag" );
     }
     else
     {
       picHeader->setEnableTMVPFlag(false);
     }
 
-    // mvd L1 zero flag
+  // mvd L1 zero flag
     if (!pps->getPPSMvdL1ZeroIdc())
     {
       WRITE_FLAG(picHeader->getMvdL1ZeroFlag(), "pic_mvd_l1_zero_flag");
     }
     else
     {
-      picHeader->setMvdL1ZeroFlag(pps->getPPSMvdL1ZeroIdc() - 1);
+      picHeader->setMvdL1ZeroFlag( pps->getPPSMvdL1ZeroIdc() - 1 );
     }
-
-    // merge candidate list size
+   
+  // merge candidate list size
     if (!pps->getPPSSixMinusMaxNumMergeCandPlus1())
     {
       CHECK(picHeader->getMaxNumMergeCand() > MRG_MAX_NUM_CANDS, "More merge candidates signalled than supported");
@@ -1786,30 +1724,28 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
       picHeader->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - (pps->getPPSSixMinusMaxNumMergeCandPlus1() - 1));
     }
 
-    // subblock merge candidate list size
-    if (sps->getUseAffine())
+  // subblock merge candidate list size
+    if ( sps->getUseAffine() )
     {
-      CHECK(picHeader->getMaxNumAffineMergeCand() > AFFINE_MRG_MAX_NUM_CANDS,
-            "More affine merge candidates signalled than supported");
-      WRITE_UVLC(AFFINE_MRG_MAX_NUM_CANDS - picHeader->getMaxNumAffineMergeCand(),
-                 "pic_five_minus_max_num_subblock_merge_cand");
+      CHECK( picHeader->getMaxNumAffineMergeCand() > AFFINE_MRG_MAX_NUM_CANDS, "More affine merge candidates signalled than supported" );
+      WRITE_UVLC(AFFINE_MRG_MAX_NUM_CANDS - picHeader->getMaxNumAffineMergeCand(), "pic_five_minus_max_num_subblock_merge_cand");
     }
     else
     {
-      picHeader->setMaxNumAffineMergeCand(sps->getSBTMVPEnabledFlag() && picHeader->getEnableTMVPFlag());
+      picHeader->setMaxNumAffineMergeCand( sps->getSBTMVPEnabledFlag() && picHeader->getEnableTMVPFlag() );
     }
 
-    // full-pel MMVD flag
+  // full-pel MMVD flag
     if (sps->getFpelMmvdEnabledFlag())
     {
-      WRITE_FLAG(picHeader->getDisFracMMVD(), "pic_fpel_mmvd_enabled_flag");
+      WRITE_FLAG( picHeader->getDisFracMMVD(), "pic_fpel_mmvd_enabled_flag" );
     }
     else
     {
       picHeader->setDisFracMMVD(false);
     }
-
-    // picture level BDOF disable flags
+  
+  // picture level BDOF disable flags
     if (sps->getBdofControlPresentFlag())
     {
       WRITE_FLAG(picHeader->getDisBdofFlag(), "pic_disable_bdof_flag");
@@ -1819,7 +1755,7 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
       picHeader->setDisBdofFlag(0);
     }
 
-    // picture level DMVR disable flags
+  // picture level DMVR disable flags
     if (sps->getDmvrControlPresentFlag())
     {
       WRITE_FLAG(picHeader->getDisDmvrFlag(), "pic_disable_dmvr_flag");
@@ -1829,7 +1765,7 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
       picHeader->setDisDmvrFlag(0);
     }
 
-    // picture level PROF disable flags
+  // picture level PROF disable flags
     if (sps->getProfControlPresentFlag())
     {
       WRITE_FLAG(picHeader->getDisProfFlag(), "pic_disable_prof_flag");
@@ -1840,40 +1776,34 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
     }
 
 #if !JVET_Q0806
-    // triangle merge candidate list size
+  // triangle merge candidate list size
     if (sps->getUseTriangle() && picHeader->getMaxNumMergeCand() >= 2)
     {
       if (!pps->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1())
       {
-        CHECK(picHeader->getMaxNumMergeCand() < picHeader->getMaxNumTriangleCand(),
-              "Incorrrect max number of triangle candidates!");
-        WRITE_UVLC(picHeader->getMaxNumMergeCand() - picHeader->getMaxNumTriangleCand(),
-                   "pic_max_num_merge_cand_minus_max_num_triangle_cand");
+        CHECK(picHeader->getMaxNumMergeCand() < picHeader->getMaxNumTriangleCand(), "Incorrrect max number of triangle candidates!");
+        WRITE_UVLC(picHeader->getMaxNumMergeCand() - picHeader->getMaxNumTriangleCand(), "pic_max_num_merge_cand_minus_max_num_triangle_cand");
       }
       else
       {
-        picHeader->setMaxNumTriangleCand(
-          (uint32_t)(picHeader->getMaxNumMergeCand() - (pps->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1() - 1)));
-      }
+        picHeader->setMaxNumTriangleCand((uint32_t)(picHeader->getMaxNumMergeCand() - (pps->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1() - 1)));
+      }    
     }
 
 #else
   // geometric merge candidate list size
-  if (sps->getUseGeo() && picHeader->getMaxNumMergeCand() >= 2)
-  {
-    if (!pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1())
+    if (sps->getUseGeo() && picHeader->getMaxNumMergeCand() >= 2)
     {
-      CHECK(picHeader->getMaxNumMergeCand() < picHeader->getMaxNumGeoCand(),
-            "Incorrrect max number of gpm candidates!");
-      WRITE_UVLC(picHeader->getMaxNumMergeCand() - picHeader->getMaxNumGeoCand(),
-                 "pic_max_num_merge_cand_minus_max_num_gpm_cand");
-    }
-    else
-    {
-      picHeader->setMaxNumGeoCand(
-        (uint32_t)(picHeader->getMaxNumMergeCand() - (pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1() - 1)));
+      if (!pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1())
+      {
+        CHECK(picHeader->getMaxNumMergeCand() < picHeader->getMaxNumGeoCand(), "Incorrrect max number of gpm candidates!");
+        WRITE_UVLC(picHeader->getMaxNumMergeCand() - picHeader->getMaxNumGeoCand(), "pic_max_num_merge_cand_minus_max_num_gpm_cand");
+      }
+      else
+      {
+      picHeader->setMaxNumGeoCand((uint32_t)(picHeader->getMaxNumMergeCand() - (pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1() - 1)));
+      }
     }
-  }
 #endif
 #if JVET_Q0819_PH_CHANGES
   }
@@ -1889,15 +1819,14 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
   // ibc merge candidate list size
   if (sps->getIBCFlag())
   {
-    CHECK(picHeader->getMaxNumIBCMergeCand() > IBC_MRG_MAX_NUM_CANDS,
-          "More IBC merge candidates signalled than supported");
+    CHECK( picHeader->getMaxNumIBCMergeCand() > IBC_MRG_MAX_NUM_CANDS, "More IBC merge candidates signalled than supported" );
     WRITE_UVLC(IBC_MRG_MAX_NUM_CANDS - picHeader->getMaxNumIBCMergeCand(), "pic_six_minus_max_num_ibc_merge_cand");
   }
 
 #if JVET_Q0819_PH_CHANGES
   if ((pps->getUseWP() || pps->getWPBiPred()) && pps->getWpInfoInPhFlag())
   {
-    xCodePredWeightTable(NULL, picHeader, sps);
+    xCodePredWeightTable(picHeader, sps);
   }
 #endif
 
@@ -1911,7 +1840,7 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
   // joint Cb/Cr sign flag
   if (sps->getJointCbCrEnabledFlag())
   {
-    WRITE_FLAG(picHeader->getJointCbCrSignFlag(), "pic_joint_cbcr_sign_flag");
+    WRITE_FLAG( picHeader->getJointCbCrSignFlag(), "pic_joint_cbcr_sign_flag" );
   }
   else
   {
@@ -1919,7 +1848,7 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
   }
 
   // sao enable flags
-  if (sps->getSAOEnabledFlag())
+  if(sps->getSAOEnabledFlag())
   {
 #if JVET_Q0819_PH_CHANGES
     if (pps->getSaoInfoInPhFlag())
@@ -1927,11 +1856,11 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
     WRITE_FLAG(picHeader->getSaoEnabledPresentFlag(), "pic_sao_enabled_present_flag");
     if (picHeader->getSaoEnabledPresentFlag())
 #endif
-    {
+    {    
 #if JVET_Q0819_PH_CHANGES
       WRITE_FLAG(picHeader->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "ph_sao_luma_enabled_flag");
 #else
-      WRITE_FLAG(picHeader->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "slice_sao_luma_flag");
+      WRITE_FLAG(picHeader->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "slice_sao_luma_flag");  
 #endif
       if (sps->getChromaFormatIdc() != CHROMA_400)
       {
@@ -1942,40 +1871,39 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
 #endif
       }
     }
-    else
+    else 
     {
-      picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, true);
+      picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA,   true);
       picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, true);
     }
   }
-  else
+  else 
   {
-    picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, false);
+    picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA,   false);
     picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false);
   }
-
+  
   // alf enable flags and aps IDs
-  if (sps->getALFEnabledFlag())
+  if( sps->getALFEnabledFlag() )
   {
 #if JVET_Q0819_PH_CHANGES
     if (pps->getAlfInfoInPhFlag())
 #else
     WRITE_FLAG(picHeader->getAlfEnabledPresentFlag(), "pic_alf_enabled_present_flag");
-    if (picHeader->getAlfEnabledPresentFlag())
+    if (picHeader->getAlfEnabledPresentFlag()) 
 #endif
     {
       WRITE_FLAG(picHeader->getAlfEnabledFlag(COMPONENT_Y), "pic_alf_enabled_flag");
       if (picHeader->getAlfEnabledFlag(COMPONENT_Y))
       {
         WRITE_CODE(picHeader->getNumAlfAps(), 3, "pic_num_alf_aps_ids_luma");
-        const std::vector<int> &apsId = picHeader->getAlfAPSs();
+        const std::vector<int>&   apsId = picHeader->getAlfAPSs();
         for (int i = 0; i < picHeader->getNumAlfAps(); i++)
         {
           WRITE_CODE(apsId[i], 3, "pic_alf_aps_id_luma");
         }
-
-        const int alfChromaIdc =
-          picHeader->getAlfEnabledFlag(COMPONENT_Cb) + picHeader->getAlfEnabledFlag(COMPONENT_Cr) * 2;
+        
+        const int alfChromaIdc = picHeader->getAlfEnabledFlag(COMPONENT_Cb) + picHeader->getAlfEnabledFlag(COMPONENT_Cr) * 2 ;
         if (sps->getChromaFormatIdc() != CHROMA_400)
         {
           WRITE_CODE(alfChromaIdc, 2, "pic_alf_chroma_idc");
@@ -2001,9 +1929,9 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
 #endif
       }
     }
-    else
+    else 
     {
-      picHeader->setAlfEnabledFlag(COMPONENT_Y, true);
+      picHeader->setAlfEnabledFlag(COMPONENT_Y,  true);
       picHeader->setAlfEnabledFlag(COMPONENT_Cb, true);
       picHeader->setAlfEnabledFlag(COMPONENT_Cr, true);
 #if JVET_Q0795_CCALF
@@ -2012,9 +1940,9 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
 #endif
     }
   }
-  else
+  else 
   {
-    picHeader->setAlfEnabledFlag(COMPONENT_Y, false);
+    picHeader->setAlfEnabledFlag(COMPONENT_Y,  false);
     picHeader->setAlfEnabledFlag(COMPONENT_Cb, false);
     picHeader->setAlfEnabledFlag(COMPONENT_Cr, false);
 #if JVET_Q0795_CCALF
@@ -2030,13 +1958,13 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
   }
   else
   {
-    picHeader->setDepQuantEnabledFlag(pps->getPPSDepQuantEnabledIdc() - 1);
+    picHeader->setDepQuantEnabledFlag( pps->getPPSDepQuantEnabledIdc() - 1 );
   }
 
   // sign data hiding
-  if (!picHeader->getDepQuantEnabledFlag())
+  if( !picHeader->getDepQuantEnabledFlag() )
   {
-    WRITE_FLAG(picHeader->getSignDataHidingEnabledFlag(), "pic_sign_data_hiding_enabled_flag");
+    WRITE_FLAG( picHeader->getSignDataHidingEnabledFlag(), "pic_sign_data_hiding_enabled_flag" );
   }
   else
   {
@@ -2046,19 +1974,19 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
   // deblocking filter controls
   if (pps->getDeblockingFilterControlPresentFlag())
   {
-    if (pps->getDeblockingFilterOverrideEnabledFlag())
-    {
+    if(pps->getDeblockingFilterOverrideEnabledFlag())
+    {    
 #if JVET_Q0819_PH_CHANGES
       if (pps->getDbfInfoInPhFlag())
 #else
-      WRITE_FLAG(picHeader->getDeblockingFilterOverridePresentFlag(), "pic_deblocking_filter_override_present_flag");
-      if (picHeader->getDeblockingFilterOverridePresentFlag())
+      WRITE_FLAG(picHeader->getDeblockingFilterOverridePresentFlag(), "pic_deblocking_filter_override_present_flag");    
+      if( picHeader->getDeblockingFilterOverridePresentFlag() ) 
 #endif
       {
-        WRITE_FLAG(picHeader->getDeblockingFilterOverrideFlag(), "pic_deblocking_filter_override_flag");
+        WRITE_FLAG ( picHeader->getDeblockingFilterOverrideFlag(), "pic_deblocking_filter_override_flag" );
       }
       else
-      {
+      {    
         picHeader->setDeblockingFilterOverrideFlag(false);
       }
     }
@@ -2070,51 +1998,51 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
       picHeader->setDeblockingFilterOverrideFlag(false);
     }
 
-    if (picHeader->getDeblockingFilterOverrideFlag())
+    if(picHeader->getDeblockingFilterOverrideFlag())
     {
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-      WRITE_FLAG(picHeader->getDeblockingFilterDisable(), "ph_deblocking_filter_disabled_flag");
-      if (!picHeader->getDeblockingFilterDisable())
+      WRITE_FLAG( picHeader->getDeblockingFilterDisable(), "ph_deblocking_filter_disabled_flag" );
+      if( !picHeader->getDeblockingFilterDisable() )
       {
-        WRITE_SVLC(picHeader->getDeblockingFilterBetaOffsetDiv2(), "ph_beta_offset_div2");
-        WRITE_SVLC(picHeader->getDeblockingFilterTcOffsetDiv2(), "ph_tc_offset_div2");
-        WRITE_SVLC(picHeader->getDeblockingFilterBetaOffsetDiv2(), "ph_cb_beta_offset_div2");
-        WRITE_SVLC(picHeader->getDeblockingFilterTcOffsetDiv2(), "ph_cb_tc_offset_div2");
-        WRITE_SVLC(picHeader->getDeblockingFilterBetaOffsetDiv2(), "ph_cr_beta_offset_div2");
-        WRITE_SVLC(picHeader->getDeblockingFilterTcOffsetDiv2(), "ph_cr_tc_offset_div2");
+        WRITE_SVLC( picHeader->getDeblockingFilterBetaOffsetDiv2(), "ph_beta_offset_div2" );
+        WRITE_SVLC( picHeader->getDeblockingFilterTcOffsetDiv2(), "ph_tc_offset_div2" );
+        WRITE_SVLC( picHeader->getDeblockingFilterBetaOffsetDiv2(), "ph_cb_beta_offset_div2" );
+        WRITE_SVLC( picHeader->getDeblockingFilterTcOffsetDiv2(), "ph_cb_tc_offset_div2" );
+        WRITE_SVLC( picHeader->getDeblockingFilterBetaOffsetDiv2(), "ph_cr_beta_offset_div2" );
+        WRITE_SVLC( picHeader->getDeblockingFilterTcOffsetDiv2(), "ph_cr_tc_offset_div2" );
       }
 #else
-      WRITE_FLAG(picHeader->getDeblockingFilterDisable(), "pic_deblocking_filter_disabled_flag");
-      if (!picHeader->getDeblockingFilterDisable())
+      WRITE_FLAG ( picHeader->getDeblockingFilterDisable(), "pic_deblocking_filter_disabled_flag" );
+      if(!picHeader->getDeblockingFilterDisable())
       {
-        WRITE_SVLC(picHeader->getDeblockingFilterBetaOffsetDiv2(), "pic_beta_offset_div2");
-        WRITE_SVLC(picHeader->getDeblockingFilterTcOffsetDiv2(), "pic_tc_offset_div2");
+        WRITE_SVLC( picHeader->getDeblockingFilterBetaOffsetDiv2(), "pic_beta_offset_div2" );
+        WRITE_SVLC( picHeader->getDeblockingFilterTcOffsetDiv2(), "pic_tc_offset_div2" );
       }
 #endif
     }
     else
     {
-      picHeader->setDeblockingFilterDisable(pps->getPPSDeblockingFilterDisabledFlag());
-      picHeader->setDeblockingFilterBetaOffsetDiv2(pps->getDeblockingFilterBetaOffsetDiv2());
-      picHeader->setDeblockingFilterTcOffsetDiv2(pps->getDeblockingFilterTcOffsetDiv2());
+      picHeader->setDeblockingFilterDisable       ( pps->getPPSDeblockingFilterDisabledFlag() );
+      picHeader->setDeblockingFilterBetaOffsetDiv2( pps->getDeblockingFilterBetaOffsetDiv2() );
+      picHeader->setDeblockingFilterTcOffsetDiv2  ( pps->getDeblockingFilterTcOffsetDiv2() );
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-      picHeader->setDeblockingFilterCbBetaOffsetDiv2(pps->getDeblockingFilterCbBetaOffsetDiv2());
-      picHeader->setDeblockingFilterCbTcOffsetDiv2(pps->getDeblockingFilterCbTcOffsetDiv2());
-      picHeader->setDeblockingFilterCrBetaOffsetDiv2(pps->getDeblockingFilterCrBetaOffsetDiv2());
-      picHeader->setDeblockingFilterCrTcOffsetDiv2(pps->getDeblockingFilterCrTcOffsetDiv2());
+      picHeader->setDeblockingFilterCbBetaOffsetDiv2( pps->getDeblockingFilterCbBetaOffsetDiv2() );
+      picHeader->setDeblockingFilterCbTcOffsetDiv2  ( pps->getDeblockingFilterCbTcOffsetDiv2() );
+      picHeader->setDeblockingFilterCrBetaOffsetDiv2( pps->getDeblockingFilterCrBetaOffsetDiv2() );
+      picHeader->setDeblockingFilterCrTcOffsetDiv2  ( pps->getDeblockingFilterCrTcOffsetDiv2() );
 #endif
     }
   }
   else
   {
-    picHeader->setDeblockingFilterDisable(false);
-    picHeader->setDeblockingFilterBetaOffsetDiv2(0);
-    picHeader->setDeblockingFilterTcOffsetDiv2(0);
+    picHeader->setDeblockingFilterDisable       ( false );
+    picHeader->setDeblockingFilterBetaOffsetDiv2( 0 );
+    picHeader->setDeblockingFilterTcOffsetDiv2  ( 0 );
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-    picHeader->setDeblockingFilterCbBetaOffsetDiv2(0);
-    picHeader->setDeblockingFilterCbTcOffsetDiv2(0);
-    picHeader->setDeblockingFilterCrBetaOffsetDiv2(0);
-    picHeader->setDeblockingFilterCrTcOffsetDiv2(0);
+    picHeader->setDeblockingFilterCbBetaOffsetDiv2( 0 );
+    picHeader->setDeblockingFilterCbTcOffsetDiv2  ( 0 );
+    picHeader->setDeblockingFilterCrBetaOffsetDiv2( 0 );
+    picHeader->setDeblockingFilterCrTcOffsetDiv2  ( 0 );
 #endif
   }
 
@@ -2142,27 +2070,27 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
   }
 
   // quantization scaling lists
-  if (sps->getScalingListFlag())
+  if( sps->getScalingListFlag() )
   {
-    WRITE_FLAG(picHeader->getScalingListPresentFlag(), "pic_scaling_list_present_flag");
-    if (picHeader->getScalingListPresentFlag())
+    WRITE_FLAG( picHeader->getScalingListPresentFlag(), "pic_scaling_list_present_flag" );
+    if( picHeader->getScalingListPresentFlag() )
     {
-      WRITE_CODE(picHeader->getScalingListAPSId(), 3, "pic_scaling_list_aps_id");
+      WRITE_CODE( picHeader->getScalingListAPSId(), 3, "pic_scaling_list_aps_id" );
     }
   }
-  else
+  else 
   {
-    picHeader->setScalingListPresentFlag(false);
+    picHeader->setScalingListPresentFlag( false );
   }
 
   // picture header extension
-  if (pps->getPictureHeaderExtensionPresentFlag())
+  if(pps->getPictureHeaderExtensionPresentFlag())
   {
-    WRITE_UVLC(0, "pic_segment_header_extension_length");
+    WRITE_UVLC(0,"pic_segment_header_extension_length");
   }
-
+  
 #if JVET_Q0775_PH_IN_SH
-  if (writeRbspTrailingBits)
+  if ( writeRbspTrailingBits )
   {
     xWriteRbspTrailingBits();
   }
@@ -2171,20 +2099,20 @@ void HLSWriter::codePictureHeader(PicHeader *picHeader)
 #endif
 }
 
-void HLSWriter::codeSliceHeader(Slice *pcSlice)
+void HLSWriter::codeSliceHeader         ( Slice* pcSlice )
 {
 #if ENABLE_TRACING
-  xTraceSliceHeader();
+  xTraceSliceHeader ();
 #endif
 
-  CodingStructure &cs = *pcSlice->getPic()->cs;
+  CodingStructure& cs = *pcSlice->getPic()->cs;
 #if JVET_Q0775_PH_IN_SH
   PicHeader *picHeader = cs.picHeader;
 #else
   const PicHeader *picHeader = cs.picHeader;
 #endif
   const ChromaFormat format                = pcSlice->getSPS()->getChromaFormatIdc();
-  const uint32_t     numberValidComponents = getNumberValidComponents(format);
+  const uint32_t         numberValidComponents = getNumberValidComponents(format);
   const bool         chromaEnabled         = isChromaEnabled(format);
 #if JVET_Q0775_PH_IN_SH
   WRITE_FLAG(pcSlice->getPictureHeaderInSliceHeader() ? 1 : 0, "picture_header_in_slice_header_flag");
@@ -2222,25 +2150,24 @@ void HLSWriter::codeSliceHeader(Slice *pcSlice)
   }
 
   // raster scan slices
-  if (pcSlice->getPPS()->getRectSliceFlag() == 0)
+  if( pcSlice->getPPS()->getRectSliceFlag() == 0 ) 
   {
     // slice address is the raster scan tile index of first tile in slice
-    if (pcSlice->getPPS()->getNumTiles() > 1)
-    {
+    if( pcSlice->getPPS()->getNumTiles() > 1 ) 
+    {      
       int bitsSliceAddress = ceilLog2(pcSlice->getPPS()->getNumTiles());
-      WRITE_CODE(pcSlice->getSliceID(), bitsSliceAddress, "slice_address");
-      WRITE_UVLC(pcSlice->getNumTilesInSlice() - 1, "num_tiles_in_slice_minus1");
+      WRITE_CODE( pcSlice->getSliceID(), bitsSliceAddress, "slice_address");
+      WRITE_UVLC( pcSlice->getNumTilesInSlice() - 1, "num_tiles_in_slice_minus1");
     }
   }
   // rectangular slices
-  else
+  else 
   {
     // slice address is the index of the slice within the current sub-picture
-    if (pcSlice->getPPS()->getNumSlicesInPic() > 1)
+    if( pcSlice->getPPS()->getNumSlicesInPic() > 1 ) 
     {
-      int bitsSliceAddress =
-        ceilLog2(pcSlice->getPPS()->getNumSlicesInPic());   // change to NumSlicesInSubPic when available
-      WRITE_CODE(pcSlice->getSliceID(), bitsSliceAddress, "slice_address");
+      int bitsSliceAddress = ceilLog2(pcSlice->getPPS()->getNumSlicesInPic());  // change to NumSlicesInSubPic when available
+      WRITE_CODE( pcSlice->getSliceID(), bitsSliceAddress, "slice_address");
     }
   }
 
@@ -2257,407 +2184,389 @@ void HLSWriter::codeSliceHeader(Slice *pcSlice)
   }
 #endif
 #if JVET_Q0155_COLOUR_ID
-  // 4:4:4 colour plane ID
-  if (pcSlice->getSPS()->getSeparateColourPlaneFlag())
-  {
-    WRITE_CODE(pcSlice->getColourPlaneId(), 2, "colour_plane_id");
-  }
+    // 4:4:4 colour plane ID
+    if( pcSlice->getSPS()->getSeparateColourPlaneFlag() )
+    {
+      WRITE_CODE( pcSlice->getColourPlaneId(), 2, "colour_plane_id" );
+    }
 #endif
 
 #if JVET_Q0819_PH_CHANGES
-  if (!pcSlice->getPPS()->getRplInfoInPhFlag()
-      && (!pcSlice->getIdrPicFlag() || pcSlice->getSPS()->getIDRRefParamListPresent()))
+  if( !pcSlice->getPPS()->getRplInfoInPhFlag() && (!pcSlice->getIdrPicFlag() || pcSlice->getSPS()->getIDRRefParamListPresent()))
 #else
-  if (!picHeader->getPicRplPresentFlag()
-      && (!pcSlice->getIdrPicFlag() || pcSlice->getSPS()->getIDRRefParamListPresent()))
+    if( !picHeader->getPicRplPresentFlag() && (!pcSlice->getIdrPicFlag() || pcSlice->getSPS()->getIDRRefParamListPresent()) )
 #endif
-  {
-    // Write L0 related syntax elements
-    if (pcSlice->getSPS()->getNumRPL0() > 0)
     {
-      if (!pcSlice->getPPS()->getPPSRefPicListSPSIdc0())
+      //Write L0 related syntax elements
+      if (pcSlice->getSPS()->getNumRPL0() > 0)
       {
-        WRITE_FLAG(pcSlice->getRPL0idx() != -1 ? 1 : 0, "ref_pic_list_sps_flag[0]");
-      }
-    }
-    if (pcSlice->getRPL0idx() != -1)
-    {
-      if (pcSlice->getSPS()->getNumRPL0() > 1)
-      {
-        int numBits = 0;
-        while ((1 << numBits) < pcSlice->getSPS()->getNumRPL0())
+        if (!pcSlice->getPPS()->getPPSRefPicListSPSIdc0())
         {
-          numBits++;
+          WRITE_FLAG(pcSlice->getRPL0idx() != -1 ? 1 : 0, "ref_pic_list_sps_flag[0]");
         }
-        WRITE_CODE(pcSlice->getRPL0idx(), numBits, "ref_pic_list_idx[0]");
       }
-    }
-    else
-    {   // write local RPL0
-      xCodeRefPicList(pcSlice->getRPL0(), pcSlice->getSPS()->getLongTermRefsPresent(),
-                      pcSlice->getSPS()->getBitsForPOC(),
-                      !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred());
-    }
-    // Deal POC Msb cycle signalling for LTRP
-    if (pcSlice->getRPL0()->getNumberOfLongtermPictures())
-    {
-      for (int i = 0;
-           i < pcSlice->getRPL0()->getNumberOfLongtermPictures() + pcSlice->getRPL0()->getNumberOfShorttermPictures();
-           i++)
+      if (pcSlice->getRPL0idx() != -1)
       {
-        if (pcSlice->getRPL0()->isRefPicLongterm(i))
+        if (pcSlice->getSPS()->getNumRPL0() > 1)
         {
-          if (pcSlice->getRPL0()->getLtrpInSliceHeaderFlag())
+          int numBits = 0;
+          while ((1 << numBits) < pcSlice->getSPS()->getNumRPL0())
           {
-            WRITE_CODE(pcSlice->getRPL0()->getRefPicIdentifier(i), pcSlice->getSPS()->getBitsForPOC(),
-                       "slice_poc_lsb_lt[listIdx][rplsIdx][j]");
+            numBits++;
           }
-          WRITE_FLAG(pcSlice->getLocalRPL0()->getDeltaPocMSBPresentFlag(i) ? 1 : 0, "delta_poc_msb_present_flag[i][j]");
-          if (pcSlice->getLocalRPL0()->getDeltaPocMSBPresentFlag(i))
+          WRITE_CODE(pcSlice->getRPL0idx(), numBits, "ref_pic_list_idx[0]");
+        }
+      }
+      else
+      {  //write local RPL0
+        xCodeRefPicList( pcSlice->getRPL0(), pcSlice->getSPS()->getLongTermRefsPresent(), pcSlice->getSPS()->getBitsForPOC(), !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred() );
+      }
+      //Deal POC Msb cycle signalling for LTRP
+      if (pcSlice->getRPL0()->getNumberOfLongtermPictures())
+      {
+        for (int i = 0; i < pcSlice->getRPL0()->getNumberOfLongtermPictures() + pcSlice->getRPL0()->getNumberOfShorttermPictures(); i++)
+        {
+          if (pcSlice->getRPL0()->isRefPicLongterm(i))
           {
-            WRITE_UVLC(pcSlice->getLocalRPL0()->getDeltaPocMSBCycleLT(i), "delta_poc_msb_cycle_lt[i][j]");
+            if (pcSlice->getRPL0()->getLtrpInSliceHeaderFlag())
+            {
+              WRITE_CODE(pcSlice->getRPL0()->getRefPicIdentifier(i), pcSlice->getSPS()->getBitsForPOC(),
+                         "slice_poc_lsb_lt[listIdx][rplsIdx][j]");
+            }
+            WRITE_FLAG(pcSlice->getLocalRPL0()->getDeltaPocMSBPresentFlag(i) ? 1 : 0, "delta_poc_msb_present_flag[i][j]");
+            if (pcSlice->getLocalRPL0()->getDeltaPocMSBPresentFlag(i))
+            {
+              WRITE_UVLC(pcSlice->getLocalRPL0()->getDeltaPocMSBCycleLT(i), "delta_poc_msb_cycle_lt[i][j]");
+            }
           }
         }
       }
-    }
 
-    // Write L1 related syntax elements
-    if (!pcSlice->getPPS()->getRpl1IdxPresentFlag())
-    {
-      CHECK(pcSlice->getRPL1idx() != pcSlice->getRPL0idx(),
-            "RPL1Idx is not signalled but it is not the same as RPL0Idx");
-      if (pcSlice->getRPL1idx() == -1)
-      {   // write local RPL1
-        xCodeRefPicList(pcSlice->getRPL1(), pcSlice->getSPS()->getLongTermRefsPresent(),
-                        pcSlice->getSPS()->getBitsForPOC(),
-                        !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred());
+      //Write L1 related syntax elements
+      if (!pcSlice->getPPS()->getRpl1IdxPresentFlag())
+      {
+        CHECK(pcSlice->getRPL1idx() != pcSlice->getRPL0idx(), "RPL1Idx is not signalled but it is not the same as RPL0Idx");
+        if (pcSlice->getRPL1idx() == -1)
+        {  //write local RPL1
+          xCodeRefPicList( pcSlice->getRPL1(), pcSlice->getSPS()->getLongTermRefsPresent(), pcSlice->getSPS()->getBitsForPOC(), !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred() );
+        }
       }
-    }
-    else
-    {
-      if (pcSlice->getSPS()->getNumRPL1() > 0)
+      else
       {
+        if (pcSlice->getSPS()->getNumRPL1() > 0)
+        {
         if (!pcSlice->getPPS()->getPPSRefPicListSPSIdc1())
         {
           WRITE_FLAG(pcSlice->getRPL1idx() != -1 ? 1 : 0, "ref_pic_list_sps_flag[1]");
         }
-      }
-      if (pcSlice->getRPL1idx() != -1)
-      {
-        if (pcSlice->getSPS()->getNumRPL1() > 1)
+        }
+        if (pcSlice->getRPL1idx() != -1)
         {
-          int numBits = 0;
-          while ((1 << numBits) < pcSlice->getSPS()->getNumRPL1())
+          if (pcSlice->getSPS()->getNumRPL1() > 1)
           {
-            numBits++;
+            int numBits = 0;
+            while ((1 << numBits) < pcSlice->getSPS()->getNumRPL1())
+            {
+              numBits++;
+            }
+            WRITE_CODE(pcSlice->getRPL1idx(), numBits, "ref_pic_list_idx[1]");
           }
-          WRITE_CODE(pcSlice->getRPL1idx(), numBits, "ref_pic_list_idx[1]");
+        }
+        else
+        {  //write local RPL1
+          xCodeRefPicList( pcSlice->getRPL1(), pcSlice->getSPS()->getLongTermRefsPresent(), pcSlice->getSPS()->getBitsForPOC(), !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred() );
         }
       }
-      else
-      {   // write local RPL1
-        xCodeRefPicList(pcSlice->getRPL1(), pcSlice->getSPS()->getLongTermRefsPresent(),
-                        pcSlice->getSPS()->getBitsForPOC(),
-                        !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred());
-      }
-    }
-    // Deal POC Msb cycle signalling for LTRP
-    if (pcSlice->getRPL1()->getNumberOfLongtermPictures())
-    {
-      for (int i = 0;
-           i < pcSlice->getRPL1()->getNumberOfLongtermPictures() + pcSlice->getRPL1()->getNumberOfShorttermPictures();
-           i++)
+      //Deal POC Msb cycle signalling for LTRP
+      if (pcSlice->getRPL1()->getNumberOfLongtermPictures())
       {
-        if (pcSlice->getRPL1()->isRefPicLongterm(i))
+        for (int i = 0; i < pcSlice->getRPL1()->getNumberOfLongtermPictures() + pcSlice->getRPL1()->getNumberOfShorttermPictures(); i++)
         {
-          if (pcSlice->getRPL1()->getLtrpInSliceHeaderFlag())
+          if (pcSlice->getRPL1()->isRefPicLongterm(i))
           {
-            WRITE_CODE(pcSlice->getRPL1()->getRefPicIdentifier(i), pcSlice->getSPS()->getBitsForPOC(),
-                       "slice_poc_lsb_lt[listIdx][rplsIdx][j]");
-          }
-          WRITE_FLAG(pcSlice->getLocalRPL1()->getDeltaPocMSBPresentFlag(i) ? 1 : 0, "delta_poc_msb_present_flag[i][j]");
-          if (pcSlice->getLocalRPL1()->getDeltaPocMSBPresentFlag(i))
-          {
-            WRITE_UVLC(pcSlice->getLocalRPL1()->getDeltaPocMSBCycleLT(i), "delta_poc_msb_cycle_lt[i][j]");
+            if (pcSlice->getRPL1()->getLtrpInSliceHeaderFlag())
+            {
+              WRITE_CODE(pcSlice->getRPL1()->getRefPicIdentifier(i), pcSlice->getSPS()->getBitsForPOC(),
+                         "slice_poc_lsb_lt[listIdx][rplsIdx][j]");
+            }
+            WRITE_FLAG(pcSlice->getLocalRPL1()->getDeltaPocMSBPresentFlag(i) ? 1 : 0, "delta_poc_msb_present_flag[i][j]");
+            if (pcSlice->getLocalRPL1()->getDeltaPocMSBPresentFlag(i))
+            {
+              WRITE_UVLC(pcSlice->getLocalRPL1()->getDeltaPocMSBCycleLT(i), "delta_poc_msb_cycle_lt[i][j]");
+            }
           }
         }
       }
     }
-  }
 
 #if JVET_Q0819_PH_CHANGES
-  if (pcSlice->getPPS()->getRplInfoInPhFlag() || !pcSlice->getIdrPicFlag()
-      || pcSlice->getSPS()->getIDRRefParamListPresent())
+    if( pcSlice->getPPS()->getRplInfoInPhFlag() || !pcSlice->getIdrPicFlag()|| pcSlice->getSPS()->getIDRRefParamListPresent() )
 #else
-  if (picHeader->getPicRplPresentFlag() || !pcSlice->getIdrPicFlag() || pcSlice->getSPS()->getIDRRefParamListPresent())
+    if( picHeader->getPicRplPresentFlag() || !pcSlice->getIdrPicFlag() || pcSlice->getSPS()->getIDRRefParamListPresent() )
 #endif
-  {
-    // check if numrefidxes match the defaults. If not, override
-
-    if ((!pcSlice->isIntra() && pcSlice->getRPL0()->getNumRefEntries() > 1)
-        || (pcSlice->isInterB() && pcSlice->getRPL1()->getNumRefEntries() > 1))
     {
-      int defaultL0 =
-        std::min<int>(pcSlice->getRPL0()->getNumRefEntries(), pcSlice->getPPS()->getNumRefIdxL0DefaultActive());
-      int defaultL1 = pcSlice->isInterB() ? std::min<int>(pcSlice->getRPL1()->getNumRefEntries(),
-                                                          pcSlice->getPPS()->getNumRefIdxL1DefaultActive())
-                                          : 0;
-      bool overrideFlag = (pcSlice->getNumRefIdx(REF_PIC_LIST_0) != defaultL0
-                           || (pcSlice->isInterB() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) != defaultL1));
-      WRITE_FLAG(overrideFlag ? 1 : 0, "num_ref_idx_active_override_flag");
-      if (overrideFlag)
+      //check if numrefidxes match the defaults. If not, override
+
+      if ((!pcSlice->isIntra() && pcSlice->getRPL0()->getNumRefEntries() > 1) ||
+          (pcSlice->isInterB() && pcSlice->getRPL1()->getNumRefEntries() > 1) )
       {
-        if (pcSlice->getRPL0()->getNumRefEntries() > 1)
-        {
-          WRITE_UVLC(pcSlice->getNumRefIdx(REF_PIC_LIST_0) - 1, "num_ref_idx_l0_active_minus1");
-        }
-        else
+        int defaultL0 = std::min<int>(pcSlice->getRPL0()->getNumRefEntries(), pcSlice->getPPS()->getNumRefIdxL0DefaultActive());
+        int defaultL1 = pcSlice->isInterB() ? std::min<int>(pcSlice->getRPL1()->getNumRefEntries(), pcSlice->getPPS()->getNumRefIdxL1DefaultActive()) : 0;
+        bool overrideFlag = ( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) != defaultL0 || ( pcSlice->isInterB() && pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) != defaultL1 ) );
+        WRITE_FLAG( overrideFlag ? 1 : 0, "num_ref_idx_active_override_flag" );
+        if( overrideFlag )
         {
-          pcSlice->setNumRefIdx(REF_PIC_LIST_0, 1);
-        }
+          if(pcSlice->getRPL0()->getNumRefEntries() > 1)
+          {
+            WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, "num_ref_idx_l0_active_minus1" );
+          }
+          else
+          {
+            pcSlice->setNumRefIdx( REF_PIC_LIST_0, 1);
+          }
 
-        if (pcSlice->isInterB() && pcSlice->getRPL1()->getNumRefEntries() > 1)
-        {
-          WRITE_UVLC(pcSlice->getNumRefIdx(REF_PIC_LIST_1) - 1, "num_ref_idx_l1_active_minus1");
+          if( pcSlice->isInterB() && pcSlice->getRPL1()->getNumRefEntries() > 1)
+          {
+            WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - 1, "num_ref_idx_l1_active_minus1" );
+          }
+          else
+          {
+            pcSlice->setNumRefIdx( REF_PIC_LIST_1, pcSlice->isInterB() ? 1 : 0);
+          }
         }
         else
         {
-          pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->isInterB() ? 1 : 0);
+          pcSlice->setNumRefIdx( REF_PIC_LIST_0, defaultL0 );
+          pcSlice->setNumRefIdx( REF_PIC_LIST_1, defaultL1 );
         }
       }
       else
       {
-        pcSlice->setNumRefIdx(REF_PIC_LIST_0, defaultL0);
-        pcSlice->setNumRefIdx(REF_PIC_LIST_1, defaultL1);
+        pcSlice->setNumRefIdx( REF_PIC_LIST_0, pcSlice->isIntra() ? 0 : 1 );
+        pcSlice->setNumRefIdx( REF_PIC_LIST_1, pcSlice->isInterB() ? 1 : 0 );
       }
     }
-    else
-    {
-      pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->isIntra() ? 0 : 1);
-      pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->isInterB() ? 1 : 0);
-    }
-  }
 
-  if (!pcSlice->isIntra())
-  {
-    if (!pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag())
-    {
-      SliceType sliceType        = pcSlice->getSliceType();
-      SliceType encCABACTableIdx = pcSlice->getEncCABACTableIdx();
-      bool      encCabacInitFlag = (sliceType != encCABACTableIdx && encCABACTableIdx != I_SLICE) ? true : false;
-      pcSlice->setCabacInitFlag(encCabacInitFlag);
-      WRITE_FLAG(encCabacInitFlag ? 1 : 0, "cabac_init_flag");
-    }
-  }
 
-  if (pcSlice->getPicHeader()->getEnableTMVPFlag())
-  {
-    if (pcSlice->getSliceType() == B_SLICE)
+    if( !pcSlice->isIntra() )
     {
-      if (!pcSlice->getPPS()->getPPSCollocatedFromL0Idc())
+      if( !pcSlice->isIntra() && pcSlice->getPPS()->getCabacInitPresentFlag() )
       {
-        WRITE_FLAG(pcSlice->getColFromL0Flag(), "collocated_from_l0_flag");
+        SliceType sliceType = pcSlice->getSliceType();
+        SliceType  encCABACTableIdx = pcSlice->getEncCABACTableIdx();
+        bool encCabacInitFlag = ( sliceType != encCABACTableIdx && encCABACTableIdx != I_SLICE ) ? true : false;
+        pcSlice->setCabacInitFlag( encCabacInitFlag );
+        WRITE_FLAG( encCabacInitFlag ? 1 : 0, "cabac_init_flag" );
       }
     }
 
-    if (pcSlice->getSliceType() != I_SLICE
-        && ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)
-            || (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1)))
+    if( pcSlice->getPicHeader()->getEnableTMVPFlag() )
     {
-      WRITE_UVLC(pcSlice->getColRefIdx(), "collocated_ref_idx");
+      if( pcSlice->getSliceType() == B_SLICE )
+      {
+        if (!pcSlice->getPPS()->getPPSCollocatedFromL0Idc())
+        {
+          WRITE_FLAG( pcSlice->getColFromL0Flag(), "collocated_from_l0_flag" );
+        }
+      }
+
+      if( pcSlice->getSliceType() != I_SLICE &&
+        ( ( pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) > 1 ) ||
+          ( pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) > 1 ) ) )
+      {
+        WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" );
+      }
     }
-  }
 
-  if ((pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType() == P_SLICE)
-      || (pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType() == B_SLICE))
-  {
-#if JVET_Q0819_PH_CHANGES
-    if (!pcSlice->getPPS()->getWpInfoInPhFlag())
+    if( ( pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType() == P_SLICE ) || ( pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType() == B_SLICE ) )
     {
-      xCodePredWeightTable(pcSlice, NULL, NULL);
-    }
+#if JVET_Q0819_PH_CHANGES
+      if( !pcSlice->getPPS()->getWpInfoInPhFlag() )
+      {
+        xCodePredWeightTable(pcSlice);
+      }
 #else
-    xCodePredWeightTable(pcSlice);
+      xCodePredWeightTable(pcSlice);
 #endif
-  }
+    }
+
 
 #if JVET_Q0819_PH_CHANGES
-  if (!pcSlice->getPPS()->getQpDeltaInfoInPhFlag())
-  {
-    WRITE_SVLC(pcSlice->getSliceQp() - (pcSlice->getPPS()->getPicInitQPMinus26() + 26), "slice_qp_delta");
-  }
-#else
-  int iCode = pcSlice->getSliceQp() - (pcSlice->getPPS()->getPicInitQPMinus26() + 26);
-  WRITE_SVLC(iCode, "slice_qp_delta");
-#endif
-  if (pcSlice->getPPS()->getSliceChromaQpFlag())
-  {
-    if (numberValidComponents > COMPONENT_Cb)
+    if (!pcSlice->getPPS()->getQpDeltaInfoInPhFlag())
     {
-      WRITE_SVLC(pcSlice->getSliceChromaQpDelta(COMPONENT_Cb), "slice_cb_qp_offset");
+      WRITE_SVLC(pcSlice->getSliceQp() - (pcSlice->getPPS()->getPicInitQPMinus26() + 26), "slice_qp_delta");
     }
-    if (numberValidComponents > COMPONENT_Cr)
+#else
+    int iCode = pcSlice->getSliceQp() - (pcSlice->getPPS()->getPicInitQPMinus26() + 26);
+    WRITE_SVLC( iCode, "slice_qp_delta" );
+#endif
+    if (pcSlice->getPPS()->getSliceChromaQpFlag())
     {
-      WRITE_SVLC(pcSlice->getSliceChromaQpDelta(COMPONENT_Cr), "slice_cr_qp_offset");
-      if (pcSlice->getSPS()->getJointCbCrEnabledFlag())
+      if (numberValidComponents > COMPONENT_Cb)
       {
-        WRITE_SVLC(pcSlice->getSliceChromaQpDelta(JOINT_CbCr), "slice_joint_cbcr_qp_offset");
+        WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb), "slice_cb_qp_offset" );
       }
+      if (numberValidComponents > COMPONENT_Cr)
+      {
+        WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr), "slice_cr_qp_offset" );
+        if (pcSlice->getSPS()->getJointCbCrEnabledFlag())
+        {
+          WRITE_SVLC( pcSlice->getSliceChromaQpDelta(JOINT_CbCr), "slice_joint_cbcr_qp_offset");
+        }
+      }
+      CHECK(numberValidComponents < COMPONENT_Cr+1, "Too many valid components");
     }
-    CHECK(numberValidComponents < COMPONENT_Cr + 1, "Too many valid components");
-  }
 
-  if (pcSlice->getPPS()->getCuChromaQpOffsetEnabledFlag())
-  {
-    WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "cu_chroma_qp_offset_enabled_flag");
-  }
+    if (pcSlice->getPPS()->getCuChromaQpOffsetEnabledFlag())
+    {
+      WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "cu_chroma_qp_offset_enabled_flag");
+    }
 
 #if JVET_Q0819_PH_CHANGES
-  if (pcSlice->getSPS()->getSAOEnabledFlag() && !pcSlice->getPPS()->getSaoInfoInPhFlag())
+    if (pcSlice->getSPS()->getSAOEnabledFlag() && !pcSlice->getPPS()->getSaoInfoInPhFlag())
 #else
-  if (pcSlice->getSPS()->getSAOEnabledFlag() && !picHeader->getSaoEnabledPresentFlag())
+    if (pcSlice->getSPS()->getSAOEnabledFlag() && !picHeader->getSaoEnabledPresentFlag())
 #endif
-  {
-    WRITE_FLAG(pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "slice_sao_luma_flag");
-    if (chromaEnabled)
     {
-      WRITE_FLAG(pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA), "slice_sao_chroma_flag");
+      WRITE_FLAG( pcSlice->getSaoEnabledFlag( CHANNEL_TYPE_LUMA ), "slice_sao_luma_flag" );
+      if( chromaEnabled )
+      {
+        WRITE_FLAG( pcSlice->getSaoEnabledFlag( CHANNEL_TYPE_CHROMA ), "slice_sao_chroma_flag" );
+      }
     }
-  }
 
 #if JVET_Q0819_PH_CHANGES
-  if (pcSlice->getSPS()->getALFEnabledFlag() && !pcSlice->getPPS()->getAlfInfoInPhFlag())
+    if (pcSlice->getSPS()->getALFEnabledFlag() && !pcSlice->getPPS()->getAlfInfoInPhFlag())
 #else
-  if (pcSlice->getSPS()->getALFEnabledFlag() && !picHeader->getAlfEnabledPresentFlag())
+    if (pcSlice->getSPS()->getALFEnabledFlag() && !picHeader->getAlfEnabledPresentFlag())
 #endif
-  {
-    const int alfEnabled = pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y);
-    WRITE_FLAG(alfEnabled, "slice_alf_enabled_flag");
-
-    if (alfEnabled)
     {
-      WRITE_CODE(pcSlice->getTileGroupNumAps(), 3, "slice_num_alf_aps_ids_luma");
-      const std::vector<int> &apsId = pcSlice->getTileGroupApsIdLuma();
-      for (int i = 0; i < pcSlice->getTileGroupNumAps(); i++)
-      {
-        WRITE_CODE(apsId[i], 3, "slice_alf_aps_id_luma");
-      }
+      const int alfEnabled = pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y);
+      WRITE_FLAG(alfEnabled, "slice_alf_enabled_flag");
 
-      const int alfChromaIdc =
-        pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cb) + pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cr) * 2;
-      if (chromaEnabled)
-      {
-        WRITE_CODE(alfChromaIdc, 2, "slice_alf_chroma_idc");
-      }
-      if (alfChromaIdc)
+      if (alfEnabled)
       {
-        WRITE_CODE(pcSlice->getTileGroupApsIdChroma(), 3, "slice_alf_aps_id_chroma");
-      }
+        WRITE_CODE(pcSlice->getTileGroupNumAps(), 3, "slice_num_alf_aps_ids_luma");
+        const std::vector<int>&   apsId = pcSlice->getTileGroupApsIdLuma();
+        for (int i = 0; i < pcSlice->getTileGroupNumAps(); i++)
+        {
+          WRITE_CODE(apsId[i], 3, "slice_alf_aps_id_luma");
+        }
 
-#if JVET_Q0795_CCALF
-      if (pcSlice->getSPS()->getCCALFEnabledFlag())
-      {
-        CcAlfFilterParam &filterParam = pcSlice->m_ccAlfFilterParam;
-        WRITE_FLAG(filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] ? 1 : 0, "slice_cc_alf_cb_enabled_flag");
-        if (filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1])
+        const int alfChromaIdc = pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cb) + pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cr) * 2 ;
+        if (chromaEnabled)
         {
-          // write CC ALF Cb APS ID
-          WRITE_CODE(pcSlice->getTileGroupCcAlfCbApsId(), 3, "slice_cc_alf_cb_aps_id");
+          WRITE_CODE(alfChromaIdc, 2, "slice_alf_chroma_idc");
         }
-        // Cr
-        WRITE_FLAG(filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] ? 1 : 0, "slice_cc_alf_cr_enabled_flag");
-        if (filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1])
+        if (alfChromaIdc)
         {
-          // write CC ALF Cr APS ID
-          WRITE_CODE(pcSlice->getTileGroupCcAlfCrApsId(), 3, "slice_cc_alf_cr_aps_id");
+          WRITE_CODE(pcSlice->getTileGroupApsIdChroma(), 3, "slice_alf_aps_id_chroma");
+        }
+
+#if JVET_Q0795_CCALF
+        if (pcSlice->getSPS()->getCCALFEnabledFlag())
+        {
+          CcAlfFilterParam &filterParam = pcSlice->m_ccAlfFilterParam;
+          WRITE_FLAG(filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] ? 1 : 0, "slice_cc_alf_cb_enabled_flag");
+          if (filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1])
+          {
+            // write CC ALF Cb APS ID
+            WRITE_CODE(pcSlice->getTileGroupCcAlfCbApsId(), 3, "slice_cc_alf_cb_aps_id");
+          }
+          // Cr
+          WRITE_FLAG(filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] ? 1 : 0, "slice_cc_alf_cr_enabled_flag");
+          if (filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1])
+          {
+            // write CC ALF Cr APS ID
+            WRITE_CODE(pcSlice->getTileGroupCcAlfCrApsId(), 3, "slice_cc_alf_cr_aps_id");
+          }
         }
-      }
 #endif
+      }
     }
-  }
+	
 
-  if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
-  {
+    if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
+    {
 #if JVET_Q0819_PH_CHANGES
-    if (pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag() && !pcSlice->getPPS()->getDbfInfoInPhFlag())
+    if( pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag() && !pcSlice->getPPS()->getDbfInfoInPhFlag() )
     {
       WRITE_FLAG(pcSlice->getDeblockingFilterOverrideFlag(), "slice_deblocking_filter_override_flag");
 #else
-    if (pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()
-        && !picHeader->getDeblockingFilterOverridePresentFlag())
-    {
-      WRITE_FLAG(pcSlice->getDeblockingFilterOverrideFlag(), "deblocking_filter_override_flag");
+      if (pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag() && !picHeader->getDeblockingFilterOverridePresentFlag())
+      {
+        WRITE_FLAG(pcSlice->getDeblockingFilterOverrideFlag(), "deblocking_filter_override_flag");
 #endif
-    }
-    else
-    {
-      pcSlice->setDeblockingFilterOverrideFlag(0);
-    }
-    if (pcSlice->getDeblockingFilterOverrideFlag())
-    {
-      WRITE_FLAG(pcSlice->getDeblockingFilterDisable(), "slice_deblocking_filter_disabled_flag");
-      if (!pcSlice->getDeblockingFilterDisable())
+      }
+      else
+      {
+        pcSlice->setDeblockingFilterOverrideFlag(0);
+      }
+      if (pcSlice->getDeblockingFilterOverrideFlag())
+      {
+        WRITE_FLAG(pcSlice->getDeblockingFilterDisable(), "slice_deblocking_filter_disabled_flag");
+        if(!pcSlice->getDeblockingFilterDisable())
+        {
+          WRITE_SVLC (pcSlice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2");
+          WRITE_SVLC (pcSlice->getDeblockingFilterTcOffsetDiv2(),   "slice_tc_offset_div2");
+#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
+          WRITE_SVLC (pcSlice->getDeblockingFilterCbBetaOffsetDiv2(), "slice_cb_beta_offset_div2");
+          WRITE_SVLC (pcSlice->getDeblockingFilterCbTcOffsetDiv2(),   "slice_cb_tc_offset_div2");
+          WRITE_SVLC (pcSlice->getDeblockingFilterCrBetaOffsetDiv2(), "slice_cr_beta_offset_div2");
+          WRITE_SVLC (pcSlice->getDeblockingFilterCrTcOffsetDiv2(),   "slice_cr_tc_offset_div2");
+#endif
+        }
+      }
+      else
       {
-        WRITE_SVLC(pcSlice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2");
-        WRITE_SVLC(pcSlice->getDeblockingFilterTcOffsetDiv2(), "slice_tc_offset_div2");
+        pcSlice->setDeblockingFilterDisable       ( picHeader->getDeblockingFilterDisable() );
+        pcSlice->setDeblockingFilterBetaOffsetDiv2( picHeader->getDeblockingFilterBetaOffsetDiv2() );
+        pcSlice->setDeblockingFilterTcOffsetDiv2  ( picHeader->getDeblockingFilterTcOffsetDiv2() );
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-        WRITE_SVLC(pcSlice->getDeblockingFilterCbBetaOffsetDiv2(), "slice_cb_beta_offset_div2");
-        WRITE_SVLC(pcSlice->getDeblockingFilterCbTcOffsetDiv2(), "slice_cb_tc_offset_div2");
-        WRITE_SVLC(pcSlice->getDeblockingFilterCrBetaOffsetDiv2(), "slice_cr_beta_offset_div2");
-        WRITE_SVLC(pcSlice->getDeblockingFilterCrTcOffsetDiv2(), "slice_cr_tc_offset_div2");
+        pcSlice->setDeblockingFilterCbBetaOffsetDiv2( picHeader->getDeblockingFilterCbBetaOffsetDiv2() );
+        pcSlice->setDeblockingFilterCbTcOffsetDiv2  ( picHeader->getDeblockingFilterCbTcOffsetDiv2() );
+        pcSlice->setDeblockingFilterCrBetaOffsetDiv2( picHeader->getDeblockingFilterCrBetaOffsetDiv2() );
+        pcSlice->setDeblockingFilterCrTcOffsetDiv2  ( picHeader->getDeblockingFilterCrTcOffsetDiv2() );
 #endif
       }
     }
     else
     {
-      pcSlice->setDeblockingFilterDisable(picHeader->getDeblockingFilterDisable());
-      pcSlice->setDeblockingFilterBetaOffsetDiv2(picHeader->getDeblockingFilterBetaOffsetDiv2());
-      pcSlice->setDeblockingFilterTcOffsetDiv2(picHeader->getDeblockingFilterTcOffsetDiv2());
+      pcSlice->setDeblockingFilterDisable       ( false );
+      pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
+      pcSlice->setDeblockingFilterTcOffsetDiv2  ( 0 );
 #if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-      pcSlice->setDeblockingFilterCbBetaOffsetDiv2(picHeader->getDeblockingFilterCbBetaOffsetDiv2());
-      pcSlice->setDeblockingFilterCbTcOffsetDiv2(picHeader->getDeblockingFilterCbTcOffsetDiv2());
-      pcSlice->setDeblockingFilterCrBetaOffsetDiv2(picHeader->getDeblockingFilterCrBetaOffsetDiv2());
-      pcSlice->setDeblockingFilterCrTcOffsetDiv2(picHeader->getDeblockingFilterCrTcOffsetDiv2());
+      pcSlice->setDeblockingFilterCbBetaOffsetDiv2( 0 );
+      pcSlice->setDeblockingFilterCbTcOffsetDiv2  ( 0 );
+      pcSlice->setDeblockingFilterCrBetaOffsetDiv2( 0 );
+      pcSlice->setDeblockingFilterCrTcOffsetDiv2  ( 0 );
 #endif
     }
-  }
-  else
-  {
-    pcSlice->setDeblockingFilterDisable(false);
-    pcSlice->setDeblockingFilterBetaOffsetDiv2(0);
-    pcSlice->setDeblockingFilterTcOffsetDiv2(0);
-#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS
-    pcSlice->setDeblockingFilterCbBetaOffsetDiv2(0);
-    pcSlice->setDeblockingFilterCbTcOffsetDiv2(0);
-    pcSlice->setDeblockingFilterCrBetaOffsetDiv2(0);
-    pcSlice->setDeblockingFilterCrTcOffsetDiv2(0);
-#endif
-  }
 
 #if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM
-  WRITE_FLAG(pcSlice->getTSResidualCodingDisabledFlag() ? 1 : 0, "slice_ts_residual_coding_disabled_flag");
+	WRITE_FLAG(pcSlice->getTSResidualCodingDisabledFlag() ? 1 : 0, "slice_ts_residual_coding_disabled_flag");
 #endif
 
-  if (pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
+  if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag())
   {
-    WRITE_UVLC(0, "slice_segment_header_extension_length");
+    WRITE_UVLC(0,"slice_segment_header_extension_length");
   }
+
 }
 
-void HLSWriter::codeConstraintInfo(const ConstraintInfo *cinfo)
+void  HLSWriter::codeConstraintInfo  ( const ConstraintInfo* cinfo )
 {
-  WRITE_FLAG(cinfo->getProgressiveSourceFlag(), "general_progressive_source_flag");
-  WRITE_FLAG(cinfo->getInterlacedSourceFlag(), "general_interlaced_source_flag");
-  WRITE_FLAG(cinfo->getNonPackedConstraintFlag(), "general_non_packed_constraint_flag");
-  WRITE_FLAG(cinfo->getFrameOnlyConstraintFlag(), "general_frame_only_constraint_flag");
-  WRITE_FLAG(cinfo->getIntraOnlyConstraintFlag(), "intra_only_constraint_flag");
+  WRITE_FLAG(cinfo->getProgressiveSourceFlag(),   "general_progressive_source_flag"         );
+  WRITE_FLAG(cinfo->getInterlacedSourceFlag(),    "general_interlaced_source_flag"          );
+  WRITE_FLAG(cinfo->getNonPackedConstraintFlag(), "general_non_packed_constraint_flag"      );
+  WRITE_FLAG(cinfo->getFrameOnlyConstraintFlag(), "general_frame_only_constraint_flag"      );
+  WRITE_FLAG(cinfo->getIntraOnlyConstraintFlag(),     "intra_only_constraint_flag"      );
 
-  WRITE_CODE(cinfo->getMaxBitDepthConstraintIdc(), 4, "max_bitdepth_constraint_idc");
-  WRITE_CODE(cinfo->getMaxChromaFormatConstraintIdc(), 2, "max_chroma_format_constraint_idc");
+  WRITE_CODE(cinfo->getMaxBitDepthConstraintIdc(), 4, "max_bitdepth_constraint_idc" );
+  WRITE_CODE(cinfo->getMaxChromaFormatConstraintIdc(), 2, "max_chroma_format_constraint_idc" );
 
   WRITE_FLAG(cinfo->getNoQtbttDualTreeIntraConstraintFlag() ? 1 : 0, "no_qtbtt_dual_tree_intra_constraint_flag");
-  WRITE_FLAG(cinfo->getNoPartitionConstraintsOverrideConstraintFlag() ? 1 : 0,
-             "no_partition_constraints_override_constraint_flag");
+  WRITE_FLAG(cinfo->getNoPartitionConstraintsOverrideConstraintFlag() ? 1 : 0, "no_partition_constraints_override_constraint_flag");
   WRITE_FLAG(cinfo->getNoSaoConstraintFlag() ? 1 : 0, "no_sao_constraint_flag");
   WRITE_FLAG(cinfo->getNoAlfConstraintFlag() ? 1 : 0, "no_alf_constraint_flag");
 #if JVET_Q0795_CCALF
@@ -2699,24 +2608,26 @@ void HLSWriter::codeConstraintInfo(const ConstraintInfo *cinfo)
   WRITE_FLAG(cinfo->getNoApsConstraintFlag() ? 1 : 0, "no_aps_constraint_flag");
 }
 
-void HLSWriter::codeProfileTierLevel(const ProfileTierLevel *ptl, int maxNumSubLayersMinus1)
+
+void  HLSWriter::codeProfileTierLevel    ( const ProfileTierLevel* ptl, int maxNumSubLayersMinus1 )
 {
-  WRITE_CODE(int(ptl->getProfileIdc()), 7, "general_profile_idc");
-  WRITE_FLAG(ptl->getTierFlag() == Level::HIGH, "general_tier_flag");
+  WRITE_CODE( int(ptl->getProfileIdc()), 7 ,   "general_profile_idc"                     );
+  WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, "general_tier_flag"                       );
 
-  codeConstraintInfo(ptl->getConstraintInfo());
+  codeConstraintInfo( ptl->getConstraintInfo() );
 
-  WRITE_CODE(int(ptl->getLevelIdc()), 8, "general_level_idc");
+  WRITE_CODE( int( ptl->getLevelIdc() ), 8, "general_level_idc" );
 
   WRITE_CODE(ptl->getNumSubProfile(), 8, "num_sub_profiles");
   for (int i = 0; i < ptl->getNumSubProfile(); i++)
   {
-    WRITE_CODE(ptl->getSubProfileIdc(i), 32, "general_sub_profile_idc[i]");
+    WRITE_CODE(ptl->getSubProfileIdc(i) , 32, "general_sub_profile_idc[i]");
   }
 
+
   for (int i = 0; i < maxNumSubLayersMinus1; i++)
   {
-    WRITE_FLAG(ptl->getSubLayerLevelPresentFlag(i), "sub_layer_level_present_flag[i]");
+    WRITE_FLAG( ptl->getSubLayerLevelPresentFlag(i),   "sub_layer_level_present_flag[i]" );
   }
 
   while (!isByteAligned())
@@ -2724,32 +2635,34 @@ void HLSWriter::codeProfileTierLevel(const ProfileTierLevel *ptl, int maxNumSubL
     WRITE_FLAG(0, "ptl_alignment_zero_bit");
   }
 
-  for (int i = 0; i < maxNumSubLayersMinus1; i++)
+  for(int i = 0; i < maxNumSubLayersMinus1; i++)
   {
-    if (ptl->getSubLayerLevelPresentFlag(i))
+    if( ptl->getSubLayerLevelPresentFlag(i) )
     {
-      WRITE_CODE(int(ptl->getSubLayerLevelIdc(i)), 8, "sub_layer_level_idc[i]");
+      WRITE_CODE( int(ptl->getSubLayerLevelIdc(i)), 8, "sub_layer_level_idc[i]" );
     }
   }
+
 }
 
+
 /**
- * Write tiles and wavefront substreams sizes for the slice header (entry points).
- *
- * \param pSlice Slice structure that contains the substream size information.
- */
-void HLSWriter::codeTilesWPPEntryPoint(Slice *pSlice)
+* Write tiles and wavefront substreams sizes for the slice header (entry points).
+*
+* \param pSlice Slice structure that contains the substream size information.
+*/
+void  HLSWriter::codeTilesWPPEntryPoint( Slice* pSlice )
 {
-  pSlice->setNumEntryPoints(pSlice->getPPS());
-  if (pSlice->getNumEntryPoints() == 0)
+  pSlice->setNumEntryPoints( pSlice->getPPS() );
+  if( pSlice->getNumEntryPoints() == 0 )
   {
     return;
   }
   uint32_t maxOffset = 0;
-  for (int idx = 0; idx < pSlice->getNumberOfSubstreamSizes(); idx++)
+  for(int idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++)
   {
-    uint32_t offset = pSlice->getSubstreamSize(idx);
-    if (offset > maxOffset)
+    uint32_t offset=pSlice->getSubstreamSize(idx);
+    if ( offset > maxOffset )
     {
       maxOffset = offset;
     }
@@ -2763,246 +2676,239 @@ void HLSWriter::codeTilesWPPEntryPoint(Slice *pSlice)
     CHECK(offsetLenMinus1 + 1 >= 32, "Invalid offset length minus 1");
   }
 
-  if (pSlice->getNumberOfSubstreamSizes() > 0)
+  if (pSlice->getNumberOfSubstreamSizes()>0)
   {
     WRITE_UVLC(offsetLenMinus1, "offset_len_minus1");
 
-    for (uint32_t idx = 0; idx < pSlice->getNumberOfSubstreamSizes(); idx++)
+    for (uint32_t idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++)
     {
-      WRITE_CODE(pSlice->getSubstreamSize(idx) - 1, offsetLenMinus1 + 1, "entry_point_offset_minus1");
+      WRITE_CODE(pSlice->getSubstreamSize(idx)-1, offsetLenMinus1+1, "entry_point_offset_minus1");
     }
   }
 }
 
+
 // ====================================================================================================================
 // Protected member functions
 // ====================================================================================================================
 
 //! Code weighted prediction tables
-#if JVET_Q0819_PH_CHANGES
-void HLSWriter::xCodePredWeightTable(Slice *pcSlice, PicHeader *picHeader, const SPS *sps)
-#else
-void HLSWriter::xCodePredWeightTable(Slice *pcSlice)
-#endif
+void HLSWriter::xCodePredWeightTable( Slice* pcSlice )
 {
-  WPScalingParam *    wp;
-#if JVET_Q0819_PH_CHANGES
-  bool               sliceLevelWp                  = (pcSlice != NULL) ? 1 : 0;
-  const ChromaFormat format                        = (sliceLevelWp) ? pcSlice->getSPS()->getChromaFormatIdc() : sps->getChromaFormatIdc();
-#else
-  const ChromaFormat format                        = pcSlice->getSPS()->getChromaFormatIdc();
-#endif
-  const uint32_t     numberValidComponents         = getNumberValidComponents(format);
-  const bool         chroma                        = isChromaEnabled(format);
-#if JVET_Q0819_PH_CHANGES
-  const int          nbRef                         = (sliceLevelWp) ? (pcSlice->getSliceType() == B_SLICE) ? (2) : (1) : 0;
-#else
-  const int          nbRef                         = (pcSlice->getSliceType() == B_SLICE) ? (2) : (1);
-#endif
-  bool               denomCoded                    = false;
-  uint32_t           totalSignalledWeightFlags     = 0;
+  WPScalingParam  *wp;
+  const ChromaFormat    format                = pcSlice->getSPS()->getChromaFormatIdc();
+  const uint32_t            numberValidComponents = getNumberValidComponents(format);
+  const bool            bChroma               = isChromaEnabled(format);
+  const int             iNbRef                = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1);
+  bool            bDenomCoded           = false;
+  uint32_t            uiTotalSignalledWeightFlags = 0;
 
-#if !JVET_Q0819_PH_CHANGES
-  if ((pcSlice->getSliceType() == P_SLICE && pcSlice->getPPS()->getUseWP())
-      || (pcSlice->getSliceType() == B_SLICE && pcSlice->getPPS()->getWPBiPred()))
+  if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPred()) )
   {
-#endif
-#if JVET_Q0819_PH_CHANGES
-    uint32_t numLxWeights         = (sliceLevelWp) ? 0 : picHeader->getNumL0Weights();
-    bool     moreSyntaxToBeParsed = true;
-    for (int numRef = 0; numRef < NUM_REF_PIC_LIST_01 && moreSyntaxToBeParsed; numRef++)   // loop over l0 and l1 syntax elements
+    for ( int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) // loop over l0 and l1 syntax elements
     {
-      RefPicList refPicList = (numRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
+      RefPicList  eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 );
+
       // NOTE: wp[].uiLog2WeightDenom and wp[].bPresentFlag are actually per-channel-type settings.
 
-      for (int refIdx = 0; refIdx < numLxWeights; refIdx++)
+      for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
       {
-        if (sliceLevelWp)
-        {
-          pcSlice->getWpScaling(refPicList, refIdx, wp);
-        }
-        else
+        pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
+        if ( !bDenomCoded )
         {
-          picHeader->getWpScaling(refPicList, refIdx, wp);
-        }
-#else
-  for (int numRef = 0; numRef < nbRef; numRef++)   // loop over l0 and l1 syntax elements
-  {
-    RefPicList refPicList = (numRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
-
-    // NOTE: wp[].uiLog2WeightDenom and wp[].bPresentFlag are actually per-channel-type settings.
+          int iDeltaDenom;
+          WRITE_UVLC( wp[COMPONENT_Y].uiLog2WeightDenom, "luma_log2_weight_denom" );
 
-    for (int refIdx = 0; refIdx < pcSlice->getNumRefIdx(refPicList); refIdx++)
-    {
-      pcSlice->getWpScaling(refPicList, refIdx, wp);
-#endif
-        if (!denomCoded)
-        {
-          int deltaDenom;
-          WRITE_UVLC(wp[COMPONENT_Y].uiLog2WeightDenom, "luma_log2_weight_denom");
-
-          if (chroma)
+          if( bChroma )
           {
-            CHECK(wp[COMPONENT_Cb].uiLog2WeightDenom != wp[COMPONENT_Cr].uiLog2WeightDenom, "Chroma blocks of different size not supported");
-            deltaDenom = (wp[COMPONENT_Cb].uiLog2WeightDenom - wp[COMPONENT_Y].uiLog2WeightDenom);
-            WRITE_SVLC(deltaDenom, "delta_chroma_log2_weight_denom");
+            CHECK( wp[COMPONENT_Cb].uiLog2WeightDenom != wp[COMPONENT_Cr].uiLog2WeightDenom, "Chroma blocks of different size not supported" );
+            iDeltaDenom = (wp[COMPONENT_Cb].uiLog2WeightDenom - wp[COMPONENT_Y].uiLog2WeightDenom);
+            WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" );
           }
-          denomCoded = true;
+          bDenomCoded = true;
         }
-        WRITE_FLAG(wp[COMPONENT_Y].bPresentFlag, numRef == 0 ? "luma_weight_l0_flag[i]" : "luma_weight_l1_flag[i]");
-        totalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag;
+        WRITE_FLAG( wp[COMPONENT_Y].bPresentFlag, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" );
+        uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag;
       }
-      if (chroma)
+      if (bChroma)
       {
-#if JVET_Q0819_PH_CHANGES
-        for (int refIdx = 0; refIdx < numLxWeights; refIdx++)
+        for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
         {
-          if (sliceLevelWp)
-          {
-            pcSlice->getWpScaling(refPicList, refIdx, wp);
-          }
-          else
-          {
-            picHeader->getWpScaling(refPicList, refIdx, wp);
-          }
-#else
-      for (int refIdx = 0; refIdx < pcSlice->getNumRefIdx(eRefPicList); refIdx++)
-      {
-        pcSlice->getWpScaling(refPicList, refIdx, wp);
-#endif
-          CHECK(wp[COMPONENT_Cb].bPresentFlag != wp[COMPONENT_Cr].bPresentFlag, "Inconsistent settings for chroma channels");
-          WRITE_FLAG(wp[COMPONENT_Cb].bPresentFlag, iNumRef == 0 ? "chroma_weight_l0_flag[i]" : "chroma_weight_l1_flag[i]");
-          totalSignalledWeightFlags += 2 * wp[COMPONENT_Cb].bPresentFlag;
+          pcSlice->getWpScaling( eRefPicList, iRefIdx, wp );
+          CHECK( wp[COMPONENT_Cb].bPresentFlag != wp[COMPONENT_Cr].bPresentFlag, "Inconsistent settings for chroma channels" );
+          WRITE_FLAG( wp[COMPONENT_Cb].bPresentFlag, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" );
+          uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag;
         }
       }
 
-#if JVET_Q0819_PH_CHANGES
-      for (int refIdx = 0; refIdx < numLxWeights; refIdx++)
+      for ( int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ )
       {
-        if (sliceLevelWp)
-        {
-          pcSlice->getWpScaling(refPicList, refIdx, wp);
-        }
-        else
-        {
-          picHeader->getWpScaling(refPicList, refIdx, wp);
-        }
-#else
-    for (int refIdx = 0; refIdx < pcSlice->getNumRefIdx(eRefPicList); refIdx++)
-    {
-      pcSlice->getWpScaling(refPicList, refIdx, wp);
-#endif
-        if (wp[COMPONENT_Y].bPresentFlag)
+        pcSlice->getWpScaling(eRefPicList, iRefIdx, wp);
+        if ( wp[COMPONENT_Y].bPresentFlag )
         {
-          int deltaWeight = (wp[COMPONENT_Y].iWeight - (1 << wp[COMPONENT_Y].uiLog2WeightDenom));
-          WRITE_SVLC(deltaWeight, iNumRef == 0 ? "delta_luma_weight_l0[i]" : "delta_luma_weight_l1[i]");
-          WRITE_SVLC(wp[COMPONENT_Y].iOffset, iNumRef == 0 ? "luma_offset_l0[i]" : "luma_offset_l1[i]");
+          int iDeltaWeight = (wp[COMPONENT_Y].iWeight - (1<<wp[COMPONENT_Y].uiLog2WeightDenom));
+          WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" );
+          WRITE_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" );
         }
 
-        if (chroma)
+        if ( bChroma )
         {
-          if (wp[COMPONENT_Cb].bPresentFlag)
+          if ( wp[COMPONENT_Cb].bPresentFlag )
           {
-            for (int j = COMPONENT_Cb; j < numberValidComponents; j++)
+            for ( int j = COMPONENT_Cb ; j < numberValidComponents ; j++ )
             {
               CHECK(wp[COMPONENT_Cb].uiLog2WeightDenom != wp[COMPONENT_Cr].uiLog2WeightDenom, "Chroma blocks of different size not supported");
-              int deltaWeight = (wp[j].iWeight - (1 << wp[COMPONENT_Cb].uiLog2WeightDenom));
-              WRITE_SVLC(deltaWeight, numRef == 0 ? "delta_chroma_weight_l0[i]" : "delta_chroma_weight_l1[i]");
+              int iDeltaWeight = (wp[j].iWeight - (1<<wp[COMPONENT_Cb].uiLog2WeightDenom));
+              WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" );
 
-#if JVET_Q0819_PH_CHANGES
-              int range = sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1 << sps->getBitDepth(CHANNEL_TYPE_CHROMA)) / 2 : 128;
-#else
-              int range = pcSlice->getSPS()->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1 << pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA)) / 2 : 128;
-#endif
-              int pred         = (range - ((range * wp[j].iWeight) >> (wp[j].uiLog2WeightDenom)));
-              int deltaChroma  = (wp[j].iOffset - pred);
-              WRITE_SVLC(deltaChroma, numRef == 0 ? "delta_chroma_offset_l0[i]" : "delta_chroma_offset_l1[i]");
+              int range=pcSlice->getSPS()->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128;
+              int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) );
+              int iDeltaChroma = (wp[j].iOffset - pred);
+              WRITE_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" );
             }
           }
         }
       }
+    }
+    CHECK(uiTotalSignalledWeightFlags>24, "Too many signalled weight flags");
+  }
+}
+
 #if JVET_Q0819_PH_CHANGES
-      if (sliceLevelWp)
+void HLSWriter::xCodePredWeightTable(PicHeader *picHeader, const SPS *sps)
+{
+  WPScalingParam *   wp;
+  const ChromaFormat format                      = sps->getChromaFormatIdc();
+  const uint32_t     numberValidComponents       = getNumberValidComponents(format);
+  const bool         chroma                      = isChromaEnabled(format);
+  bool               denomCoded                  = false;
+  uint32_t           totalSignalledWeightFlags   = 0;
+
+  uint32_t numLxWeights                          = picHeader->getNumL0Weights();
+  bool     moreSyntaxToBeParsed                  = true;
+  for (int numRef = 0; numRef < NUM_REF_PIC_LIST_01 && moreSyntaxToBeParsed; numRef++)   // loop over l0 and l1 syntax elements
+  {
+    RefPicList refPicList = (numRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
+    // NOTE: wp[].uiLog2WeightDenom and wp[].bPresentFlag are actually per-channel-type settings.
+
+    for (int refIdx = 0; refIdx < numLxWeights; refIdx++)
+    {
+      picHeader->getWpScaling(refPicList, refIdx, wp);
+      if (!denomCoded)
       {
-        moreSyntaxToBeParsed = (numRef < nbRef) ? true : false;
+        int deltaDenom;
+        WRITE_UVLC(wp[COMPONENT_Y].uiLog2WeightDenom, "luma_log2_weight_denom");
+
+        if (chroma)
+        {
+          CHECK(wp[COMPONENT_Cb].uiLog2WeightDenom != wp[COMPONENT_Cr].uiLog2WeightDenom, "Chroma blocks of different size not supported");
+          deltaDenom = (wp[COMPONENT_Cb].uiLog2WeightDenom - wp[COMPONENT_Y].uiLog2WeightDenom);
+          WRITE_SVLC(deltaDenom, "delta_chroma_log2_weight_denom");
+        }
+        denomCoded = true;
       }
-      else
+      WRITE_FLAG(wp[COMPONENT_Y].bPresentFlag, numRef == 0 ? "luma_weight_l0_flag[i]" : "luma_weight_l1_flag[i]");
+      totalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag;
+    }
+    if (chroma)
+    {
+      for (int refIdx = 0; refIdx < numLxWeights; refIdx++)
       {
-        if (numRef == 0)
+        picHeader->getWpScaling(refPicList, refIdx, wp);
+        CHECK(wp[COMPONENT_Cb].bPresentFlag != wp[COMPONENT_Cr].bPresentFlag, "Inconsistent settings for chroma channels");
+        WRITE_FLAG(wp[COMPONENT_Cb].bPresentFlag, numRef == 0 ? "chroma_weight_l0_flag[i]" : "chroma_weight_l1_flag[i]");
+        totalSignalledWeightFlags += 2 * wp[COMPONENT_Cb].bPresentFlag;
+      }
+    }
+
+    for (int refIdx = 0; refIdx < numLxWeights; refIdx++)
+    {
+      picHeader->getWpScaling(refPicList, refIdx, wp);
+      if (wp[COMPONENT_Y].bPresentFlag)
+      {
+        int deltaWeight = (wp[COMPONENT_Y].iWeight - (1 << wp[COMPONENT_Y].uiLog2WeightDenom));
+        WRITE_SVLC(deltaWeight, numRef == 0 ? "delta_luma_weight_l0[i]" : "delta_luma_weight_l1[i]");
+        WRITE_SVLC(wp[COMPONENT_Y].iOffset, numRef == 0 ? "luma_offset_l0[i]" : "luma_offset_l1[i]");
+      }
+
+      if (chroma)
+      {
+        if (wp[COMPONENT_Cb].bPresentFlag)
         {
-          numLxWeights         = picHeader->getNumL1Weights();
-          moreSyntaxToBeParsed = (numLxWeights == 0) ? false : true;
-        }     
+          for (int j = COMPONENT_Cb; j < numberValidComponents; j++)
+          {
+            CHECK(wp[COMPONENT_Cb].uiLog2WeightDenom != wp[COMPONENT_Cr].uiLog2WeightDenom, "Chroma blocks of different size not supported");
+            int deltaWeight = (wp[j].iWeight - (1 << wp[COMPONENT_Cb].uiLog2WeightDenom));
+            WRITE_SVLC(deltaWeight, numRef == 0 ? "delta_chroma_weight_l0[i]" : "delta_chroma_weight_l1[i]");
+
+            int range = sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1 << sps->getBitDepth(CHANNEL_TYPE_CHROMA)) / 2 : 128;
+            int pred         = (range - ((range * wp[j].iWeight) >> (wp[j].uiLog2WeightDenom)));
+            int deltaChroma = (wp[j].iOffset - pred);
+            WRITE_SVLC(deltaChroma, numRef == 0 ? "delta_chroma_offset_l0[i]" : "delta_chroma_offset_l1[i]");
+          }
+        }
       }
-#endif
     }
-    CHECK(totalSignalledWeightFlags > 24, "Too many signalled weight flags");
-#if !JVET_Q0819_PH_CHANGES
+    if (numRef == 0)
+    {
+      numLxWeights         = picHeader->getNumL1Weights();
+      moreSyntaxToBeParsed = (numLxWeights == 0) ? false : true;
+    }
   }
-#endif
+  CHECK(totalSignalledWeightFlags > 24, "Too many signalled weight flags");
 }
+#endif
 
 /** code quantization matrix
- *  \param scalingList quantization matrix information
- */
-void HLSWriter::codeScalingList(const ScalingList &scalingList)
+*  \param scalingList quantization matrix information
+*/
+void HLSWriter::codeScalingList( const ScalingList &scalingList )
 {
-  // for each size
-  WRITE_FLAG(scalingList.getDisableScalingMatrixForLfnstBlks(), "scaling_matrix_for_lfnst_disabled_flag");
+  //for each size
+  WRITE_FLAG(scalingList.getDisableScalingMatrixForLfnstBlks(), "scaling_matrix_for_lfnst_disabled_flag"); 
   for (uint32_t scalingListId = 0; scalingListId < 28; scalingListId++)
   {
     bool scalingListCopyModeFlag = scalingList.getScalingListCopyModeFlag(scalingListId);
-    WRITE_FLAG(scalingListCopyModeFlag, "scaling_list_copy_mode_flag");   // copy mode
-    if (!scalingListCopyModeFlag)                                         // Copy Mode
+    WRITE_FLAG(scalingListCopyModeFlag, "scaling_list_copy_mode_flag"); //copy mode
+    if (!scalingListCopyModeFlag)// Copy Mode
     {
       WRITE_FLAG(scalingList.getScalingListPreditorModeFlag(scalingListId), "scaling_list_predictor_mode_flag");
     }
-    if ((scalingListCopyModeFlag || scalingList.getScalingListPreditorModeFlag(scalingListId))
-        && scalingListId != SCALING_LIST_1D_START_2x2 && scalingListId != SCALING_LIST_1D_START_4x4
-        && scalingListId != SCALING_LIST_1D_START_8x8)
+    if ((scalingListCopyModeFlag || scalingList.getScalingListPreditorModeFlag(scalingListId)) && scalingListId!= SCALING_LIST_1D_START_2x2 && scalingListId != SCALING_LIST_1D_START_4x4 && scalingListId != SCALING_LIST_1D_START_8x8)
     {
-      WRITE_UVLC((int) scalingListId - (int) scalingList.getRefMatrixId(scalingListId),
-                 "scaling_list_pred_matrix_id_delta");
+      WRITE_UVLC((int)scalingListId - (int)scalingList.getRefMatrixId(scalingListId), "scaling_list_pred_matrix_id_delta");
     }
     if (!scalingListCopyModeFlag)
     {
-      // DPCM
+      //DPCM
       xCodeScalingList(&scalingList, scalingListId, scalingList.getScalingListPreditorModeFlag(scalingListId));
     }
   }
   return;
 }
 /** code DPCM
- * \param scalingList quantization matrix information
- * \param sizeId      size index
- * \param listId      list index
- */
-void HLSWriter::xCodeScalingList(const ScalingList *scalingList, uint32_t scalingListId, bool isPredictor)
+* \param scalingList quantization matrix information
+* \param sizeId      size index
+* \param listId      list index
+*/
+void HLSWriter::xCodeScalingList(const ScalingList* scalingList, uint32_t scalingListId, bool isPredictor)
 {
-  int matrixSize =
-    (scalingListId < SCALING_LIST_1D_START_4x4) ? 2 : ((scalingListId < SCALING_LIST_1D_START_8x8) ? 4 : 8);
-  int          coefNum = matrixSize * matrixSize;
-  ScanElement *scan =
-    g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][gp_sizeIdxInfo->idxFrom(matrixSize)][gp_sizeIdxInfo->idxFrom(matrixSize)];
+  int matrixSize = (scalingListId < SCALING_LIST_1D_START_4x4) ? 2 : ((scalingListId < SCALING_LIST_1D_START_8x8) ? 4 : 8);
+  int coefNum = matrixSize * matrixSize;
+  ScanElement *scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][gp_sizeIdxInfo->idxFrom(matrixSize)][gp_sizeIdxInfo->idxFrom(matrixSize)];
   int nextCoef = (isPredictor) ? 0 : SCALING_LIST_START_VALUE;
 
-  int        data;
-  const int *src        = scalingList->getScalingListAddress(scalingListId);
-  int        PredListId = scalingList->getRefMatrixId(scalingListId);
-  const int *srcPred    = (isPredictor)
-                         ? ((scalingListId == PredListId) ? scalingList->getScalingListDefaultAddress(scalingListId)
-                                                          : scalingList->getScalingListAddress(PredListId))
-                         : NULL;
+  int data;
+  const int *src = scalingList->getScalingListAddress(scalingListId);
+  int PredListId = scalingList->getRefMatrixId(scalingListId);
+  const int *srcPred = (isPredictor) ? ((scalingListId==PredListId) ? scalingList->getScalingListDefaultAddress(scalingListId) : scalingList->getScalingListAddress(PredListId)) : NULL;
   int deltasrc[65] = { 0 };
 
   if (isPredictor)
   {
     if (scalingListId >= SCALING_LIST_1D_START_16x16)
     {
-      deltasrc[64] = scalingList->getScalingListDC(scalingListId)
-                     - ((PredListId >= SCALING_LIST_1D_START_16x16)
-                          ? ((scalingListId == PredListId) ? 16 : scalingList->getScalingListDC(PredListId))
-                          : srcPred[scan[0].idx]);
+      deltasrc[64] = scalingList->getScalingListDC(scalingListId) - ((PredListId >= SCALING_LIST_1D_START_16x16) ? ((scalingListId == PredListId) ? 16 : scalingList->getScalingListDC(PredListId)) : srcPred[scan[0].idx]);
     }
     for (int i = 0; i < coefNum; i++)
     {
@@ -3013,36 +2919,35 @@ void HLSWriter::xCodeScalingList(const ScalingList *scalingList, uint32_t scalin
   {
     if (isPredictor)
     {
-      data     = deltasrc[64];
+      data = deltasrc[64];
       nextCoef = deltasrc[64];
     }
     else
     {
-      data     = scalingList->getScalingListDC(scalingListId) - nextCoef;
+      data = scalingList->getScalingListDC(scalingListId) - nextCoef;
       nextCoef = scalingList->getScalingListDC(scalingListId);
     }
     data = ((data + 128) & 255) - 128;
-    WRITE_SVLC((int8_t) data, "scaling_list_dc_coef");
+    WRITE_SVLC((int8_t)data, "scaling_list_dc_coef");
   }
-  for (int i = 0; i < coefNum; i++)
+  for(int i=0;i<coefNum;i++)
   {
     if (scalingListId >= SCALING_LIST_1D_START_64x64 && scan[i].x >= 4 && scan[i].y >= 4)
       continue;
-    data     = (isPredictor) ? (deltasrc[i] - nextCoef) : (src[scan[i].idx] - nextCoef);
+    data = (isPredictor) ? (deltasrc[i] - nextCoef) : (src[scan[i].idx] - nextCoef);
     nextCoef = (isPredictor) ? deltasrc[i] : src[scan[i].idx];
-    data     = ((data + 128) & 255) - 128;
-    WRITE_SVLC((int8_t) data, "scaling_list_delta_coef");
+    data = ((data + 128) & 255) - 128;
+    WRITE_SVLC((int8_t)data, "scaling_list_delta_coef");
   }
 }
 
-bool HLSWriter::xFindMatchingLTRP(Slice *pcSlice, uint32_t *ltrpsIndex, int ltrpPOC, bool usedFlag)
+bool HLSWriter::xFindMatchingLTRP(Slice* pcSlice, uint32_t *ltrpsIndex, int ltrpPOC, bool usedFlag)
 {
   // bool state = true, state2 = false;
-  int lsb = ltrpPOC & ((1 << pcSlice->getSPS()->getBitsForPOC()) - 1);
+  int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1);
   for (int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++)
   {
-    if ((lsb == pcSlice->getSPS()->getLtRefPicPocLsbSps(k))
-        && (usedFlag == pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(k)))
+    if ( (lsb == pcSlice->getSPS()->getLtRefPicPocLsbSps(k)) && (usedFlag == pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(k)) )
     {
       *ltrpsIndex = k;
       return true;
@@ -3051,60 +2956,62 @@ bool HLSWriter::xFindMatchingLTRP(Slice *pcSlice, uint32_t *ltrpsIndex, int ltrp
   return false;
 }
 
-void HLSWriter::alfGolombEncode(int coeff, int k, const bool signed_coeff)
+void HLSWriter::alfGolombEncode( int coeff, int k, const bool signed_coeff )
 {
-  unsigned int symbol = abs(coeff);
-  while (symbol >= (unsigned int) (1 << k))
+  unsigned int symbol = abs( coeff );
+  while ( symbol >= (unsigned int)( 1 << k ) )
   {
     symbol -= 1 << k;
     k++;
-    WRITE_FLAG(0, "alf_coeff_abs_prefix");
+    WRITE_FLAG( 0, "alf_coeff_abs_prefix" );
   }
-  WRITE_FLAG(1, "alf_coeff_abs_prefix");
+  WRITE_FLAG( 1, "alf_coeff_abs_prefix" );
 
-  if (k > 0)
+  if ( k > 0 )
   {
-    WRITE_CODE(symbol, k, "alf_coeff_abs_suffix");
+    WRITE_CODE( symbol, k, "alf_coeff_abs_suffix" );
   }
-  if (signed_coeff && coeff != 0)
+  if ( signed_coeff && coeff != 0 )
   {
-    WRITE_FLAG((coeff < 0) ? 1 : 0, "alf_coeff_sign");
+    WRITE_FLAG( (coeff < 0) ? 1 : 0, "alf_coeff_sign" );
   }
 }
 
-void HLSWriter::alfFilter(const AlfParam &alfParam, const bool isChroma, const int altIdx)
+void HLSWriter::alfFilter( const AlfParam& alfParam, const bool isChroma, const int altIdx )
 {
   AlfFilterShape alfShape(isChroma ? 5 : 7);
-  const short *  coeff      = isChroma ? alfParam.chromaCoeff[altIdx] : alfParam.lumaCoeff;
-  const short *  clipp      = isChroma ? alfParam.chromaClipp[altIdx] : alfParam.lumaClipp;
-  const int      numFilters = isChroma ? 1 : alfParam.numLumaFilters;
+  const short* coeff = isChroma ? alfParam.chromaCoeff[altIdx] : alfParam.lumaCoeff;
+  const short* clipp = isChroma ? alfParam.chromaClipp[altIdx] : alfParam.lumaClipp;
+  const int numFilters = isChroma ? 1 : alfParam.numLumaFilters;
 
   // vlc for all
 
   // Filter coefficients
-  for (int ind = 0; ind < numFilters; ++ind)
+  for( int ind = 0; ind < numFilters; ++ind )
   {
-    for (int i = 0; i < alfShape.numCoeff - 1; i++)
+
+    for( int i = 0; i < alfShape.numCoeff - 1; i++ )
     {
-      alfGolombEncode(coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i], 3);   // alf_coeff_chroma[i], alf_coeff_luma_delta[i][j]
+      alfGolombEncode( coeff[ind* MAX_NUM_ALF_LUMA_COEFF + i], 3 );  // alf_coeff_chroma[i], alf_coeff_luma_delta[i][j]
     }
   }
 
   // Clipping values coding
 #if JVET_Q0249_ALF_CHROMA_CLIPFLAG
-  if (alfParam.nonLinearFlag[isChroma])
+  if( alfParam.nonLinearFlag[isChroma] )
 #else
-  if (alfParam.nonLinearFlag[isChroma][altIdx])
+  if( alfParam.nonLinearFlag[isChroma][altIdx] )
 #endif
   {
     for (int ind = 0; ind < numFilters; ++ind)
     {
       for (int i = 0; i < alfShape.numCoeff - 1; i++)
       {
-        WRITE_CODE(clipp[ind * MAX_NUM_ALF_LUMA_COEFF + i], 2, "alf_clipping_index");
+        WRITE_CODE(clipp[ind* MAX_NUM_ALF_LUMA_COEFF + i], 2, "alf_clipping_index");
       }
     }
   }
 }
 
+
 //! \}
diff --git a/source/Lib/EncoderLib/VLCWriter.h b/source/Lib/EncoderLib/VLCWriter.h
index 54e4bcd3bf83b54c48b20e4a9f76e25e85c5ac43..da8f1b5fda86b5c1f126e8dc2a4eb99955df2f22 100644
--- a/source/Lib/EncoderLib/VLCWriter.h
+++ b/source/Lib/EncoderLib/VLCWriter.h
@@ -115,10 +115,9 @@ public:
 private:
   void xCodeRefPicList( const ReferencePictureList* rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount, const bool isForbiddenZeroDeltaPoc );
   bool xFindMatchingLTRP        ( Slice* pcSlice, uint32_t *ltrpsIndex, int ltrpPOC, bool usedFlag );
+  void xCodePredWeightTable     ( Slice* pcSlice );
 #if JVET_Q0819_PH_CHANGES
-  void xCodePredWeightTable     ( Slice *pcSlice, PicHeader *picHeader, const SPS *sps );
-#else
-  void xCodePredWeightTable     ( Slice *pcSlice );
+  void xCodePredWeightTable     ( PicHeader *picHeader, const SPS *sps );
 #endif
   void xCodeScalingList         ( const ScalingList* scalingList, uint32_t scalinListId, bool isPredictor);
 public: