History

Update and fix temporal direct prediction and fix multi-reference picure re-ordering.

xiaotiansf committed 7 years ago

Commit 4b8913f1 parent 94ffa1f10 files · +411 −466Browse files

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

Unified · Split

codec/decoder/core/src/decode_slice.cpp+19−24
@@ -54,12 +54,6 @@ namespace WelsDec { · 53 unmodified lines
5454
5555 extern void FreePicture (PPicture pPic, CMemoryAlign* pMa);
5656
57−static inline int32_t iAbs (int32_t x) {
58− static const int32_t INT_BITS = (sizeof (int) * CHAR_BIT) - 1;
59− int32_t y = x >> INT_BITS;
60− return (x ^ y) - y;
61−}
62−
6357 extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight);
6458
6559 int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) {
@@ -1423,19 +1417,17 @@ int32_t WelsDecodeMbCabacBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 1357 unmodified lines
14231417 pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete)
14241418 || ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete);
14251419
1426−
1420+ SubMbType subMbType;
14271421 if (pSliceHeader->iDirectSpatialMvPredFlag) {
14281422
14291423 //predict direct spatial mv
1430− SubMbType subMbType;
14311424 int32_t ret = PredMvBDirectSpatial (pCtx, pMv, ref, subMbType);
14321425 if (ret != ERR_NONE) {
14331426 return ret;
14341427 }
14351428 } else {
14361429 //temporal direct mode
1437− ComputeColocated (pCtx);
1438− int32_t ret = PredBDirectTemporal (pCtx, pMv, ref);
1430+ int32_t ret = PredBDirectTemporal (pCtx, pMv, ref, subMbType);
14391431 if (ret != ERR_NONE) {
14401432 return ret;
14411433 }
@@ -2386,18 +2378,17 @@ int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 944 unmodified lines
23862378 pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete)
23872379 || ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete);
23882380 //predict iMv
2381+ SubMbType subMbType;
23892382 if (pSliceHeader->iDirectSpatialMvPredFlag) {
23902383
23912384 //predict direct spatial mv
2392− SubMbType subMbType;
23932385 int32_t ret = PredMvBDirectSpatial (pCtx, iMv, ref, subMbType);
23942386 if (ret != ERR_NONE) {
23952387 return ret;
23962388 }
23972389 } else {
23982390 //temporal direct mode
2399− ComputeColocated (pCtx);
2400− int32_t ret = PredBDirectTemporal (pCtx, iMv, ref);
2391+ int32_t ret = PredBDirectTemporal (pCtx, iMv, ref, subMbType);
24012392 if (ret != ERR_NONE) {
24022393 return ret;
24032394 }
@@ -2838,17 +2829,21 @@ bool ComputeColocated (PWelsDecoderContext pCtx) { · 434 unmodified lines
28382829 PSlice pCurSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
28392830 PSliceHeader pSliceHeader = &pCurSlice->sSliceHeaderExt.sSliceHeader;
28402831 if (!pSliceHeader->iDirectSpatialMvPredFlag) {
2841− uint32_t uiShortRefCount = pCtx->sRefPic.uiShortRefCount[LIST_0];
2842− for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
2843− for (uint32_t i = 0; i < uiShortRefCount; ++i) {
2844− int32_t iTRb = WELS_CLIP3 (-128, 127, pSliceHeader->iPicOrderCntLsb - pCtx->sRefPic.pRefList[listIdx][i]->iFramePoc);
2845− int32_t iTRp = WELS_CLIP3 (-128, 127,
2846− pCtx->sRefPic.pRefList[LIST_1][i]->iFramePoc - pCtx->sRefPic.pRefList[LIST_0][i]->iFramePoc);
2847− if (iTRp != 0) {
2848− int32_t prescale = (16384 + iAbs (iTRp / 2)) / iTRp;
2849− pCurSlice->iMvScale[listIdx][i] = WELS_CLIP3 (-1024, 1023, (iTRb * prescale + 32) >> 6);
2850− } else {
2851− pCurSlice->iMvScale[listIdx][i] = 0x03FFF;
2832+ uint32_t uiRefCount = pSliceHeader->uiRefCount[LIST_0];
2833+ if (pCtx->sRefPic.pRefList[LIST_1][0] != NULL) {
2834+ for (uint32_t i = 0; i < uiRefCount; ++i) {
2835+ if (pCtx->sRefPic.pRefList[LIST_0][i] != NULL) {
2836+ const int32_t poc0 = pCtx->sRefPic.pRefList[LIST_0][i]->iFramePoc;
2837+ const int32_t poc1 = pCtx->sRefPic.pRefList[LIST_1][0]->iFramePoc;
2838+ const int32_t poc = pSliceHeader->iPicOrderCntLsb;
2839+ const int32_t td = WELS_CLIP3 (poc1 - poc0, -128, 127);
2840+ if (td == 0) {
2841+ pCurSlice->iMvScale[LIST_0][i] = 1 << 8;
2842+ } else {
2843+ int32_t tb = WELS_CLIP3 (poc - poc0, -128, 127);
2844+ int32_t tx = (16384 + (abs (td) >> 1)) / td;
2845+ pCurSlice->iMvScale[LIST_0][i] = WELS_CLIP3 ((tb * tx + 32) >> 6, -1024, 1023);
2846+ }
28522847 }
28532848 }
28542849 }

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