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
54 54
55extern void FreePicture (PPicture pPic, CMemoryAlign* pMa);55extern void FreePicture (PPicture pPic, CMemoryAlign* pMa);
56 56
57static 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
63extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight);57extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight);
64 58
65int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) {59int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) {
@@ -1417,19 +1411,17 @@ int32_t WelsDecodeMbCabacBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 1351 unmodified lines
1417 pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete)1411 pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete)
1418 || ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete);1412 || ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete);
1419 1413
1420 1414 SubMbType subMbType;
1421 if (pSliceHeader->iDirectSpatialMvPredFlag) {1415 if (pSliceHeader->iDirectSpatialMvPredFlag) {
1422 1416
1423 //predict direct spatial mv1417 //predict direct spatial mv
1424 SubMbType subMbType;
1425 int32_t ret = PredMvBDirectSpatial (pCtx, pMv, ref, subMbType);1418 int32_t ret = PredMvBDirectSpatial (pCtx, pMv, ref, subMbType);
1426 if (ret != ERR_NONE) {1419 if (ret != ERR_NONE) {
1427 return ret;1420 return ret;
1428 }1421 }
1429 } else {1422 } else {
1430 //temporal direct mode1423 //temporal direct mode
1431 ComputeColocated (pCtx);1424 int32_t ret = PredBDirectTemporal (pCtx, pMv, ref, subMbType);
1432 int32_t ret = PredBDirectTemporal (pCtx, pMv, ref);
1433 if (ret != ERR_NONE) {1425 if (ret != ERR_NONE) {
1434 return ret;1426 return ret;
1435 }1427 }
@@ -2380,18 +2372,17 @@ int32_t WelsDecodeMbCavlcBSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 944 unmodified lines
2380 pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete)2372 pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPicL0[0] && ppRefPicL0[0]->bIsComplete)
2381 || ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete);2373 || ! (ppRefPicL1[0] && ppRefPicL1[0]->bIsComplete);
2382 //predict iMv2374 //predict iMv
2375 SubMbType subMbType;
2383 if (pSliceHeader->iDirectSpatialMvPredFlag) {2376 if (pSliceHeader->iDirectSpatialMvPredFlag) {
2384 2377
2385 //predict direct spatial mv2378 //predict direct spatial mv
2386 SubMbType subMbType;
2387 int32_t ret = PredMvBDirectSpatial (pCtx, iMv, ref, subMbType);2379 int32_t ret = PredMvBDirectSpatial (pCtx, iMv, ref, subMbType);
2388 if (ret != ERR_NONE) {2380 if (ret != ERR_NONE) {
2389 return ret;2381 return ret;
2390 }2382 }
2391 } else {2383 } else {
2392 //temporal direct mode2384 //temporal direct mode
2393 ComputeColocated (pCtx);2385 int32_t ret = PredBDirectTemporal (pCtx, iMv, ref, subMbType);
2394 int32_t ret = PredBDirectTemporal (pCtx, iMv, ref);
2395 if (ret != ERR_NONE) {2386 if (ret != ERR_NONE) {
2396 return ret;2387 return ret;
2397 }2388 }
@@ -2832,17 +2823,21 @@ bool ComputeColocated (PWelsDecoderContext pCtx) { · 434 unmodified lines
2832 PSlice pCurSlice = &pCurLayer->sLayerInfo.sSliceInLayer;2823 PSlice pCurSlice = &pCurLayer->sLayerInfo.sSliceInLayer;
2833 PSliceHeader pSliceHeader = &pCurSlice->sSliceHeaderExt.sSliceHeader;2824 PSliceHeader pSliceHeader = &pCurSlice->sSliceHeaderExt.sSliceHeader;
2834 if (!pSliceHeader->iDirectSpatialMvPredFlag) {2825 if (!pSliceHeader->iDirectSpatialMvPredFlag) {
2835 uint32_t uiShortRefCount = pCtx->sRefPic.uiShortRefCount[LIST_0];2826 uint32_t uiRefCount = pSliceHeader->uiRefCount[LIST_0];
2836 for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {2827 if (pCtx->sRefPic.pRefList[LIST_1][0] != NULL) {
2837 for (uint32_t i = 0; i < uiShortRefCount; ++i) {2828 for (uint32_t i = 0; i < uiRefCount; ++i) {
2838 int32_t iTRb = WELS_CLIP3 (-128, 127, pSliceHeader->iPicOrderCntLsb - pCtx->sRefPic.pRefList[listIdx][i]->iFramePoc);2829 if (pCtx->sRefPic.pRefList[LIST_0][i] != NULL) {
2839 int32_t iTRp = WELS_CLIP3 (-128, 127,2830 const int32_t poc0 = pCtx->sRefPic.pRefList[LIST_0][i]->iFramePoc;
2840 pCtx->sRefPic.pRefList[LIST_1][i]->iFramePoc - pCtx->sRefPic.pRefList[LIST_0][i]->iFramePoc);2831 const int32_t poc1 = pCtx->sRefPic.pRefList[LIST_1][0]->iFramePoc;
2841 if (iTRp != 0) {2832 const int32_t poc = pSliceHeader->iPicOrderCntLsb;
2842 int32_t prescale = (16384 + iAbs (iTRp / 2)) / iTRp;2833 const int32_t td = WELS_CLIP3 (poc1 - poc0, -128, 127);
2843 pCurSlice->iMvScale[listIdx][i] = WELS_CLIP3 (-1024, 1023, (iTRb * prescale + 32) >> 6);2834 if (td == 0) {
2844 } else {2835 pCurSlice->iMvScale[LIST_0][i] = 1 << 8;
2845 pCurSlice->iMvScale[listIdx][i] = 0x03FFF;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 }
2846 }2841 }
2847 }2842 }
2848 }2843 }

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