shithub: openh264

Download patch

ref: e751502412b2938ed3f5b78bc599ae493de78115
parent: 901f8ba19ab0625534c2ce8fbdd58506fc8a7d36
parent: 47430de2949283d2c34dd355d94334a0d07263e4
author: dongzha <[email protected]>
date: Tue May 20 06:45:55 EDT 2014

Merge pull request #864 from ruil2/enc_quant

set minimum quant as 4 to avoid level code overflow

--- a/codec/encoder/core/inc/rc.h
+++ b/codec/encoder/core/inc/rc.h
@@ -66,6 +66,8 @@
   VGOP_SIZE             = 8,
 
   //qp information
+  FIX_MIN_QP_MODE       = 4, //qp <4 will cause level code overflow in cavlc coding which isn't suppored in baseline profile
+  FIX_MAX_QP_MODE       = 51,
   GOM_MIN_QP_MODE       = 12,
   GOM_MAX_QP_MODE       = 36,
   MAX_LOW_BR_QP			= 42,
--- a/codec/encoder/core/src/ratectl.cpp
+++ b/codec/encoder/core/src/ratectl.cpp
@@ -920,7 +920,10 @@
   if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
     pEncCtx->iGlobalQp = (int32_t)WELS_CLIP3 (pEncCtx->iGlobalQp -
                          pEncCtx->pVaa->sAdaptiveQuantParam.dAverMotionTextureIndexToDeltaQp, GOM_MIN_QP_MODE, GOM_MAX_QP_MODE);
+  }else{
+    pEncCtx->iGlobalQp = WELS_CLIP3(pEncCtx->iGlobalQp, FIX_MIN_QP_MODE, FIX_MAX_QP_MODE);
   }
+
   pWelsSvcRc->iAverageFrameQp = pEncCtx->iGlobalQp;
 }
 
@@ -934,6 +937,8 @@
   if (pEncCtx->pSvcParam->bEnableAdaptiveQuant && (pEncCtx->eSliceType == P_SLICE)) {
     iLumaQp   = (int8_t)WELS_CLIP3 (iLumaQp +
                                     pEncCtx->pVaa->sAdaptiveQuantParam.pMotionTextureIndexToDeltaQp[pCurMb->iMbXY], GOM_MIN_QP_MODE, 51);
+  }else{
+    iLumaQp = WELS_CLIP3(iLumaQp,FIX_MIN_QP_MODE,FIX_MAX_QP_MODE);
   }
   pCurMb->uiChromaQp = g_kuiChromaQpTable[iLumaQp];
   pCurMb->uiLumaQp = iLumaQp;