shithub: openh264

Download patch

ref: 47430de2949283d2c34dd355d94334a0d07263e4
parent: e15742b4044f35d2df0be6f494b5efb28fc169c2
author: unknown <[email protected]>
date: Tue May 20 06:19:58 EDT 2014

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;