History

Squashed merge from writenal_refactor2

sijchen committed 12 years ago

Commit e45e8591 parent a921bc616 files · +431 −263Browse files

Showing the changes to codec/encoder/core/src/svc_encode_slice.cpp (1 of 16 files). Show all

Unified · Split

codec/encoder/core/src/svc_encode_slice.cpp+45−21
@@ -50,7 +50,7 @@ · 49 unmodified lines
5050 namespace WelsSVCEnc {
5151 //#define ENC_TRACE
5252
53−typedef void (*PWelsCodingSliceFunc) (sWelsEncCtx* pCtx, SSlice* pSlice);
53+typedef int32_t (*PWelsCodingSliceFunc) (sWelsEncCtx* pCtx, SSlice* pSlice);
5454 typedef void (*PWelsSliceHeaderWriteFunc) (SBitStringAux* pBs, SDqLayer* pCurLayer, SSlice* pSlice,
5555 int32_t* pPpsIdDelta);
5656
@@ -465,7 +465,7 @@ void OutputPMbWithoutConstructCsRsNoCopy (sWelsEncCtx* pCtx, SDqLayer* pDq, SSli · 408 unmodified lines
465465 //encapsulate two kinds of reconstruction:
466466 //first. store base or highest Dependency Layer with only one quality (without CS RS reconstruction)
467467 //second. lower than highest Dependency Layer, and for every Dependency Layer with one quality layer(single layer)
468−void WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding
468+int32_t WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding
469469 SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
470470 SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx;
471471 SMbCache* pMbCache = &pSlice->sMbCacheInfo;
@@ -479,6 +479,7 @@ void WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding · 7 unmodified lines
479479 const int32_t kiSliceIdx = pSlice->uiSliceIdx;
480480 const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
481481 SWelsMD sMd;
482+ int32_t iEncReturn = ENC_RETURN_SUCCESS;
482483
483484 for (; ;) {
484485 iCurMbIdx = iNextMbIdx;
@@ -494,7 +495,9 @@ void WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding · 9 unmodified lines
494495 WelsMdIntraMb (pEncCtx, &sMd, pCurMb, pMbCache);
495496 UpdateNonZeroCountCache (pCurMb, pMbCache);
496497
497− WelsSpatialWriteMbSyn (pEncCtx, pSlice, pCurMb);
498+ iEncReturn = WelsSpatialWriteMbSyn (pEncCtx, pSlice, pCurMb);
499+ if (ENC_RETURN_SUCCESS != iEncReturn)
500+ return iEncReturn;
498501
499502 pCurMb->uiSliceIdc = kiSliceIdx;
500503
@@ -511,10 +514,12 @@ void WelsISliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding · 10 unmodified lines
511514 break;
512515 }
513516 }
517+
518+ return ENC_RETURN_SUCCESS;
514519 }
515520
516521 // Only for intra dynamic slicing
517−void WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding
522+int32_t WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + encoding
518523 SBitStringAux* pBs = pSlice->pSliceBsa;
519524 SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
520525 SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx;
@@ -529,6 +534,7 @@ void WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + enc · 8 unmodified lines
529534 const int32_t kiSliceIdx = pSlice->uiSliceIdx;
530535 const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum);
531536 const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
537+ int32_t iEncReturn = ENC_RETURN_SUCCESS;
532538
533539 SWelsMD sMd;
534540 SDynamicSlicingStack sDss;
@@ -557,7 +563,9 @@ void WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + enc · 22 unmodified lines
557563 sDss.uiBsStackCurBits = pBs->uiCurBits;
558564 sDss.iBsStackLeftBits = pBs->iLeftBits;
559565
560− WelsSpatialWriteMbSyn (pEncCtx, pSlice, pCurMb);
566+ iEncReturn = WelsSpatialWriteMbSyn (pEncCtx, pSlice, pCurMb);
567+ if (ENC_RETURN_SUCCESS != iEncReturn)
568+ return iEncReturn;
561569
562570 sDss.iCurrentPos = BsGetBitsPos (pBs);
563571
@@ -574,6 +582,7 @@ void WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + enc · 10 unmodified lines
574582 break;
575583 }
576584
585+
577586 pCurMb->uiSliceIdc = kiSliceIdx;
578587
579588 #if defined(MB_TYPES_CHECK)
@@ -593,12 +602,13 @@ void WelsISliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice) { //pMd + enc · 13 unmodified lines
593602 break;
594603 }
595604 }
605+ return iEncReturn;
596606 }
597607
598608 //encapsulate two kinds of reconstruction:
599609 // first. store base or highest Dependency Layer with only one quality (without CS RS reconstruction)
600610 // second. lower than highest Dependency Layer, and for every Dependency Layer with one quality layer(single layer)
601−void WelsPSliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag) { //pMd + encoding
611+int32_t WelsPSliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag) { //pMd + encoding
602612 const SSliceHeaderExt* kpShExt = &pSlice->sSliceHeaderExt;
603613 const SSliceHeader* kpSh = &kpShExt->sSliceHeader;
604614 const int32_t kiSliceFirstMbXY = kpSh->iFirstMbInSlice;
@@ -610,10 +620,10 @@ void WelsPSliceMdEnc (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHigh · 5 unmodified lines
610620 memset (&sMd.sMe, 0, sizeof (sMd.sMe));
611621
612622 //pMb loop
613− WelsMdInterMbLoop (pEncCtx, pSlice, &sMd, kiSliceFirstMbXY);
623+ return WelsMdInterMbLoop (pEncCtx, pSlice, &sMd, kiSliceFirstMbXY);
614624 }
615625
616−void WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag) {
626+int32_t WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kbIsHighestDlayerFlag) {
617627 const SSliceHeaderExt* kpShExt = &pSlice->sSliceHeaderExt;
618628 const SSliceHeader* kpSh = &kpShExt->sSliceHeader;
619629 const int32_t kiSliceFirstMbXY = kpSh->iFirstMbInSlice;
@@ -625,10 +635,10 @@ void WelsPSliceMdEncDynamic (sWelsEncCtx* pEncCtx, SSlice* pSlice, const bool kb · 5 unmodified lines
625635 memset (&sMd.sMe, 0, sizeof (sMd.sMe));
626636
627637 //mb loop
628− WelsMdInterMbLoopOverDynamicSlice (pEncCtx, pSlice, &sMd, kiSliceFirstMbXY);
638+ return WelsMdInterMbLoopOverDynamicSlice (pEncCtx, pSlice, &sMd, kiSliceFirstMbXY);
629639 }
630640
631−void WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
641+int32_t WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
632642 //pSlice-level init should be outside and before this function
633643 SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
634644
@@ -644,10 +654,10 @@ void WelsCodePSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) { · 9 unmodified lines
644654 //initial pMd pointer
645655 pEncCtx->pFuncList->pfInterMd = WelsMdInterMb;
646656 }
647− WelsPSliceMdEnc (pEncCtx, pSlice, kbHighestSpatial);
657+ return WelsPSliceMdEnc (pEncCtx, pSlice, kbHighestSpatial);
648658 }
649659
650−void WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
660+int32_t WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) {
651661 //pSlice-level init should be outside and before this function
652662 SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
653663
@@ -663,22 +673,22 @@ void WelsCodePOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice) { · 9 unmodified lines
663673 //initial pMd pointer
664674 pEncCtx->pFuncList->pfInterMd = WelsMdInterMb;
665675 }
666− WelsPSliceMdEncDynamic (pEncCtx, pSlice, kbHighestSpatial);
676+ return WelsPSliceMdEncDynamic (pEncCtx, pSlice, kbHighestSpatial);
667677 }
668678
669679 // 1st index: 0: for P pSlice; 1: for I pSlice;
670680 // 2nd index: 0: for non-dynamic pSlice; 1: for dynamic I pSlice;
671−const PWelsCodingSliceFunc g_pWelsSliceCoding[2][2] = {
681+PWelsCodingSliceFunc g_pWelsSliceCoding[2][2] = {
672682 { WelsCodePSlice, WelsCodePOverDynamicSlice }, // P SSlice
673683 { WelsISliceMdEnc, WelsISliceMdEncDynamic } // I SSlice
674684 };
675−const PWelsSliceHeaderWriteFunc g_pWelsWriteSliceHeader[2] = { // 0: for base; 1: for ext;
685+PWelsSliceHeaderWriteFunc g_pWelsWriteSliceHeader[2] = { // 0: for base; 1: for ext;
676686 WelsSliceHeaderWrite,
677687 WelsSliceHeaderExtWrite
678688 };
679689
680690
681−void WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int32_t kiNalType) {
691+int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int32_t kiNalType) {
682692 SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
683693 SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt;
684694 SSlice* pCurSlice = &pCurLayer->sLayerInfo.pSliceInLayer[kiSliceIdx];
@@ -715,11 +725,15 @@ void WelsCodeOneSlice (sWelsEncCtx* pEncCtx, const int32_t kiSliceIdx, const int · 30 unmodified lines
715725
716726 pCurSlice->uiLastMbQp = pCurLayer->sLayerInfo.pPpsP->iPicInitQp + pCurSlice->sSliceHeaderExt.sSliceHeader.iSliceQpDelta;
717727
718− g_pWelsSliceCoding[pNalHeadExt->bIdrFlag][kiDynamicSliceFlag] (pEncCtx, pCurSlice);
728+ int32_t iEncReturn = g_pWelsSliceCoding[pNalHeadExt->bIdrFlag][kiDynamicSliceFlag] (pEncCtx, pCurSlice);
729+ if (ENC_RETURN_SUCCESS != iEncReturn)
730+ return iEncReturn;
719731
720732 BsRbspTrailingBits (pBs);
721733
722734 BsFlush (pBs);
735+
736+ return ENC_RETURN_SUCCESS;
723737 }
724738
725739 //pFunc: UpdateMbNeighbourInfoForNextSlice()
@@ -905,7 +919,7 @@ bool DynSlcJudgeSliceBoundaryStepBack (void* pCtx, void* pSlice, SSliceCtx* pSli · 179 unmodified lines
905919 // pMb loop
906920 ///////////////
907921 // for inter non-dynamic pSlice
908−void WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, const int32_t kiSliceFirstMbXY) {
922+int32_t WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, const int32_t kiSliceFirstMbXY) {
909923 SWelsMD* pMd = (SWelsMD*)pWelsMd;
910924 SBitStringAux* pBs = pSlice->pSliceBsa;
911925 SDqLayer* pCurLayer = pEncCtx->pCurDqLayer;
@@ -923,6 +937,7 @@ void WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, con · 11 unmodified lines
923937 uint16_t* pMvdCostTableInter = &pEncCtx->pMvdCostTableInter[kiMvdInterTableSize];
924938 const int32_t kiSliceIdx = pSlice->uiSliceIdx;
925939 const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
940+ int32_t iEncReturn = ENC_RETURN_SUCCESS;
926941
927942 for (;;) {
928943 //point to current pMb
@@ -958,7 +973,9 @@ void WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, con · 29 unmodified lines
958973 } else {
959974 BsWriteUE (pBs, iMbSkipRun);
960975 iMbSkipRun = 0;
961− WelsSpatialWriteMbSyn (pEncCtx, pSlice, pCurMb);
976+ iEncReturn = WelsSpatialWriteMbSyn (pEncCtx, pSlice, pCurMb);
977+ if (ENC_RETURN_SUCCESS != iEncReturn)
978+ return iEncReturn;
962979 }
963980
964981 //step (7): reconstruct current MB
@@ -984,10 +1001,12 @@ void WelsMdInterMbLoop (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd, con · 19 unmodified lines
9841001 if (iMbSkipRun) {
9851002 BsWriteUE (pBs, iMbSkipRun);
9861003 }
1004+
1005+ return iEncReturn;
9871006 }
9881007
9891008 // Only for inter dynamic slicing
990−void WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd,
1009+int32_t WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, void* pWelsMd,
9911010 const int32_t kiSliceFirstMbXY) {
9921011 SWelsMD* pMd = (SWelsMD*)pWelsMd;
9931012 SBitStringAux* pBs = pSlice->pSliceBsa;
@@ -1007,6 +1026,7 @@ void WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, vo · 13 unmodified lines
10071026 const int32_t kiSliceIdx = pSlice->uiSliceIdx;
10081027 const int32_t kiPartitionId = (kiSliceIdx % pEncCtx->iActiveThreadsNum);
10091028 const uint8_t kuiChromaQpIndexOffset = pCurLayer->sLayerInfo.pPpsP->uiChromaQpIndexOffset;
1029+ int32_t iEncReturn = ENC_RETURN_SUCCESS;
10101030
10111031 SDynamicSlicingStack sDss;
10121032 sDss.iStartPos = BsGetBitsPos (pBs);
@@ -1063,7 +1083,9 @@ void WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, vo · 50 unmodified lines
10631083 } else {
10641084 BsWriteUE (pBs, iMbSkipRun);
10651085 iMbSkipRun = 0;
1066− WelsSpatialWriteMbSyn (pEncCtx, pSlice, pCurMb);
1086+ iEncReturn = WelsSpatialWriteMbSyn (pEncCtx, pSlice, pCurMb);
1087+ if (ENC_RETURN_SUCCESS != iEncReturn)
1088+ return iEncReturn;
10671089 }
10681090
10691091 //DYNAMIC_SLICING_ONE_THREAD - MultiD
@@ -1108,6 +1130,8 @@ void WelsMdInterMbLoopOverDynamicSlice (sWelsEncCtx* pEncCtx, SSlice* pSlice, vo · 38 unmodified lines
11081130 if (iMbSkipRun) {
11091131 BsWriteUE (pBs, iMbSkipRun);
11101132 }
1133+
1134+ return iEncReturn;
11111135 }
11121136
11131137 }//namespace WelsSVCEnc

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