History

modify return value check inside decoder

unknown committed 10 years ago

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

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

Unified · Split

codec/decoder/core/src/decode_slice.cpp+103−103
@@ -70,7 +70,7 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { · 69 unmodified lines
7070 PDeblockingFilterMbFunc pDeblockMb;
7171
7272 if (!pCtx->bAvcBasedFlag && iCurLayerWidth != pCtx->iCurSeqIntervalMaxPicWidth) {
73− return -1;
73+ return ERR_INFO_WIDTH_MISMATCH;
7474 }
7575
7676 iNextMbXyIndex = pSliceHeader->iFirstMbInSlice;
@@ -96,7 +96,7 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { · 19 unmodified lines
9696 "WelsTargetSliceConstruction():::MB(%d, %d) construction error. pCurSlice_type:%d",
9797 pCurLayer->iMbX, pCurLayer->iMbY, pCurSlice->eSliceType);
9898
99− return -1;
99+ return ERR_INFO_MB_RECON_FAIL;
100100 }
101101 }
102102
@@ -112,7 +112,7 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { · 9 unmodified lines
112112 "WelsTargetSliceConstruction():::pCtx->iTotalNumMbRec:%d, iTotalMbTargetLayer:%d",
113113 pCtx->iTotalNumMbRec, iTotalMbTargetLayer);
114114
115− return -1;
115+ return ERR_INFO_MB_NUM_EXCEED_FAIL;
116116 }
117117
118118 if (pSliceHeader->pPps->uiNumSliceGroups > 1) {
@@ -132,22 +132,22 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { · 13 unmodified lines
132132 pCtx->pDec->iHeightInPixel = iCurLayerHeight;
133133
134134 if ((pCurSlice->eSliceType != I_SLICE) && (pCurSlice->eSliceType != P_SLICE))
135− return 0;
135+ return ERR_NONE; //no error but just ignore the type unsupported
136136
137137 if (pCtx->pParam->bParseOnly) //for parse only, deblocking should not go on
138− return 0;
138+ return ERR_NONE;
139139
140140 pDeblockMb = WelsDeblockingMb;
141141
142142 if (1 == pSliceHeader->uiDisableDeblockingFilterIdc
143143 || pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice <= 0) {
144− return 0;//NO_SUPPORTED_FILTER_IDX
144+ return ERR_NONE;//NO_SUPPORTED_FILTER_IDX
145145 } else {
146146 WelsDeblockingFilterSlice (pCtx, pDeblockMb);
147147 }
148148 // any other filter_idc not supported here, 7/22/2010
149149
150− return 0;
150+ return ERR_NONE;
151151 }
152152
153153 int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer,
@@ -191,7 +191,7 @@ int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLa · 37 unmodified lines
191191 }
192192 }
193193
194− return 0;
194+ return ERR_NONE;
195195 }
196196 int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) {
197197 int32_t iMbX = pCurLayer->iMbX;
@@ -210,7 +210,7 @@ int32_t WelsMbInterConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) { · 12 unmodified lines
210210
211211 pCtx->sBlockFunc.pWelsSetNonZeroCountFunc (
212212 pCurLayer->pNzc[pCurLayer->iMbXyIndex]); // set all none-zero nzc to 1; dbk can be opti!
213− return 0;
213+ return ERR_NONE;
214214 }
215215
216216 void WelsLumaDcDequantIdct (int16_t* pBlock, int32_t iQp, PWelsDecoderContext pCtx) {
@@ -265,7 +265,7 @@ int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pC · 48 unmodified lines
265265 WelsLumaDcDequantIdct (pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx);
266266 RecI16x16Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
267267
268− return 0;
268+ return ERR_NONE;
269269 }
270270
271271 if (IS_INTRA8x8 (pCurLayer->pMbType[iMbXy])) {
@@ -275,7 +275,7 @@ int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pC · 3 unmodified lines
275275 if (IS_INTRA4x4 (pCurLayer->pMbType[iMbXy]))
276276 RecI4x4Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
277277
278− return 0;
278+ return ERR_NONE;
279279 }
280280
281281 int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) {
@@ -292,14 +292,14 @@ int32_t WelsMbInterPrediction (PWelsDecoderContext pCtx, PDqLayer pCurLayer) { · 10 unmodified lines
292292
293293 GetInterPred (pDstY, pDstCb, pDstCr, pCtx);
294294
295− return 0;
295+ return ERR_NONE;
296296 }
297297
298298 int32_t WelsTargetMbConstruction (PWelsDecoderContext pCtx) {
299299 PDqLayer pCurLayer = pCtx->pCurDqLayer;
300300 if (MB_TYPE_INTRA_PCM == pCurLayer->pMbType[pCurLayer->iMbXyIndex]) {
301301 //already decoded and reconstructed when parsing
302− return 0;
302+ return ERR_NONE;
303303 } else if (IS_INTRA (pCurLayer->pMbType[pCurLayer->iMbXyIndex])) {
304304 WelsMbIntraPredictionConstruction (pCtx, pCurLayer, 1);
305305 } else if (IS_INTER (pCurLayer->pMbType[pCurLayer->iMbXyIndex])) { //InterMB
@@ -311,10 +311,10 @@ int32_t WelsTargetMbConstruction (PWelsDecoderContext pCtx) { · 5 unmodified lines
311311 } else {
312312 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "WelsTargetMbConstruction():::::Unknown MB type: %d",
313313 pCurLayer->pMbType[pCurLayer->iMbXyIndex]);
314− return -1;
314+ return ERR_INFO_MB_RECON_FAIL;
315315 }
316316
317− return 0;
317+ return ERR_NONE;
318318 }
319319
320320 void WelsChromaDcIdct (int16_t* pBlock) {
@@ -445,7 +445,7 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 124 unmodified lines
445445
446446 iFinalMode = CheckIntraNxNPredMode (&iSampleAvail[0], &iBestMode, i, false);
447447 if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) {
448− return ERR_INFO_INVALID_I4x4_PRED_MODE;
448+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I4x4_PRED_MODE);
449449 }
450450
451451 pCurDqLayer->pIntra4x4FinalMode[iMbXy][g_kuiScan4[i]] = iFinalMode;
@@ -465,20 +465,20 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 13 unmodified lines
465465 if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
466466 WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
467467 if (iCode > MAX_PRED_MODE_ID_CHROMA) {
468− return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
468+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
469469 }
470470 pCurDqLayer->pChromaPredMode[iMbXy] = iCode;
471471 } else {
472472 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //intra_chroma_pred_mode
473473 if (uiCode > MAX_PRED_MODE_ID_CHROMA) {
474− return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
474+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
475475 }
476476 pCurDqLayer->pChromaPredMode[iMbXy] = uiCode;
477477 }
478478
479479 if (-1 == pCurDqLayer->pChromaPredMode[iMbXy]
480480 || CheckIntraChromaPredMode (uiNeighAvail, &pCurDqLayer->pChromaPredMode[iMbXy])) {
481− return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
481+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
482482 }
483483 return ERR_NONE;
484484 }
@@ -529,7 +529,7 @@ int32_t ParseIntra8x8Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 44 unmodified lines
529529 iFinalMode = CheckIntraNxNPredMode (&iSampleAvail[0], &iBestMode, i << 2, true);
530530
531531 if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) {
532− return ERR_INFO_INVALID_I4x4_PRED_MODE;
532+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I4x4_PRED_MODE);
533533 }
534534
535535 for (int j = 0; j < 4; j++) {
@@ -545,20 +545,20 @@ int32_t ParseIntra8x8Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 9 unmodified lines
545545 if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
546546 WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
547547 if (iCode > MAX_PRED_MODE_ID_CHROMA) {
548− return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
548+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
549549 }
550550 pCurDqLayer->pChromaPredMode[iMbXy] = iCode;
551551 } else {
552552 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //intra_chroma_pred_mode
553553 if (uiCode > MAX_PRED_MODE_ID_CHROMA) {
554− return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
554+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
555555 }
556556 pCurDqLayer->pChromaPredMode[iMbXy] = uiCode;
557557 }
558558
559559 if (-1 == pCurDqLayer->pChromaPredMode[iMbXy]
560560 || CheckIntraChromaPredMode (uiNeighAvail, &pCurDqLayer->pChromaPredMode[iMbXy])) {
561− return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
561+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
562562 }
563563
564564 return ERR_NONE;
@@ -574,7 +574,7 @@ int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAva · 9 unmodified lines
574574
575575 if (CheckIntra16x16PredMode (uiNeighAvail,
576576 &pCurDqLayer->pIntraPredMode[iMbXy][7])) { //invalid iPredMode, must stop decoding
577− return ERR_INFO_INVALID_I16x16_PRED_MODE;
577+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I16x16_PRED_MODE);
578578 }
579579 if (pCtx->pSps->uiChromaFormatIdc == 0)
580580 return ERR_NONE;
@@ -582,19 +582,19 @@ int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAva · 1 unmodified line
582582 if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
583583 WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
584584 if (iCode > MAX_PRED_MODE_ID_CHROMA) {
585− return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
585+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
586586 }
587587 pCurDqLayer->pChromaPredMode[iMbXy] = iCode;
588588 } else {
589589 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //intra_chroma_pred_mode
590590 if (uiCode > MAX_PRED_MODE_ID_CHROMA) {
591− return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
591+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
592592 }
593593 pCurDqLayer->pChromaPredMode[iMbXy] = uiCode;
594594 }
595595 if (-1 == pCurDqLayer->pChromaPredMode[iMbXy]
596596 || CheckIntraChromaPredMode (uiNeighAvail, &pCurDqLayer->pChromaPredMode[iMbXy])) {
597− return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
597+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_I_CHROMA_PRED_MODE);
598598 }
599599
600600 return ERR_NONE;
@@ -622,10 +622,10 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 21 unmodified lines
622622 GetNeighborAvailMbType (&sNeighAvail, pCurLayer);
623623 WELS_READ_VERIFY (ParseMBTypeISliceCabac (pCtx, &sNeighAvail, uiMbType));
624624 if (uiMbType > 25) {
625− return ERR_INFO_INVALID_MB_TYPE;
625+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE);
626626 } else if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17
627627 && uiMbType <= 24))) {
628− return ERR_INFO_INVALID_MB_TYPE;
628+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE);
629629 } else if (25 == uiMbType) { //I_PCM
630630 WELS_READ_VERIFY (ParseIPCMInfoCabac (pCtx));
631631 pSlice->iLastDeltaQp = 0;
@@ -688,7 +688,7 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 56 unmodified lines
688688 int32_t iQpDelta, iId8x8, iId4x4;
689689 WELS_READ_VERIFY (ParseDeltaQpCabac (pCtx, iQpDelta));
690690 if (iQpDelta > 25 || iQpDelta < -26) {//out of iQpDelta range
691− return ERR_INFO_INVALID_QP;
691+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
692692 }
693693 pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
694694 pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
@@ -841,9 +841,9 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 146 unmodified lines
841841 } else { //Intra mode
842842 uiMbType -= 5;
843843 if (uiMbType > 25)
844− return ERR_INFO_INVALID_MB_TYPE;
844+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE);
845845 if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17 && uiMbType <= 24)))
846− return ERR_INFO_INVALID_MB_TYPE;
846+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE);
847847
848848 if (25 == uiMbType) { //I_PCM
849849 WELS_READ_VERIFY (ParseIPCMInfoCabac (pCtx));
@@ -922,7 +922,7 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 72 unmodified lines
922922
923923 WELS_READ_VERIFY (ParseDeltaQpCabac (pCtx, iQpDelta));
924924 if (iQpDelta > 25 || iQpDelta < -26) { //out of iQpDelta range
925− return ERR_INFO_INVALID_QP;
925+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
926926 }
927927 pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
928928 pSlice->iLastMbQp = pCurLayer->pLumaQp[iMbXy];
@@ -1276,6 +1276,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 347 unmodified lines
12761276 const int32_t iMbXy = pCurLayer->iMbXyIndex;
12771277 int8_t* pNzc = pCurLayer->pNzc[iMbXy];
12781278 int32_t i;
1279+ int32_t iRet = ERR_NONE;
12791280 uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
12801281 uint32_t uiCode;
12811282 int32_t iCode;
@@ -1291,9 +1292,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 9 unmodified lines
12911292 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType
12921293 uiMbType = uiCode;
12931294 if (uiMbType > 25)
1294− return ERR_INFO_INVALID_MB_TYPE;
1295+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE);
12951296 if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17 && uiMbType <= 24)))
1296− return ERR_INFO_INVALID_MB_TYPE;
1297+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE);
12971298
12981299 if (25 == uiMbType) {
12991300 int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0];
@@ -1345,7 +1346,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 45 unmodified lines
13451346 memset (pCurLayer->pChromaQp[iMbXy], 0, sizeof (pCurLayer->pChromaQp[iMbXy]));
13461347 memset (pNzc, 16, sizeof (pCurLayer->pNzc[iMbXy])); //Rec. 9.2.1 for PCM, nzc=16
13471348 WELS_READ_VERIFY (InitReadBits (pBs, 0));
1348− return 0;
1349+ return ERR_NONE;
13491350 } else if (0 == uiMbType) { //reference to JM
13501351 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
13511352 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
@@ -1369,9 +1370,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 17 unmodified lines
13691370 uiCbp = uiCode;
13701371 //G.9.1 Alternative parsing process for coded pBlock pattern
13711372 if (pCtx->pSps->uiChromaFormatIdc && (uiCbp > 47))
1372− return ERR_INFO_INVALID_CBP;
1373+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP);
13731374 if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
1374− return ERR_INFO_INVALID_CBP;
1375+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP);
13751376
13761377 if (pCtx->pSps->uiChromaFormatIdc)
13771378 uiCbp = g_kuiIntra4x4CbpTable[uiCbp];
@@ -1416,7 +1417,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 38 unmodified lines
14161417 iQpDelta = iCode;
14171418
14181419 if (iQpDelta > 25 || iQpDelta < -26) { //out of iQpDelta range
1419− return ERR_INFO_INVALID_QP;
1420+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
14201421 }
14211422
14221423 pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
@@ -1432,17 +1433,17 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 9 unmodified lines
14321433
14331434 if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
14341435 //step1: Luma DC
1435− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 0, 16,
1436− g_kuiLumaDcZigzagScan, I16_LUMA_DC, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)) {
1437− return -1;//abnormal
1436+ if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 0, 16, g_kuiLumaDcZigzagScan, I16_LUMA_DC,
1437+ pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
1438+ return iRet;//abnormal
14381439 }
14391440 //step2: Luma AC
14401441 if (uiCbpL) {
14411442 for (i = 0; i < 16; i++) {
1442− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, i,
1443− iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
1444− I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
1445− return -1;//abnormal
1443+ if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1,
1444+ g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4),
1445+ pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
1446+ return iRet;//abnormal
14461447 }
14471448 }
14481449 ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1]));
@@ -1457,10 +1458,10 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 8 unmodified lines
14571458 if (uiCbpL & (1 << iId8x8)) {
14581459 int32_t iIndex = (iId8x8 << 2);
14591460 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1460− if (WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex,
1461− iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty,
1462− pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, pCurLayer->pLumaQp[iMbXy], pCtx)) {
1463− return -1;
1461+ if ((iRet = WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1,
1462+ g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4,
1463+ pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
1464+ return iRet;
14641465 }
14651466 iIndex++;
14661467 }
@@ -1479,10 +1480,10 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 12 unmodified lines
14791480 int32_t iIndex = (iId8x8 << 2);
14801481 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
14811482 //Luma (DC and AC decoding together)
1482− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
1483− iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart,
1484− LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
1485− return -1;//abnormal
1483+ if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1,
1484+ g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
1485+ pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
1486+ return iRet;//abnormal
14861487 }
14871488 iIndex++;
14881489 }
@@ -1503,10 +1504,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 14 unmodified lines
15031504 if (1 == uiCbpC || 2 == uiCbpC) {
15041505 for (i = 0; i < 2; i++) { //Cb Cr
15051506 iMbResProperty = i ? CHROMA_DC_V : CHROMA_DC_U;
1506− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs,
1507− 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6),
1508− pCurLayer->pChromaQp[iMbXy][i], pCtx)) {
1509− return -1;//abnormal
1507+ if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty,
1508+ pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
1509+ return iRet;//abnormal
15101510 }
15111511 }
15121512 }
@@ -1517,10 +1517,10 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 4 unmodified lines
15171517 iMbResProperty = i ? CHROMA_AC_V : CHROMA_AC_U;
15181518 int32_t iIndex = 16 + (i << 2);
15191519 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1520− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
1521− iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
1522− iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx)) {
1523− return -1;//abnormal
1520+ if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - WELS_MAX (iScanIdxStart,
1521+ 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
1522+ pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
1523+ return iRet;//abnormal
15241524 }
15251525 iIndex++;
15261526 }
@@ -1533,7 +1533,7 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 6 unmodified lines
15331533 BsEndCavlc (pBs);
15341534 }
15351535
1536− return 0;
1536+ return ERR_NONE;
15371537 }
15381538
15391539 int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
@@ -1572,9 +1572,9 @@ int32_t WelsDecodeMbCavlcISlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 32 unmodified lines
15721572 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
15731573 "WelsDecodeMbCavlcISlice()::::pBs incomplete, iUsedBits:%" PRId64 " > pBs->iBits:%d, MUST stop decoding.",
15741574 (int64_t) iUsedBits, pBs->iBits);
1575− return -1;
1575+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_BS_INCOMPLETE);
15761576 }
1577− return 0;
1577+ return ERR_NONE;
15781578 }
15791579
15801580 int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) {
@@ -1593,6 +1593,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 12 unmodified lines
15931593 const int32_t iMbXy = pCurLayer->iMbXyIndex;
15941594 int8_t* pNzc = pCurLayer->pNzc[iMbXy];
15951595 int32_t i;
1596+ int32_t iRet = ERR_NONE;
15961597 uint32_t uiMbType = 0, uiCbp = 0, uiCbpL = 0, uiCbpC = 0;
15971598 uint32_t uiCode;
15981599 int32_t iCode;
@@ -1609,8 +1610,8 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 10 unmodified lines
16091610 pCurLayer->pMbType[iMbXy] = g_ksInterMbTypeInfo[uiMbType].iType;
16101611 WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer);
16111612
1612− if (ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) {
1613− return -1;//abnormal
1613+ if ((iRet = ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) != ERR_NONE) {
1614+ return iRet;//abnormal
16141615 }
16151616
16161617 if (pSlice->sSliceHeaderExt.bAdaptiveResidualPredFlag == 1) {
@@ -1624,14 +1625,14 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 7 unmodified lines
16241625 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
16251626 } else {
16261627 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "residual_pred_flag = 1 not supported.");
1627− return -1;
1628+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP);
16281629 }
16291630 } else { //intra MB type
16301631 uiMbType -= 5;
16311632 if (uiMbType > 25)
1632− return ERR_INFO_INVALID_MB_TYPE;
1633+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE);
16331634 if (!pCtx->pSps->uiChromaFormatIdc && ((uiMbType >= 5 && uiMbType <= 12) || (uiMbType >= 17 && uiMbType <= 24)))
1634− return ERR_INFO_INVALID_MB_TYPE;
1635+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_TYPE);
16351636
16361637 if (25 == uiMbType) {
16371638 int32_t iDecStrideL = pCurLayer->pDec->iLinesize[0];
@@ -1689,7 +1690,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 51 unmodified lines
16891690 ST32A4 (&pNzc[16], 0x10101010);
16901691 ST32A4 (&pNzc[20], 0x10101010);
16911692 WELS_READ_VERIFY (InitReadBits (pBs, 0));
1692− return 0;
1693+ return ERR_NONE;
16931694 } else {
16941695 if (0 == uiMbType) {
16951696 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
@@ -1717,8 +1718,8 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 21 unmodified lines
17171718 uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
17181719 uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
17191720 WelsFillCacheNonZeroCount (&sNeighAvail, pNonZeroCount, pCurLayer);
1720− if (ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer)) {
1721− return -1;
1721+ if ((iRet = ParseIntra16x16Mode (pCtx, &sNeighAvail, pBs, pCurLayer)) != ERR_NONE) {
1722+ return iRet;
17221723 }
17231724 }
17241725 }
@@ -1729,9 +1730,9 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 4 unmodified lines
17291730 uiCbp = uiCode;
17301731 {
17311732 if (pCtx->pSps->uiChromaFormatIdc && (uiCbp > 47))
1732− return ERR_INFO_INVALID_CBP;
1733+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP);
17331734 if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
1734− return ERR_INFO_INVALID_CBP;
1735+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_CBP);
17351736 if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurLayer->pMbType[iMbXy]) {
17361737
17371738 uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp];
@@ -1779,7 +1780,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 41 unmodified lines
17791780 iQpDelta = iCode;
17801781
17811782 if (iQpDelta > 25 || iQpDelta < -26) { //out of iQpDelta range
1782− return ERR_INFO_INVALID_QP;
1783+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_QP);
17831784 }
17841785
17851786 pCurLayer->pLumaQp[iMbXy] = (pSlice->iLastMbQp + iQpDelta + 52) % 52; //update last_mb_qp
@@ -1794,17 +1795,17 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 8 unmodified lines
17941795
17951796 if (MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
17961797 //step1: Luma DC
1797− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 0, 16, g_kuiLumaDcZigzagScan,
1798− I16_LUMA_DC, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)) {
1799− return -1;//abnormal
1798+ if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 0, 16, g_kuiLumaDcZigzagScan, I16_LUMA_DC,
1799+ pCurLayer->pScaledTCoeff[iMbXy], pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
1800+ return iRet;//abnormal
18001801 }
18011802 //step2: Luma AC
18021803 if (uiCbpL) {
18031804 for (i = 0; i < 16; i++) {
1804− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, i,
1805− iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
1806− I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
1807− return -1;//abnormal
1805+ if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, i, iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1,
1806+ g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), I16_LUMA_AC, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4),
1807+ pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
1808+ return iRet;//abnormal
18081809 }
18091810 }
18101811 ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1]));
@@ -1819,10 +1820,10 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 8 unmodified lines
18191820 if (uiCbpL & (1 << iId8x8)) {
18201821 int32_t iIndex = (iId8x8 << 2);
18211822 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1822− if (WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex,
1823− iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty,
1824− pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, pCurLayer->pLumaQp[iMbXy], pCtx)) {
1825− return -1;
1823+ if ((iRet = WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1,
1824+ g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4,
1825+ pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
1826+ return iRet;
18261827 }
18271828 iIndex++;
18281829 }
@@ -1842,10 +1843,10 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 13 unmodified lines
18421843 int32_t iIndex = (iId8x8 << 2);
18431844 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
18441845 //Luma (DC and AC decoding together)
1845− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
1846− iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, iMbResProperty,
1847− pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
1848− return -1;//abnormal
1846+ if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - iScanIdxStart + 1,
1847+ g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
1848+ pCurLayer->pLumaQp[iMbXy], pCtx)) != ERR_NONE) {
1849+ return iRet;//abnormal
18491850 }
18501851 iIndex++;
18511852 }
@@ -1871,10 +1872,9 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 19 unmodified lines
18711872 else
18721873 iMbResProperty = i ? CHROMA_DC_V_INTER : CHROMA_DC_U_INTER;
18731874
1874− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs,
1875− 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6),
1876− pCurLayer->pChromaQp[iMbXy][i], pCtx)) {
1877− return -1;//abnormal
1875+ if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, 16 + (i << 2), 4, g_kuiChromaDcScan, iMbResProperty,
1876+ pCurLayer->pScaledTCoeff[iMbXy] + 256 + (i << 6), pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
1877+ return iRet;//abnormal
18781878 }
18791879 }
18801880 } else {
@@ -1889,10 +1889,10 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 8 unmodified lines
18891889
18901890 int32_t iIndex = 16 + (i << 2);
18911891 for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1892− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
1893− iScanIdxEnd - WELS_MAX (iScanIdxStart, 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1),
1894− iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pChromaQp[iMbXy][i], pCtx)) {
1895− return -1;//abnormal
1892+ if ((iRet = WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, iScanIdxEnd - WELS_MAX (iScanIdxStart,
1893+ 1) + 1, g_kuiZigzagScan + WELS_MAX (iScanIdxStart, 1), iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4),
1894+ pCurLayer->pChromaQp[iMbXy][i], pCtx)) != ERR_NONE) {
1895+ return iRet;//abnormal
18961896 }
18971897 iIndex++;
18981898 }
@@ -1905,7 +1905,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 6 unmodified lines
19051905 BsEndCavlc (pBs);
19061906 }
19071907
1908− return 0;
1908+ return ERR_NONE;
19091909 }
19101910
19111911 int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uint32_t& uiEosFlag) {
@@ -1928,7 +1928,7 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 16 unmodified lines
19281928 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run
19291929 pSlice->iMbSkipRun = uiCode;
19301930 if (-1 == pSlice->iMbSkipRun) {
1931− return -1;
1931+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_INVALID_MB_SKIP_RUN);
19321932 }
19331933 }
19341934 if (pSlice->iMbSkipRun--) {
@@ -1995,9 +1995,9 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 60 unmodified lines
19951995 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
19961996 "WelsDecodeMbCavlcISlice()::::pBs incomplete, iUsedBits:%" PRId64 " > pBs->iBits:%d, MUST stop decoding.",
19971997 (int64_t) iUsedBits, pBs->iBits);
1998− return -1;
1998+ return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_BS_INCOMPLETE);
19991999 }
2000− return 0;
2000+ return ERR_NONE;
20012001 }
20022002
20032003 void WelsBlockFuncInit (SBlockFunc* pFunc, int32_t iCpu) {

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