Index: branches/SHM-dev/source/Lib/TLibDecoder/TDecSlice.cpp
===================================================================
--- branches/SHM-dev/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 1244)
+++ branches/SHM-dev/source/Lib/TLibDecoder/TDecSlice.cpp	(revision 1245)
@@ -228,29 +228,29 @@
     }
 
-    // Should the sub-stream/stream be terminated after this CTU?
-    // (end of slice-segment, end of tile, end of wavefront-CTU-row)
-    if (isLastCtuOfSliceSegment ||
-         (  ctuXPosInCtus + 1 == tileXPosInCtus + currentTile.getTileWidthInCtus() &&
-          ( ctuYPosInCtus + 1 == tileYPosInCtus + currentTile.getTileHeightInCtus() || wavefrontsEnabled)
-         )
-       )
-    {
+    if (isLastCtuOfSliceSegment)
+    {
+#if DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES
+      pcSbacDecoder->parseRemainingBytes(false);
+#endif
+      if(!pcSlice->getDependentSliceSegmentFlag())
+      {
+        pcSlice->setSliceCurEndCtuTsAddr( ctuTsAddr+1 );
+      }
+      pcSlice->setSliceSegmentCurEndCtuTsAddr( ctuTsAddr+1 );
+    }
+    else if (  ctuXPosInCtus + 1 == tileXPosInCtus + currentTile.getTileWidthInCtus() &&
+             ( ctuYPosInCtus + 1 == tileYPosInCtus + currentTile.getTileHeightInCtus() || wavefrontsEnabled)
+            )
+    {
+      // The sub-stream/stream should be terminated after this CTU.
+      // (end of slice-segment, end of tile, end of wavefront-CTU-row)
       UInt binVal;
       pcSbacDecoder->parseTerminatingBit( binVal );
       assert( binVal );
 #if DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES
-      pcSbacDecoder->parseRemainingBytes(!isLastCtuOfSliceSegment);
-#endif
-
-      if (isLastCtuOfSliceSegment)
-      {
-        if(!pcSlice->getDependentSliceSegmentFlag())
-        {
-          pcSlice->setSliceCurEndCtuTsAddr( ctuTsAddr+1 );
-        }
-        pcSlice->setSliceSegmentCurEndCtuTsAddr( ctuTsAddr+1 );
-        break;
-      }
-    }
+      pcSbacDecoder->parseRemainingBytes(true);
+#endif
+    }
+
   }
 
