Changeset 1196 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComPrediction.cpp
- Timestamp:
- 4 May 2015, 17:47:40 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComPrediction.cpp
r1179 r1196 54 54 m_pDepthBlock = (Int*) malloc(MAX_NUM_SPU_W*MAX_NUM_SPU_W*sizeof(Int)); 55 55 if (m_pDepthBlock == NULL) 56 { 56 57 printf("ERROR: UKTGHU, No memory allocated.\n"); 58 } 57 59 #endif 58 60 } … … 62 64 #if H_3D_VSP 63 65 if (m_pDepthBlock != NULL) 64 free(m_pDepthBlock); 66 { 67 free(m_pDepthBlock); 68 } 65 69 m_cYuvDepthOnVsp.destroy(); 66 70 #endif … … 513 517 514 518 #if H_3D_DIM_DMM 515 if( dimType == DMM4_IDX && dmm4Segmentation == NULL ) { dmmSegmentation->destroy(); delete dmmSegmentation; } 519 if( dimType == DMM4_IDX && dmm4Segmentation == NULL ) 520 { 521 dmmSegmentation->destroy(); 522 delete dmmSegmentation; 523 } 516 524 #endif 517 525 } … … 630 638 631 639 #if H_3D_DBBP 632 #if HS_DBBP_CLEAN_K0048633 640 PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize, TComDataCU*& pcCU) 634 #else635 PartSize TComPrediction::getPartitionSizeFromDepth(Pel* pDepthPels, UInt uiDepthStride, UInt uiSize)636 #endif637 641 { 638 642 // find virtual partitioning for this CU based on depth block 639 643 // segmentation of texture block --> mask IDs 640 644 Pel* pDepthBlockStart = pDepthPels; 641 645 642 646 // first compute average of depth block for thresholding 643 647 Int iSumDepth = 0; 644 648 Int iSubSample = 4; 645 #if HS_DBBP_CLEAN_K0048646 649 Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(); 647 650 Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(); … … 653 656 Int iBlkX = ( pcCU->getAddr() % pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUWidth + g_auiRasterToPelX[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getHor()+2)>>2); 654 657 Int iBlkY = ( pcCU->getAddr() / pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getFrameWidthInCU() ) * g_uiMaxCUHeight + g_auiRasterToPelY[ g_auiZscanToRaster[ pcCU->getZorderIdxInCU() ] ]+ ((cDv.getVer()+2)>>2); 658 655 659 UInt t=0; 656 660 657 661 for (Int y=0; y<uiSize; y+=iSubSample) 658 662 { 659 663 for (Int x=0; x<uiSize; x+=iSubSample) 660 {661 if (iBlkX+x>iPictureWidth)662 {663 Int depthPel = pDepthPels[t];664 iSumDepth += depthPel;665 }666 else667 {668 Int depthPel = pDepthPels[x];669 t=x;670 iSumDepth += depthPel;671 }672 }673 664 { 665 if (iBlkX+x>iPictureWidth) 666 { 667 Int depthPel = pDepthPels[t]; 668 iSumDepth += depthPel; 669 } 670 else 671 { 672 Int depthPel = pDepthPels[x]; 673 t=x; 674 iSumDepth += depthPel; 675 } 676 } 677 674 678 // next row 675 679 if (!(iBlkY+y+4>iPictureHeight)) 676 pDepthPels += uiDepthStride*iSubSample; 677 #else 678 for (Int y=0; y<uiSize; y+=iSubSample) 679 { 680 for (Int x=0; x<uiSize; x+=iSubSample) 681 { 682 Int depthPel = pDepthPels[x]; 683 684 iSumDepth += depthPel; 685 } 686 687 // next row 688 pDepthPels += uiDepthStride*iSubSample; 689 #endif 690 } 691 680 { 681 pDepthPels += uiDepthStride*iSubSample; 682 } 683 } 684 692 685 Int iSizeInBits = g_aucConvertToBit[uiSize] - g_aucConvertToBit[iSubSample]; // respect sub-sampling factor 693 686 Int iMean = iSumDepth >> iSizeInBits*2; // iMean /= (uiSize*uiSize); 694 687 695 688 // start again for segmentation 696 689 pDepthPels = pDepthBlockStart; 697 690 698 691 // start mapping process 699 692 Int matchedPartSum[2][2] = {{0,0},{0,0}}; // counter for each part size and boolean option 700 693 PartSize virtualPartSizes[2] = { SIZE_Nx2N, SIZE_2NxN}; 701 694 702 695 UInt uiHalfSize = uiSize>>1; 703 696 for (Int y=0; y<uiSize; y+=iSubSample) … … 705 698 for (Int x=0; x<uiSize; x+=iSubSample) 706 699 { 707 #if HS_DBBP_CLEAN_K0048708 700 Int depthPel = 0; 709 if (iBlkX+x>iPictureWidth) 710 { 711 depthPel = pDepthPels[t]; 712 } 713 else 714 { 715 depthPel = pDepthPels[x]; 716 t=x; 717 } 718 #else 719 Int depthPel = pDepthPels[x]; 720 #endif 721 701 if (iBlkX+x>iPictureWidth) 702 { 703 depthPel = pDepthPels[t]; 704 } 705 else 706 { 707 depthPel = pDepthPels[x]; 708 t=x; 709 } 710 722 711 // decide which segment this pixel belongs to 723 712 Int ucSegment = (Int)(depthPel>iMean); 724 713 725 714 // Matched Filter to find optimal (conventional) partitioning 726 715 727 716 // SIZE_Nx2N 728 717 if(x<uiHalfSize) // left … … 734 723 matchedPartSum[0][1-ucSegment]++; 735 724 } 736 725 737 726 // SIZE_2NxN 738 727 if(y<uiHalfSize) // top … … 745 734 } 746 735 } 747 736 748 737 // next row 749 #if HS_DBBP_CLEAN_K0048750 738 if (!(iBlkY+y+4>iPictureHeight)) 751 #endif 752 pDepthPels += uiDepthStride*iSubSample; 753 } 754 739 { 740 pDepthPels += uiDepthStride*iSubSample; 741 } 742 } 743 755 744 PartSize matchedPartSize = SIZE_NONE; 756 745 757 746 Int iMaxMatchSum = 0; 758 747 for(Int p=0; p<2; p++) // loop over partition … … 767 756 } 768 757 } 769 758 770 759 AOF( matchedPartSize != SIZE_NONE ); 771 760 772 761 return matchedPartSize; 773 762 } 774 763 775 #if HS_DBBP_CLEAN_K0048776 764 Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask, TComDataCU*& pcCU) 777 #else778 Bool TComPrediction::getSegmentMaskFromDepth( Pel* pDepthPels, UInt uiDepthStride, UInt uiWidth, UInt uiHeight, Bool* pMask )779 #endif780 765 { 781 766 // segmentation of texture block --> mask IDs … … 786 771 Int uiMinDepth = MAX_INT; 787 772 Int uiMaxDepth = 0; 788 #if HS_DBBP_CLEAN_K0048789 773 uiMinDepth = pDepthPels[ 0 ]; 790 774 uiMaxDepth = pDepthPels[ 0 ]; 791 775 iSumDepth = pDepthPels[ 0 ]; 792 UInt t=0;776 793 777 Int iPictureWidth = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getWidth(); 794 778 Int iPictureHeight = pcCU->getSlice()->getIvPic (true, pcCU->getDvInfo(0).m_aVIdxCan)->getPicYuvRec()->getHeight(); … … 848 832 uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]); 849 833 } 850 #else851 iSumDepth = pDepthPels[ 0 ];852 iSumDepth += pDepthPels[ uiWidth - 1 ];853 iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) ];854 iSumDepth += pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ];855 856 uiMinDepth = pDepthPels[ 0 ];857 uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiWidth - 1 ]);858 uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) ]);859 uiMinDepth = std::min( uiMinDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]);860 861 uiMaxDepth = pDepthPels[ 0 ];862 uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiWidth - 1 ]);863 uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) ]);864 uiMaxDepth = std::max( uiMaxDepth, (Int)pDepthPels[ uiDepthStride * (uiHeight - 1) + uiWidth - 1 ]);865 #endif866 834 867 835 // don't generate mask for blocks with small depth range (encoder decision) … … 880 848 881 849 // generate mask 850 UInt t=0; 882 851 UInt uiSumPix[2] = {0,0}; 883 852 for (Int y=0; y<uiHeight; y++) … … 885 854 for (Int x=0; x<uiHeight; x++) 886 855 { 887 #if HS_DBBP_CLEAN_K0048888 856 Int depthPel = 0; 889 857 if (iBlkX+x>iPictureWidth) … … 896 864 t=x; 897 865 } 898 #else899 Int depthPel = pDepthPels[x];900 #endif901 866 902 867 // decide which segment this pixel belongs to … … 916 881 917 882 // next row 918 #if HS_DBBP_CLEAN_K0048919 883 if (!(iBlkY+y+1>iPictureHeight)) 920 #endif921 884 pDepthPels += uiDepthStride; 922 885 pMask += MAX_CU_SIZE; … … 1003 966 } 1004 967 1005 if ( tmpTar ) { xFree(tmpTar); tmpTar = NULL; } 968 if ( tmpTar ) 969 { 970 xFree(tmpTar); 971 tmpTar = NULL; 972 } 1006 973 1007 974 // now combine chroma … … 1106 1073 } 1107 1074 1108 if ( tmpTarU ) { xFree(tmpTarU); tmpTarU = NULL; } 1109 if ( tmpTarV ) { xFree(tmpTarV); tmpTarV = NULL; } 1075 if( tmpTarU ) 1076 { 1077 xFree(tmpTarU); 1078 tmpTarU = NULL; 1079 } 1080 if ( tmpTarV ) 1081 { 1082 xFree(tmpTarV); 1083 tmpTarV = NULL; 1084 } 1110 1085 } 1111 1086 #endif … … 1293 1268 TComMv cMv = pcCU->getCUMvField( eRefPicList )->getMv( uiPartAddr ); 1294 1269 pcCU->clipMv(cMv); 1295 #if SONY_MV_V_CONST_C00781296 pcCU->checkM V_V(cMv, eRefPicList, iRefIdx );1270 #if H_MV 1271 pcCU->checkMvVertRest(cMv, eRefPicList, iRefIdx ); 1297 1272 #endif 1298 1273 #if H_3D_ARP … … 1393 1368 #if H_3D_NBDV 1394 1369 DisInfo cDistparity; 1395 #if SEC_ARP_REM_ENC_RESTRICT_K00351396 1370 cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV; 1397 1371 cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan; 1398 1372 #else 1399 cDistparity.bDV = pcCU->getDvInfo(uiPartAddr).bDV;1400 if( cDistparity.bDV )1401 {1402 cDistparity.m_acNBDV = pcCU->getDvInfo(0).m_acNBDV;1403 assert(pcCU->getDvInfo(uiPartAddr).bDV == pcCU->getDvInfo(0).bDV);1404 cDistparity.m_aVIdxCan = pcCU->getDvInfo(uiPartAddr).m_aVIdxCan;1405 }1406 #endif1407 #else1408 1373 assert(0); // ARP can be applied only when a DV is available 1409 1374 #endif 1410 #if SEC_ARP_REM_ENC_RESTRICT_K00351411 1375 UChar dW = pcCU->getARPW ( uiPartAddr ); 1412 #else 1413 UChar dW = cDistparity.bDV ? pcCU->getARPW ( uiPartAddr ) : 0; 1414 #endif 1415 1416 #if !SEC_ARP_REM_ENC_RESTRICT_K0035 1417 if( cDistparity.bDV ) 1418 #endif 1376 1419 1377 { 1420 1378 Int arpRefIdx = pcCU->getSlice()->getFirstTRefIdx(eRefPicList); … … 1468 1426 pYuvB0->clear(); pYuvB1->clear(); 1469 1427 } 1470 #if !SEC_ARP_REM_ENC_RESTRICT_K00351471 assert ( cDistparity.bDV );1472 #endif1473 1428 TComMv cNBDV = cDistparity.m_acNBDV; 1474 1429 pcCU->clipMv( cNBDV ); … … 2438 2393 for( UInt k = 0; k < (patternStride * patternStride); k++ ) 2439 2394 { 2440 if( true == biSegPattern[k] ) { ptrDst[k] = valDC2; } 2441 else { ptrDst[k] = valDC1; } 2395 if( true == biSegPattern[k] ) 2396 { 2397 ptrDst[k] = valDC2; 2398 } 2399 else 2400 { 2401 ptrDst[k] = valDC1; 2402 } 2442 2403 } 2443 2404 } … … 2449 2410 for( UInt uiX = 0; uiX < patternStride; uiX++ ) 2450 2411 { 2451 if( true == biSegPattern[uiX] ) { piTemp[uiX] = valDC2; } 2452 else { piTemp[uiX] = valDC1; } 2412 if( true == biSegPattern[uiX] ) 2413 { 2414 piTemp[uiX] = valDC2; 2415 } 2416 else 2417 { 2418 piTemp[uiX] = valDC1; 2419 } 2453 2420 } 2454 2421 piTemp += dstStride; … … 2520 2487 Int iSumPix[2]; 2521 2488 memset(iSumPix, 0, sizeof(Int)*2); 2489 2522 2490 for( Int i = 0; i < uiNumSegments; i++ ) 2523 2491 { 2524 rpSegMeans[i] = 0; 2525 } 2526 if (orgDC == false) 2492 rpSegMeans[i] = 0; 2493 } 2494 2495 if ( !orgDC ) 2527 2496 { 2528 2497 Pel* pLeftTop = pOrig; … … 2544 2513 subSamplePix = 1; 2545 2514 } 2515 2546 2516 for (Int y=0; y<uiSize; y+=subSamplePix) 2547 2517 { … … 2563 2533 { 2564 2534 if( iSumPix[ucSeg] > 0 ) 2535 { 2565 2536 rpSegMeans[ucSeg] = iSumDepth[ucSeg] / iSumPix[ucSeg]; 2537 } 2566 2538 else 2539 { 2567 2540 rpSegMeans[ucSeg] = 0; // this happens for zero-segments 2541 } 2568 2542 } 2569 2543 }
Note: See TracChangeset for help on using the changeset viewer.