shithub: openh264

Download patch

ref: f3376c2537bf0e8f90dff42fd99eafdf342441f1
parent: eac070c0b9202040cd0458cadbe4a46956a75c60
parent: 986f3d06e67ff42d7c87101c3d685f2229c0af74
author: guangwei <GuangweiWang@users.noreply.github.com>
date: Mon Jun 5 10:53:25 EDT 2017

Merge pull request #2758 from huili2/MMCO_456_once_only_bugfix

MMCO's constraint for 4,5,6 once only

--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -77,7 +77,8 @@
 
 
   if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE) {
-    if ((pCtx->sDecoderStatistics.uiWidth != (unsigned int) kiActualWidth) || (pCtx->sDecoderStatistics.uiHeight != (unsigned int) kiActualHeight)) {
+    if ((pCtx->sDecoderStatistics.uiWidth != (unsigned int) kiActualWidth)
+        || (pCtx->sDecoderStatistics.uiHeight != (unsigned int) kiActualHeight)) {
       pCtx->sDecoderStatistics.uiResolutionChangeTimes++;
       pCtx->sDecoderStatistics.uiWidth = kiActualWidth;
       pCtx->sDecoderStatistics.uiHeight = kiActualHeight;
@@ -438,6 +439,7 @@
     kpRefMarking->bAdaptiveRefPicMarkingModeFlag = !!uiCode;
     if (kpRefMarking->bAdaptiveRefPicMarkingModeFlag) {
       int32_t iIdx = 0;
+      bool bAllowMmco5 = true, bMmco4Exist = false, bMmco5Exist = false, bMmco6Exist = false;
       do {
         WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //memory_management_control_operation
         const uint32_t kuiMmco = uiCode;
@@ -447,20 +449,31 @@
           break;
 
         if (kuiMmco == MMCO_SHORT2UNUSED || kuiMmco == MMCO_SHORT2LONG) {
+          bAllowMmco5 = false;
           WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //difference_of_pic_nums_minus1
           kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum = 1 + uiCode;
           kpRefMarking->sMmcoRef[iIdx].iShortFrameNum = (pSh->iFrameNum - kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum) & ((
                 1 << pSps->uiLog2MaxFrameNum) - 1);
         } else if (kuiMmco == MMCO_LONG2UNUSED) {
+          bAllowMmco5 = false;
           WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_pic_num
           kpRefMarking->sMmcoRef[iIdx].uiLongTermPicNum = uiCode;
         }
         if (kuiMmco == MMCO_SHORT2LONG || kuiMmco == MMCO_LONG) {
+          if (kuiMmco == MMCO_LONG) {
+            WELS_VERIFY_RETURN_IF (-1, bMmco6Exist);
+            bMmco6Exist = true;
+          }
           WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_frame_idx
           kpRefMarking->sMmcoRef[iIdx].iLongTermFrameIdx = uiCode;
         } else if (kuiMmco == MMCO_SET_MAX_LONG) {
+          WELS_VERIFY_RETURN_IF (-1, bMmco4Exist);
+          bMmco4Exist = true;
           WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //max_long_term_frame_idx_plus1
           kpRefMarking->sMmcoRef[iIdx].iMaxLongTermFrameIdx = -1 + uiCode;
+        } else if (kuiMmco == MMCO_RESET) {
+          WELS_VERIFY_RETURN_IF (-1, (!bAllowMmco5 || bMmco5Exist));
+          bMmco5Exist = true;
         }
         ++ iIdx;