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
7676
7777 /***************************************************************************
7878 * Description:
79−* class CWelsDecoder constructor function, do initialization and
79+* class CWelsDecoder constructor function, do initialization and
8080 * alloc memory required
8181 *
8282 * Input parameters: none
8383 *
8484 * return: none
8585 /***************************************************************************/
86−CWelsDecoder::CWelsDecoder(void_t)
87−: m_pDecContext( NULL ),
88− m_pTrace( NULL )
89−{
86+CWelsDecoder::CWelsDecoder (void_t)
87+ : m_pDecContext (NULL),
88+ m_pTrace (NULL) {
9089 #ifdef OUTPUT_BIT_STREAM
91− str_t chFileName[1024] = { 0 }; //for .264
92− int iBufUsed = 0;
93− int iBufLeft = 1023;
90+ str_t chFileName[1024] = { 0 }; //for .264
91+ int iBufUsed = 0;
92+ int iBufLeft = 1023;
9493
95− str_t chFileNameSize[1024] = { 0 }; //for .len
96− int iBufUsedSize = 0;
97− int iBufLeftSize = 1023;
94+ str_t chFileNameSize[1024] = { 0 }; //for .len
95+ int iBufUsedSize = 0;
96+ int iBufLeftSize = 1023;
9897 #endif//OUTPUT_BIT_STREAM
9998
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+
101103
102− IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO,"CWelsDecoder::CWelsDecoder() entry");
103−
104−
105104 #ifdef OUTPUT_BIT_STREAM
106− SWelsTime sCurTime;
107−
108− WelsGetTimeOfDay(&sCurTime);
109−
110− iBufUsed += WelsSnprintf(chFileName, iBufLeft, "bs_0x%p_", (void_t*)this);
111− iBufUsedSize += WelsSnprintf(chFileNameSize, iBufLeftSize, "size_0x%p_", (void_t*)this);
112−
113− iBufLeft -= iBufUsed;
114− if ( iBufLeft > iBufUsed )
115− {
116− iBufUsed += WelsStrftime(&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime);
117− iBufLeft -= iBufUsed;
118− }
119−
120− iBufLeftSize -= iBufUsedSize;
121− if ( iBufLeftSize> iBufUsedSize )
122− {
123− iBufUsedSize += WelsStrftime(&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime);
124− iBufLeftSize -= iBufUsedSize;
125− }
126−
127− if ( iBufLeft > iBufUsed )
128− {
129− iBufUsed += WelsSnprintf(&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillsecond(&sCurTime));
130− iBufLeft -= iBufUsed;
131− }
132−
133− if ( iBufLeftSize > iBufUsedSize )
134− {
135− iBufUsedSize += WelsSnprintf(&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len", WelsGetMillsecond(&sCurTime));
136− iBufLeftSize -= iBufUsedSize;
137− }
138−
139−
140− m_pFBS = WelsFopen(chFileName, "wb");
141− m_pFBSSize = WelsFopen(chFileNameSize, "wb");
105+ SWelsTime sCurTime;
106+
107+ WelsGetTimeOfDay (&sCurTime);
108+
109+ iBufUsed += WelsSnprintf (chFileName, iBufLeft, "bs_0x%p_", (void_t*)this);
110+ iBufUsedSize += WelsSnprintf (chFileNameSize, iBufLeftSize, "size_0x%p_", (void_t*)this);
111+
112+ iBufLeft -= iBufUsed;
113+ if (iBufLeft > iBufUsed) {
114+ iBufUsed += WelsStrftime (&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime);
115+ iBufLeft -= iBufUsed;
116+ }
117+
118+ iBufLeftSize -= iBufUsedSize;
119+ if (iBufLeftSize > iBufUsedSize) {
120+ iBufUsedSize += WelsStrftime (&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime);
121+ iBufLeftSize -= iBufUsedSize;
122+ }
123+
124+ if (iBufLeft > iBufUsed) {
125+ iBufUsed += WelsSnprintf (&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillsecond (&sCurTime));
126+ iBufLeft -= iBufUsed;
127+ }
128+
129+ if (iBufLeftSize > iBufUsedSize) {
130+ iBufUsedSize += WelsSnprintf (&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len",
131+ WelsGetMillsecond (&sCurTime));
132+ iBufLeftSize -= iBufUsedSize;
133+ }
134+
135+
136+ m_pFBS = WelsFopen (chFileName, "wb");
137+ m_pFBSSize = WelsFopen (chFileNameSize, "wb");
142138 #endif//OUTPUT_BIT_STREAM
143−
139+
144140 }
145141
146142 /***************************************************************************
147143 * Description:
148144 * class CWelsDecoder destructor function, destroy allocced memory
149−*
145+*
150146 * Input parameters: none
151147 *
152148 * return: none
153149 /***************************************************************************/
154−CWelsDecoder::~CWelsDecoder()
155−{
156− IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()");
150+CWelsDecoder::~CWelsDecoder() {
151+ IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()");
157152
158− UninitDecoder();
153+ UninitDecoder();
159154
160155 #ifdef OUTPUT_BIT_STREAM
161− if ( m_pFBS )
162− {
163− WelsFclose( m_pFBS );
164− m_pFBS = NULL;
165− }
166− if ( m_pFBSSize )
167− {
168− WelsFclose( m_pFBSSize );
169− m_pFBSSize = NULL;
170− }
156+ if (m_pFBS) {
157+ WelsFclose (m_pFBS);
158+ m_pFBS = NULL;
159+ }
160+ if (m_pFBSSize) {
161+ WelsFclose (m_pFBSSize);
162+ m_pFBSSize = NULL;
163+ }
171164 #endif//OUTPUT_BIT_STREAM
172165
173− if( NULL != m_pTrace ){
174− delete m_pTrace;
175− m_pTrace = NULL;
176− }
166+ if (NULL != m_pTrace) {
167+ delete m_pTrace;
168+ m_pTrace = NULL;
169+ }
177170 }
178171
179−long CWelsDecoder::Initialize(void_t* pParam, const INIT_TYPE keInitType)
180−{
181− if ( pParam == NULL || keInitType != INIT_TYPE_PARAMETER_BASED ){
182− IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::Initialize(), invalid input argument.");
183− return cmInitParaError;
184− }
172+long CWelsDecoder::Initialize (void_t* pParam, const INIT_TYPE keInitType) {
173+ if (pParam == NULL || keInitType != INIT_TYPE_PARAMETER_BASED) {
174+ IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::Initialize(), invalid input argument.");
175+ return cmInitParaError;
176+ }
185177
186− // H.264 decoder initialization,including memory allocation,then open it ready to decode
187− InitDecoder();
178+ // H.264 decoder initialization,including memory allocation,then open it ready to decode
179+ InitDecoder();
188180
189− DecoderConfigParam( m_pDecContext, pParam );
190−
191− return cmResultSuccess;
181+ DecoderConfigParam (m_pDecContext, pParam);
182+
183+ return cmResultSuccess;
192184 }
193185
194−long CWelsDecoder::Uninitialize()
195−{
196− UninitDecoder();
197−
198− return ERR_NONE;
186+long CWelsDecoder::Uninitialize() {
187+ UninitDecoder();
188+
189+ return ERR_NONE;
199190 }
200191
201−void_t CWelsDecoder::UninitDecoder( void_t )
202−{
203− if ( NULL == m_pDecContext )
204− return;
205−
206− IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "into CWelsDecoder::uninit_decoder()..");
192+void_t CWelsDecoder::UninitDecoder (void_t) {
193+ if (NULL == m_pDecContext)
194+ return;
207195
208− WelsEndDecoder( m_pDecContext );
196+ IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "into CWelsDecoder::uninit_decoder()..");
209197
210− if ( NULL != m_pDecContext )
211− {
212− WelsFree( m_pDecContext, "m_pDecContext" );
198+ WelsEndDecoder (m_pDecContext);
213199
214− m_pDecContext = NULL;
215− }
200+ if (NULL != m_pDecContext) {
201+ WelsFree (m_pDecContext, "m_pDecContext");
216202
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()..");
218207 }
219208
220209 // the return value of this function is not suitable, it need report failure info to upper layer.
221−void_t CWelsDecoder::InitDecoder( void_t )
222−{
223− IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder()..");
210+void_t CWelsDecoder::InitDecoder (void_t) {
211+ IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "CWelsDecoder::init_decoder()..");
212+
213+ m_pDecContext = (PWelsDecoderContext)WelsMalloc (sizeof (SWelsDecoderContext), "m_pDecContext");
224214
225− m_pDecContext = (PWelsDecoderContext)WelsMalloc( sizeof(SWelsDecoderContext), "m_pDecContext" );
226−
227− WelsInitDecoder( m_pDecContext, m_pTrace, IWelsTrace::WelsTrace );
215+ WelsInitDecoder (m_pDecContext, m_pTrace, IWelsTrace::WelsTrace);
228216
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");
230218 }
231219
232220 /*
233− * Set Option
221+ * Set Option
234222 */
235−long CWelsDecoder::SetOption(DECODER_OPTION eOptID, void_t* pOption)
236−{
237− int iVal = 0;
238−
239− if ( m_pDecContext == NULL )
240− return dsInitialOptExpected;
241−
242− if ( eOptID == DECODER_OPTION_DATAFORMAT ) // Set color space of decoding output frame
243− {
244− if ( pOption == NULL )
245− return cmInitParaError;
246−
247− iVal = *((int*)pOption); // is_rgb
248−
249− return DecoderSetCsp( m_pDecContext, iVal );
250− }
251− else if ( eOptID == DECODER_OPTION_END_OF_STREAM ) // Indicate bit-stream of the final frame to be decoded
252− {
253− if ( pOption == NULL )
254− return cmInitParaError;
255−
256− iVal = *((int*)pOption); // boolean value for whether enabled End Of Stream flag
257−
258− m_pDecContext->bEndOfStreamFlag = iVal ? true : false;
259−
260− return cmResultSuccess;
261− }
262− else if ( eOptID == DECODER_OPTION_MODE)
263− {
264− if ( pOption == NULL )
265− return cmInitParaError;
266−
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− {
223+long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void_t* pOption) {
224+ int iVal = 0;
225+
226+ if (m_pDecContext == NULL)
227+ return dsInitialOptExpected;
228+
229+ if (eOptID == DECODER_OPTION_DATAFORMAT) { // Set color space of decoding output frame
230+ if (pOption == NULL)
231+ return cmInitParaError;
232+
233+ iVal = * ((int*)pOption); // is_rgb
234+
235+ return DecoderSetCsp (m_pDecContext, iVal);
236+ } else if (eOptID == DECODER_OPTION_END_OF_STREAM) { // Indicate bit-stream of the final frame to be decoded
237+ if (pOption == NULL)
238+ return cmInitParaError;
239+
240+ iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag
241+
242+ m_pDecContext->bEndOfStreamFlag = iVal ? true : false;
243+
244+ return cmResultSuccess;
245+ } else if (eOptID == DECODER_OPTION_MODE) {
246+ if (pOption == NULL)
247+ return cmInitParaError;
248+
249+ iVal = * ((int*)pOption);
250+
251+ m_pDecContext->iSetMode = iVal;
252+ if (iVal == SW_MODE) {
253+ m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;
254+ } else {
276255 #if !defined(__APPLE__)
277− m_pDecContext->iDecoderOutputProperty = BUFFER_DEVICE;
256+ m_pDecContext->iDecoderOutputProperty = BUFFER_DEVICE;
278257 #else
279− m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;//BUFFER_HOST;//BUFFER_DEVICE;
258+ m_pDecContext->iDecoderOutputProperty = BUFFER_HOST;//BUFFER_HOST;//BUFFER_DEVICE;
280259 #endif
281−
282− }
283−
284− return cmResultSuccess;
285− }
286− else if ( eOptID == DECODER_OPTION_OUTPUT_PROPERTY)
287− {
288− if ( pOption == NULL)
289− return cmInitParaError;
290−
291− iVal = *((int *)pOption);
292− if( m_pDecContext->iSetMode != SW_MODE)
293− m_pDecContext->iDecoderOutputProperty = iVal;
294− }
295−
296−
297− return cmInitParaError;
260+
261+ }
262+
263+ return cmResultSuccess;
264+ } else if (eOptID == DECODER_OPTION_OUTPUT_PROPERTY) {
265+ if (pOption == NULL)
266+ return cmInitParaError;
267+
268+ iVal = * ((int*)pOption);
269+ if (m_pDecContext->iSetMode != SW_MODE)
270+ m_pDecContext->iDecoderOutputProperty = iVal;
271+ }
272+
273+
274+ return cmInitParaError;
298275 }
299276
300277 /*
301278 * Get Option
302279 */
303−long CWelsDecoder::GetOption(DECODER_OPTION eOptID, void_t* pOption)
304−{
305− int iVal = 0;
306−
307− if ( m_pDecContext == NULL )
308− return cmInitExpected;
309−
310− if ( pOption == NULL )
311− return cmInitParaError;
312−
313− if ( DECODER_OPTION_DATAFORMAT == eOptID ){
314− iVal = m_pDecContext->iOutputColorFormat;
315− *((int*)pOption) = iVal;
316− return cmResultSuccess;
317− }
318− else if ( DECODER_OPTION_END_OF_STREAM == eOptID ){
319− iVal = m_pDecContext->bEndOfStreamFlag;
320− *((int*)pOption) = iVal;
321− return cmResultSuccess;
322− }
280+long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void_t* pOption) {
281+ int iVal = 0;
282+
283+ if (m_pDecContext == NULL)
284+ return cmInitExpected;
285+
286+ if (pOption == NULL)
287+ return cmInitParaError;
288+
289+ if (DECODER_OPTION_DATAFORMAT == eOptID) {
290+ iVal = m_pDecContext->iOutputColorFormat;
291+ * ((int*)pOption) = iVal;
292+ return cmResultSuccess;
293+ } else if (DECODER_OPTION_END_OF_STREAM == eOptID) {
294+ iVal = m_pDecContext->bEndOfStreamFlag;
295+ * ((int*)pOption) = iVal;
296+ return cmResultSuccess;
297+ }
323298 #ifdef LONG_TERM_REF
324− else if ( DECODER_OPTION_IDR_PIC_ID == eOptID ){
325− iVal = m_pDecContext->uiCurIdrPicId;
326− *((int*)pOption) = iVal;
327− return cmResultSuccess;
328− }
329− else if ( DECODER_OPTION_FRAME_NUM == eOptID)
330− {
331− iVal = m_pDecContext->iFrameNum;
332− *((int*)pOption) = iVal;
333− return cmResultSuccess;
334− }
335− else if ( DECODER_OPTION_LTR_MARKING_FLAG == eOptID )
336− {
337− iVal = m_pDecContext->bCurAuContainLtrMarkSeFlag;
338− *((int*)pOption) = iVal;
339− return cmResultSuccess;
340− }
341− else if ( DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID )
342− {
343− iVal = m_pDecContext->iFrameNumOfAuMarkedLtr;
344− *((int*)pOption) = iVal;
345− return cmResultSuccess;
346− }
299+ else if (DECODER_OPTION_IDR_PIC_ID == eOptID) {
300+ iVal = m_pDecContext->uiCurIdrPicId;
301+ * ((int*)pOption) = iVal;
302+ return cmResultSuccess;
303+ } else if (DECODER_OPTION_FRAME_NUM == eOptID) {
304+ iVal = m_pDecContext->iFrameNum;
305+ * ((int*)pOption) = iVal;
306+ return cmResultSuccess;
307+ } else if (DECODER_OPTION_LTR_MARKING_FLAG == eOptID) {
308+ iVal = m_pDecContext->bCurAuContainLtrMarkSeFlag;
309+ * ((int*)pOption) = iVal;
310+ return cmResultSuccess;
311+ } else if (DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID) {
312+ iVal = m_pDecContext->iFrameNumOfAuMarkedLtr;
313+ * ((int*)pOption) = iVal;
314+ return cmResultSuccess;
315+ }
347316 #endif
348− else if ( DECODER_OPTION_VCL_NAL == eOptID ) //feedback whether or not have VCL NAL in current AU
349− {
350− iVal = m_pDecContext->iFeedbackVclNalInAu;
351− *((int*)pOption) = iVal;
352− return cmResultSuccess;
353− }
354− else if ( DECODER_OPTION_TEMPORAL_ID == eOptID ) //if have VCL NAL in current AU, then feedback the temporal ID
355− {
356− iVal = m_pDecContext->iFeedbackTidInAu;
357− *((int*)pOption) = iVal;
358− return cmResultSuccess;
359− }
360− else if ( DECODER_OPTION_MODE == eOptID )
361− {
362− if ( pOption == NULL )
363− return cmInitParaError;
364−
365− iVal = m_pDecContext->iSetMode;
366−
367− *((int *)pOption) = iVal;
368− return cmResultSuccess;
369− }
370− else if ( DECODER_OPTION_DEVICE_INFO == eOptID )
371− {
372− if ( pOption == NULL )
373− return cmInitParaError;
374−
375− return cmResultSuccess;
376− }
377−
378− return cmInitParaError;
317+ else if (DECODER_OPTION_VCL_NAL == eOptID) { //feedback whether or not have VCL NAL in current AU
318+ iVal = m_pDecContext->iFeedbackVclNalInAu;
319+ * ((int*)pOption) = iVal;
320+ return cmResultSuccess;
321+ } else if (DECODER_OPTION_TEMPORAL_ID == eOptID) { //if have VCL NAL in current AU, then feedback the temporal ID
322+ iVal = m_pDecContext->iFeedbackTidInAu;
323+ * ((int*)pOption) = iVal;
324+ return cmResultSuccess;
325+ } else if (DECODER_OPTION_MODE == eOptID) {
326+ if (pOption == NULL)
327+ return cmInitParaError;
328+
329+ iVal = m_pDecContext->iSetMode;
330+
331+ * ((int*)pOption) = iVal;
332+ return cmResultSuccess;
333+ } else if (DECODER_OPTION_DEVICE_INFO == eOptID) {
334+ if (pOption == NULL)
335+ return cmInitParaError;
336+
337+ return cmResultSuccess;
338+ }
339+
340+ return cmInitParaError;
379341 }
380342
381−DECODING_STATE CWelsDecoder::DecodeFrame( const unsigned char* kpSrc,
382− const int kiSrcLen,
383− void_t ** ppDst,
384− SBufferInfo* pDstInfo)
385−{
386− if ( kiSrcLen > 0 && kpSrc != NULL )
387− {
343+DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc,
344+ const int kiSrcLen,
345+ void_t** ppDst,
346+ SBufferInfo* pDstInfo) {
347+ if (kiSrcLen > 0 && kpSrc != NULL) {
388348 #ifdef OUTPUT_BIT_STREAM
389− if ( m_pFBS )
390− {
391− WelsFwrite( kpSrc, sizeof(unsigned char), kiSrcLen, m_pFBS );
392− WelsFflush( m_pFBS );
393− }
394− if ( m_pFBSSize )
395− {
396− WelsFwrite( &kiSrcLen, sizeof(int), 1, m_pFBSSize );
397− WelsFflush( m_pFBSSize );
398− }
349+ if (m_pFBS) {
350+ WelsFwrite (kpSrc, sizeof (unsigned char), kiSrcLen, m_pFBS);
351+ WelsFflush (m_pFBS);
352+ }
353+ if (m_pFBSSize) {
354+ WelsFwrite (&kiSrcLen, sizeof (int), 1, m_pFBSSize);
355+ WelsFflush (m_pFBSSize);
356+ }
399357 #endif//OUTPUT_BIT_STREAM
400− m_pDecContext->bEndOfStreamFlag = false;
401− }
402− else
403− { //For application MODE, the error detection should be added for safe.
404− //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.
405− m_pDecContext->bEndOfStreamFlag = true;
406− }
407−
408− ppDst[0] = ppDst[1] = ppDst[2] = NULL;
409− m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.
410− m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize
411− memset(pDstInfo,0,sizeof(SBufferInfo));
412− pDstInfo->eBufferProperty = (EBufferProperty)m_pDecContext->iDecoderOutputProperty;
358+ m_pDecContext->bEndOfStreamFlag = false;
359+ } else {
360+ //For application MODE, the error detection should be added for safe.
361+ //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.
362+ m_pDecContext->bEndOfStreamFlag = true;
363+ }
364+
365+ ppDst[0] = ppDst[1] = ppDst[2] = NULL;
366+ m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.
367+ m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize
368+ memset (pDstInfo, 0, sizeof (SBufferInfo));
369+ pDstInfo->eBufferProperty = (EBufferProperty)m_pDecContext->iDecoderOutputProperty;
413370
414371 #ifdef LONG_TERM_REF
415− m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR
416− m_pDecContext->bCurAuContainLtrMarkSeFlag = false;
417− m_pDecContext->iFrameNumOfAuMarkedLtr = 0;
418− m_pDecContext->iFrameNum = -1; //initialize
372+ m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR
373+ m_pDecContext->bCurAuContainLtrMarkSeFlag = false;
374+ m_pDecContext->iFrameNumOfAuMarkedLtr = 0;
375+ m_pDecContext->iFrameNum = -1; //initialize
419376 #endif
420377
421− m_pDecContext->iFeedbackTidInAu = -1; //initialize
422−
423− WelsDecodeBs( m_pDecContext, kpSrc, kiSrcLen, (unsigned char**)ppDst, pDstInfo); //iErrorCode has been modified in this function
424−
425− pDstInfo->eWorkMode = (EDecodeMode)m_pDecContext->iDecoderMode;
426−
427− if ( m_pDecContext->iErrorCode )
428− {
429− ENalUnitType eNalType = NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently
430−
431− eNalType = m_pDecContext->sCurNalHead.eNalUnitType;
432−
433− //for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss.
434− if ( (IS_PARAM_SETS_NALS(eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) ||
435− (VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType) )
436− {
378+ m_pDecContext->iFeedbackTidInAu = -1; //initialize
379+
380+ WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, (unsigned char**)ppDst,
381+ pDstInfo); //iErrorCode has been modified in this function
382+
383+ pDstInfo->eWorkMode = (EDecodeMode)m_pDecContext->iDecoderMode;
384+
385+ if (m_pDecContext->iErrorCode) {
386+ ENalUnitType eNalType =
387+ NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently
388+
389+ eNalType = m_pDecContext->sCurNalHead.eNalUnitType;
390+
391+ //for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss.
392+ if ((IS_PARAM_SETS_NALS (eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) ||
393+ (VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType)) {
437394 #ifdef LONG_TERM_REF
438− m_pDecContext->bParamSetsLostFlag = true;
395+ m_pDecContext->bParamSetsLostFlag = true;
439396 #else
440− m_pDecContext->bReferenceLostAtT0Flag = true;
397+ m_pDecContext->bReferenceLostAtT0Flag = true;
441398 #endif
442− ResetParameterSetsState( m_pDecContext ); //initial SPS&PPS ready flag
443− }
399+ ResetParameterSetsState (m_pDecContext); //initial SPS&PPS ready flag
400+ }
444401
445− IWelsTrace::WelsVTrace(m_pTrace, IWelsTrace::WELS_LOG_INFO, "decode failed, failure type:%d \n", m_pDecContext->iErrorCode);
446− return (DECODING_STATE)m_pDecContext->iErrorCode;
447− }
402+ IWelsTrace::WelsVTrace (m_pTrace, IWelsTrace::WELS_LOG_INFO, "decode failed, failure type:%d \n",
403+ m_pDecContext->iErrorCode);
404+ return (DECODING_STATE)m_pDecContext->iErrorCode;
405+ }
448406
449− return dsErrorFree;
407+ return dsErrorFree;
450408 }
451409
452−DECODING_STATE CWelsDecoder::DecodeFrame( const unsigned char* kpSrc,
453− const int kiSrcLen,
454− unsigned char** ppDst,
455− int* pStride,
456− int& iWidth,
457− int& iHeight )
458−{
459− DECODING_STATE eDecState = dsErrorFree;
460− SBufferInfo DstInfo;
461−
462− memset(&DstInfo, 0, sizeof(SBufferInfo));
463− DstInfo.UsrData.sSystemBuffer.iStride[0] = pStride[0];
464− DstInfo.UsrData.sSystemBuffer.iStride[1] = pStride[1];
465− DstInfo.UsrData.sSystemBuffer.iWidth = iWidth;
466− DstInfo.UsrData.sSystemBuffer.iHeight = iHeight;
467− DstInfo.eBufferProperty = BUFFER_HOST;
468−
469− eDecState = DecodeFrame(kpSrc, kiSrcLen, (void_t **)ppDst, &DstInfo);
470− if (eDecState == dsErrorFree)
471− {
472− pStride[0] = DstInfo.UsrData.sSystemBuffer.iStride[0];
473− pStride[1] = DstInfo.UsrData.sSystemBuffer.iStride[1];
474− iWidth = DstInfo.UsrData.sSystemBuffer.iWidth;
475− iHeight = DstInfo.UsrData.sSystemBuffer.iHeight;
476− }
477−
478− return eDecState;
410+DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc,
411+ const int kiSrcLen,
412+ unsigned char** ppDst,
413+ int* pStride,
414+ int& iWidth,
415+ int& iHeight) {
416+ DECODING_STATE eDecState = dsErrorFree;
417+ SBufferInfo DstInfo;
418+
419+ memset (&DstInfo, 0, sizeof (SBufferInfo));
420+ DstInfo.UsrData.sSystemBuffer.iStride[0] = pStride[0];
421+ DstInfo.UsrData.sSystemBuffer.iStride[1] = pStride[1];
422+ DstInfo.UsrData.sSystemBuffer.iWidth = iWidth;
423+ DstInfo.UsrData.sSystemBuffer.iHeight = iHeight;
424+ DstInfo.eBufferProperty = BUFFER_HOST;
425+
426+ eDecState = DecodeFrame (kpSrc, kiSrcLen, (void_t**)ppDst, &DstInfo);
427+ if (eDecState == dsErrorFree) {
428+ pStride[0] = DstInfo.UsrData.sSystemBuffer.iStride[0];
429+ pStride[1] = DstInfo.UsrData.sSystemBuffer.iStride[1];
430+ iWidth = DstInfo.UsrData.sSystemBuffer.iWidth;
431+ iHeight = DstInfo.UsrData.sSystemBuffer.iHeight;
432+ }
433+
434+ return eDecState;
479435 }
480436
481−DECODING_STATE CWelsDecoder::DecodeFrameEx(const unsigned char * kpSrc,
482− const int kiSrcLen,
483− unsigned char * pDst,
484− int iDstStride,
485− int & iDstLen,
486− int & iWidth,
487− int & iHeight,
488− int & iColorFormat )
489−{
490− DECODING_STATE state = dsErrorFree;
491−
492− return state;
437+DECODING_STATE CWelsDecoder::DecodeFrameEx (const unsigned char* kpSrc,
438+ const int kiSrcLen,
439+ unsigned char* pDst,
440+ int iDstStride,
441+ int& iDstLen,
442+ int& iWidth,
443+ int& iHeight,
444+ int& iColorFormat) {
445+ DECODING_STATE state = dsErrorFree;
446+
447+ return state;
493448 }
494449
495450
@@ -504,29 +459,27 @@ using namespace WelsDec; · 8 unmodified lines
504459 * CreateDecoder
505460 * @return: success in return 0, otherwise failed.
506461 */
507−long CreateDecoder( ISVCDecoder** ppDecoder )
508−{
462+long CreateDecoder (ISVCDecoder** ppDecoder) {
509463
510− if ( NULL == ppDecoder ){
511− return ERR_INVALID_PARAMETERS;
512− }
464+ if (NULL == ppDecoder) {
465+ return ERR_INVALID_PARAMETERS;
466+ }
513467
514− *ppDecoder = new CWelsDecoder();
468+ *ppDecoder = new CWelsDecoder();
515469
516− if ( NULL == *ppDecoder ){
517− return ERR_MALLOC_FAILED;
518− }
470+ if (NULL == *ppDecoder) {
471+ return ERR_MALLOC_FAILED;
472+ }
519473
520− return ERR_NONE;
474+ return ERR_NONE;
521475 }
522476
523477 /*
524478 * DestroyDecoder
525479 */
526−void_t DestroyDecoder( ISVCDecoder* pDecoder )
527−{
528− if ( NULL != pDecoder ){
529− delete (CWelsDecoder *)pDecoder;
530− pDecoder = NULL;
531− }
480+void_t DestroyDecoder (ISVCDecoder* pDecoder) {
481+ if (NULL != pDecoder) {
482+ delete (CWelsDecoder*)pDecoder;
483+ pDecoder = NULL;
484+ }
532485 }

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