shithub: openh264

Download patch

ref: 5bffb627d62de215ab96cffe01d9e342bac566a6
parent: 8962b7c98baa809867d23d301665b9c0e99db10b
author: Licai Guo <guolicai@gmail.com>
date: Thu Mar 13 15:31:28 EDT 2014

nzc bug fix and clear

--- a/codec/decoder/core/src/decode_slice.cpp
+++ b/codec/decoder/core/src/decode_slice.cpp
@@ -517,7 +517,7 @@
     //step 3: update QP and pNonZeroCount
     pCurLayer->pLumaQp[iMbXy] = 0;
     pCurLayer->pChromaQp[iMbXy] = 0;
-    memset (pCurLayer->pNzc[iMbXy], 16, sizeof (pCurLayer->pNzc[iMbXy]));   //JVT-x201wcm1.doc, page229, 2009.10.23
+    memset (pCurLayer->pNzc[iMbXy], 16, sizeof (pCurLayer->pNzc[iMbXy]));   //Rec. 9.2.1 for PCM, nzc=16
     return 0;
   } else if (0 == uiMbType) { //reference to JM
     ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
@@ -683,13 +683,6 @@
       ST16 (&pCurLayer->pNzc[iMbXy][22], 0);
     }
     BsEndCavlc (pBs);
-  } else {
-    ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
-    ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
-    ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
-    ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
-    ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
-    ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
   }
 
   return 0;
@@ -827,10 +820,13 @@
       //step 3: update QP and pNonZeroCount
       pCurLayer->pLumaQp[iMbXy] = 0;
       pCurLayer->pChromaQp[iMbXy] = 0;
-      ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
-      ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
-      ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
-      ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
+      //Rec. 9.2.1 for PCM, nzc=16
+      ST32 (&pCurLayer->pNzc[iMbXy][0], 0x10101010);
+      ST32 (&pCurLayer->pNzc[iMbXy][4], 0x10101010);
+      ST32 (&pCurLayer->pNzc[iMbXy][8], 0x10101010);
+      ST32 (&pCurLayer->pNzc[iMbXy][12], 0x10101010);
+      ST32 (&pCurLayer->pNzc[iMbXy][16], 0x10101010);
+      ST32 (&pCurLayer->pNzc[iMbXy][20], 0x10101010);
       return 0;
     } else {
       if (0 == uiMbType) {
@@ -883,6 +879,7 @@
     ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
     ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
     ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
+    ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
     ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
     if (pCurLayer->pCbp[iMbXy] == 0 && !IS_INTRA16x16 (pCurLayer->pMbType[iMbXy]) && !IS_I_BL (pCurLayer->pMbType[iMbXy])) {
       pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
@@ -1004,13 +1001,6 @@
       ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
     }
     BsEndCavlc (pBs);
-  } else {
-    ST32 (&pCurLayer->pNzc[iMbXy][0], 0);
-    ST32 (&pCurLayer->pNzc[iMbXy][4], 0);
-    ST32 (&pCurLayer->pNzc[iMbXy][8], 0);
-    ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
-    ST32 (&pCurLayer->pNzc[iMbXy][16], 0);
-    ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
   }
 
   return 0;