move DecoderConfigParam into InitDecoder
This commit is contained in:
parent
d0d7ad57c2
commit
ecab683f0f
@ -525,13 +525,6 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa
|
||||
if (NULL == pCtx || NULL == kpParam)
|
||||
return 1;
|
||||
|
||||
CMemoryAlign* pMa = pCtx->pMemAlign;
|
||||
|
||||
pCtx->pParam = (SDecodingParam*)pMa->WelsMallocz (sizeof (SDecodingParam), "SDecodingParam");
|
||||
|
||||
if (NULL == pCtx->pParam)
|
||||
return 1;
|
||||
|
||||
memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));
|
||||
pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat;
|
||||
if (!pCtx->bParseOnly) {
|
||||
@ -539,6 +532,14 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa
|
||||
if (iRet)
|
||||
return iRet;
|
||||
}
|
||||
if ((pCtx->pParam->eEcActiveIdc > ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE)
|
||||
|| (pCtx->pParam->eEcActiveIdc < ERROR_CON_DISABLE)) {
|
||||
WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
|
||||
"eErrorConMethod (%d) not in range: (%d - %d). Set as default value: (%d).", pCtx->pParam->eEcActiveIdc,
|
||||
ERROR_CON_DISABLE, ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE,
|
||||
ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE);
|
||||
pCtx->pParam->eEcActiveIdc = ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE;
|
||||
}
|
||||
pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc;
|
||||
|
||||
if (pCtx->bParseOnly) //parse only, disable EC method
|
||||
|
@ -109,7 +109,7 @@ virtual long EXTAPI GetOption (DECODER_OPTION eOptID, void* pOption);
|
||||
PWelsDecoderContext m_pDecContext;
|
||||
welsCodecTrace* m_pWelsTrace;
|
||||
|
||||
int32_t InitDecoder (const bool);
|
||||
int32_t InitDecoder (const SDecodingParam* pParam);
|
||||
void UninitDecoder (void);
|
||||
int32_t ResetDecoder();
|
||||
|
||||
|
@ -198,11 +198,7 @@ long CWelsDecoder::Initialize (const SDecodingParam* pParam) {
|
||||
}
|
||||
|
||||
// H.264 decoder initialization,including memory allocation,then open it ready to decode
|
||||
iRet = InitDecoder (pParam->bParseOnly);
|
||||
if (iRet)
|
||||
return iRet;
|
||||
|
||||
iRet = DecoderConfigParam (m_pDecContext, pParam);
|
||||
iRet = InitDecoder (pParam);
|
||||
if (iRet)
|
||||
return iRet;
|
||||
|
||||
@ -241,11 +237,11 @@ void CWelsDecoder::UninitDecoder (void) {
|
||||
}
|
||||
|
||||
// the return value of this function is not suitable, it need report failure info to upper layer.
|
||||
int32_t CWelsDecoder::InitDecoder (const bool bParseOnly) {
|
||||
int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) {
|
||||
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
|
||||
"CWelsDecoder::init_decoder(), openh264 codec version = %s, ParseOnly = %d",
|
||||
VERSION_NUMBER, (int32_t)bParseOnly);
|
||||
VERSION_NUMBER, (int32_t)pParam->bParseOnly);
|
||||
|
||||
if (m_pDecContext) //free
|
||||
UninitDecoder();
|
||||
@ -256,7 +252,17 @@ int32_t CWelsDecoder::InitDecoder (const bool bParseOnly) {
|
||||
m_pDecContext->pMemAlign = new CMemoryAlign (iCacheLineSize);
|
||||
WELS_VERIFY_RETURN_PROC_IF (1, (NULL == m_pDecContext->pMemAlign), UninitDecoder())
|
||||
|
||||
return WelsInitDecoder (m_pDecContext, bParseOnly, &m_pWelsTrace->m_sLogCtx);
|
||||
WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, WelsInitDecoder (m_pDecContext, pParam->bParseOnly,
|
||||
&m_pWelsTrace->m_sLogCtx), UninitDecoder())
|
||||
|
||||
//check param and update decoder context
|
||||
m_pDecContext->pParam = (SDecodingParam*) m_pDecContext->pMemAlign->WelsMallocz (sizeof (SDecodingParam),
|
||||
"SDecodingParam");
|
||||
WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == m_pDecContext->pParam), UninitDecoder());
|
||||
int32_t iRet = DecoderConfigParam (m_pDecContext, pParam);
|
||||
WELS_VERIFY_RETURN_IFNEQ (iRet, cmResultSuccess);
|
||||
|
||||
return cmResultSuccess;
|
||||
}
|
||||
|
||||
int32_t CWelsDecoder::ResetDecoder() {
|
||||
@ -267,11 +273,7 @@ int32_t CWelsDecoder::ResetDecoder() {
|
||||
SDecodingParam sPrevParam;
|
||||
memcpy (&sPrevParam, m_pDecContext->pParam, sizeof (SDecodingParam));
|
||||
|
||||
int32_t iRet = InitDecoder (m_pDecContext->bParseOnly);
|
||||
if (iRet)
|
||||
return iRet;
|
||||
|
||||
return DecoderConfigParam (m_pDecContext, &sPrevParam);
|
||||
WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, InitDecoder (&sPrevParam), UninitDecoder());
|
||||
} else if (m_pWelsTrace != NULL) {
|
||||
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "ResetDecoder() failed as decoder context null");
|
||||
}
|
||||
|
@ -58,40 +58,6 @@ DECODING_STATE DecodeFrame (const unsigned char* kpSrc,
|
||||
return dsErrorFree;
|
||||
}
|
||||
|
||||
|
||||
int32_t InitDecoder (const bool bParseOnly, PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
|
||||
|
||||
|
||||
if (NULL == pCtx)
|
||||
return cmMallocMemeError;
|
||||
|
||||
if (NULL == pCtx->pMemAlign) {
|
||||
pCtx->pMemAlign = new CMemoryAlign (16);
|
||||
if (NULL == pCtx->pMemAlign)
|
||||
return cmMallocMemeError;
|
||||
}
|
||||
|
||||
return WelsInitDecoder (pCtx, bParseOnly, pLogCtx);
|
||||
}
|
||||
|
||||
long Initialize (const SDecodingParam* pParam, PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
|
||||
int iRet = ERR_NONE;
|
||||
if (pParam == NULL) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
|
||||
// H.264 decoder initialization,including memory allocation,then open it ready to decode
|
||||
iRet = InitDecoder (pParam->bParseOnly, pCtx, pLogCtx);
|
||||
if (iRet)
|
||||
return iRet;
|
||||
|
||||
iRet = DecoderConfigParam (pCtx, pParam);
|
||||
if (iRet)
|
||||
return iRet;
|
||||
|
||||
return cmResultSuccess;
|
||||
}
|
||||
|
||||
void UninitDecoder (PWelsDecoderContext pCtx) {
|
||||
if (NULL == pCtx)
|
||||
return;
|
||||
@ -107,6 +73,43 @@ void UninitDecoder (PWelsDecoderContext pCtx) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int32_t InitDecoder (const SDecodingParam* pParam, PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
|
||||
|
||||
|
||||
if (NULL == pCtx)
|
||||
return cmMallocMemeError;
|
||||
|
||||
if (NULL == pCtx->pMemAlign) {
|
||||
pCtx->pMemAlign = new CMemoryAlign (16);
|
||||
if (NULL == pCtx->pMemAlign)
|
||||
return cmMallocMemeError;
|
||||
}
|
||||
|
||||
WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, WelsInitDecoder (pCtx, pParam->bParseOnly, pLogCtx), UninitDecoder (pCtx));
|
||||
//check param and update decoder context
|
||||
pCtx->pParam = (SDecodingParam*) pCtx->pMemAlign->WelsMallocz (sizeof (SDecodingParam), "SDecodingParam");
|
||||
WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == pCtx->pParam), UninitDecoder (pCtx));
|
||||
int32_t iRet = DecoderConfigParam (pCtx, pCtx->pParam);
|
||||
WELS_VERIFY_RETURN_IFNEQ (iRet, cmResultSuccess);
|
||||
|
||||
return cmResultSuccess;
|
||||
}
|
||||
|
||||
long Initialize (const SDecodingParam* pParam, PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
|
||||
int iRet = ERR_NONE;
|
||||
if (pParam == NULL) {
|
||||
return cmInitParaError;
|
||||
}
|
||||
|
||||
// H.264 decoder initialization,including memory allocation,then open it ready to decode
|
||||
iRet = InitDecoder (pParam, pCtx, pLogCtx);
|
||||
if (iRet)
|
||||
return iRet;
|
||||
|
||||
return cmResultSuccess;
|
||||
}
|
||||
|
||||
class DecoderParseSyntaxTest : public ::testing::Test {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user