shithub: openh264

Download patch

ref: 35e073714dcc042c31508f8493e4ac7db9a0bc3e
parent: 60cbb7758377b36eaeee5e354622456a3f5b0c99
author: Karina <ruil2@cisco.com>
date: Wed Jun 22 09:33:50 EDT 2016

fix QP issue when adaptive quant turns on

--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -464,14 +464,12 @@
                           pWelsSvcRc->iLastCalculatedQScale + pWelsSvcRc->iFrameDeltaQpUpper + iDeltaQpTemporal);
     iLumaQp = WELS_CLIP3 (iLumaQp,  pTOverRc->iMinQp, pTOverRc->iMaxQp);
 
-    pWelsSvcRc->iQStep = RcConvertQp2QStep (iLumaQp);
-    pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
-
     if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
       iLumaQp = WELS_CLIP3 ((iLumaQp * INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp) /
                             INT_MULTIPLY, pTOverRc->iMinQp, pTOverRc->iMaxQp);
     }
-
+    pWelsSvcRc->iQStep = RcConvertQp2QStep (iLumaQp);
+    pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
     pEncCtx->iGlobalQp = iLumaQp;
 
     return;
@@ -500,9 +498,6 @@
   }
 
   iLumaQp = WELS_CLIP3 (iLumaQp,  pTOverRc->iMinQp, pTOverRc->iMaxQp);
-
-  pWelsSvcRc->iQStep = RcConvertQp2QStep (iLumaQp);
-  pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
   if (pEncCtx->pSvcParam->bEnableAdaptiveQuant) {
 
     iLumaQp =  WELS_DIV_ROUND (iLumaQp * INT_MULTIPLY - pEncCtx->pVaa->sAdaptiveQuantParam.iAverMotionTextureIndexToDeltaQp,
@@ -509,6 +504,8 @@
                                INT_MULTIPLY);
     iLumaQp = WELS_CLIP3 (iLumaQp, pTOverRc->iMinQp, pTOverRc->iMaxQp);
   }
+  pWelsSvcRc->iQStep = RcConvertQp2QStep (iLumaQp);
+  pWelsSvcRc->iLastCalculatedQScale = iLumaQp;
   pEncCtx->iGlobalQp = iLumaQp;
 }