History

make the decoder compile and run with treason

Sigrid Solveig Haflínudóttir committed 5 years ago

Commit 37423d41 parent be8e62f71 files · +961 −1217Browse files

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

Unified · Split

codec/decoder/core/src/decoder.cpp+53−65
@@ -54,8 +54,6 @@ · 53 unmodified lines
5454 #include "memory_align.h"
5555 #include "wels_decoder_thread.h"
5656
57−namespace WelsDec {
58−
5957 extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight);
6058
6159 extern void FreePicture (PPicture pPic, CMemoryAlign* pMa);
@@ -64,7 +62,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 2 unmodified lines
6462 const int32_t kiPicWidth, const int32_t kiPicHeight) {
6563
6664 PPicBuff pPicBuf = NULL;
67− int32_t iPicIdx = 0;
65+ int32_t iPicIdx;
6866 if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
6967 return ERR_INFO_INVALID_PARAM;
7068 }
@@ -108,7 +106,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 37 unmodified lines
108106 const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) {
109107 PPicBuff pPicOldBuf = *ppPicBuf;
110108 PPicBuff pPicNewBuf = NULL;
111− int32_t iPicIdx = 0;
109+ int32_t iPicIdx;
112110 if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
113111 return ERR_INFO_INVALID_PARAM;
114112 }
@@ -162,7 +160,6 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 47 unmodified lines
162160 pPicOldBuf->iCapacity = 0;
163161 pPicOldBuf->iCurrentIdx = 0;
164162 pMa->WelsFree (pPicOldBuf, "pPicOldBuf");
165− pPicOldBuf = NULL;
166163 return ERR_NONE;
167164 }
168165
@@ -170,7 +167,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 1 unmodified line
170167 const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) {
171168 PPicBuff pPicOldBuf = *ppPicBuf;
172169 PPicBuff pPicNewBuf = NULL;
173− int32_t iPicIdx = 0;
170+ int32_t iPicIdx;
174171 if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
175172 return ERR_INFO_INVALID_PARAM;
176173 }
@@ -193,7 +190,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 16 unmodified lines
193190
194191 ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false);
195192
196− int32_t iPrevPicIdx = -1;
193+ int32_t iPrevPicIdx;
197194 for (iPrevPicIdx = 0; iPrevPicIdx < kiOldSize; ++iPrevPicIdx) {
198195 if (pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) {
199196 break;
@@ -250,13 +247,12 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 50 unmodified lines
250247 pPicOldBuf->iCapacity = 0;
251248 pPicOldBuf->iCurrentIdx = 0;
252249 pMa->WelsFree (pPicOldBuf, "pPicOldBuf");
253− pPicOldBuf = NULL;
254250
255251 return ERR_NONE;
256252 }
257253
258254 void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* pMa) {
259− PPicBuff pPicBuf = NULL;
255+ PPicBuff pPicBuf;
260256
261257 ResetReorderingPictureBuffers (pCtx->pPictReoderingStatus, pCtx->pPictInfoList, false);
262258
@@ -271,7 +267,6 @@ void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* · 8 unmodified lines
271267 if (pPic != NULL) {
272268 FreePicture (pPic, pMa);
273269 }
274− pPic = NULL;
275270 ++ iPicIdx;
276271 }
277272
@@ -284,15 +279,14 @@ void DestroyPicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, CMemoryAlign* · 6 unmodified lines
284279
285280 pMa->WelsFree (pPicBuf, "pPicBuf");
286281
287− pPicBuf = NULL;
288282 *ppPicBuf = NULL;
289283 }
290284
291285 //reset picture reodering buffer list
292286 void ResetReorderingPictureBuffers (PPictReoderingStatus pPictReoderingStatus, PPictInfo pPictInfo,
293− const bool& fullReset) {
287+ const bool *fullReset) {
294288 if (pPictReoderingStatus != NULL && pPictInfo != NULL) {
295− int32_t pictInfoListCount = fullReset ? 16 : (pPictReoderingStatus->iLargestBufferedPicIndex + 1);
289+ int32_t pictInfoListCount = *fullReset ? 16 : (pPictReoderingStatus->iLargestBufferedPicIndex + 1);
296290 pPictReoderingStatus->iPictInfoIndex = 0;
297291 pPictReoderingStatus->iMinPOC = IMinInt32;
298292 pPictReoderingStatus->iNumOfPicts = 0;
@@ -367,33 +361,33 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 68 unmodified lines
367361 /*
368362 * fill data fields in SPS and PPS default for decoder context
369363 */
370−void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX& sSpsPpsCtx) {
371− sSpsPpsCtx.bSpsExistAheadFlag = false;
372− sSpsPpsCtx.bSubspsExistAheadFlag = false;
373− sSpsPpsCtx.bPpsExistAheadFlag = false;
374− sSpsPpsCtx.bAvcBasedFlag = true;
375− sSpsPpsCtx.iSpsErrorIgnored = 0;
376− sSpsPpsCtx.iSubSpsErrorIgnored = 0;
377− sSpsPpsCtx.iPpsErrorIgnored = 0;
378− sSpsPpsCtx.iPPSInvalidNum = 0;
379− sSpsPpsCtx.iPPSLastInvalidId = -1;
380− sSpsPpsCtx.iSPSInvalidNum = 0;
381− sSpsPpsCtx.iSPSLastInvalidId = -1;
382− sSpsPpsCtx.iSubSPSInvalidNum = 0;
383− sSpsPpsCtx.iSubSPSLastInvalidId = -1;
384− sSpsPpsCtx.iSeqId = -1;
364+void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX *sSpsPpsCtx) {
365+ sSpsPpsCtx->bSpsExistAheadFlag = false;
366+ sSpsPpsCtx->bSubspsExistAheadFlag = false;
367+ sSpsPpsCtx->bPpsExistAheadFlag = false;
368+ sSpsPpsCtx->bAvcBasedFlag = true;
369+ sSpsPpsCtx->iSpsErrorIgnored = 0;
370+ sSpsPpsCtx->iSubSpsErrorIgnored = 0;
371+ sSpsPpsCtx->iPpsErrorIgnored = 0;
372+ sSpsPpsCtx->iPPSInvalidNum = 0;
373+ sSpsPpsCtx->iPPSLastInvalidId = -1;
374+ sSpsPpsCtx->iSPSInvalidNum = 0;
375+ sSpsPpsCtx->iSPSLastInvalidId = -1;
376+ sSpsPpsCtx->iSubSPSInvalidNum = 0;
377+ sSpsPpsCtx->iSubSPSLastInvalidId = -1;
378+ sSpsPpsCtx->iSeqId = -1;
385379 }
386380
387381 /*
388382 * fill last decoded picture info
389383 */
390−void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo) {
391− sLastDecPicInfo.iPrevPicOrderCntMsb = 0;
392− sLastDecPicInfo.iPrevPicOrderCntLsb = 0;
393− sLastDecPicInfo.pPreviousDecodedPictureInDpb = NULL;
394− sLastDecPicInfo.iPrevFrameNum = -1;
395− sLastDecPicInfo.bLastHasMmco5 = false;
396− sLastDecPicInfo.uiDecodingTimeStamp = 0;
384+void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo *sLastDecPicInfo) {
385+ sLastDecPicInfo->iPrevPicOrderCntMsb = 0;
386+ sLastDecPicInfo->iPrevPicOrderCntLsb = 0;
387+ sLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL;
388+ sLastDecPicInfo->iPrevFrameNum = -1;
389+ sLastDecPicInfo->bLastHasMmco5 = false;
390+ sLastDecPicInfo->uiDecodingTimeStamp = 0;
397391 }
398392
399393 /*!
@@ -432,7 +426,7 @@ void CopySpsPps (PWelsDecoderContext pFromCtx, PWelsDecoderContext pToCtx) { · 32 unmodified lines
432426 * get size of reference picture list in target layer incoming, = (iNumRefFrames
433427 */
434428 static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) {
435− int32_t iNumRefFrames = 0;
429+ int32_t iNumRefFrames;
436430 // +2 for EC MV Copy buffer exchange
437431 if ((pCtx == NULL) || (pCtx->pSps == NULL)) {
438432 iNumRefFrames = MAX_REF_PIC_COUNT + 2;
@@ -458,13 +452,13 @@ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { · 19 unmodified lines
458452 * request memory blocks for decoder avc part
459453 */
460454 int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight,
461− bool& bReallocFlag) {
455+ bool *bReallocFlag) {
462456 const int32_t kiPicWidth = kiMbWidth << 4;
463457 const int32_t kiPicHeight = kiMbHeight << 4;
464− int32_t iErr = ERR_NONE;
458+ int32_t iErr;
465459
466− int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
467− bReallocFlag = false;
460+ int32_t iPicQueueSize; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
461+ *bReallocFlag = false;
468462 bool bNeedChangePicQueue = true;
469463 CMemoryAlign* pMa = pCtx->pMemAlign;
470464
@@ -537,7 +531,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 66 unmodified lines
537531 pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) pMa->WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine");
538532 WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine))
539533
540− bReallocFlag = true; // memory re-allocation successfully finished
534+ *bReallocFlag = true; // memory re-allocation successfully finished
541535 return ERR_NONE;
542536 }
543537
@@ -594,7 +588,7 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 50 unmodified lines
594588 * \brief Open decoder
595589 */
596590 int32_t WelsOpenDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
597− int iRet = ERR_NONE;
591+ int iRet;
598592 // function pointers
599593 InitDecFuncs (pCtx, pCtx->uiCpuFlag);
600594
@@ -735,21 +729,22 @@ void GetVclNalTemporalId (PWelsDecoderContext pCtx) { · 134 unmodified lines
735729 */
736730 int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const int32_t kiBsLen,
737731 uint8_t** ppDst, SBufferInfo* pDstBufInfo, SParserBsInfo* pDstBsInfo) {
732+ USED(pDstBsInfo);
738733 if (!pCtx->bEndOfStreamFlag) {
739734 SDataBuffer* pRawData = &pCtx->sRawData;
740− SDataBuffer* pSavedData = NULL;
735+ SDataBuffer* pSavedData;
741736
742737 int32_t iSrcIdx = 0; //the index of source bit-stream till now after parsing one or more NALs
743738 int32_t iSrcConsumed = 0; // consumed bit count of source bs
744739 int32_t iDstIdx = 0; //the size of current NAL after 0x03 removal and 00 00 01 removal
745− int32_t iSrcLength = 0; //the total size of current AU or NAL
740+ int32_t iSrcLength; //the total size of current AU or NAL
746741 int32_t iRet = 0;
747742 int32_t iConsumedBytes = 0;
748743 int32_t iOffset = 0;
749744
750− uint8_t* pSrcNal = NULL;
751− uint8_t* pDstNal = NULL;
752− uint8_t* pNalPayload = NULL;
745+ uint8_t* pSrcNal;
746+ uint8_t* pDstNal;
747+ uint8_t* pNalPayload;
753748
754749
755750 if (NULL == DetectStartCodePrefix (kpBsBuf, &iOffset,
@@ -758,7 +753,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 2 unmodified lines
758753 return dsBitstreamError;
759754 }
760755
761− pSrcNal = const_cast<uint8_t*> (kpBsBuf) + iOffset;
756+ pSrcNal = (uint8_t*) (kpBsBuf) + iOffset;
762757 iSrcLength = kiBsLen - iOffset;
763758
764759 if ((kiBsLen + 4) > (pRawData->pEnd - pRawData->pCurPos)) {
@@ -834,7 +829,6 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 69 unmodified lines
834829 }
835830 }
836831 if (iRet) {
837− iRet = 0;
838832 if (dsNoParamSets & pCtx->iErrorCode) {
839833 #ifdef LONG_TERM_REF
840834 pCtx->bParamSetsLostFlag = true;
@@ -896,7 +890,6 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 55 unmodified lines
896890 return pCtx->iErrorCode;
897891 }
898892 if (iRet) {
899− iRet = 0;
900893 if (dsNoParamSets & pCtx->iErrorCode) {
901894 #ifdef LONG_TERM_REF
902895 pCtx->bParamSetsLostFlag = true;
@@ -942,7 +935,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 39 unmodified lines
942935 * \return 0 - successful; none 0 - something wrong
943936 */
944937 int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) {
945− int32_t iErr = ERR_NONE;
938+ int32_t iErr;
946939 const int32_t kiPicWidth = kiMbWidth << 4;
947940 const int32_t kiPicHeight = kiMbHeight << 4;
948941 //fix Bugzilla Bug1479656 reallocate temp dec picture
@@ -952,7 +945,7 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 3 unmodified lines
952945 pCtx->pTempDec = AllocPicture (pCtx, pCtx->pSps->iMbWidth << 4, pCtx->pSps->iMbHeight << 4);
953946 }
954947 bool bReallocFlag = false;
955− iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight, bReallocFlag); // common memory used
948+ iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight, &bReallocFlag); // common memory used
956949 if (ERR_NONE != iErr) {
957950 WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
958951 "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure.");
@@ -969,7 +962,7 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 10 unmodified lines
969962 #if defined(MEMORY_MONITOR)
970963 if (bReallocFlag) {
971964 WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes",
972− static_cast<unsigned long long> (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage()));
965+ (unsigned long long) (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage()));
973966 }
974967 #endif//MEMORY_MONITOR
975968 return iErr;
@@ -983,23 +976,21 @@ void InitDecFuncs (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 7 unmodified lines
983976 DeblockingInit (&pCtx->sDeblockingFunc, uiCpuFlag);
984977 }
985978
986−namespace {
987979
988−template<void pfIdctResAddPred (uint8_t* pPred, int32_t iStride, int16_t* pRs)>
980+
989981 void IdctFourResAddPred_ (uint8_t* pPred, int32_t iStride, int16_t* pRs, const int8_t* pNzc) {
990982 if (pNzc[0] || pRs[0 * 16])
991− pfIdctResAddPred (pPred + 0 * iStride + 0, iStride, pRs + 0 * 16);
983+ IdctResAddPred_c (pPred + 0 * iStride + 0, iStride, pRs + 0 * 16);
992984 if (pNzc[1] || pRs[1 * 16])
993− pfIdctResAddPred (pPred + 0 * iStride + 4, iStride, pRs + 1 * 16);
985+ IdctResAddPred_c (pPred + 0 * iStride + 4, iStride, pRs + 1 * 16);
994986 if (pNzc[4] || pRs[2 * 16])
995− pfIdctResAddPred (pPred + 4 * iStride + 0, iStride, pRs + 2 * 16);
987+ IdctResAddPred_c (pPred + 4 * iStride + 0, iStride, pRs + 2 * 16);
996988 if (pNzc[5] || pRs[3 * 16])
997− pfIdctResAddPred (pPred + 4 * iStride + 4, iStride, pRs + 3 * 16);
989+ IdctResAddPred_c (pPred + 4 * iStride + 4, iStride, pRs + 3 * 16);
998990 }
999991
1000−} // anon ns
1001−
1002992 void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) {
993+ USED(uiCpuFlag);
1003994 pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c;
1004995 pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c;
1005996 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c;
@@ -1047,7 +1038,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 41 unmodified lines
10471038 pCtx->pGetIChromaPredFunc[C_PRED_DC_128] = WelsIChromaPredDcNA_c;
10481039
10491040 pCtx->pIdctResAddPredFunc = IdctResAddPred_c;
1050− pCtx->pIdctFourResAddPredFunc = IdctFourResAddPred_<IdctResAddPred_c>;
1041+ pCtx->pIdctFourResAddPredFunc = (void*)IdctResAddPred_c;
10511042
10521043 pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c;
10531044
@@ -1243,6 +1234,3 @@ void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput) { · 189 unmodified lines
12431234 else if (kbOutput)
12441235 UpdateDecStatNoFreezingInfo (pCtx);
12451236 }
1246−
1247−
1248−} // namespace WelsDec

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