Index: /branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 1264)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComDataCU.h	(revision 1265)
@@ -101,5 +101,5 @@
   Bool*          m_CUTransquantBypass;   ///< array of cu_transquant_bypass flags
   Char*          m_phQP;               ///< array of QP values
-  UChar*         m_ChromaQpAdj;        ///< array of chroma QP adjustments (indexed)
+  UChar*         m_ChromaQpAdj;        ///< array of chroma QP adjustments (indexed). when value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
   UInt           m_codedChromaQpAdj;
   UChar*         m_puhTrIdx;           ///< array of transform indices
@@ -267,7 +267,7 @@
   Char          getCodedQP            ()                        { return m_codedQP;           }
 
-  UChar*        getChromaQpAdj        ()                        { return m_ChromaQpAdj;       }
-  UChar         getChromaQpAdj        (Int idx)           const { return m_ChromaQpAdj[idx];  }
-  Void          setChromaQpAdj        (Int idx, UChar val)      { m_ChromaQpAdj[idx] = val;   }
+  UChar*        getChromaQpAdj        ()                        { return m_ChromaQpAdj;       } ///< array of chroma QP adjustments (indexed). when value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
+  UChar         getChromaQpAdj        (Int idx)           const { return m_ChromaQpAdj[idx];  } ///< When value = 0, cu_chroma_qp_offset_flag=0; when value>0, indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=value-1
+  Void          setChromaQpAdj        (Int idx, UChar val)      { m_ChromaQpAdj[idx] = val;   } ///< When val = 0,   cu_chroma_qp_offset_flag=0; when val>0,   indicates cu_chroma_qp_offset_flag=1 and cu_chroma_qp_offset_idx=val-1
   Void          setChromaQpAdjSubParts( UChar val, Int absPartIdx, Int depth );
   Void          setCodedChromaQpAdj   ( Char qp )               { m_codedChromaQpAdj = qp;    }
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 1264)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp	(revision 1265)
@@ -2295,6 +2295,6 @@
     m_saoOffsetBitShift[ch] = 0;
   }
-  m_ChromaQpAdjTable[0].u.comp.CbOffset = 0;
-  m_ChromaQpAdjTable[0].u.comp.CrOffset = 0;
+  m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CbOffset = 0; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0. This is initialised here and never subsequently changed.
+  m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CrOffset = 0;
 
 #if SVC_EXTENSION
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1264)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1265)
@@ -1615,6 +1615,6 @@
   // Chroma QP Adjustments
   Int              m_MaxCuChromaQpAdjDepth;
-  Int              m_ChromaQpAdjTableSize;
-  ChromaQpAdj      m_ChromaQpAdjTable[7];
+  Int              m_ChromaQpAdjTableSize; // size (excludes the null entry used in the following array).
+  ChromaQpAdj      m_ChromaQpAdjTableIncludingNullEntry[1+MAX_QP_OFFSET_LIST_SIZE]; //!< Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise
 
   Int              m_chromaCbQpOffset;
@@ -1725,10 +1725,17 @@
   Void                   clearChromaQpAdjTable()                                          { m_ChromaQpAdjTableSize = 0;                   }
   Int                    getChromaQpAdjTableSize() const                                  { return m_ChromaQpAdjTableSize;                }
-  const ChromaQpAdj&     getChromaQpAdjTableAt( Int idx ) const                           { return m_ChromaQpAdjTable[idx];               }
-  Void                   setChromaQpAdjTableAt( Int idx, Int cbOffset, Int crOffset )
+
+  const ChromaQpAdj&     getChromaQpAdjTableAt( Int cuChromaQpOffsetIdxPlus1 ) const
   {
-    m_ChromaQpAdjTable[idx].u.comp.CbOffset = cbOffset;
-    m_ChromaQpAdjTable[idx].u.comp.CrOffset = crOffset;
-    m_ChromaQpAdjTableSize = max(m_ChromaQpAdjTableSize, idx);
+    assert(cuChromaQpOffsetIdxPlus1 < m_ChromaQpAdjTableSize+1);
+    return m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1]; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise
+  }
+
+  Void                   setChromaQpAdjTableAt( Int cuChromaQpOffsetIdxPlus1, Int cbOffset, Int crOffset )
+  {
+    assert (cuChromaQpOffsetIdxPlus1 != 0 && cuChromaQpOffsetIdxPlus1 <= MAX_QP_OFFSET_LIST_SIZE);
+    m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.CbOffset = cbOffset; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0, and entries [cu_chroma_qp_offset_idx+1...] otherwise
+    m_ChromaQpAdjTableIncludingNullEntry[cuChromaQpOffsetIdxPlus1].u.comp.CrOffset = crOffset;
+    m_ChromaQpAdjTableSize = max(m_ChromaQpAdjTableSize, cuChromaQpOffsetIdxPlus1);
   }
 
Index: /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1264)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1265)
@@ -314,4 +314,5 @@
 #define O0043_BEST_EFFORT_DECODING                        0 ///< 0 (default) = disable code related to best effort decoding, 1 = enable code relating to best effort decoding [ decode-side only ].
 
+#define MAX_QP_OFFSET_LIST_SIZE                           6 ///< Maximum size of QP offset list is 6 entries
 // Cost mode support
 
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1264)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp	(revision 1265)
@@ -385,6 +385,7 @@
               UInt tableSizeMinus1 = 0;
               READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1");
-              /* skip zero index */
-              for (Int chromaQpAdjustmentIndex = 1; chromaQpAdjustmentIndex <= (tableSizeMinus1 + 1); chromaQpAdjustmentIndex++)
+              assert(tableSizeMinus1 < MAX_QP_OFFSET_LIST_SIZE);
+
+              for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++)
               {
                 Int cbOffset;
@@ -394,5 +395,6 @@
                 READ_SVLC(crOffset, "cr_qp_offset_list[i]");
                 assert(crOffset >= -12 && crOffset <= 12);
-                pcPPS->setChromaQpAdjTableAt(chromaQpAdjustmentIndex, cbOffset, crOffset);
+                // table uses +1 for index (see comment inside the function)
+                pcPPS->setChromaQpAdjTableAt(cuChromaQpOffsetIdx+1, cbOffset, crOffset);
               }
               assert(pcPPS->getChromaQpAdjTableSize() == tableSizeMinus1 + 1);
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1264)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp	(revision 1265)
@@ -300,8 +300,8 @@
               WRITE_UVLC(pcPPS->getChromaQpAdjTableSize() - 1,                    "chroma_qp_offset_list_len_minus1");
               /* skip zero index */
-              for (Int chromaQpAdjustmentIndex = 1; chromaQpAdjustmentIndex <= pcPPS->getChromaQpAdjTableSize(); chromaQpAdjustmentIndex++)
+              for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < pcPPS->getChromaQpAdjTableSize(); cuChromaQpOffsetIdx++)
               {
-                WRITE_SVLC(pcPPS->getChromaQpAdjTableAt(chromaQpAdjustmentIndex).u.comp.CbOffset,     "cb_qp_offset_list[i]");
-                WRITE_SVLC(pcPPS->getChromaQpAdjTableAt(chromaQpAdjustmentIndex).u.comp.CrOffset,     "cr_qp_offset_list[i]");
+                WRITE_SVLC(pcPPS->getChromaQpAdjTableAt(cuChromaQpOffsetIdx+1).u.comp.CbOffset,     "cb_qp_offset_list[i]");
+                WRITE_SVLC(pcPPS->getChromaQpAdjTableAt(cuChromaQpOffsetIdx+1).u.comp.CrOffset,     "cr_qp_offset_list[i]");
               }
             }
