History

Restore unix newlines after "Merge pull request #2991 from xiaotianshi2/master"

Some newlines were fixed in "Merge pull request #2997 from GuangweiWang/fix-issue-external", but lots were still left behind.

Martin Storsjö committed 8 years ago

Commit 1fb2f7d1 parent d43bfc114 files · +9238 −9238Browse files

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

Unified · Split

codec/decoder/plus/src/welsDecoderExt.cpp+1016−1016
@@ -1,1016 +1,1016 @@
1/*!1/*!
2 * \copy2 * \copy
3 * Copyright (c) 2009-2013, Cisco Systems3 * Copyright (c) 2009-2013, Cisco Systems
4 * All rights reserved.4 * All rights reserved.
5 *5 *
6 * Redistribution and use in source and binary forms, with or without6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions7 * modification, are permitted provided that the following conditions
8 * are met:8 * are met:
9 *9 *
10 * * Redistributions of source code must retain the above copyright10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.11 * notice, this list of conditions and the following disclaimer.
12 *12 *
13 * * Redistributions in binary form must reproduce the above copyright13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the15 * the documentation and/or other materials provided with the
16 * distribution.16 * distribution.
17 *17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.29 * POSSIBILITY OF SUCH DAMAGE.
30 *30 *
31 *31 *
32 * welsDecoderExt.cpp32 * welsDecoderExt.cpp
33 *33 *
34 * Abstract34 * Abstract
35 * Cisco OpenH264 decoder extension utilization35 * Cisco OpenH264 decoder extension utilization
36 *36 *
37 * History37 * History
38 * 3/12/2009 Created38 * 3/12/2009 Created
39 *39 *
40 *40 *
41 ************************************************************************/41 ************************************************************************/
42//#include <assert.h>42//#include <assert.h>
43#include "welsDecoderExt.h"43#include "welsDecoderExt.h"
44#include "welsCodecTrace.h"44#include "welsCodecTrace.h"
45#include "codec_def.h"45#include "codec_def.h"
46#include "typedefs.h"46#include "typedefs.h"
47#include "memory_align.h"47#include "memory_align.h"
48#include "utils.h"48#include "utils.h"
49#include "version.h"49#include "version.h"
50 50
51//#include "macros.h"51//#include "macros.h"
52#include "decoder.h"52#include "decoder.h"
53#include "decoder_core.h"53#include "decoder_core.h"
54#include "error_concealment.h"54#include "error_concealment.h"
55 55
56#include "measure_time.h"56#include "measure_time.h"
57extern "C" {57extern "C" {
58#include "decoder_core.h"58#include "decoder_core.h"
59#include "manage_dec_ref.h"59#include "manage_dec_ref.h"
60}60}
61#include "error_code.h"61#include "error_code.h"
62#include "crt_util_safe_x.h" // Safe CRT routines like util for cross platforms62#include "crt_util_safe_x.h" // Safe CRT routines like util for cross platforms
63#include <time.h>63#include <time.h>
64#if defined(_WIN32) /*&& defined(_DEBUG)*/64#if defined(_WIN32) /*&& defined(_DEBUG)*/
65 65
66#include <windows.h>66#include <windows.h>
67#include <stdio.h>67#include <stdio.h>
68#include <stdarg.h>68#include <stdarg.h>
69#include <sys/types.h>69#include <sys/types.h>
70#else70#else
71#include <sys/time.h>71#include <sys/time.h>
72#endif72#endif
73 73
74#define _PICTURE_REORDERING_ 174#define _PICTURE_REORDERING_ 1
75 75
76static int32_t sIMinInt32 = -0x7FFFFFFF;76static int32_t sIMinInt32 = -0x7FFFFFFF;
77 77
78namespace WelsDec {78namespace WelsDec {
79 79
80//////////////////////////////////////////////////////////////////////80//////////////////////////////////////////////////////////////////////
81// Construction/Destruction81// Construction/Destruction
82//////////////////////////////////////////////////////////////////////82//////////////////////////////////////////////////////////////////////
83 83
84/***************************************************************************84/***************************************************************************
85* Description:85* Description:
86* class CWelsDecoder constructor function, do initialization and86* class CWelsDecoder constructor function, do initialization and
87* alloc memory required87* alloc memory required
88*88*
89* Input parameters: none89* Input parameters: none
90*90*
91* return: none91* return: none
92***************************************************************************/92***************************************************************************/
93CWelsDecoder::CWelsDecoder (void)93CWelsDecoder::CWelsDecoder (void)
94 : m_pDecContext (NULL),94 : m_pDecContext (NULL),
95 m_pWelsTrace (NULL),95 m_pWelsTrace (NULL),
96 m_iPictInfoIndex (0),96 m_iPictInfoIndex (0),
97 m_iMinPOC (sIMinInt32),97 m_iMinPOC (sIMinInt32),
98 m_iNumOfPicts (0),98 m_iNumOfPicts (0),
99 m_iLastGOPRemainPicts (0),99 m_iLastGOPRemainPicts (0),
100 m_LastWrittenPOC (sIMinInt32),100 m_LastWrittenPOC (sIMinInt32),
101 m_iLargestBufferedPicIndex (0) {101 m_iLargestBufferedPicIndex (0) {
102#ifdef OUTPUT_BIT_STREAM102#ifdef OUTPUT_BIT_STREAM
103 char chFileName[1024] = { 0 }; //for .264103 char chFileName[1024] = { 0 }; //for .264
104 int iBufUsed = 0;104 int iBufUsed = 0;
105 int iBufLeft = 1023;105 int iBufLeft = 1023;
106 int iCurUsed;106 int iCurUsed;
107 107
108 char chFileNameSize[1024] = { 0 }; //for .len108 char chFileNameSize[1024] = { 0 }; //for .len
109 int iBufUsedSize = 0;109 int iBufUsedSize = 0;
110 int iBufLeftSize = 1023;110 int iBufLeftSize = 1023;
111 int iCurUsedSize;111 int iCurUsedSize;
112#endif//OUTPUT_BIT_STREAM112#endif//OUTPUT_BIT_STREAM
113 113
114 114
115 m_pWelsTrace = new welsCodecTrace();115 m_pWelsTrace = new welsCodecTrace();
116 if (m_pWelsTrace != NULL) {116 if (m_pWelsTrace != NULL) {
117 m_pWelsTrace->SetCodecInstance (this);117 m_pWelsTrace->SetCodecInstance (this);
118 m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR);118 m_pWelsTrace->SetTraceLevel (WELS_LOG_ERROR);
119 119
120 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry");120 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry");
121 }121 }
122 122
123 for (int32_t i = 0; i < 16; ++i) {123 for (int32_t i = 0; i < 16; ++i) {
124 m_sPictInfoList[i].bLastGOP = false;124 m_sPictInfoList[i].bLastGOP = false;
125 m_sPictInfoList[i].iPOC = sIMinInt32;125 m_sPictInfoList[i].iPOC = sIMinInt32;
126 }126 }
127 127
128#ifdef OUTPUT_BIT_STREAM128#ifdef OUTPUT_BIT_STREAM
129 SWelsTime sCurTime;129 SWelsTime sCurTime;
130 130
131 WelsGetTimeOfDay (&sCurTime);131 WelsGetTimeOfDay (&sCurTime);
132 132
133 iCurUsed = WelsSnprintf (chFileName, iBufLeft, "bs_0x%p_", (void*)this);133 iCurUsed = WelsSnprintf (chFileName, iBufLeft, "bs_0x%p_", (void*)this);
134 iCurUsedSize = WelsSnprintf (chFileNameSize, iBufLeftSize, "size_0x%p_", (void*)this);134 iCurUsedSize = WelsSnprintf (chFileNameSize, iBufLeftSize, "size_0x%p_", (void*)this);
135 135
136 iBufUsed += iCurUsed;136 iBufUsed += iCurUsed;
137 iBufLeft -= iCurUsed;137 iBufLeft -= iCurUsed;
138 if (iBufLeft > 0) {138 if (iBufLeft > 0) {
139 iCurUsed = WelsStrftime (&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime);139 iCurUsed = WelsStrftime (&chFileName[iBufUsed], iBufLeft, "%y%m%d%H%M%S", &sCurTime);
140 iBufUsed += iCurUsed;140 iBufUsed += iCurUsed;
141 iBufLeft -= iCurUsed;141 iBufLeft -= iCurUsed;
142 }142 }
143 143
144 iBufUsedSize += iCurUsedSize;144 iBufUsedSize += iCurUsedSize;
145 iBufLeftSize -= iCurUsedSize;145 iBufLeftSize -= iCurUsedSize;
146 if (iBufLeftSize > 0) {146 if (iBufLeftSize > 0) {
147 iCurUsedSize = WelsStrftime (&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime);147 iCurUsedSize = WelsStrftime (&chFileNameSize[iBufUsedSize], iBufLeftSize, "%y%m%d%H%M%S", &sCurTime);
148 iBufUsedSize += iCurUsedSize;148 iBufUsedSize += iCurUsedSize;
149 iBufLeftSize -= iCurUsedSize;149 iBufLeftSize -= iCurUsedSize;
150 }150 }
151 151
152 if (iBufLeft > 0) {152 if (iBufLeft > 0) {
153 iCurUsed = WelsSnprintf (&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillisecond (&sCurTime));153 iCurUsed = WelsSnprintf (&chFileName[iBufUsed], iBufLeft, ".%03.3u.264", WelsGetMillisecond (&sCurTime));
154 iBufUsed += iCurUsed;154 iBufUsed += iCurUsed;
155 iBufLeft -= iCurUsed;155 iBufLeft -= iCurUsed;
156 }156 }
157 157
158 if (iBufLeftSize > 0) {158 if (iBufLeftSize > 0) {
159 iCurUsedSize = WelsSnprintf (&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len",159 iCurUsedSize = WelsSnprintf (&chFileNameSize[iBufUsedSize], iBufLeftSize, ".%03.3u.len",
160 WelsGetMillisecond (&sCurTime));160 WelsGetMillisecond (&sCurTime));
161 iBufUsedSize += iCurUsedSize;161 iBufUsedSize += iCurUsedSize;
162 iBufLeftSize -= iCurUsedSize;162 iBufLeftSize -= iCurUsedSize;
163 }163 }
164 164
165 165
166 m_pFBS = WelsFopen (chFileName, "wb");166 m_pFBS = WelsFopen (chFileName, "wb");
167 m_pFBSSize = WelsFopen (chFileNameSize, "wb");167 m_pFBSSize = WelsFopen (chFileNameSize, "wb");
168#endif//OUTPUT_BIT_STREAM168#endif//OUTPUT_BIT_STREAM
169}169}
170 170
171/***************************************************************************171/***************************************************************************
172* Description:172* Description:
173* class CWelsDecoder destructor function, destroy allocced memory173* class CWelsDecoder destructor function, destroy allocced memory
174*174*
175* Input parameters: none175* Input parameters: none
176*176*
177* return: none177* return: none
178***************************************************************************/178***************************************************************************/
179CWelsDecoder::~CWelsDecoder() {179CWelsDecoder::~CWelsDecoder() {
180 if (m_pWelsTrace != NULL) {180 if (m_pWelsTrace != NULL) {
181 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()");181 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::~CWelsDecoder()");
182 }182 }
183 183
184 UninitDecoder();184 UninitDecoder();
185 185
186#ifdef OUTPUT_BIT_STREAM186#ifdef OUTPUT_BIT_STREAM
187 if (m_pFBS) {187 if (m_pFBS) {
188 WelsFclose (m_pFBS);188 WelsFclose (m_pFBS);
189 m_pFBS = NULL;189 m_pFBS = NULL;
190 }190 }
191 if (m_pFBSSize) {191 if (m_pFBSSize) {
192 WelsFclose (m_pFBSSize);192 WelsFclose (m_pFBSSize);
193 m_pFBSSize = NULL;193 m_pFBSSize = NULL;
194 }194 }
195#endif//OUTPUT_BIT_STREAM195#endif//OUTPUT_BIT_STREAM
196 196
197 if (m_pWelsTrace != NULL) {197 if (m_pWelsTrace != NULL) {
198 delete m_pWelsTrace;198 delete m_pWelsTrace;
199 m_pWelsTrace = NULL;199 m_pWelsTrace = NULL;
200 }200 }
201}201}
202 202
203long CWelsDecoder::Initialize (const SDecodingParam* pParam) {203long CWelsDecoder::Initialize (const SDecodingParam* pParam) {
204 int iRet = ERR_NONE;204 int iRet = ERR_NONE;
205 if (m_pWelsTrace == NULL) {205 if (m_pWelsTrace == NULL) {
206 return cmMallocMemeError;206 return cmMallocMemeError;
207 }207 }
208 208
209 if (pParam == NULL) {209 if (pParam == NULL) {
210 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsDecoder::Initialize(), invalid input argument.");210 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsDecoder::Initialize(), invalid input argument.");
211 return cmInitParaError;211 return cmInitParaError;
212 }212 }
213 213
214 // H.264 decoder initialization,including memory allocation,then open it ready to decode214 // H.264 decoder initialization,including memory allocation,then open it ready to decode
215 iRet = InitDecoder (pParam);215 iRet = InitDecoder (pParam);
216 if (iRet)216 if (iRet)
217 return iRet;217 return iRet;
218 218
219 return cmResultSuccess;219 return cmResultSuccess;
220}220}
221 221
222long CWelsDecoder::Uninitialize() {222long CWelsDecoder::Uninitialize() {
223 UninitDecoder();223 UninitDecoder();
224 224
225 return ERR_NONE;225 return ERR_NONE;
226}226}
227 227
228void CWelsDecoder::UninitDecoder (void) {228void CWelsDecoder::UninitDecoder (void) {
229 if (NULL == m_pDecContext)229 if (NULL == m_pDecContext)
230 return;230 return;
231 231
232 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::UninitDecoder(), openh264 codec version = %s.",232 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::UninitDecoder(), openh264 codec version = %s.",
233 VERSION_NUMBER);233 VERSION_NUMBER);
234 234
235 WelsEndDecoder (m_pDecContext);235 WelsEndDecoder (m_pDecContext);
236 236
237 if (m_pDecContext->pMemAlign != NULL) {237 if (m_pDecContext->pMemAlign != NULL) {
238 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,238 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
239 "CWelsDecoder::UninitDecoder(), verify memory usage (%d bytes) after free..",239 "CWelsDecoder::UninitDecoder(), verify memory usage (%d bytes) after free..",
240 m_pDecContext->pMemAlign->WelsGetMemoryUsage());240 m_pDecContext->pMemAlign->WelsGetMemoryUsage());
241 delete m_pDecContext->pMemAlign;241 delete m_pDecContext->pMemAlign;
242 m_pDecContext->pMemAlign = NULL;242 m_pDecContext->pMemAlign = NULL;
243 }243 }
244 244
245 if (NULL != m_pDecContext) {245 if (NULL != m_pDecContext) {
246 WelsFree (m_pDecContext, "m_pDecContext");246 WelsFree (m_pDecContext, "m_pDecContext");
247 247
248 m_pDecContext = NULL;248 m_pDecContext = NULL;
249 }249 }
250}250}
251 251
252// the return value of this function is not suitable, it need report failure info to upper layer.252// the return value of this function is not suitable, it need report failure info to upper layer.
253int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) {253int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) {
254 254
255 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,255 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
256 "CWelsDecoder::init_decoder(), openh264 codec version = %s, ParseOnly = %d",256 "CWelsDecoder::init_decoder(), openh264 codec version = %s, ParseOnly = %d",
257 VERSION_NUMBER, (int32_t)pParam->bParseOnly);257 VERSION_NUMBER, (int32_t)pParam->bParseOnly);
258 258
259 //reset decoder context259 //reset decoder context
260 if (m_pDecContext) //free260 if (m_pDecContext) //free
261 UninitDecoder();261 UninitDecoder();
262 m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext");262 m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext");
263 if (NULL == m_pDecContext)263 if (NULL == m_pDecContext)
264 return cmMallocMemeError;264 return cmMallocMemeError;
265 int32_t iCacheLineSize = 16; // on chip cache line size in byte265 int32_t iCacheLineSize = 16; // on chip cache line size in byte
266 m_pDecContext->pMemAlign = new CMemoryAlign (iCacheLineSize);266 m_pDecContext->pMemAlign = new CMemoryAlign (iCacheLineSize);
267 WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == m_pDecContext->pMemAlign), UninitDecoder())267 WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == m_pDecContext->pMemAlign), UninitDecoder())
268 268
269 //fill in default value into context269 //fill in default value into context
270 WelsDecoderDefaults (m_pDecContext, &m_pWelsTrace->m_sLogCtx);270 WelsDecoderDefaults (m_pDecContext, &m_pWelsTrace->m_sLogCtx);
271 271
272 //check param and update decoder context272 //check param and update decoder context
273 m_pDecContext->pParam = (SDecodingParam*)m_pDecContext->pMemAlign->WelsMallocz (sizeof (SDecodingParam),273 m_pDecContext->pParam = (SDecodingParam*)m_pDecContext->pMemAlign->WelsMallocz (sizeof (SDecodingParam),
274 "SDecodingParam");274 "SDecodingParam");
275 WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == m_pDecContext->pParam), UninitDecoder());275 WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == m_pDecContext->pParam), UninitDecoder());
276 int32_t iRet = DecoderConfigParam (m_pDecContext, pParam);276 int32_t iRet = DecoderConfigParam (m_pDecContext, pParam);
277 WELS_VERIFY_RETURN_IFNEQ (iRet, cmResultSuccess);277 WELS_VERIFY_RETURN_IFNEQ (iRet, cmResultSuccess);
278 278
279 //init decoder279 //init decoder
280 WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, WelsInitDecoder (m_pDecContext, &m_pWelsTrace->m_sLogCtx),280 WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, WelsInitDecoder (m_pDecContext, &m_pWelsTrace->m_sLogCtx),
281 UninitDecoder())281 UninitDecoder())
282 282
283 return cmResultSuccess;283 return cmResultSuccess;
284}284}
285 285
286int32_t CWelsDecoder::ResetDecoder() {286int32_t CWelsDecoder::ResetDecoder() {
287 // TBC: need to be modified when context and trace point are null287 // TBC: need to be modified when context and trace point are null
288 if (m_pDecContext != NULL && m_pWelsTrace != NULL) {288 if (m_pDecContext != NULL && m_pWelsTrace != NULL) {
289 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "ResetDecoder(), context error code is %d",289 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "ResetDecoder(), context error code is %d",
290 m_pDecContext->iErrorCode);290 m_pDecContext->iErrorCode);
291 SDecodingParam sPrevParam;291 SDecodingParam sPrevParam;
292 memcpy (&sPrevParam, m_pDecContext->pParam, sizeof (SDecodingParam));292 memcpy (&sPrevParam, m_pDecContext->pParam, sizeof (SDecodingParam));
293 293
294 WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, InitDecoder (&sPrevParam), UninitDecoder());294 WELS_VERIFY_RETURN_PROC_IF (cmInitParaError, InitDecoder (&sPrevParam), UninitDecoder());
295 } else if (m_pWelsTrace != NULL) {295 } else if (m_pWelsTrace != NULL) {
296 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "ResetDecoder() failed as decoder context null");296 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "ResetDecoder() failed as decoder context null");
297 }297 }
298 return ERR_INFO_UNINIT;298 return ERR_INFO_UNINIT;
299}299}
300 300
301/*301/*
302 * Set Option302 * Set Option
303 */303 */
304long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) {304long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) {
305 int iVal = 0;305 int iVal = 0;
306 306
307 if (m_pDecContext == NULL && eOptID != DECODER_OPTION_TRACE_LEVEL &&307 if (m_pDecContext == NULL && eOptID != DECODER_OPTION_TRACE_LEVEL &&
308 eOptID != DECODER_OPTION_TRACE_CALLBACK && eOptID != DECODER_OPTION_TRACE_CALLBACK_CONTEXT)308 eOptID != DECODER_OPTION_TRACE_CALLBACK && eOptID != DECODER_OPTION_TRACE_CALLBACK_CONTEXT)
309 return dsInitialOptExpected;309 return dsInitialOptExpected;
310 if (eOptID == DECODER_OPTION_END_OF_STREAM) { // Indicate bit-stream of the final frame to be decoded310 if (eOptID == DECODER_OPTION_END_OF_STREAM) { // Indicate bit-stream of the final frame to be decoded
311 if (pOption == NULL)311 if (pOption == NULL)
312 return cmInitParaError;312 return cmInitParaError;
313 313
314 iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag314 iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag
315 315
316 m_pDecContext->bEndOfStreamFlag = iVal ? true : false;316 m_pDecContext->bEndOfStreamFlag = iVal ? true : false;
317 317
318 return cmResultSuccess;318 return cmResultSuccess;
319 } else if (eOptID == DECODER_OPTION_ERROR_CON_IDC) { // Indicate error concealment status319 } else if (eOptID == DECODER_OPTION_ERROR_CON_IDC) { // Indicate error concealment status
320 if (pOption == NULL)320 if (pOption == NULL)
321 return cmInitParaError;321 return cmInitParaError;
322 322
323 iVal = * ((int*)pOption); // int value for error concealment idc323 iVal = * ((int*)pOption); // int value for error concealment idc
324 iVal = WELS_CLIP3 (iVal, (int32_t)ERROR_CON_DISABLE, (int32_t)ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE);324 iVal = WELS_CLIP3 (iVal, (int32_t)ERROR_CON_DISABLE, (int32_t)ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE);
325 if ((m_pDecContext->pParam->bParseOnly) && (iVal != (int32_t)ERROR_CON_DISABLE)) {325 if ((m_pDecContext->pParam->bParseOnly) && (iVal != (int32_t)ERROR_CON_DISABLE)) {
326 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,326 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
327 "CWelsDecoder::SetOption for ERROR_CON_IDC = %d not allowd for parse only!.", iVal);327 "CWelsDecoder::SetOption for ERROR_CON_IDC = %d not allowd for parse only!.", iVal);
328 return cmInitParaError;328 return cmInitParaError;
329 }329 }
330 330
331 m_pDecContext->pParam->eEcActiveIdc = (ERROR_CON_IDC)iVal;331 m_pDecContext->pParam->eEcActiveIdc = (ERROR_CON_IDC)iVal;
332 InitErrorCon (m_pDecContext);332 InitErrorCon (m_pDecContext);
333 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,333 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
334 "CWelsDecoder::SetOption for ERROR_CON_IDC = %d.", iVal);334 "CWelsDecoder::SetOption for ERROR_CON_IDC = %d.", iVal);
335 335
336 return cmResultSuccess;336 return cmResultSuccess;
337 } else if (eOptID == DECODER_OPTION_TRACE_LEVEL) {337 } else if (eOptID == DECODER_OPTION_TRACE_LEVEL) {
338 if (m_pWelsTrace) {338 if (m_pWelsTrace) {
339 uint32_t level = * ((uint32_t*)pOption);339 uint32_t level = * ((uint32_t*)pOption);
340 m_pWelsTrace->SetTraceLevel (level);340 m_pWelsTrace->SetTraceLevel (level);
341 }341 }
342 return cmResultSuccess;342 return cmResultSuccess;
343 } else if (eOptID == DECODER_OPTION_TRACE_CALLBACK) {343 } else if (eOptID == DECODER_OPTION_TRACE_CALLBACK) {
344 if (m_pWelsTrace) {344 if (m_pWelsTrace) {
345 WelsTraceCallback callback = * ((WelsTraceCallback*)pOption);345 WelsTraceCallback callback = * ((WelsTraceCallback*)pOption);
346 m_pWelsTrace->SetTraceCallback (callback);346 m_pWelsTrace->SetTraceCallback (callback);
347 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,347 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
348 "CWelsDecoder::SetOption():DECODER_OPTION_TRACE_CALLBACK callback = %p.",348 "CWelsDecoder::SetOption():DECODER_OPTION_TRACE_CALLBACK callback = %p.",
349 callback);349 callback);
350 }350 }
351 return cmResultSuccess;351 return cmResultSuccess;
352 } else if (eOptID == DECODER_OPTION_TRACE_CALLBACK_CONTEXT) {352 } else if (eOptID == DECODER_OPTION_TRACE_CALLBACK_CONTEXT) {
353 if (m_pWelsTrace) {353 if (m_pWelsTrace) {
354 void* ctx = * ((void**)pOption);354 void* ctx = * ((void**)pOption);
355 m_pWelsTrace->SetTraceCallbackContext (ctx);355 m_pWelsTrace->SetTraceCallbackContext (ctx);
356 }356 }
357 return cmResultSuccess;357 return cmResultSuccess;
358 } else if (eOptID == DECODER_OPTION_GET_STATISTICS) {358 } else if (eOptID == DECODER_OPTION_GET_STATISTICS) {
359 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,359 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,
360 "CWelsDecoder::SetOption():DECODER_OPTION_GET_STATISTICS: this option is get-only!");360 "CWelsDecoder::SetOption():DECODER_OPTION_GET_STATISTICS: this option is get-only!");
361 return cmInitParaError;361 return cmInitParaError;
362 } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {362 } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
363 if (pOption) {363 if (pOption) {
364 m_pDecContext->sDecoderStatistics.iStatisticsLogInterval = (* ((unsigned int*)pOption));364 m_pDecContext->sDecoderStatistics.iStatisticsLogInterval = (* ((unsigned int*)pOption));
365 return cmResultSuccess;365 return cmResultSuccess;
366 }366 }
367 } else if (eOptID == DECODER_OPTION_GET_SAR_INFO) {367 } else if (eOptID == DECODER_OPTION_GET_SAR_INFO) {
368 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,368 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,
369 "CWelsDecoder::SetOption():DECODER_OPTION_GET_SAR_INFO: this option is get-only!");369 "CWelsDecoder::SetOption():DECODER_OPTION_GET_SAR_INFO: this option is get-only!");
370 return cmInitParaError;370 return cmInitParaError;
371 }371 }
372 return cmInitParaError;372 return cmInitParaError;
373}373}
374 374
375/*375/*
376 * Get Option376 * Get Option
377 */377 */
378long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) {378long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) {
379 int iVal = 0;379 int iVal = 0;
380 380
381 if (m_pDecContext == NULL)381 if (m_pDecContext == NULL)
382 return cmInitExpected;382 return cmInitExpected;
383 383
384 if (pOption == NULL)384 if (pOption == NULL)
385 return cmInitParaError;385 return cmInitParaError;
386 386
387 if (DECODER_OPTION_END_OF_STREAM == eOptID) {387 if (DECODER_OPTION_END_OF_STREAM == eOptID) {
388 iVal = m_pDecContext->bEndOfStreamFlag;388 iVal = m_pDecContext->bEndOfStreamFlag;
389 * ((int*)pOption) = iVal;389 * ((int*)pOption) = iVal;
390 return cmResultSuccess;390 return cmResultSuccess;
391 }391 }
392#ifdef LONG_TERM_REF392#ifdef LONG_TERM_REF
393 else if (DECODER_OPTION_IDR_PIC_ID == eOptID) {393 else if (DECODER_OPTION_IDR_PIC_ID == eOptID) {
394 iVal = m_pDecContext->uiCurIdrPicId;394 iVal = m_pDecContext->uiCurIdrPicId;
395 * ((int*)pOption) = iVal;395 * ((int*)pOption) = iVal;
396 return cmResultSuccess;396 return cmResultSuccess;
397 } else if (DECODER_OPTION_FRAME_NUM == eOptID) {397 } else if (DECODER_OPTION_FRAME_NUM == eOptID) {
398 iVal = m_pDecContext->iFrameNum;398 iVal = m_pDecContext->iFrameNum;
399 * ((int*)pOption) = iVal;399 * ((int*)pOption) = iVal;
400 return cmResultSuccess;400 return cmResultSuccess;
401 } else if (DECODER_OPTION_LTR_MARKING_FLAG == eOptID) {401 } else if (DECODER_OPTION_LTR_MARKING_FLAG == eOptID) {
402 iVal = m_pDecContext->bCurAuContainLtrMarkSeFlag;402 iVal = m_pDecContext->bCurAuContainLtrMarkSeFlag;
403 * ((int*)pOption) = iVal;403 * ((int*)pOption) = iVal;
404 return cmResultSuccess;404 return cmResultSuccess;
405 } else if (DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID) {405 } else if (DECODER_OPTION_LTR_MARKED_FRAME_NUM == eOptID) {
406 iVal = m_pDecContext->iFrameNumOfAuMarkedLtr;406 iVal = m_pDecContext->iFrameNumOfAuMarkedLtr;
407 * ((int*)pOption) = iVal;407 * ((int*)pOption) = iVal;
408 return cmResultSuccess;408 return cmResultSuccess;
409 }409 }
410#endif410#endif
411 else if (DECODER_OPTION_VCL_NAL == eOptID) { //feedback whether or not have VCL NAL in current AU411 else if (DECODER_OPTION_VCL_NAL == eOptID) { //feedback whether or not have VCL NAL in current AU
412 iVal = m_pDecContext->iFeedbackVclNalInAu;412 iVal = m_pDecContext->iFeedbackVclNalInAu;
413 * ((int*)pOption) = iVal;413 * ((int*)pOption) = iVal;
414 return cmResultSuccess;414 return cmResultSuccess;
415 } else if (DECODER_OPTION_TEMPORAL_ID == eOptID) { //if have VCL NAL in current AU, then feedback the temporal ID415 } else if (DECODER_OPTION_TEMPORAL_ID == eOptID) { //if have VCL NAL in current AU, then feedback the temporal ID
416 iVal = m_pDecContext->iFeedbackTidInAu;416 iVal = m_pDecContext->iFeedbackTidInAu;
417 * ((int*)pOption) = iVal;417 * ((int*)pOption) = iVal;
418 return cmResultSuccess;418 return cmResultSuccess;
419 } else if (DECODER_OPTION_IS_REF_PIC == eOptID) {419 } else if (DECODER_OPTION_IS_REF_PIC == eOptID) {
420 iVal = m_pDecContext->iFeedbackNalRefIdc;420 iVal = m_pDecContext->iFeedbackNalRefIdc;
421 if (iVal > 0)421 if (iVal > 0)
422 iVal = 1;422 iVal = 1;
423 * ((int*)pOption) = iVal;423 * ((int*)pOption) = iVal;
424 return cmResultSuccess;424 return cmResultSuccess;
425 } else if (DECODER_OPTION_ERROR_CON_IDC == eOptID) {425 } else if (DECODER_OPTION_ERROR_CON_IDC == eOptID) {
426 iVal = (int)m_pDecContext->pParam->eEcActiveIdc;426 iVal = (int)m_pDecContext->pParam->eEcActiveIdc;
427 * ((int*)pOption) = iVal;427 * ((int*)pOption) = iVal;
428 return cmResultSuccess;428 return cmResultSuccess;
429 } else if (DECODER_OPTION_GET_STATISTICS == eOptID) { // get decoder statistics info for real time debugging429 } else if (DECODER_OPTION_GET_STATISTICS == eOptID) { // get decoder statistics info for real time debugging
430 SDecoderStatistics* pDecoderStatistics = (static_cast<SDecoderStatistics*> (pOption));430 SDecoderStatistics* pDecoderStatistics = (static_cast<SDecoderStatistics*> (pOption));
431 431
432 memcpy (pDecoderStatistics, &m_pDecContext->sDecoderStatistics, sizeof (SDecoderStatistics));432 memcpy (pDecoderStatistics, &m_pDecContext->sDecoderStatistics, sizeof (SDecoderStatistics));
433 433
434 if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount != 0) { //not original status434 if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount != 0) { //not original status
435 pDecoderStatistics->fAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /435 pDecoderStatistics->fAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /
436 (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount);436 (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount);
437 pDecoderStatistics->fActualAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /437 pDecoderStatistics->fActualAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /
438 (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount + m_pDecContext->sDecoderStatistics.uiFreezingIDRNum +438 (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount + m_pDecContext->sDecoderStatistics.uiFreezingIDRNum +
439 m_pDecContext->sDecoderStatistics.uiFreezingNonIDRNum);439 m_pDecContext->sDecoderStatistics.uiFreezingNonIDRNum);
440 }440 }
441 return cmResultSuccess;441 return cmResultSuccess;
442 } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {442 } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
443 if (pOption) {443 if (pOption) {
444 iVal = m_pDecContext->sDecoderStatistics.iStatisticsLogInterval;444 iVal = m_pDecContext->sDecoderStatistics.iStatisticsLogInterval;
445 * ((unsigned int*)pOption) = iVal;445 * ((unsigned int*)pOption) = iVal;
446 return cmResultSuccess;446 return cmResultSuccess;
447 }447 }
448 } else if (DECODER_OPTION_GET_SAR_INFO == eOptID) { //get decoder SAR info in VUI448 } else if (DECODER_OPTION_GET_SAR_INFO == eOptID) { //get decoder SAR info in VUI
449 PVuiSarInfo pVuiSarInfo = (static_cast<PVuiSarInfo> (pOption));449 PVuiSarInfo pVuiSarInfo = (static_cast<PVuiSarInfo> (pOption));
450 memset (pVuiSarInfo, 0, sizeof (SVuiSarInfo));450 memset (pVuiSarInfo, 0, sizeof (SVuiSarInfo));
451 if (!m_pDecContext->pSps) {451 if (!m_pDecContext->pSps) {
452 return cmInitExpected;452 return cmInitExpected;
453 } else {453 } else {
454 pVuiSarInfo->uiSarWidth = m_pDecContext->pSps->sVui.uiSarWidth;454 pVuiSarInfo->uiSarWidth = m_pDecContext->pSps->sVui.uiSarWidth;
455 pVuiSarInfo->uiSarHeight = m_pDecContext->pSps->sVui.uiSarHeight;455 pVuiSarInfo->uiSarHeight = m_pDecContext->pSps->sVui.uiSarHeight;
456 pVuiSarInfo->bOverscanAppropriateFlag = m_pDecContext->pSps->sVui.bOverscanAppropriateFlag;456 pVuiSarInfo->bOverscanAppropriateFlag = m_pDecContext->pSps->sVui.bOverscanAppropriateFlag;
457 return cmResultSuccess;457 return cmResultSuccess;
458 }458 }
459 } else if (DECODER_OPTION_PROFILE == eOptID) {459 } else if (DECODER_OPTION_PROFILE == eOptID) {
460 if (!m_pDecContext->pSps) {460 if (!m_pDecContext->pSps) {
461 return cmInitExpected;461 return cmInitExpected;
462 }462 }
463 iVal = (int)m_pDecContext->pSps->uiProfileIdc;463 iVal = (int)m_pDecContext->pSps->uiProfileIdc;
464 * ((int*)pOption) = iVal;464 * ((int*)pOption) = iVal;
465 return cmResultSuccess;465 return cmResultSuccess;
466 } else if (DECODER_OPTION_LEVEL == eOptID) {466 } else if (DECODER_OPTION_LEVEL == eOptID) {
467 if (!m_pDecContext->pSps) {467 if (!m_pDecContext->pSps) {
468 return cmInitExpected;468 return cmInitExpected;
469 }469 }
470 iVal = (int)m_pDecContext->pSps->uiLevelIdc;470 iVal = (int)m_pDecContext->pSps->uiLevelIdc;
471 * ((int*)pOption) = iVal;471 * ((int*)pOption) = iVal;
472 return cmResultSuccess;472 return cmResultSuccess;
473 } else if (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER == eOptID) {473 } else if (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER == eOptID) {
474 if (m_pDecContext->pSps && m_pDecContext->pSps->uiProfileIdc != 66 && m_pDecContext->pPps->bEntropyCodingModeFlag) {474 if (m_pDecContext->pSps && m_pDecContext->pSps->uiProfileIdc != 66 && m_pDecContext->pPps->bEntropyCodingModeFlag) {
475 * ((int*)pOption) = m_iNumOfPicts > 0 ? m_iNumOfPicts : 0;475 * ((int*)pOption) = m_iNumOfPicts > 0 ? m_iNumOfPicts : 0;
476 }476 }
477 return cmResultSuccess;477 return cmResultSuccess;
478 }478 }
479 479
480 return cmInitParaError;480 return cmInitParaError;
481}481}
482 482
483DECODING_STATE CWelsDecoder::DecodeFrameNoDelay (const unsigned char* kpSrc,483DECODING_STATE CWelsDecoder::DecodeFrameNoDelay (const unsigned char* kpSrc,
484 const int kiSrcLen,484 const int kiSrcLen,
485 unsigned char** ppDst,485 unsigned char** ppDst,
486 SBufferInfo* pDstInfo) {486 SBufferInfo* pDstInfo) {
487 int iRet;487 int iRet;
488 //SBufferInfo sTmpBufferInfo;488 //SBufferInfo sTmpBufferInfo;
489 //unsigned char* ppTmpDst[3] = {NULL, NULL, NULL};489 //unsigned char* ppTmpDst[3] = {NULL, NULL, NULL};
490 iRet = (int)DecodeFrame2 (kpSrc, kiSrcLen, ppDst, pDstInfo);490 iRet = (int)DecodeFrame2 (kpSrc, kiSrcLen, ppDst, pDstInfo);
491 //memcpy (&sTmpBufferInfo, pDstInfo, sizeof (SBufferInfo));491 //memcpy (&sTmpBufferInfo, pDstInfo, sizeof (SBufferInfo));
492 //ppTmpDst[0] = ppDst[0];492 //ppTmpDst[0] = ppDst[0];
493 //ppTmpDst[1] = ppDst[1];493 //ppTmpDst[1] = ppDst[1];
494 //ppTmpDst[2] = ppDst[2];494 //ppTmpDst[2] = ppDst[2];
495 iRet |= DecodeFrame2 (NULL, 0, ppDst, pDstInfo);495 iRet |= DecodeFrame2 (NULL, 0, ppDst, pDstInfo);
496 //if ((pDstInfo->iBufferStatus == 0) && (sTmpBufferInfo.iBufferStatus == 1)) {496 //if ((pDstInfo->iBufferStatus == 0) && (sTmpBufferInfo.iBufferStatus == 1)) {
497 //memcpy (pDstInfo, &sTmpBufferInfo, sizeof (SBufferInfo));497 //memcpy (pDstInfo, &sTmpBufferInfo, sizeof (SBufferInfo));
498 //ppDst[0] = ppTmpDst[0];498 //ppDst[0] = ppTmpDst[0];
499 //ppDst[1] = ppTmpDst[1];499 //ppDst[1] = ppTmpDst[1];
500 //ppDst[2] = ppTmpDst[2];500 //ppDst[2] = ppTmpDst[2];
501 //}501 //}
502 return (DECODING_STATE)iRet;502 return (DECODING_STATE)iRet;
503}503}
504 504
505DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc,505DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc,
506 const int kiSrcLen,506 const int kiSrcLen,
507 unsigned char** ppDst,507 unsigned char** ppDst,
508 SBufferInfo* pDstInfo) {508 SBufferInfo* pDstInfo) {
509 if (m_pDecContext == NULL || m_pDecContext->pParam == NULL) {509 if (m_pDecContext == NULL || m_pDecContext->pParam == NULL) {
510 if (m_pWelsTrace != NULL) {510 if (m_pWelsTrace != NULL) {
511 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "Call DecodeFrame2 without Initialize.\n");511 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "Call DecodeFrame2 without Initialize.\n");
512 }512 }
513 return dsInitialOptExpected;513 return dsInitialOptExpected;
514 }514 }
515 515
516 if (m_pDecContext->pParam->bParseOnly) {516 if (m_pDecContext->pParam->bParseOnly) {
517 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be false for this API calling! \n");517 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be false for this API calling! \n");
518 m_pDecContext->iErrorCode |= dsInvalidArgument;518 m_pDecContext->iErrorCode |= dsInvalidArgument;
519 return dsInvalidArgument;519 return dsInvalidArgument;
520 }520 }
521 if (CheckBsBuffer (m_pDecContext, kiSrcLen)) {521 if (CheckBsBuffer (m_pDecContext, kiSrcLen)) {
522 if (ResetDecoder())522 if (ResetDecoder())
523 return dsOutOfMemory;523 return dsOutOfMemory;
524 524
525 return dsErrorFree;525 return dsErrorFree;
526 }526 }
527 if (kiSrcLen > 0 && kpSrc != NULL) {527 if (kiSrcLen > 0 && kpSrc != NULL) {
528#ifdef OUTPUT_BIT_STREAM528#ifdef OUTPUT_BIT_STREAM
529 if (m_pFBS) {529 if (m_pFBS) {
530 WelsFwrite (kpSrc, sizeof (unsigned char), kiSrcLen, m_pFBS);530 WelsFwrite (kpSrc, sizeof (unsigned char), kiSrcLen, m_pFBS);
531 WelsFflush (m_pFBS);531 WelsFflush (m_pFBS);
532 }532 }
533 if (m_pFBSSize) {533 if (m_pFBSSize) {
534 WelsFwrite (&kiSrcLen, sizeof (int), 1, m_pFBSSize);534 WelsFwrite (&kiSrcLen, sizeof (int), 1, m_pFBSSize);
535 WelsFflush (m_pFBSSize);535 WelsFflush (m_pFBSSize);
536 }536 }
537#endif//OUTPUT_BIT_STREAM537#endif//OUTPUT_BIT_STREAM
538 m_pDecContext->bEndOfStreamFlag = false;538 m_pDecContext->bEndOfStreamFlag = false;
539 } else {539 } else {
540 //For application MODE, the error detection should be added for safe.540 //For application MODE, the error detection should be added for safe.
541 //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.541 //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.
542 m_pDecContext->bEndOfStreamFlag = true;542 m_pDecContext->bEndOfStreamFlag = true;
543 m_pDecContext->bInstantDecFlag = true;543 m_pDecContext->bInstantDecFlag = true;
544 }544 }
545 545
546 int64_t iStart, iEnd;546 int64_t iStart, iEnd;
547 iStart = WelsTime();547 iStart = WelsTime();
548 548
549 ppDst[0] = ppDst[1] = ppDst[2] = NULL;549 ppDst[0] = ppDst[1] = ppDst[2] = NULL;
550 m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.550 m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.
551 m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize551 m_pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize
552 unsigned long long uiInBsTimeStamp = pDstInfo->uiInBsTimeStamp;552 unsigned long long uiInBsTimeStamp = pDstInfo->uiInBsTimeStamp;
553 memset (pDstInfo, 0, sizeof (SBufferInfo));553 memset (pDstInfo, 0, sizeof (SBufferInfo));
554 pDstInfo->uiInBsTimeStamp = uiInBsTimeStamp;554 pDstInfo->uiInBsTimeStamp = uiInBsTimeStamp;
555#ifdef LONG_TERM_REF555#ifdef LONG_TERM_REF
556 m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR556 m_pDecContext->bReferenceLostAtT0Flag = false; //initialize for LTR
557 m_pDecContext->bCurAuContainLtrMarkSeFlag = false;557 m_pDecContext->bCurAuContainLtrMarkSeFlag = false;
558 m_pDecContext->iFrameNumOfAuMarkedLtr = 0;558 m_pDecContext->iFrameNumOfAuMarkedLtr = 0;
559 m_pDecContext->iFrameNum = -1; //initialize559 m_pDecContext->iFrameNum = -1; //initialize
560#endif560#endif
561 561
562 m_pDecContext->iFeedbackTidInAu = -1; //initialize562 m_pDecContext->iFeedbackTidInAu = -1; //initialize
563 m_pDecContext->iFeedbackNalRefIdc = -1; //initialize563 m_pDecContext->iFeedbackNalRefIdc = -1; //initialize
564 if (pDstInfo) {564 if (pDstInfo) {
565 pDstInfo->uiOutYuvTimeStamp = 0;565 pDstInfo->uiOutYuvTimeStamp = 0;
566 m_pDecContext->uiTimeStamp = pDstInfo->uiInBsTimeStamp;566 m_pDecContext->uiTimeStamp = pDstInfo->uiInBsTimeStamp;
567 } else {567 } else {
568 m_pDecContext->uiTimeStamp = 0;568 m_pDecContext->uiTimeStamp = 0;
569 }569 }
570 WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, ppDst,570 WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, ppDst,
571 pDstInfo, NULL); //iErrorCode has been modified in this function571 pDstInfo, NULL); //iErrorCode has been modified in this function
572 m_pDecContext->bInstantDecFlag = false; //reset no-delay flag572 m_pDecContext->bInstantDecFlag = false; //reset no-delay flag
573 if (m_pDecContext->iErrorCode) {573 if (m_pDecContext->iErrorCode) {
574 EWelsNalUnitType eNalType =574 EWelsNalUnitType eNalType =
575 NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently575 NAL_UNIT_UNSPEC_0; //for NBR, IDR frames are expected to decode as followed if error decoding an IDR currently
576 576
577 eNalType = m_pDecContext->sCurNalHead.eNalUnitType;577 eNalType = m_pDecContext->sCurNalHead.eNalUnitType;
578 578
579 if (m_pDecContext->iErrorCode & dsOutOfMemory) {579 if (m_pDecContext->iErrorCode & dsOutOfMemory) {
580 if (ResetDecoder())580 if (ResetDecoder())
581 return dsOutOfMemory;581 return dsOutOfMemory;
582 582
583 return dsErrorFree;583 return dsErrorFree;
584 }584 }
585 //for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss.585 //for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss.
586 if ((IS_PARAM_SETS_NALS (eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) ||586 if ((IS_PARAM_SETS_NALS (eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) ||
587 (VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType)) {587 (VIDEO_BITSTREAM_AVC == m_pDecContext->eVideoType)) {
588 if (m_pDecContext->pParam->eEcActiveIdc == ERROR_CON_DISABLE) {588 if (m_pDecContext->pParam->eEcActiveIdc == ERROR_CON_DISABLE) {
589#ifdef LONG_TERM_REF589#ifdef LONG_TERM_REF
590 m_pDecContext->bParamSetsLostFlag = true;590 m_pDecContext->bParamSetsLostFlag = true;
591#else591#else
592 m_pDecContext->bReferenceLostAtT0Flag = true;592 m_pDecContext->bReferenceLostAtT0Flag = true;
593#endif593#endif
594 }594 }
595 }595 }
596 596
597 if (m_pDecContext->bPrintFrameErrorTraceFlag) {597 if (m_pDecContext->bPrintFrameErrorTraceFlag) {
598 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "decode failed, failure type:%d \n",598 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "decode failed, failure type:%d \n",
599 m_pDecContext->iErrorCode);599 m_pDecContext->iErrorCode);
600 m_pDecContext->bPrintFrameErrorTraceFlag = false;600 m_pDecContext->bPrintFrameErrorTraceFlag = false;
601 } else {601 } else {
602 m_pDecContext->iIgnoredErrorInfoPacketCount++;602 m_pDecContext->iIgnoredErrorInfoPacketCount++;
603 if (m_pDecContext->iIgnoredErrorInfoPacketCount == INT_MAX) {603 if (m_pDecContext->iIgnoredErrorInfoPacketCount == INT_MAX) {
604 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, "continuous error reached INT_MAX! Restart as 0.");604 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, "continuous error reached INT_MAX! Restart as 0.");
605 m_pDecContext->iIgnoredErrorInfoPacketCount = 0;605 m_pDecContext->iIgnoredErrorInfoPacketCount = 0;
606 }606 }
607 }607 }
608 if ((m_pDecContext->pParam->eEcActiveIdc != ERROR_CON_DISABLE) && (pDstInfo->iBufferStatus == 1)) {608 if ((m_pDecContext->pParam->eEcActiveIdc != ERROR_CON_DISABLE) && (pDstInfo->iBufferStatus == 1)) {
609 //TODO after dec status updated609 //TODO after dec status updated
610 m_pDecContext->iErrorCode |= dsDataErrorConcealed;610 m_pDecContext->iErrorCode |= dsDataErrorConcealed;
611 611
612 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;612 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
613 if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t613 if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t
614 ResetDecStatNums (&m_pDecContext->sDecoderStatistics);614 ResetDecStatNums (&m_pDecContext->sDecoderStatistics);
615 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;615 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
616 }616 }
617 int32_t iMbConcealedNum = m_pDecContext->iMbEcedNum + m_pDecContext->iMbEcedPropNum;617 int32_t iMbConcealedNum = m_pDecContext->iMbEcedNum + m_pDecContext->iMbEcedPropNum;
618 m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->iMbNum == 0 ?618 m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->iMbNum == 0 ?
619 (m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : ((619 (m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : ((
620 m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + ((620 m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + ((
621 iMbConcealedNum * 100) / m_pDecContext->iMbNum));621 iMbConcealedNum * 100) / m_pDecContext->iMbNum));
622 m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->iMbNum == 0 ?622 m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->iMbNum == 0 ?
623 (m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : ((623 (m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : ((
624 m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + ((624 m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + ((
625 m_pDecContext->iMbEcedPropNum * 100) / m_pDecContext->iMbNum));625 m_pDecContext->iMbEcedPropNum * 100) / m_pDecContext->iMbNum));
626 m_pDecContext->sDecoderStatistics.uiEcFrameNum += (iMbConcealedNum == 0 ? 0 : 1);626 m_pDecContext->sDecoderStatistics.uiEcFrameNum += (iMbConcealedNum == 0 ? 0 : 1);
627 m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 :627 m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 :
628 m_pDecContext->sDecoderStatistics.uiAvgEcRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum;628 m_pDecContext->sDecoderStatistics.uiAvgEcRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum;
629 m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 :629 m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 :
630 m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum;630 m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum;
631 }631 }
632 iEnd = WelsTime();632 iEnd = WelsTime();
633 m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;633 m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;
634 634
635 OutputStatisticsLog (m_pDecContext->sDecoderStatistics);635 OutputStatisticsLog (m_pDecContext->sDecoderStatistics);
636 636
637#ifdef _PICTURE_REORDERING_637#ifdef _PICTURE_REORDERING_
638 ReorderPicturesInDisplay (ppDst, pDstInfo);638 ReorderPicturesInDisplay (ppDst, pDstInfo);
639#endif639#endif
640 640
641 return (DECODING_STATE)m_pDecContext->iErrorCode;641 return (DECODING_STATE)m_pDecContext->iErrorCode;
642 }642 }
643 // else Error free, the current codec works well643 // else Error free, the current codec works well
644 644
645 if (pDstInfo->iBufferStatus == 1) {645 if (pDstInfo->iBufferStatus == 1) {
646 646
647 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;647 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
648 if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t648 if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t
649 ResetDecStatNums (&m_pDecContext->sDecoderStatistics);649 ResetDecStatNums (&m_pDecContext->sDecoderStatistics);
650 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;650 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
651 }651 }
652 652
653 OutputStatisticsLog (m_pDecContext->sDecoderStatistics);653 OutputStatisticsLog (m_pDecContext->sDecoderStatistics);
654 }654 }
655 iEnd = WelsTime();655 iEnd = WelsTime();
656 m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;656 m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;
657 657
658#ifdef _PICTURE_REORDERING_658#ifdef _PICTURE_REORDERING_
659 ReorderPicturesInDisplay (ppDst, pDstInfo);659 ReorderPicturesInDisplay (ppDst, pDstInfo);
660#endif660#endif
661 return dsErrorFree;661 return dsErrorFree;
662}662}
663 663
664DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst,664DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst,
665 SBufferInfo* pDstInfo) {665 SBufferInfo* pDstInfo) {
666 if (m_pDecContext->bEndOfStreamFlag && m_iNumOfPicts > 0) {666 if (m_pDecContext->bEndOfStreamFlag && m_iNumOfPicts > 0) {
667 m_iMinPOC = sIMinInt32;667 m_iMinPOC = sIMinInt32;
668 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {668 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
669 if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) {669 if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) {
670 m_iMinPOC = m_sPictInfoList[i].iPOC;670 m_iMinPOC = m_sPictInfoList[i].iPOC;
671 m_iPictInfoIndex = i;671 m_iPictInfoIndex = i;
672 }672 }
673 if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) {673 if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) {
674 m_iMinPOC = m_sPictInfoList[i].iPOC;674 m_iMinPOC = m_sPictInfoList[i].iPOC;
675 m_iPictInfoIndex = i;675 m_iPictInfoIndex = i;
676 }676 }
677 }677 }
678 }678 }
679 if (m_iMinPOC > sIMinInt32) {679 if (m_iMinPOC > sIMinInt32) {
680 m_LastWrittenPOC = m_iMinPOC;680 m_LastWrittenPOC = m_iMinPOC;
681#if defined (_DEBUG)681#if defined (_DEBUG)
682#ifdef _MOTION_VECTOR_DUMP_682#ifdef _MOTION_VECTOR_DUMP_
683 fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC);683 fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC);
684#endif684#endif
685#endif685#endif
686 memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo));686 memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo));
687 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];687 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
688 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];688 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
689 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];689 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
690 m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;690 m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
691 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;691 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
692 m_iMinPOC = sIMinInt32;692 m_iMinPOC = sIMinInt32;
693 --m_iNumOfPicts;693 --m_iNumOfPicts;
694 }694 }
695 return dsErrorFree;695 return dsErrorFree;
696}696}
697 697
698void CWelsDecoder::OutputStatisticsLog (SDecoderStatistics& sDecoderStatistics) {698void CWelsDecoder::OutputStatisticsLog (SDecoderStatistics& sDecoderStatistics) {
699 if ((sDecoderStatistics.uiDecodedFrameCount > 0) && (sDecoderStatistics.iStatisticsLogInterval > 0)699 if ((sDecoderStatistics.uiDecodedFrameCount > 0) && (sDecoderStatistics.iStatisticsLogInterval > 0)
700 && ((sDecoderStatistics.uiDecodedFrameCount % sDecoderStatistics.iStatisticsLogInterval) == 0)) {700 && ((sDecoderStatistics.uiDecodedFrameCount % sDecoderStatistics.iStatisticsLogInterval) == 0)) {
701 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,701 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
702 "DecoderStatistics: uiWidth=%d, uiHeight=%d, fAverageFrameSpeedInMs=%.1f, fActualAverageFrameSpeedInMs=%.1f, \702 "DecoderStatistics: uiWidth=%d, uiHeight=%d, fAverageFrameSpeedInMs=%.1f, fActualAverageFrameSpeedInMs=%.1f, \
703 uiDecodedFrameCount=%d, uiResolutionChangeTimes=%d, uiIDRCorrectNum=%d, \703 uiDecodedFrameCount=%d, uiResolutionChangeTimes=%d, uiIDRCorrectNum=%d, \
704 uiAvgEcRatio=%d, uiAvgEcPropRatio=%d, uiEcIDRNum=%d, uiEcFrameNum=%d, \704 uiAvgEcRatio=%d, uiAvgEcPropRatio=%d, uiEcIDRNum=%d, uiEcFrameNum=%d, \
705 uiIDRLostNum=%d, uiFreezingIDRNum=%d, uiFreezingNonIDRNum=%d, iAvgLumaQp=%d, \705 uiIDRLostNum=%d, uiFreezingIDRNum=%d, uiFreezingNonIDRNum=%d, iAvgLumaQp=%d, \
706 iSpsReportErrorNum=%d, iSubSpsReportErrorNum=%d, iPpsReportErrorNum=%d, iSpsNoExistNalNum=%d, iSubSpsNoExistNalNum=%d, iPpsNoExistNalNum=%d, \706 iSpsReportErrorNum=%d, iSubSpsReportErrorNum=%d, iPpsReportErrorNum=%d, iSpsNoExistNalNum=%d, iSubSpsNoExistNalNum=%d, iPpsNoExistNalNum=%d, \
707 uiProfile=%d, uiLevel=%d, \707 uiProfile=%d, uiLevel=%d, \
708 iCurrentActiveSpsId=%d, iCurrentActivePpsId=%d,",708 iCurrentActiveSpsId=%d, iCurrentActivePpsId=%d,",
709 sDecoderStatistics.uiWidth,709 sDecoderStatistics.uiWidth,
710 sDecoderStatistics.uiHeight,710 sDecoderStatistics.uiHeight,
711 sDecoderStatistics.fAverageFrameSpeedInMs,711 sDecoderStatistics.fAverageFrameSpeedInMs,
712 sDecoderStatistics.fActualAverageFrameSpeedInMs,712 sDecoderStatistics.fActualAverageFrameSpeedInMs,
713 713
714 sDecoderStatistics.uiDecodedFrameCount,714 sDecoderStatistics.uiDecodedFrameCount,
715 sDecoderStatistics.uiResolutionChangeTimes,715 sDecoderStatistics.uiResolutionChangeTimes,
716 sDecoderStatistics.uiIDRCorrectNum,716 sDecoderStatistics.uiIDRCorrectNum,
717 717
718 sDecoderStatistics.uiAvgEcRatio,718 sDecoderStatistics.uiAvgEcRatio,
719 sDecoderStatistics.uiAvgEcPropRatio,719 sDecoderStatistics.uiAvgEcPropRatio,
720 sDecoderStatistics.uiEcIDRNum,720 sDecoderStatistics.uiEcIDRNum,
721 sDecoderStatistics.uiEcFrameNum,721 sDecoderStatistics.uiEcFrameNum,
722 722
723 sDecoderStatistics.uiIDRLostNum,723 sDecoderStatistics.uiIDRLostNum,
724 sDecoderStatistics.uiFreezingIDRNum,724 sDecoderStatistics.uiFreezingIDRNum,
725 sDecoderStatistics.uiFreezingNonIDRNum,725 sDecoderStatistics.uiFreezingNonIDRNum,
726 sDecoderStatistics.iAvgLumaQp,726 sDecoderStatistics.iAvgLumaQp,
727 727
728 sDecoderStatistics.iSpsReportErrorNum,728 sDecoderStatistics.iSpsReportErrorNum,
729 sDecoderStatistics.iSubSpsReportErrorNum,729 sDecoderStatistics.iSubSpsReportErrorNum,
730 sDecoderStatistics.iPpsReportErrorNum,730 sDecoderStatistics.iPpsReportErrorNum,
731 sDecoderStatistics.iSpsNoExistNalNum,731 sDecoderStatistics.iSpsNoExistNalNum,
732 sDecoderStatistics.iSubSpsNoExistNalNum,732 sDecoderStatistics.iSubSpsNoExistNalNum,
733 sDecoderStatistics.iPpsNoExistNalNum,733 sDecoderStatistics.iPpsNoExistNalNum,
734 734
735 sDecoderStatistics.uiProfile,735 sDecoderStatistics.uiProfile,
736 sDecoderStatistics.uiLevel,736 sDecoderStatistics.uiLevel,
737 737
738 sDecoderStatistics.iCurrentActiveSpsId,738 sDecoderStatistics.iCurrentActiveSpsId,
739 sDecoderStatistics.iCurrentActivePpsId);739 sDecoderStatistics.iCurrentActivePpsId);
740 }740 }
741}741}
742 742
743DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SBufferInfo* pDstInfo) {743DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SBufferInfo* pDstInfo) {
744 if (pDstInfo->iBufferStatus == 1 && m_pDecContext->pSps->uiProfileIdc != 66744 if (pDstInfo->iBufferStatus == 1 && m_pDecContext->pSps->uiProfileIdc != 66
745 && m_pDecContext->pPps->bEntropyCodingModeFlag) {745 && m_pDecContext->pPps->bEntropyCodingModeFlag) {
746 if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) {746 if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) {
747 if (m_iNumOfPicts > 0) {747 if (m_iNumOfPicts > 0) {
748 m_iLastGOPRemainPicts = m_iNumOfPicts;748 m_iLastGOPRemainPicts = m_iNumOfPicts;
749 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {749 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
750 if (m_sPictInfoList[i].iPOC > sIMinInt32) {750 if (m_sPictInfoList[i].iPOC > sIMinInt32) {
751 m_sPictInfoList[i].bLastGOP = true;751 m_sPictInfoList[i].bLastGOP = true;
752 }752 }
753 }753 }
754 }754 }
755 }755 }
756 for (int32_t i = 0; i < 16; ++i) {756 for (int32_t i = 0; i < 16; ++i) {
757 if (m_sPictInfoList[i].iPOC == sIMinInt32) {757 if (m_sPictInfoList[i].iPOC == sIMinInt32) {
758 memcpy (&m_sPictInfoList[i].sBufferInfo, pDstInfo, sizeof (SBufferInfo));758 memcpy (&m_sPictInfoList[i].sBufferInfo, pDstInfo, sizeof (SBufferInfo));
759 m_sPictInfoList[i].pData[0] = ppDst[0];759 m_sPictInfoList[i].pData[0] = ppDst[0];
760 m_sPictInfoList[i].pData[1] = ppDst[1];760 m_sPictInfoList[i].pData[1] = ppDst[1];
761 m_sPictInfoList[i].pData[2] = ppDst[2];761 m_sPictInfoList[i].pData[2] = ppDst[2];
762 m_sPictInfoList[i].iPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb;762 m_sPictInfoList[i].iPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb;
763 m_sPictInfoList[i].iFrameNum = m_pDecContext->pSliceHeader->iFrameNum;763 m_sPictInfoList[i].iFrameNum = m_pDecContext->pSliceHeader->iFrameNum;
764 m_sPictInfoList[i].bLastGOP = false;764 m_sPictInfoList[i].bLastGOP = false;
765 pDstInfo->iBufferStatus = 0;765 pDstInfo->iBufferStatus = 0;
766 ++m_iNumOfPicts;766 ++m_iNumOfPicts;
767 if (i > m_iLargestBufferedPicIndex) {767 if (i > m_iLargestBufferedPicIndex) {
768 m_iLargestBufferedPicIndex = i;768 m_iLargestBufferedPicIndex = i;
769 }769 }
770 break;770 break;
771 }771 }
772 }772 }
773 if (m_iLastGOPRemainPicts > 0) {773 if (m_iLastGOPRemainPicts > 0) {
774 m_iMinPOC = sIMinInt32;774 m_iMinPOC = sIMinInt32;
775 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {775 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
776 if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].bLastGOP) {776 if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].bLastGOP) {
777 m_iMinPOC = m_sPictInfoList[i].iPOC;777 m_iMinPOC = m_sPictInfoList[i].iPOC;
778 m_iPictInfoIndex = i;778 m_iPictInfoIndex = i;
779 }779 }
780 if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC && m_sPictInfoList[i].bLastGOP) {780 if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC && m_sPictInfoList[i].bLastGOP) {
781 m_iMinPOC = m_sPictInfoList[i].iPOC;781 m_iMinPOC = m_sPictInfoList[i].iPOC;
782 m_iPictInfoIndex = i;782 m_iPictInfoIndex = i;
783 }783 }
784 }784 }
785 m_LastWrittenPOC = m_iMinPOC;785 m_LastWrittenPOC = m_iMinPOC;
786#if defined (_DEBUG)786#if defined (_DEBUG)
787#ifdef _MOTION_VECTOR_DUMP_787#ifdef _MOTION_VECTOR_DUMP_
788 fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC);788 fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC);
789#endif789#endif
790#endif790#endif
791 memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo));791 memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo));
792 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];792 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
793 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];793 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
794 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];794 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
795 m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;795 m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
796 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;796 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
797 m_iMinPOC = sIMinInt32;797 m_iMinPOC = sIMinInt32;
798 --m_iNumOfPicts;798 --m_iNumOfPicts;
799 --m_iLastGOPRemainPicts;799 --m_iLastGOPRemainPicts;
800 if (m_iLastGOPRemainPicts == 0) {800 if (m_iLastGOPRemainPicts == 0) {
801 m_LastWrittenPOC = sIMinInt32;801 m_LastWrittenPOC = sIMinInt32;
802 }802 }
803 return dsErrorFree;803 return dsErrorFree;
804 }804 }
805 if (m_iNumOfPicts > 0) {805 if (m_iNumOfPicts > 0) {
806 m_iMinPOC = sIMinInt32;806 m_iMinPOC = sIMinInt32;
807 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {807 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
808 if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) {808 if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) {
809 m_iMinPOC = m_sPictInfoList[i].iPOC;809 m_iMinPOC = m_sPictInfoList[i].iPOC;
810 m_iPictInfoIndex = i;810 m_iPictInfoIndex = i;
811 }811 }
812 if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) {812 if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) {
813 m_iMinPOC = m_sPictInfoList[i].iPOC;813 m_iMinPOC = m_sPictInfoList[i].iPOC;
814 m_iPictInfoIndex = i;814 m_iPictInfoIndex = i;
815 }815 }
816 }816 }
817 }817 }
818 if (m_iMinPOC > sIMinInt32) {818 if (m_iMinPOC > sIMinInt32) {
819 if ((m_LastWrittenPOC > sIMinInt32 && m_iMinPOC - m_LastWrittenPOC <= 1)819 if ((m_LastWrittenPOC > sIMinInt32 && m_iMinPOC - m_LastWrittenPOC <= 1)
820 || m_iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) {820 || m_iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) {
821 m_LastWrittenPOC = m_iMinPOC;821 m_LastWrittenPOC = m_iMinPOC;
822#if defined (_DEBUG)822#if defined (_DEBUG)
823#ifdef _MOTION_VECTOR_DUMP_823#ifdef _MOTION_VECTOR_DUMP_
824 fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC);824 fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC);
825#endif825#endif
826#endif826#endif
827 memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo));827 memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo));
828 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];828 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
829 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];829 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
830 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];830 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
831 m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;831 m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
832 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;832 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
833 m_iMinPOC = sIMinInt32;833 m_iMinPOC = sIMinInt32;
834 --m_iNumOfPicts;834 --m_iNumOfPicts;
835 return dsErrorFree;835 return dsErrorFree;
836 }836 }
837 }837 }
838 }838 }
839 839
840 return dsErrorFree;840 return dsErrorFree;
841}841}
842 842
843DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc,843DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc,
844 const int kiSrcLen,844 const int kiSrcLen,
845 SParserBsInfo* pDstInfo) {845 SParserBsInfo* pDstInfo) {
846 if (m_pDecContext == NULL || m_pDecContext->pParam == NULL) {846 if (m_pDecContext == NULL || m_pDecContext->pParam == NULL) {
847 if (m_pWelsTrace != NULL) {847 if (m_pWelsTrace != NULL) {
848 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "Call DecodeParser without Initialize.\n");848 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "Call DecodeParser without Initialize.\n");
849 }849 }
850 return dsInitialOptExpected;850 return dsInitialOptExpected;
851 }851 }
852 852
853 if (!m_pDecContext->pParam->bParseOnly) {853 if (!m_pDecContext->pParam->bParseOnly) {
854 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be true for this API calling! \n");854 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "bParseOnly should be true for this API calling! \n");
855 m_pDecContext->iErrorCode |= dsInvalidArgument;855 m_pDecContext->iErrorCode |= dsInvalidArgument;
856 return dsInvalidArgument;856 return dsInvalidArgument;
857 }857 }
858 int64_t iEnd, iStart = WelsTime();858 int64_t iEnd, iStart = WelsTime();
859 if (CheckBsBuffer (m_pDecContext, kiSrcLen)) {859 if (CheckBsBuffer (m_pDecContext, kiSrcLen)) {
860 if (ResetDecoder())860 if (ResetDecoder())
861 return dsOutOfMemory;861 return dsOutOfMemory;
862 862
863 return dsErrorFree;863 return dsErrorFree;
864 }864 }
865 if (kiSrcLen > 0 && kpSrc != NULL) {865 if (kiSrcLen > 0 && kpSrc != NULL) {
866#ifdef OUTPUT_BITSTREAM866#ifdef OUTPUT_BITSTREAM
867 if (m_pFBS) {867 if (m_pFBS) {
868 WelsFwrite (kpSrc, sizeof (unsigned char), kiSrcLen, m_pFBS);868 WelsFwrite (kpSrc, sizeof (unsigned char), kiSrcLen, m_pFBS);
869 WelsFflush (m_pFBS);869 WelsFflush (m_pFBS);
870 }870 }
871#endif//OUTPUT_BIT_STREAM871#endif//OUTPUT_BIT_STREAM
872 m_pDecContext->bEndOfStreamFlag = false;872 m_pDecContext->bEndOfStreamFlag = false;
873 } else {873 } else {
874 //For application MODE, the error detection should be added for safe.874 //For application MODE, the error detection should be added for safe.
875 //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.875 //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.
876 m_pDecContext->bEndOfStreamFlag = true;876 m_pDecContext->bEndOfStreamFlag = true;
877 m_pDecContext->bInstantDecFlag = true;877 m_pDecContext->bInstantDecFlag = true;
878 }878 }
879 879
880 m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.880 m_pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.
881 m_pDecContext->pParam->eEcActiveIdc = ERROR_CON_DISABLE; //add protection to disable EC here.881 m_pDecContext->pParam->eEcActiveIdc = ERROR_CON_DISABLE; //add protection to disable EC here.
882 m_pDecContext->iFeedbackNalRefIdc = -1; //initialize882 m_pDecContext->iFeedbackNalRefIdc = -1; //initialize
883 if (!m_pDecContext->bFramePending) { //frame complete883 if (!m_pDecContext->bFramePending) { //frame complete
884 m_pDecContext->pParserBsInfo->iNalNum = 0;884 m_pDecContext->pParserBsInfo->iNalNum = 0;
885 memset (m_pDecContext->pParserBsInfo->pNalLenInByte, 0, MAX_NAL_UNITS_IN_LAYER);885 memset (m_pDecContext->pParserBsInfo->pNalLenInByte, 0, MAX_NAL_UNITS_IN_LAYER);
886 }886 }
887 pDstInfo->iNalNum = 0;887 pDstInfo->iNalNum = 0;
888 pDstInfo->iSpsWidthInPixel = pDstInfo->iSpsHeightInPixel = 0;888 pDstInfo->iSpsWidthInPixel = pDstInfo->iSpsHeightInPixel = 0;
889 if (pDstInfo) {889 if (pDstInfo) {
890 m_pDecContext->uiTimeStamp = pDstInfo->uiInBsTimeStamp;890 m_pDecContext->uiTimeStamp = pDstInfo->uiInBsTimeStamp;
891 pDstInfo->uiOutBsTimeStamp = 0;891 pDstInfo->uiOutBsTimeStamp = 0;
892 } else {892 } else {
893 m_pDecContext->uiTimeStamp = 0;893 m_pDecContext->uiTimeStamp = 0;
894 }894 }
895 WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, NULL, NULL, pDstInfo);895 WelsDecodeBs (m_pDecContext, kpSrc, kiSrcLen, NULL, NULL, pDstInfo);
896 if (m_pDecContext->iErrorCode & dsOutOfMemory) {896 if (m_pDecContext->iErrorCode & dsOutOfMemory) {
897 if (ResetDecoder())897 if (ResetDecoder())
898 return dsOutOfMemory;898 return dsOutOfMemory;
899 return dsErrorFree;899 return dsErrorFree;
900 }900 }
901 901
902 if (!m_pDecContext->bFramePending && m_pDecContext->pParserBsInfo->iNalNum) {902 if (!m_pDecContext->bFramePending && m_pDecContext->pParserBsInfo->iNalNum) {
903 memcpy (pDstInfo, m_pDecContext->pParserBsInfo, sizeof (SParserBsInfo));903 memcpy (pDstInfo, m_pDecContext->pParserBsInfo, sizeof (SParserBsInfo));
904 904
905 if (m_pDecContext->iErrorCode == ERR_NONE) { //update statistics: decoding frame count905 if (m_pDecContext->iErrorCode == ERR_NONE) { //update statistics: decoding frame count
906 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;906 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
907 if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t907 if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t
908 ResetDecStatNums (&m_pDecContext->sDecoderStatistics);908 ResetDecStatNums (&m_pDecContext->sDecoderStatistics);
909 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;909 m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
910 }910 }
911 }911 }
912 }912 }
913 913
914 m_pDecContext->bInstantDecFlag = false; //reset no-delay flag914 m_pDecContext->bInstantDecFlag = false; //reset no-delay flag
915 915
916 if (m_pDecContext->iErrorCode && m_pDecContext->bPrintFrameErrorTraceFlag) {916 if (m_pDecContext->iErrorCode && m_pDecContext->bPrintFrameErrorTraceFlag) {
917 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "decode failed, failure type:%d \n", m_pDecContext->iErrorCode);917 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "decode failed, failure type:%d \n", m_pDecContext->iErrorCode);
918 m_pDecContext->bPrintFrameErrorTraceFlag = false;918 m_pDecContext->bPrintFrameErrorTraceFlag = false;
919 }919 }
920 iEnd = WelsTime();920 iEnd = WelsTime();
921 m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;921 m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;
922 922
923 return (DECODING_STATE) m_pDecContext->iErrorCode;923 return (DECODING_STATE) m_pDecContext->iErrorCode;
924}924}
925 925
926DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc,926DECODING_STATE CWelsDecoder::DecodeFrame (const unsigned char* kpSrc,
927 const int kiSrcLen,927 const int kiSrcLen,
928 unsigned char** ppDst,928 unsigned char** ppDst,
929 int* pStride,929 int* pStride,
930 int& iWidth,930 int& iWidth,
931 int& iHeight) {931 int& iHeight) {
932 DECODING_STATE eDecState = dsErrorFree;932 DECODING_STATE eDecState = dsErrorFree;
933 SBufferInfo DstInfo;933 SBufferInfo DstInfo;
934 934
935 memset (&DstInfo, 0, sizeof (SBufferInfo));935 memset (&DstInfo, 0, sizeof (SBufferInfo));
936 DstInfo.UsrData.sSystemBuffer.iStride[0] = pStride[0];936 DstInfo.UsrData.sSystemBuffer.iStride[0] = pStride[0];
937 DstInfo.UsrData.sSystemBuffer.iStride[1] = pStride[1];937 DstInfo.UsrData.sSystemBuffer.iStride[1] = pStride[1];
938 DstInfo.UsrData.sSystemBuffer.iWidth = iWidth;938 DstInfo.UsrData.sSystemBuffer.iWidth = iWidth;
939 DstInfo.UsrData.sSystemBuffer.iHeight = iHeight;939 DstInfo.UsrData.sSystemBuffer.iHeight = iHeight;
940 940
941 eDecState = DecodeFrame2 (kpSrc, kiSrcLen, ppDst, &DstInfo);941 eDecState = DecodeFrame2 (kpSrc, kiSrcLen, ppDst, &DstInfo);
942 if (eDecState == dsErrorFree) {942 if (eDecState == dsErrorFree) {
943 pStride[0] = DstInfo.UsrData.sSystemBuffer.iStride[0];943 pStride[0] = DstInfo.UsrData.sSystemBuffer.iStride[0];
944 pStride[1] = DstInfo.UsrData.sSystemBuffer.iStride[1];944 pStride[1] = DstInfo.UsrData.sSystemBuffer.iStride[1];
945 iWidth = DstInfo.UsrData.sSystemBuffer.iWidth;945 iWidth = DstInfo.UsrData.sSystemBuffer.iWidth;
946 iHeight = DstInfo.UsrData.sSystemBuffer.iHeight;946 iHeight = DstInfo.UsrData.sSystemBuffer.iHeight;
947 }947 }
948 948
949 return eDecState;949 return eDecState;
950}950}
951 951
952DECODING_STATE CWelsDecoder::DecodeFrameEx (const unsigned char* kpSrc,952DECODING_STATE CWelsDecoder::DecodeFrameEx (const unsigned char* kpSrc,
953 const int kiSrcLen,953 const int kiSrcLen,
954 unsigned char* pDst,954 unsigned char* pDst,
955 int iDstStride,955 int iDstStride,
956 int& iDstLen,956 int& iDstLen,
957 int& iWidth,957 int& iWidth,
958 int& iHeight,958 int& iHeight,
959 int& iColorFormat) {959 int& iColorFormat) {
960 DECODING_STATE state = dsErrorFree;960 DECODING_STATE state = dsErrorFree;
961 961
962 return state;962 return state;
963}963}
964 964
965 965
966} // namespace WelsDec966} // namespace WelsDec
967 967
968 968
969using namespace WelsDec;969using namespace WelsDec;
970/*970/*
971* WelsGetDecoderCapability971* WelsGetDecoderCapability
972* @return: DecCapability information972* @return: DecCapability information
973*/973*/
974int WelsGetDecoderCapability (SDecoderCapability* pDecCapability) {974int WelsGetDecoderCapability (SDecoderCapability* pDecCapability) {
975 memset (pDecCapability, 0, sizeof (SDecoderCapability));975 memset (pDecCapability, 0, sizeof (SDecoderCapability));
976 pDecCapability->iProfileIdc = 66; //Baseline976 pDecCapability->iProfileIdc = 66; //Baseline
977 pDecCapability->iProfileIop = 0xE0; //11100000b977 pDecCapability->iProfileIop = 0xE0; //11100000b
978 pDecCapability->iLevelIdc = 32; //level_idc = 3.2978 pDecCapability->iLevelIdc = 32; //level_idc = 3.2
979 pDecCapability->iMaxMbps = 216000; //from level_idc = 3.2979 pDecCapability->iMaxMbps = 216000; //from level_idc = 3.2
980 pDecCapability->iMaxFs = 5120; //from level_idc = 3.2980 pDecCapability->iMaxFs = 5120; //from level_idc = 3.2
981 pDecCapability->iMaxCpb = 20000; //from level_idc = 3.2981 pDecCapability->iMaxCpb = 20000; //from level_idc = 3.2
982 pDecCapability->iMaxDpb = 20480; //from level_idc = 3.2982 pDecCapability->iMaxDpb = 20480; //from level_idc = 3.2
983 pDecCapability->iMaxBr = 20000; //from level_idc = 3.2983 pDecCapability->iMaxBr = 20000; //from level_idc = 3.2
984 pDecCapability->bRedPicCap = 0; //not support redundant pic984 pDecCapability->bRedPicCap = 0; //not support redundant pic
985 985
986 return ERR_NONE;986 return ERR_NONE;
987}987}
988/* WINAPI is indeed in prefix due to sync to application layer callings!! */988/* WINAPI is indeed in prefix due to sync to application layer callings!! */
989 989
990/*990/*
991* WelsCreateDecoder991* WelsCreateDecoder
992* @return: success in return 0, otherwise failed.992* @return: success in return 0, otherwise failed.
993*/993*/
994long WelsCreateDecoder (ISVCDecoder** ppDecoder) {994long WelsCreateDecoder (ISVCDecoder** ppDecoder) {
995 995
996 if (NULL == ppDecoder) {996 if (NULL == ppDecoder) {
997 return ERR_INVALID_PARAMETERS;997 return ERR_INVALID_PARAMETERS;
998 }998 }
999 999
1000 *ppDecoder = new CWelsDecoder();1000 *ppDecoder = new CWelsDecoder();
1001 1001
1002 if (NULL == *ppDecoder) {1002 if (NULL == *ppDecoder) {
1003 return ERR_MALLOC_FAILED;1003 return ERR_MALLOC_FAILED;
1004 }1004 }
1005 1005
1006 return ERR_NONE;1006 return ERR_NONE;
1007}1007}
1008 1008
1009/*1009/*
1010* WelsDestroyDecoder1010* WelsDestroyDecoder
1011*/1011*/
1012void WelsDestroyDecoder (ISVCDecoder* pDecoder) {1012void WelsDestroyDecoder (ISVCDecoder* pDecoder) {
1013 if (NULL != pDecoder) {1013 if (NULL != pDecoder) {
1014 delete (CWelsDecoder*)pDecoder;1014 delete (CWelsDecoder*)pDecoder;
1015 }1015 }
1016}1016}

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