History

modify return value check inside decoder

unknown committed 10 years ago

Commit 9cb4f4e1 parent 13586a311 files · +216 −197Browse files

Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 11 files). Show all

Unified · Split

codec/decoder/core/src/decoder.cpp+16−16
@@ -64,7 +64,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 63 unmodified lines
64 PPicBuff pPicBuf = NULL;64 PPicBuff pPicBuf = NULL;
65 int32_t iPicIdx = 0;65 int32_t iPicIdx = 0;
66 if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {66 if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
67 return 1;67 return ERR_INFO_INVALID_PARAM;
68 }68 }
69 69
70 CMemoryAlign* pMa = pCtx->pMemAlign;70 CMemoryAlign* pMa = pCtx->pMemAlign;
@@ -72,7 +72,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 1 unmodified line
72 pPicBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff");72 pPicBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff");
73 73
74 if (NULL == pPicBuf) {74 if (NULL == pPicBuf) {
75 return 1;75 return ERR_INFO_OUT_OF_MEMORY;
76 }76 }
77 77
78 pPicBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiSize * sizeof (PPicture), "PPicture*");78 pPicBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiSize * sizeof (PPicture), "PPicture*");
@@ -80,7 +80,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 1 unmodified line
80 if (NULL == pPicBuf->ppPic) {80 if (NULL == pPicBuf->ppPic) {
81 pPicBuf->iCapacity = 0;81 pPicBuf->iCapacity = 0;
82 DestroyPicBuff (&pPicBuf, pMa);82 DestroyPicBuff (&pPicBuf, pMa);
83 return 1;83 return ERR_INFO_OUT_OF_MEMORY;
84 }84 }
85 85
86 for (iPicIdx = 0; iPicIdx < kiSize; ++ iPicIdx) {86 for (iPicIdx = 0; iPicIdx < kiSize; ++ iPicIdx) {
@@ -89,7 +89,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 2 unmodified lines
89 // init capacity first for free memory89 // init capacity first for free memory
90 pPicBuf->iCapacity = iPicIdx;90 pPicBuf->iCapacity = iPicIdx;
91 DestroyPicBuff (&pPicBuf, pMa);91 DestroyPicBuff (&pPicBuf, pMa);
92 return 1;92 return ERR_INFO_OUT_OF_MEMORY;
93 }93 }
94 pPicBuf->ppPic[iPicIdx] = pPic;94 pPicBuf->ppPic[iPicIdx] = pPic;
95 }95 }
@@ -99,7 +99,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 3 unmodified lines
99 pPicBuf->iCurrentIdx = 0;99 pPicBuf->iCurrentIdx = 0;
100 * ppPicBuf = pPicBuf;100 * ppPicBuf = pPicBuf;
101 101
102 return 0;102 return ERR_NONE;
103}103}
104 104
105static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiOldSize,105static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiOldSize,
@@ -108,14 +108,14 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 2 unmodified lines
108 PPicBuff pPicNewBuf = NULL;108 PPicBuff pPicNewBuf = NULL;
109 int32_t iPicIdx = 0;109 int32_t iPicIdx = 0;
110 if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {110 if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
111 return 1;111 return ERR_INFO_INVALID_PARAM;
112 }112 }
113 113
114 CMemoryAlign* pMa = pCtx->pMemAlign;114 CMemoryAlign* pMa = pCtx->pMemAlign;
115 pPicNewBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff");115 pPicNewBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff");
116 116
117 if (NULL == pPicNewBuf) {117 if (NULL == pPicNewBuf) {
118 return 1;118 return ERR_INFO_OUT_OF_MEMORY;
119 }119 }
120 120
121 pPicNewBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");121 pPicNewBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");
@@ -123,7 +123,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 1 unmodified line
123 if (NULL == pPicNewBuf->ppPic) {123 if (NULL == pPicNewBuf->ppPic) {
124 pPicNewBuf->iCapacity = 0;124 pPicNewBuf->iCapacity = 0;
125 DestroyPicBuff (&pPicNewBuf, pMa);125 DestroyPicBuff (&pPicNewBuf, pMa);
126 return 1;126 return ERR_INFO_OUT_OF_MEMORY;
127 }127 }
128 128
129 // increase new PicBuf129 // increase new PicBuf
@@ -133,7 +133,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 3 unmodified lines
133 // Set maximum capacity as the new malloc memory at the tail133 // Set maximum capacity as the new malloc memory at the tail
134 pPicNewBuf->iCapacity = iPicIdx;134 pPicNewBuf->iCapacity = iPicIdx;
135 DestroyPicBuff (&pPicNewBuf, pMa);135 DestroyPicBuff (&pPicNewBuf, pMa);
136 return 1;136 return ERR_INFO_OUT_OF_MEMORY;
137 }137 }
138 pPicNewBuf->ppPic[iPicIdx] = pPic;138 pPicNewBuf->ppPic[iPicIdx] = pPic;
139 }139 }
@@ -162,7 +162,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 22 unmodified lines
162 pPicOldBuf->iCurrentIdx = 0;162 pPicOldBuf->iCurrentIdx = 0;
163 pMa->WelsFree (pPicOldBuf, "pPicOldBuf");163 pMa->WelsFree (pPicOldBuf, "pPicOldBuf");
164 pPicOldBuf = NULL;164 pPicOldBuf = NULL;
165 return 0;165 return ERR_NONE;
166}166}
167 167
168static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiOldSize,168static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiOldSize,
@@ -171,7 +171,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 2 unmodified lines
171 PPicBuff pPicNewBuf = NULL;171 PPicBuff pPicNewBuf = NULL;
172 int32_t iPicIdx = 0;172 int32_t iPicIdx = 0;
173 if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {173 if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
174 return 1;174 return ERR_INFO_INVALID_PARAM;
175 }175 }
176 176
177 CMemoryAlign* pMa = pCtx->pMemAlign;177 CMemoryAlign* pMa = pCtx->pMemAlign;
@@ -179,7 +179,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 1 unmodified line
179 pPicNewBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff");179 pPicNewBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff");
180 180
181 if (NULL == pPicNewBuf) {181 if (NULL == pPicNewBuf) {
182 return 1;182 return ERR_INFO_OUT_OF_MEMORY;
183 }183 }
184 184
185 pPicNewBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");185 pPicNewBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");
@@ -187,7 +187,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 1 unmodified line
187 if (NULL == pPicNewBuf->ppPic) {187 if (NULL == pPicNewBuf->ppPic) {
188 pPicNewBuf->iCapacity = 0;188 pPicNewBuf->iCapacity = 0;
189 DestroyPicBuff (&pPicNewBuf, pMa);189 DestroyPicBuff (&pPicNewBuf, pMa);
190 return 1;190 return ERR_INFO_OUT_OF_MEMORY;
191 }191 }
192 192
193 int32_t iPrevPicIdx = -1;193 int32_t iPrevPicIdx = -1;
@@ -239,7 +239,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 45 unmodified lines
239 pMa->WelsFree (pPicOldBuf, "pPicOldBuf");239 pMa->WelsFree (pPicOldBuf, "pPicOldBuf");
240 pPicOldBuf = NULL;240 pPicOldBuf = NULL;
241 241
242 return 0;242 return ERR_NONE;
243}243}
244 244
245void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) {245void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) {
@@ -523,7 +523,7 @@ void WelsCloseDecoder (PWelsDecoderContext pCtx) { · 277 unmodified lines
523 */523 */
524int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpParam) {524int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpParam) {
525 if (NULL == pCtx || NULL == kpParam)525 if (NULL == pCtx || NULL == kpParam)
526 return 1;526 return ERR_INFO_INVALID_PARAM;
527 527
528 memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));528 memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));
529 if ((pCtx->pParam->eEcActiveIdc > ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE)529 if ((pCtx->pParam->eEcActiveIdc > ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE)
@@ -549,7 +549,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 19 unmodified lines
549 549
550 WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "eVideoType: %d", pCtx->eVideoType);550 WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "eVideoType: %d", pCtx->eVideoType);
551 551
552 return 0;552 return ERR_NONE;
553}553}
554 554
555/*!555/*!

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