History

Pretty printed the C++ code with astyle

Ethan Hugg committed 12 years ago

Commit ff6b6691 parent 063709c225 files · +48457 −51954Browse files

Showing the changes to codec/decoder/plus/src/welsDecoderExt.cpp (1 of 225 files). Show all

Unified · Split

codec/decoder/plus/src/welsDecoderExt.cpp+308−355
@@ -76,420 +76,375 @@ namespace WelsDec { · 75 unmodified lines
76 76
77/***************************************************************************77/***************************************************************************
78* Description:78* Description:
79* class CWelsDecoder constructor function, do initialization and 79* class CWelsDecoder constructor function, do initialization and
80* alloc memory required80* alloc memory required
81*81*
82* Input parameters: none82* Input parameters: none
83*83*
84* return: none84* return: none
85/***************************************************************************/85/***************************************************************************/
86CWelsDecoder::CWelsDecoder(void_t)86CWelsDecoder::CWelsDecoder (void_t)
87: m_pDecContext( NULL ),87 : m_pDecContext (NULL),
88 m_pTrace( NULL )88 m_pTrace (NULL) {
89{
90#ifdef OUTPUT_BIT_STREAM89#ifdef OUTPUT_BIT_STREAM
91 str_t chFileName[1024] = { 0 }; //for .26490 str_t chFileName[1024] = { 0 }; //for .264
92 int iBufUsed = 0;91 int iBufUsed = 0;
93 int iBufLeft = 1023;92 int iBufLeft = 1023;
94 93
95 str_t chFileNameSize[1024] = { 0 }; //for .len94 str_t chFileNameSize[1024] = { 0 }; //for .len
96 int iBufUsedSize = 0;95 int iBufUsedSize = 0;
97 int iBufLeftSize = 1023;96 int iBufLeftSize = 1023;
98#endif//OUTPUT_BIT_STREAM 97#endif//OUTPUT_BIT_STREAM
99 98
100 m_pTrace = CreateWelsTrace(Wels_Trace_Type); 99 m_pTrace = CreateWelsTrace (Wels_Trace_Type);
100
101 IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry");
102
101 103
102 IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO,"CWelsDecoder::CWelsDecoder() entry");
103
104
105#ifdef OUTPUT_BIT_STREAM104#ifdef OUTPUT_BIT_STREAM
106 SWelsTime sCurTime;105 SWelsTime sCurTime;
107 106
108 WelsGetTimeOfDay(&sCurTime); 107 WelsGetTimeOfDay (&sCurTime);
109 108
110 iBufUsed += WelsSnprintf(chFileName, iBufLeft, "bs_0x%p_", (void_t*)this);109 iBufUsed += WelsSnprintf (chFileName, iBufLeft, "bs_0x%p_", (void_t*)this);
111 iBufUsedSize += WelsSnprintf(chFileNameSize, iBufLeftSize, "size_0x%p_", (void_t*)this);110 iBufUsedSize += WelsSnprintf (chFileNameSize, iBufLeftSize, "size_0x%p_", (void_t*)this);
112 111
113 iBufLeft -= iBufUsed;112 iBufLeft -= iBufUsed;
114 if ( iBufLeft > iBufUsed )113 if (iBufLeft > iBufUsed) {
115 {114 iBufUsed += WelsStrftime (&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime);
116 iBufUsed += WelsStrftime(&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime);115 iBufLeft -= iBufUsed;
117 iBufLeft -= iBufUsed;116 }
118 }117
119 118 iBufLeftSize -= iBufUsedSize;
120 iBufLeftSize -= iBufUsedSize;119 if (iBufLeftSize > iBufUsedSize) {
121 if ( iBufLeftSize> iBufUsedSize )120 iBufUsedSize += WelsStrftime (&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime);
122 { 121 iBufLeftSize -= iBufUsedSize;
123 iBufUsedSize += WelsStrftime(&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime);122 }
124 iBufLeftSize -= iBufUsedSize;123
125 }124 if (iBufLeft > iBufUsed) {
126 125 iBufUsed += WelsSnprintf (&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillsecond (&sCurTime));
127 if ( iBufLeft > iBufUsed )126 iBufLeft -= iBufUsed;
128 {127 }
129 iBufUsed += WelsSnprintf(&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillsecond(&sCurTime));128
130 iBufLeft -= iBufUsed;129 if (iBufLeftSize > iBufUsedSize) {
131 }130 iBufUsedSize += WelsSnprintf (&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len",
132 131 WelsGetMillsecond (&sCurTime));
133 if ( iBufLeftSize > iBufUsedSize )132 iBufLeftSize -= iBufUsedSize;
134 {133 }
135 iBufUsedSize += WelsSnprintf(&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len", WelsGetMillsecond(&sCurTime));134
136 iBufLeftSize -= iBufUsedSize;135
137 }136 m_pFBS = WelsFopen (chFileName, "wb");
138 137 m_pFBSSize = WelsFopen (chFileNameSize, "wb");
139
140 m_pFBS = WelsFopen(chFileName, "wb");
141 m_pFBSSize = WelsFopen(chFileNameSize, "wb");
142#endif//OUTPUT_BIT_STREAM138#endif//OUTPUT_BIT_STREAM
143 139
144}140}
145 141
146/***************************************************************************142/***************************************************************************
147* Description:143* Description:
148* class CWelsDecoder destructor function, destroy allocced memory144* class CWelsDecoder destructor function, destroy allocced memory
149* 145*
150* Input parameters: none146* Input parameters: none
151*147*
152* return: none148* return: none
153/***************************************************************************/149/***************************************************************************/
154CWelsDecoder::~CWelsDecoder()150CWelsDecoder::~CWelsDecoder() {
155{ 151 IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()");
156 IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()");
157 152
158 UninitDecoder();153 UninitDecoder();
159 154
160#ifdef OUTPUT_BIT_STREAM155#ifdef OUTPUT_BIT_STREAM
161 if ( m_pFBS )156 if (m_pFBS) {
162 {157 WelsFclose (m_pFBS);
163 WelsFclose( m_pFBS );158 m_pFBS = NULL;
164 m_pFBS = NULL;159 }
165 }160 if (m_pFBSSize) {
166 if ( m_pFBSSize )161 WelsFclose (m_pFBSSize);
167 {162 m_pFBSSize = NULL;
168 WelsFclose( m_pFBSSize );163 }
169 m_pFBSSize = NULL;
170 }
171#endif//OUTPUT_BIT_STREAM164#endif//OUTPUT_BIT_STREAM
172 165
173 if( NULL != m_pTrace ){166 if (NULL != m_pTrace) {
174 delete m_pTrace;167 delete m_pTrace;
175 m_pTrace = NULL;168 m_pTrace = NULL;
176 } 169 }
177}170}
178 171
179long CWelsDecoder::Initialize(void_t* pParam, const INIT_TYPE keInitType)172long CWelsDecoder::Initialize (void_t* pParam, const INIT_TYPE keInitType) {
180{173 if (pParam == NULL || keInitType != INIT_TYPE_PARAMETER_BASED) {
181 if ( pParam == NULL || keInitType != INIT_TYPE_PARAMETER_BASED ){174 IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::Initialize(), invalid input argument.");
182 IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::Initialize(), invalid input argument.");175 return cmInitParaError;
183 return cmInitParaError;176 }
184 }
185 177
186 // H.264 decoder initialization,including memory allocation,then open it ready to decode178 // H.264 decoder initialization,including memory allocation,then open it ready to decode
187 InitDecoder();179 InitDecoder();
188 180
189 DecoderConfigParam( m_pDecContext, pParam );181 DecoderConfigParam (m_pDecContext, pParam);
190 182
191 return cmResultSuccess;183 return cmResultSuccess;
192}184}
193 185
194long CWelsDecoder::Uninitialize()186long CWelsDecoder::Uninitialize() {
195{187 UninitDecoder();
196 UninitDecoder();188
197 189 return ERR_NONE;
198 return ERR_NONE;
199}190}
200 191
201void_t CWelsDecoder::UninitDecoder( void_t )192void_t CWelsDecoder::UninitDecoder (void_t) {
202{193 if (NULL == m_pDecContext)
203 if ( NULL == m_pDecContext )194 return;
204 return;
205
206 IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "into CWelsDecoder::uninit_decoder()..");
207 195
208 WelsEndDecoder( m_pDecContext );196 IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "into CWelsDecoder::uninit_decoder()..");
209 197
210 if ( NULL != m_pDecContext )198 WelsEndDecoder (m_pDecContext);
211 {
212 WelsFree( m_pDecContext, "m_pDecContext" );
213 199
214 m_pDecContext = NULL;200 if (NULL != m_pDecContext) {
215 }201 WelsFree (m_pDecContext, "m_pDecContext");
216 202
217 IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "left CWelsDecoder::uninit_decoder()..");203 m_pDecContext = NULL;
204 }
205
206 IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "left CWelsDecoder::uninit_decoder()..");
218}207}
219 208
220// the return value of this function is not suitable, it need report failure info to upper layer.209// the return value of this function is not suitable, it need report failure info to upper layer.
221void_t CWelsDecoder::InitDecoder( void_t )210void_t CWelsDecoder::InitDecoder (void_t) {
222{211 IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder()..");
223 IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder().."); 212
213 m_pDecContext = (PWelsDecoderContext)WelsMalloc (sizeof (SWelsDecoderContext), "m_pDecContext");
224 214
225 m_pDecContext = (PWelsDecoderContext)WelsMalloc( sizeof(SWelsDecoderContext), "m_pDecContext" );215 WelsInitDecoder (m_pDecContext, m_pTrace, IWelsTrace::WelsTrace);
226
227 WelsInitDecoder( m_pDecContext, m_pTrace, IWelsTrace::WelsTrace );
228 216
229 IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder().. left");217 IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder().. left");
230}218}
231 219
232/*220/*
233 * Set Option 221 * Set Option
234 */222 */
235long CWelsDecoder::SetOption(DECODER_OPTION eOptID, void_t* pOption)223long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void_t* pOption) {
236{224 int iVal = 0;
237 int iVal = 0;225
238 226 if (m_pDecContext == NULL)
239 if ( m_pDecContext == NULL )227 return dsInitialOptExpected;
240 return dsInitialOptExpected;228
241 229 if (eOptID == DECODER_OPTION_DATAFORMAT) { // Set color space of decoding output frame
242 if ( eOptID == DECODER_OPTION_DATAFORMAT ) // Set color space of decoding output frame230 if (pOption == NULL)
243 { 231 return cmInitParaError;
244 if ( pOption == NULL )232
245 return cmInitParaError;233 iVal = * ((int*)pOption); // is_rgb
246 234
247 iVal = *((int*)pOption); // is_rgb235 return DecoderSetCsp (m_pDecContext, iVal);
248 236 } else if (eOptID == DECODER_OPTION_END_OF_STREAM) { // Indicate bit-stream of the final frame to be decoded
249 return DecoderSetCsp( m_pDecContext, iVal );237 if (pOption == NULL)
250 }238 return cmInitParaError;
251 else if ( eOptID == DECODER_OPTION_END_OF_STREAM ) // Indicate bit-stream of the final frame to be decoded239
252 {240 iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag
253 if ( pOption == NULL )241
254 return cmInitParaError;242 m_pDecContext->bEndOfStreamFlag = iVal ? true : false;
255 243
256 iVal = *((int*)pOption); // boolean value for whether enabled End Of Stream flag244 return cmResultSuccess;
257 245 } else if (eOptID == DECODER_OPTION_MODE) {
258 m_pDecContext->bEndOfStreamFlag = iVal ? true : false;246 if (pOption == NULL)
259 247 return cmInitParaError;
260 return cmResultSuccess;248
261 }249 iVal = * ((int*)pOption);
262 else if ( eOptID == DECODER_OPTION_MODE)250
263 {251 m_pDecContext->iSetMode = iVal;
264 if ( pOption == NULL )252 if (iVal == SW_MODE) {
265 return cmInitParaError;253 m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;
266 254 } else {
267 iVal = *((int *)pOption);
268
269 m_pDecContext->iSetMode = iVal;
270 if(iVal == SW_MODE)
271 {
272 m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;
273 }
274 else
275 {
276#if !defined(__APPLE__)255#if !defined(__APPLE__)
277 m_pDecContext->iDecoderOutputProperty = BUFFER_DEVICE;256 m_pDecContext->iDecoderOutputProperty = BUFFER_DEVICE;
278#else257#else
279 m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;//BUFFER_HOST;//BUFFER_DEVICE;258 m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;//BUFFER_HOST;//BUFFER_DEVICE;
280#endif259#endif
281 260
282 }261 }
283 262
284 return cmResultSuccess;263 return cmResultSuccess;
285 }264 } else if (eOptID == DECODER_OPTION_OUTPUT_PROPERTY) {
286 else if ( eOptID == DECODER_OPTION_OUTPUT_PROPERTY)265 if (pOption == NULL)
287 {266 return cmInitParaError;
288 if ( pOption == NULL)267
289 return cmInitParaError;268 iVal = * ((int*)pOption);
290 269 if (m_pDecContext->iSetMode != SW_MODE)
291 iVal = *((int *)pOption);270 m_pDecContext->iDecoderOutputProperty = iVal;
292 if( m_pDecContext->iSetMode != SW_MODE) 271 }
293 m_pDecContext->iDecoderOutputProperty = iVal;272
294 }273
295 274 return cmInitParaError;
296
297 return cmInitParaError;
298}275}
299 276
300/*277/*
301 * Get Option278 * Get Option
302 */279 */
303long CWelsDecoder::GetOption(DECODER_OPTION eOptID, void_t* pOption)280long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void_t* pOption) {
304{281 int iVal = 0;
305 int iVal = 0;282
306 283 if (m_pDecContext == NULL)
307 if ( m_pDecContext == NULL )284 return cmInitExpected;
308 return cmInitExpected;285
309 286 if (pOption == NULL)
310 if ( pOption == NULL )287 return cmInitParaError;
311 return cmInitParaError;288
312 289 if (DECODER_OPTION_DATAFORMAT == eOptID) {
313 if ( DECODER_OPTION_DATAFORMAT == eOptID ){290 iVal = m_pDecContext->iOutputColorFormat;
314 iVal = m_pDecContext->iOutputColorFormat;291 * ((int*)pOption) = iVal;
315 *((int*)pOption) = iVal;292 return cmResultSuccess;
316 return cmResultSuccess;293 } else if (DECODER_OPTION_END_OF_STREAM == eOptID) {
317 }294 iVal = m_pDecContext->bEndOfStreamFlag;
318 else if ( DECODER_OPTION_END_OF_STREAM == eOptID ){295 * ((int*)pOption) = iVal;
319 iVal = m_pDecContext->bEndOfStreamFlag;296 return cmResultSuccess;
320 *((int*)pOption) = iVal;297 }
321 return cmResultSuccess;
322 }
323#ifdef LONG_TERM_REF298#ifdef LONG_TERM_REF
324 else if ( DECODER_OPTION_IDR_PIC_ID == eOptID ){299 else if (DECODER_OPTION_IDR_PIC_ID == eOptID) {
325 iVal = m_pDecContext->uiCurIdrPicId;300 iVal = m_pDecContext->uiCurIdrPicId;
326 *((int*)pOption) = iVal;301 * ((int*)pOption) = iVal;
327 return cmResultSuccess;302 return cmResultSuccess;
328 }303 } else if (DECODER_OPTION_FRAME_NUM == eOptID) {
329 else if ( DECODER_OPTION_FRAME_NUM == eOptID)304 iVal = m_pDecContext->iFrameNum;
330 {305 * ((int*)pOption) = iVal;
331 iVal = m_pDecContext->iFrameNum;306 return cmResultSuccess;
332 *((int*)pOption) = iVal;307 } else if (DECODER_OPTION_LTR_MARKING_FLAG == eOptID) {
333 return cmResultSuccess;308 iVal = m_pDecContext->bCurAuContainLtrMarkSeFlag;
334 }309 * ((int*)pOption) = iVal;
335 else if ( DECODER_OPTION_LTR_MARKING_FLAG == eOptID )310 return cmResultSuccess;
336 {311 } else if (DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID) {
337 iVal = m_pDecContext->bCurAuContainLtrMarkSeFlag;312 iVal = m_pDecContext->iFrameNumOfAuMarkedLtr;
338 *((int*)pOption) = iVal;313 * ((int*)pOption) = iVal;
339 return cmResultSuccess;314 return cmResultSuccess;
340 }315 }
341 else if ( DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID )
342 {
343 iVal = m_pDecContext->iFrameNumOfAuMarkedLtr;
344 *((int*)pOption) = iVal;
345 return cmResultSuccess;
346 }
347#endif316#endif
348 else if ( DECODER_OPTION_VCL_NAL == eOptID ) //feedback whether or not have VCL NAL in current AU317 else if (DECODER_OPTION_VCL_NAL == eOptID) { //feedback whether or not have VCL NAL in current AU
349 {318 iVal = m_pDecContext->iFeedbackVclNalInAu;
350 iVal = m_pDecContext->iFeedbackVclNalInAu;319 * ((int*)pOption) = iVal;
351 *((int*)pOption) = iVal;320 return cmResultSuccess;
352 return cmResultSuccess;321 } else if (DECODER_OPTION_TEMPORAL_ID == eOptID) { //if have VCL NAL in current AU, then feedback the temporal ID
353 }322 iVal = m_pDecContext->iFeedbackTidInAu;
354 else if ( DECODER_OPTION_TEMPORAL_ID == eOptID ) //if have VCL NAL in current AU, then feedback the temporal ID323 * ((int*)pOption) = iVal;
355 {324 return cmResultSuccess;
356 iVal = m_pDecContext->iFeedbackTidInAu;325 } else if (DECODER_OPTION_MODE == eOptID) {
357 *((int*)pOption) = iVal;326 if (pOption == NULL)
358 return cmResultSuccess;327 return cmInitParaError;
359 }328
360 else if ( DECODER_OPTION_MODE == eOptID )329 iVal = m_pDecContext->iSetMode;
361 {330
362 if ( pOption == NULL )331 * ((int*)pOption) = iVal;
363 return cmInitParaError;332 return cmResultSuccess;
364 333 } else if (DECODER_OPTION_DEVICE_INFO == eOptID) {
365 iVal = m_pDecContext->iSetMode;334 if (pOption == NULL)
366 335 return cmInitParaError;
367 *((int *)pOption) = iVal;336
368 return cmResultSuccess;337 return cmResultSuccess;
369 }338 }
370 else if ( DECODER_OPTION_DEVICE_INFO == eOptID )339
371 {340 return cmInitParaError;
372 if ( pOption == NULL )
373 return cmInitParaError;
374
375 return cmResultSuccess;
376 }
377
378 return cmInitParaError;
379}341}
380 342
381DECODING_STATE CWelsDecoder::DecodeFrame( const unsigned char* kpSrc,343DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc,
382 const int kiSrcLen, 344 const int kiSrcLen,
383 void_t ** ppDst,345 void_t** ppDst,
384 SBufferInfo* pDstInfo)346 SBufferInfo* pDstInfo) {
385{347 if (kiSrcLen > 0 && kpSrc != NULL) {
386 if ( kiSrcLen > 0 && kpSrc != NULL )
387 {
388#ifdef OUTPUT_BIT_STREAM348#ifdef OUTPUT_BIT_STREAM
389 if ( m_pFBS )349 if (m_pFBS) {
390 {350 WelsFwrite (kpSrc, sizeof (unsigned char), kiSrcLen, m_pFBS);
391 WelsFwrite( kpSrc, sizeof(unsigned char), kiSrcLen, m_pFBS );351 WelsFflush (m_pFBS);
392 WelsFflush( m_pFBS );352 }
393 }353 if (m_pFBSSize) {
394 if ( m_pFBSSize )354 WelsFwrite (&kiSrcLen, sizeof (int), 1, m_pFBSSize);
395 {355 WelsFflush (m_pFBSSize);
396 WelsFwrite( &kiSrcLen, sizeof(int), 1, m_pFBSSize );356 }
397 WelsFflush( m_pFBSSize );
398 }
399#endif//OUTPUT_BIT_STREAM357#endif//OUTPUT_BIT_STREAM
400 m_pDecContext->bEndOfStreamFlag = false;358 m_pDecContext->bEndOfStreamFlag = false;
401 }359 } else {
402 else 360 //For application MODE, the error detection should be added for safe.
403 { //For application MODE, the error detection should be added for safe.361 //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.
404 //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL. 362 m_pDecContext->bEndOfStreamFlag = true;
405 m_pDecContext->bEndOfStreamFlag = true;363 }
406 }364
407 365 ppDst[0] = ppDst[1] = ppDst[2] = NULL;
408 ppDst[0] = ppDst[1] = ppDst[2] = NULL;366 m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.
409 m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.367 m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize
410 m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize368 memset (pDstInfo, 0, sizeof (SBufferInfo));
411 memset(pDstInfo,0,sizeof(SBufferInfo));369 pDstInfo->eBufferProperty = (EBufferProperty)m_pDecContext->iDecoderOutputProperty;
412 pDstInfo->eBufferProperty = (EBufferProperty)m_pDecContext->iDecoderOutputProperty;
413 370
414#ifdef LONG_TERM_REF371#ifdef LONG_TERM_REF
415 m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR372 m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR
416 m_pDecContext->bCurAuContainLtrMarkSeFlag = false;373 m_pDecContext->bCurAuContainLtrMarkSeFlag = false;
417 m_pDecContext->iFrameNumOfAuMarkedLtr = 0;374 m_pDecContext->iFrameNumOfAuMarkedLtr = 0;
418 m_pDecContext->iFrameNum = -1; //initialize375 m_pDecContext->iFrameNum = -1; //initialize
419#endif376#endif
420 377
421 m_pDecContext->iFeedbackTidInAu = -1; //initialize378 m_pDecContext->iFeedbackTidInAu = -1; //initialize
422 379
423 WelsDecodeBs( m_pDecContext, kpSrc, kiSrcLen, (unsigned char**)ppDst, pDstInfo); //iErrorCode has been modified in this function380 WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, (unsigned char**)ppDst,
424 381 pDstInfo); //iErrorCode has been modified in this function
425 pDstInfo->eWorkMode = (EDecodeMode)m_pDecContext->iDecoderMode;382
426 383 pDstInfo->eWorkMode = (EDecodeMode)m_pDecContext->iDecoderMode;
427 if ( m_pDecContext->iErrorCode )384
428 { 385 if (m_pDecContext->iErrorCode) {
429 ENalUnitType eNalType = NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently 386 ENalUnitType eNalType =
430 387 NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently
431 eNalType = m_pDecContext->sCurNalHead.eNalUnitType;388
432 389 eNalType = m_pDecContext->sCurNalHead.eNalUnitType;
433 //for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss.390
434 if ( (IS_PARAM_SETS_NALS(eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) ||391 //for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss.
435 (VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType) )392 if ((IS_PARAM_SETS_NALS (eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) ||
436 {393 (VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType)) {
437#ifdef LONG_TERM_REF394#ifdef LONG_TERM_REF
438 m_pDecContext->bParamSetsLostFlag = true;395 m_pDecContext->bParamSetsLostFlag = true;
439#else396#else
440 m_pDecContext->bReferenceLostAtT0Flag = true;397 m_pDecContext->bReferenceLostAtT0Flag = true;
441#endif398#endif
442 ResetParameterSetsState( m_pDecContext ); //initial SPS&PPS ready flag399 ResetParameterSetsState (m_pDecContext); //initial SPS&PPS ready flag
443 } 400 }
444 401
445 IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "decode failed, failure type:%d \n", m_pDecContext->iErrorCode);402 IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "decode failed, failure type:%d \n",
446 return (DECODING_STATE)m_pDecContext->iErrorCode;403 m_pDecContext->iErrorCode);
447 }404 return (DECODING_STATE)m_pDecContext->iErrorCode;
405 }
448 406
449 return dsErrorFree;407 return dsErrorFree;
450}408}
451 409
452DECODING_STATE CWelsDecoder::DecodeFrame( const unsigned char* kpSrc,410DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc,
453 const int kiSrcLen, 411 const int kiSrcLen,
454 unsigned char** ppDst,412 unsigned char** ppDst,
455 int* pStride,413 int* pStride,
456 int& iWidth,414 int& iWidth,
457 int& iHeight )415 int& iHeight) {
458{416 DECODING_STATE eDecState = dsErrorFree;
459 DECODING_STATE eDecState = dsErrorFree;417 SBufferInfo DstInfo;
460 SBufferInfo DstInfo;418
461 419 memset (&DstInfo, 0, sizeof (SBufferInfo));
462 memset(&DstInfo, 0, sizeof(SBufferInfo));420 DstInfo.UsrData.sSystemBuffer.iStride[0] = pStride[0];
463 DstInfo.UsrData.sSystemBuffer.iStride[0] = pStride[0];421 DstInfo.UsrData.sSystemBuffer.iStride[1] = pStride[1];
464 DstInfo.UsrData.sSystemBuffer.iStride[1] = pStride[1];422 DstInfo.UsrData.sSystemBuffer.iWidth = iWidth;
465 DstInfo.UsrData.sSystemBuffer.iWidth = iWidth;423 DstInfo.UsrData.sSystemBuffer.iHeight = iHeight;
466 DstInfo.UsrData.sSystemBuffer.iHeight = iHeight;424 DstInfo.eBufferProperty = BUFFER_HOST;
467 DstInfo.eBufferProperty = BUFFER_HOST;425
468 426 eDecState = DecodeFrame (kpSrc, kiSrcLen, (void_t**)ppDst, &DstInfo);
469 eDecState = DecodeFrame(kpSrc, kiSrcLen, (void_t **)ppDst, &DstInfo);427 if (eDecState == dsErrorFree) {
470 if (eDecState == dsErrorFree)428 pStride[0] = DstInfo.UsrData.sSystemBuffer.iStride[0];
471 {429 pStride[1] = DstInfo.UsrData.sSystemBuffer.iStride[1];
472 pStride[0] = DstInfo.UsrData.sSystemBuffer.iStride[0];430 iWidth = DstInfo.UsrData.sSystemBuffer.iWidth;
473 pStride[1] = DstInfo.UsrData.sSystemBuffer.iStride[1];431 iHeight = DstInfo.UsrData.sSystemBuffer.iHeight;
474 iWidth = DstInfo.UsrData.sSystemBuffer.iWidth;432 }
475 iHeight = DstInfo.UsrData.sSystemBuffer.iHeight;433
476 }434 return eDecState;
477
478 return eDecState;
479}435}
480 436
481DECODING_STATE CWelsDecoder::DecodeFrameEx(const unsigned char * kpSrc,437DECODING_STATE CWelsDecoder::DecodeFrameEx (const unsigned char* kpSrc,
482 const int kiSrcLen,438 const int kiSrcLen,
483 unsigned char * pDst,439 unsigned char* pDst,
484 int iDstStride,440 int iDstStride,
485 int & iDstLen,441 int& iDstLen,
486 int & iWidth,442 int& iWidth,
487 int & iHeight,443 int& iHeight,
488 int & iColorFormat )444 int& iColorFormat) {
489{445 DECODING_STATE state = dsErrorFree;
490 DECODING_STATE state = dsErrorFree;446
491 447 return state;
492 return state;
493}448}
494 449
495 450
@@ -504,29 +459,27 @@ using namespace WelsDec; · 8 unmodified lines
504* CreateDecoder459* CreateDecoder
505* @return: success in return 0, otherwise failed.460* @return: success in return 0, otherwise failed.
506*/461*/
507long CreateDecoder( ISVCDecoder** ppDecoder )462long CreateDecoder (ISVCDecoder** ppDecoder) {
508{
509 463
510 if ( NULL == ppDecoder ){ 464 if (NULL == ppDecoder) {
511 return ERR_INVALID_PARAMETERS;465 return ERR_INVALID_PARAMETERS;
512 }466 }
513 467
514 *ppDecoder = new CWelsDecoder();468 *ppDecoder = new CWelsDecoder();
515 469
516 if ( NULL == *ppDecoder ){ 470 if (NULL == *ppDecoder) {
517 return ERR_MALLOC_FAILED;471 return ERR_MALLOC_FAILED;
518 } 472 }
519 473
520 return ERR_NONE;474 return ERR_NONE;
521}475}
522 476
523/*477/*
524* DestroyDecoder478* DestroyDecoder
525*/479*/
526void_t DestroyDecoder( ISVCDecoder* pDecoder )480void_t DestroyDecoder (ISVCDecoder* pDecoder) {
527{ 481 if (NULL != pDecoder) {
528 if ( NULL != pDecoder ){482 delete (CWelsDecoder*)pDecoder;
529 delete (CWelsDecoder *)pDecoder;483 pDecoder = NULL;
530 pDecoder = NULL;484 }
531 }
532}485}

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