shithub: openh264

Download patch

ref: 84a5f883dbca6036bd1a17c19da5bbec37e2b602
parent: 7c868cab4d6f962f7e0c6440e5151cb24253dec4
parent: 38ffbf7df48df92592410fe904e372f27b857dab
author: huili2 <huili2@cisco.com>
date: Fri May 8 12:24:22 EDT 2015

Merge pull request #1935 from sijchen/fix_rc3

fix an improper mb-size assignment

--- a/codec/encoder/core/src/svc_enc_slice_segment.cpp
+++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp
@@ -280,33 +280,33 @@
     iGomSize = kiMbWidth * GOM_ROW_MODE0_360P;
   else
     iGomSize = kiMbWidth * GOM_ROW_MODE0_720P;
+  // GOM boundary aligned
+  int32_t iNumMbAssigning = WELS_DIV_ROUND (INT_MULTIPLY * kiMbNumPerSlice, iGomSize * INT_MULTIPLY) * iGomSize;
+  int32_t iCurNumMbAssigning = 0;
 
   iMinimalMbNum	= iGomSize;
-  iMaximalMbNum	= kiMbNumInFrame - (kuiSliceNum - 1) * iMinimalMbNum;
-
   while (uiSliceIdx + 1 < kuiSliceNum) {
-    // GOM boundary aligned
-    int32_t iNumMbAssigning = WELS_DIV_ROUND (INT_MULTIPLY * kiMbNumPerSlice, iGomSize * INT_MULTIPLY) * iGomSize;
+    iMaximalMbNum	= iNumMbLeft - (kuiSliceNum - uiSliceIdx - 1) * iMinimalMbNum;	// get maximal num_mb in left parts
 
     // make sure one GOM at least in each slice for safe
     if (iNumMbAssigning < iMinimalMbNum)
-      iNumMbAssigning	= iMinimalMbNum;
+      iCurNumMbAssigning	= iMinimalMbNum;
     else if (iNumMbAssigning > iMaximalMbNum)
-      iNumMbAssigning	= iMaximalMbNum;
+      iCurNumMbAssigning	= ( iMaximalMbNum / iGomSize ) * iGomSize;
+    else
+      iCurNumMbAssigning = iNumMbAssigning;
 
-    if (iNumMbAssigning <= 0) {
+    if (iCurNumMbAssigning <= 0) {
       return false;
     }
 
-    iNumMbLeft -= iNumMbAssigning;
+    iNumMbLeft -= iCurNumMbAssigning;
     if (iNumMbLeft <= 0)  {
       return false;
     }
 
-    pSlicesAssignList[uiSliceIdx]	= iNumMbAssigning;
-
+    pSlicesAssignList[uiSliceIdx]	= iCurNumMbAssigning;
     ++ uiSliceIdx;
-    iMaximalMbNum	= iNumMbLeft - (kuiSliceNum - uiSliceIdx - 1) * iMinimalMbNum;	// get maximal num_mb in left parts
   }
   pSlicesAssignList[uiSliceIdx] = iNumMbLeft;