shithub: openh264

Download patch

ref: 36d56b6638ee705d01fd30ec8e8e3099fbdc7ee7
parent: 2c796337baa11227bd7299464ee43b2618090777
author: ruil2 <[email protected]>
date: Mon Mar 17 06:46:38 EDT 2014

modify EncoderFrame return type.
commit b99a307ab94183c32a293ad5fda8b0e3323546a0
Author: ruil2 <[email protected]>
Date:   Wed Mar 12 13:34:27 2014 +0800

    fix typo

--- a/codec/api/svc/codec_api.h
+++ b/codec/api/svc/codec_api.h
@@ -64,7 +64,7 @@
   virtual int EXTAPI Uninitialize() = 0;
 
   /*
-   * return: EVideoFrameType [IDR: videoFrameTypeIDR; P: videoFrameTypeP; ERROR: videoFrameTypeInvalid]
+   * return: 0 - success; otherwise -failed;
    */
   virtual int EXTAPI EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) = 0;
   /*
--- a/codec/api/svc/codec_def.h
+++ b/codec/api/svc/codec_def.h
@@ -75,6 +75,7 @@
   cmUnkonwReason,
   cmMallocMemeError,                /*Malloc a memory error*/
   cmInitExpected,			  /*Initial action is expected*/
+  cmUnsupportedData,
 } CM_RETURN;
 
 
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -1730,8 +1730,8 @@
       break;
     case SM_AUTO_SLICE:
       iMaxSliceCount = MAX_SLICES_NUM;
-	  pDlp->sSliceCfg.sSliceArgument.uiSliceNum = kiCpuCores;
-	  if (pDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceCount){
+      pDlp->sSliceCfg.sSliceArgument.uiSliceNum = kiCpuCores;
+      if (pDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceCount){
         pDlp->sSliceCfg.sSliceArgument.uiSliceNum = iMaxSliceCount;
       }
       if (pDlp->sSliceCfg.sSliceArgument.uiSliceNum == 1) {
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -508,12 +508,29 @@
  */
 int CWelsH264SVCEncoder::EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) {
   if (! (kpSrcPic && m_pEncContext && m_bInitialFlag)) {
-    return videoFrameTypeInvalid;
+    return cmInitParaError;
   }
 
-  int32_t uiFrameType = videoFrameTypeInvalid;
-  uiFrameType = EncodeFrameInternal(kpSrcPic, pBsInfo);
+  const int32_t kiEncoderReturn = EncodeFrameInternal(kpSrcPic, pBsInfo);
 
+  switch (kiEncoderReturn) {
+  case ENC_RETURN_MEMALLOCERR:
+    WelsUninitEncoderExt (&m_pEncContext);
+    return cmMallocMemeError;
+  case ENC_RETURN_SUCCESS:
+  case ENC_RETURN_CORRECTED:
+    break;//continue processing
+  case ENC_RETURN_UNSUPPORTED_PARA:
+    return cmUnsupportedData;
+	break;
+  case ENC_RETURN_UNEXPECTED:
+    return cmUnkonwReason;
+  default:
+    WelsLog (m_pEncContext, WELS_LOG_ERROR, "unexpected return(%d) from WelsEncoderEncodeExt()!\n", kiEncoderReturn);
+    return cmUnkonwReason;
+  }
+
+
 #ifdef REC_FRAME_COUNT
   ++ m_uiCountFrameNum;
   WelsLog (m_pEncContext, WELS_LOG_INFO,
@@ -524,7 +541,7 @@
   DumpSrcPicture (pSrc);
 #endif // DUMP_SRC_PICTURE
 
-  return uiFrameType;
+  return cmResultSuccess;
 }