History

move DecoderConfigParam into InitDecoder

huili2 committed 11 years ago

Commit ecab6831 parent d0d7ad54 files · +49 −43Browse files

Showing the changes to test/decoder/DecUT_ParseSyntax.cpp (1 of 4 files). Show all

Unified · Split

test/decoder/DecUT_ParseSyntax.cpp+25−22
@@ -58,8 +58,23 @@ DECODING_STATE DecodeFrame (const unsigned char* kpSrc, · 57 unmodified lines
5858 return dsErrorFree;
5959 }
6060
61+void UninitDecoder (PWelsDecoderContext pCtx) {
62+ if (NULL == pCtx)
63+ return;
64+
65+ WelsEndDecoder (pCtx);
66+ if (NULL != pCtx->pMemAlign) {
67+ delete pCtx->pMemAlign;
68+ pCtx->pMemAlign = NULL;
69+ }
70+ if (NULL != pCtx) {
71+ free (pCtx);
72+ pCtx = NULL;
73+ }
6174
62−int32_t InitDecoder (const bool bParseOnly, PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
75+}
76+
77+int32_t InitDecoder (const SDecodingParam* pParam, PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
6378
6479
6580 if (NULL == pCtx)
@@ -71,7 +86,14 @@ int32_t InitDecoder (const bool bParseOnly, PWelsDecoderContext pCtx, SLogContex · 5 unmodified lines
7186 return cmMallocMemeError;
7287 }
7388
74− return WelsInitDecoder (pCtx, bParseOnly, pLogCtx);
89+ WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, WelsInitDecoder (pCtx, pParam->bParseOnly, pLogCtx), UninitDecoder (pCtx));
90+ //check param and update decoder context
91+ pCtx->pParam = (SDecodingParam*) pCtx->pMemAlign->WelsMallocz (sizeof (SDecodingParam), "SDecodingParam");
92+ WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == pCtx->pParam), UninitDecoder (pCtx));
93+ int32_t iRet = DecoderConfigParam (pCtx, pCtx->pParam);
94+ WELS_VERIFY_RETURN_IFNEQ (iRet, cmResultSuccess);
95+
96+ return cmResultSuccess;
7597 }
7698
7799 long Initialize (const SDecodingParam* pParam, PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
@@ -81,32 +103,13 @@ long Initialize (const SDecodingParam* pParam, PWelsDecoderContext pCtx, SLogCon · 3 unmodified lines
81103 }
82104
83105 // H.264 decoder initialization,including memory allocation,then open it ready to decode
84− iRet = InitDecoder (pParam->bParseOnly, pCtx, pLogCtx);
85− if (iRet)
86− return iRet;
87−
88− iRet = DecoderConfigParam (pCtx, pParam);
106+ iRet = InitDecoder (pParam, pCtx, pLogCtx);
89107 if (iRet)
90108 return iRet;
91109
92110 return cmResultSuccess;
93111 }
94112
95−void UninitDecoder (PWelsDecoderContext pCtx) {
96− if (NULL == pCtx)
97− return;
98−
99− WelsEndDecoder (pCtx);
100− if (NULL != pCtx->pMemAlign) {
101− delete pCtx->pMemAlign;
102− pCtx->pMemAlign = NULL;
103− }
104− if (NULL != pCtx) {
105− free (pCtx);
106− pCtx = NULL;
107− }
108−
109−}
110113 class DecoderParseSyntaxTest : public ::testing::Test {
111114 public:
112115 virtual void SetUp() {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t