History

Merge pull request #3080 from xiaotiansf/GeneralFix

Update and fix temporal direct prediction and fix multi-reference pic…

huili2 committed 7 years ago

Commit 316a3ba2 parents 7364765 26d334618 files · +411 −466Browse files

Showing the changes to codec/decoder/core/src/decode_slice.cpp (1 of 18 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) {
@@ -1417,19 +1411,17 @@ int32_t WelsDecodeMbCabacBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 1351 unmodified lines
14171411 pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete)
14181412 || ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete);
14191413
1420−
1414+ SubMbType subMbType;
14211415 if (pSliceHeader->iDirectSpatialMvPredFlag) {
14221416
14231417 //predict direct spatial mv
1424− SubMbType subMbType;
14251418 int32_t ret = PredMvBDirectSpatial (pCtx, pMv, ref, subMbType);
14261419 if (ret != ERR_NONE) {
14271420 return ret;
14281421 }
14291422 } else {
14301423 //temporal direct mode
1431− ComputeColocated (pCtx);
1432− int32_t ret = PredBDirectTemporal (pCtx, pMv, ref);
1424+ int32_t ret = PredBDirectTemporal (pCtx, pMv, ref, subMbType);
14331425 if (ret != ERR_NONE) {
14341426 return ret;
14351427 }
@@ -2380,18 +2372,17 @@ int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 944 unmodified lines
23802372 pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete)
23812373 || ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete);
23822374 //predict iMv
2375+ SubMbType subMbType;
23832376 if (pSliceHeader->iDirectSpatialMvPredFlag) {
23842377
23852378 //predict direct spatial mv
2386− SubMbType subMbType;
23872379 int32_t ret = PredMvBDirectSpatial (pCtx, iMv, ref, subMbType);
23882380 if (ret != ERR_NONE) {
23892381 return ret;
23902382 }
23912383 } else {
23922384 //temporal direct mode
2393− ComputeColocated (pCtx);
2394− int32_t ret = PredBDirectTemporal (pCtx, iMv, ref);
2385+ int32_t ret = PredBDirectTemporal (pCtx, iMv, ref, subMbType);
23952386 if (ret != ERR_NONE) {
23962387 return ret;
23972388 }
@@ -2832,17 +2823,21 @@ bool ComputeColocated (PWelsDecoderContext pCtx) { · 434 unmodified lines
28322823 PSlice pCurSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
28332824 PSliceHeader pSliceHeader = &pCurSlice->sSliceHeaderExt.sSliceHeader;
28342825 if (!pSliceHeader->iDirectSpatialMvPredFlag) {
2835− uint32_t uiShortRefCount = pCtx->sRefPic.uiShortRefCount[LIST_0];
2836− for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
2837− for (uint32_t i = 0; i < uiShortRefCount; ++i) {
2838− int32_t iTRb = WELS_CLIP3 (-128, 127, pSliceHeader->iPicOrderCntLsb - pCtx->sRefPic.pRefList[listIdx][i]->iFramePoc);
2839− int32_t iTRp = WELS_CLIP3 (-128, 127,
2840− pCtx->sRefPic.pRefList[LIST_1][i]->iFramePoc - pCtx->sRefPic.pRefList[LIST_0][i]->iFramePoc);
2841− if (iTRp != 0) {
2842− int32_t prescale = (16384 + iAbs (iTRp / 2)) / iTRp;
2843− pCurSlice->iMvScale[listIdx][i] = WELS_CLIP3 (-1024, 1023, (iTRb * prescale + 32) >> 6);
2844− } else {
2845− pCurSlice->iMvScale[listIdx][i] = 0x03FFF;
2826+ uint32_t uiRefCount = pSliceHeader->uiRefCount[LIST_0];
2827+ if (pCtx->sRefPic.pRefList[LIST_1][0] != NULL) {
2828+ for (uint32_t i = 0; i < uiRefCount; ++i) {
2829+ if (pCtx->sRefPic.pRefList[LIST_0][i] != NULL) {
2830+ const int32_t poc0 = pCtx->sRefPic.pRefList[LIST_0][i]->iFramePoc;
2831+ const int32_t poc1 = pCtx->sRefPic.pRefList[LIST_1][0]->iFramePoc;
2832+ const int32_t poc = pSliceHeader->iPicOrderCntLsb;
2833+ const int32_t td = WELS_CLIP3 (poc1 - poc0, -128, 127);
2834+ if (td == 0) {
2835+ pCurSlice->iMvScale[LIST_0][i] = 1 << 8;
2836+ } else {
2837+ int32_t tb = WELS_CLIP3 (poc - poc0, -128, 127);
2838+ int32_t tx = (16384 + (abs (td) >> 1)) / td;
2839+ pCurSlice->iMvScale[LIST_0][i] = WELS_CLIP3 ((tb * tx + 32) >> 6, -1024, 1023);
2840+ }
28462841 }
28472842 }
28482843 }

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