shithub: openh264

Download patch

ref: 66165a65d5e204ca8db31220aa7e3523d79b569a
parent: 128546b99229a0dc3d42052c8f1e45a9b0b83116
author: ruil2 <[email protected]>
date: Thu Nov 13 08:26:14 EST 2014

add return value processing

--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -2086,9 +2086,14 @@
     return iRet;
   }
 
-  if (pCodingParam->iMultipleThreadIdc > 1)
+  if (pCodingParam->iMultipleThreadIdc > 1) {
     iRet = CreateSliceThreads (pCtx);
-
+    if (iRet != 0) {
+      WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), CreateSliceThreads failed return %d.", iRet);
+      FreeMemorySvc (&pCtx);
+      return iRet;
+    }
+  }
   if (pCodingParam->iEntropyCodingModeFlag)
     WelsCabacInit (pCtx);
   WelsRcInitModule (pCtx,  pCtx->pSvcParam->iRCMode);
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -963,8 +963,11 @@
   int32_t iIdx = 0;
 
   while (iIdx < kiThreadCount) {
-    WelsThreadCreate (&pCtx->pSliceThreading->pThreadHandles[iIdx], CodingSliceThreadProc,
-                      &pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0);
+    if (WelsThreadCreate (&pCtx->pSliceThreading->pThreadHandles[iIdx], CodingSliceThreadProc,
+                          &pCtx->pSliceThreading->pThreadPEncCtx[iIdx], 0)) {
+      return 1;
+    }
+
 
     ++ iIdx;
   }