shithub: openh264

Download patch

ref: 943981abc4f0e891386c293b843d037d8bdebf15
parent: bea361a1f09f57698b360e31dafaea854c9988fc
author: Sijia Chen <sijchen@cisco.com>
date: Mon Feb 9 08:50:31 EST 2015

fix a nal generation for simulcast avc and add nal-type check for simulcast avc UT

--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -355,6 +355,13 @@
     pCodingParam->eSpsPpsIdStrategy = INCREASING_ID;
   }
 
+  if (pCodingParam->bSimulcastAVC && pCodingParam->bPrefixNalAddingCtrl) {
+    WelsLog (pLogCtx, WELS_LOG_INFO,
+             "ParamValidationExt(), bSimulcastAVC(%d) is not compatible with bPrefixNalAddingCtrl(%d) true, adjusted bPrefixNalAddingCtrl to false",
+             pCodingParam->eSpsPpsIdStrategy, pCodingParam->bSimulcastAVC);
+    pCodingParam->bPrefixNalAddingCtrl = false;
+  }
+
   for (i = 0; i < pCodingParam->iSpatialLayerNum; ++ i) {
     SSpatialLayerConfig* pSpatialLayer = &pCodingParam->sSpatialLayers[i];
     const int32_t kiPicWidth = pSpatialLayer->iVideoWidth;
@@ -3689,9 +3696,9 @@
 
     iNalIdxInLayer	= 0;
     bAvcBased	= ((pSvcParam->bSimulcastAVC) || (iCurDid == BASE_DEPENDENCY_ID));
-    pCtx->bNeedPrefixNalFlag	= (bAvcBased &&
+    pCtx->bNeedPrefixNalFlag	= ((!pSvcParam->bSimulcastAVC) && (bAvcBased &&
                                  (pSvcParam->bPrefixNalAddingCtrl ||
-                                  (pSvcParam->iSpatialLayerNum > 1)));
+                                  (pSvcParam->iSpatialLayerNum > 1))));
 
     if (eFrameType == videoFrameTypeP) {
       eNalType	= bAvcBased ? NAL_UNIT_CODED_SLICE : NAL_UNIT_CODED_SLICE_EXT;
--- a/test/api/encode_decode_api_test.cpp
+++ b/test/api/encode_decode_api_test.cpp
@@ -3210,6 +3210,9 @@
     for (int iLayer = 0; iLayer < info.iLayerNum; ++iLayer) {
       iLayerLen = 0;
       const SLayerBSInfo& layerInfo = info.sLayerInfo[iLayer];
+      const int kiFirstNalType = ((* (layerInfo.pBsBuf + 4)) & 0x1f);
+      ASSERT_TRUE ((kiFirstNalType == NAL_SPS) || (kiFirstNalType == NAL_PPS) || (kiFirstNalType == NAL_SLICE)
+                   || (kiFirstNalType == NAL_SLICE_IDR) || (kiFirstNalType == NAL_SEI));
       for (int iNal = 0; iNal < layerInfo.iNalCount; ++iNal) {
         iLayerLen += layerInfo.pNalLengthInByte[iNal];
       }