shithub: openh264

Download patch

ref: 78a34c5c89ed89c07f3980f2791f4808c930e23e
parent: 6ea8b264bb39e83b68ebfaeb3ac93206358c023b
author: Linjie Fu <linjie.fu@intel.com>
date: Fri Apr 10 13:13:12 EDT 2020

codec/encoder: fix multi refs encoding support for FFmpeg

1. pCodingParam.iNumRefFrame should be valid within the range of
(MIN_REF_PIC_COUNT, MAX_REF_PIC_COUNT), inclusive.

2. While in WelsBuildRefList(), we should not break after finishing
the first RefList;

3. pCurSliceHeader->uiRefCount should be allowed to equal to
pCurLayer->sLayerInfo.pSpsP->iNumRefFrames.

Signed-off-by: Linjie Fu <fulinjie@zju.edu.cn>

--- a/codec/encoder/core/inc/param_svc.h
+++ b/codec/encoder/core/inc/param_svc.h
@@ -365,7 +365,7 @@
       uiIntraPeriod = ((uiIntraPeriod + uiGopSize - 1) / uiGopSize) * uiGopSize;
 
     if (((pCodingParam.iNumRefFrame != AUTO_REF_PIC_COUNT)
-         && ((pCodingParam.iNumRefFrame > MAX_REF_PIC_COUNT) || (pCodingParam.iNumRefFrame < MIN_REF_PIC_COUNT)))
+         && !((pCodingParam.iNumRefFrame > MAX_REF_PIC_COUNT) || (pCodingParam.iNumRefFrame < MIN_REF_PIC_COUNT)))
         || ((iNumRefFrame != AUTO_REF_PIC_COUNT) && (pCodingParam.iNumRefFrame == AUTO_REF_PIC_COUNT))) {
       iNumRefFrame  = pCodingParam.iNumRefFrame;
     }
--- a/codec/encoder/core/src/ref_list_mgr_svc.cpp
+++ b/codec/encoder/core/src/ref_list_mgr_svc.cpp
@@ -628,7 +628,6 @@
           WelsLog (& (pCtx->sLogCtx), WELS_LOG_DETAIL,
                    "WelsBuildRefList pCtx->uiTemporalId = %d,pRef->iFrameNum = %d,pRef->uiTemporalId = %d",
                    pCtx->uiTemporalId, pRef->iFrameNum, pRef->uiTemporalId);
-          break;
         }
       }
     }
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -101,7 +101,7 @@
   if (P_SLICE == pEncCtx->eSliceType) {
     pCurSliceHeader->uiNumRefIdxL0Active = 1;
     if (pCurSliceHeader->uiRefCount > 0 &&
-        pCurSliceHeader->uiRefCount < pCurLayer->sLayerInfo.pSpsP->iNumRefFrames) {
+        pCurSliceHeader->uiRefCount <= pCurLayer->sLayerInfo.pSpsP->iNumRefFrames) {
       pCurSliceHeader->bNumRefIdxActiveOverrideFlag = true;
       pCurSliceHeader->uiNumRefIdxL0Active = pCurSliceHeader->uiRefCount;
     }