Changeset 438 in 3DVCSoftware for branches/HTM-DEV-0.2-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
- Timestamp:
- 23 May 2013, 15:40:36 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-DEV-0.2-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
r401 r438 175 175 } 176 176 177 /** copy SAO parameter 178 * \param dst 179 * \param src 180 */ 181 inline Void copySaoOneLcuParam(SaoLcuParam* dst, SaoLcuParam* src) 182 { 183 Int i; 184 dst->partIdx = src->partIdx; 185 dst->typeIdx = src->typeIdx; 186 if (dst->typeIdx != -1) 187 { 188 dst->subTypeIdx = src->subTypeIdx ; 189 dst->length = src->length; 190 for (i=0;i<dst->length;i++) 191 { 192 dst->offset[i] = src->offset[i]; 193 } 194 } 195 else 196 { 197 dst->length = 0; 198 for (i=0;i<SAO_BO_LEN;i++) 199 { 200 dst->offset[i] = 0; 201 } 202 } 203 } 204 177 205 Void TDecCavlc::parsePPS(TComPPS* pcPPS) 178 206 { … … 372 400 373 401 READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); 402 assert(pcVUI->getFieldSeqFlag() == false); // not supported yet 374 403 375 404 READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); … … 564 593 565 594 READ_UVLC( uiCode, "bit_depth_luma_minus8" ); 566 pcSPS->setBitDepthY( uiCode + 8 ); 595 g_bitDepthY = 8 + uiCode; 596 pcSPS->setBitDepthY(g_bitDepthY); 567 597 pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); 568 598 569 599 READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); 570 pcSPS->setBitDepthC( uiCode + 8 ); 600 g_bitDepthC = 8 + uiCode; 601 pcSPS->setBitDepthC(g_bitDepthC); 571 602 pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); 572 603 … … 577 608 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 578 609 { 579 #if L0323_DPB580 #if H_MV581 READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]");582 #else583 READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1");584 #endif585 pcSPS->setMaxDecPicBuffering( uiCode + 1, i);586 #else587 610 READ_UVLC ( uiCode, "sps_max_dec_pic_buffering"); 588 611 pcSPS->setMaxDecPicBuffering( uiCode, i); 589 #endif590 #if H_MV591 READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" );592 #else593 612 READ_UVLC ( uiCode, "sps_num_reorder_pics" ); 594 #endif595 613 pcSPS->setNumReorderPics(uiCode, i); 596 #if H_MV597 READ_UVLC ( uiCode, "sps_max_latency_increase[i]");598 #else599 614 READ_UVLC ( uiCode, "sps_max_latency_increase"); 600 #endif601 615 pcSPS->setMaxLatencyIncrease( uiCode, i ); 602 616 … … 614 628 615 629 READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); 616 Int log2MinCUSize = uiCode + 3; 617 pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); 630 UInt log2MinCUSize = uiCode + 3; 618 631 READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); 619 pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); 620 Int maxCUDepthDelta = uiCode; 621 pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); 622 pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); 632 UInt uiMaxCUDepthCorrect = uiCode; 633 pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + uiMaxCUDepthCorrect) ); g_uiMaxCUWidth = 1<<(log2MinCUSize + uiMaxCUDepthCorrect); 634 pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + uiMaxCUDepthCorrect) ); g_uiMaxCUHeight = 1<<(log2MinCUSize + uiMaxCUDepthCorrect); 623 635 READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); 624 636 … … 628 640 READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); 629 641 READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); 630 631 Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); 632 pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); 633 642 g_uiAddCUDepth = 0; 643 while( ( pcSPS->getMaxCUWidth() >> uiMaxCUDepthCorrect ) > ( 1 << ( pcSPS->getQuadtreeTULog2MinSize() + g_uiAddCUDepth ) ) ) 644 { 645 g_uiAddCUDepth++; 646 } 647 pcSPS->setMaxCUDepth( uiMaxCUDepthCorrect+g_uiAddCUDepth ); 648 g_uiMaxCUDepth = uiMaxCUDepthCorrect+g_uiAddCUDepth; 649 // BB: these parameters may be removed completly and replaced by the fixed values 650 pcSPS->setMinTrDepth( 0 ); 651 pcSPS->setMaxTrDepth( 1 ); 634 652 READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); 635 653 if(pcSPS->getScalingListFlag()) … … 692 710 if (uiCode) 693 711 { 694 #if H_MV695 READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false);696 #else697 712 while ( xMoreRbspData() ) 698 713 { 699 714 READ_FLAG( uiCode, "sps_extension_data_flag"); 700 715 } 701 #endif702 716 } 703 717 } … … 706 720 { 707 721 UInt uiCode; 708 722 709 723 READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); 710 724 READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); … … 730 744 for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) 731 745 { 732 #if L0323_DPB733 READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i );734 #else735 746 READ_UVLC( uiCode, "vps_max_dec_pic_buffering[i]" ); pcVPS->setMaxDecPicBuffering( uiCode, i ); 736 #endif737 747 READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); 738 748 READ_UVLC( uiCode, "vps_max_latency_increase[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); … … 1042 1052 iPOCmsb = iPrevPOCmsb; 1043 1053 } 1044 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA _W_LP1045 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA _W_RADL1054 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA 1055 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT 1046 1056 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 1047 1057 { … … 1052 1062 1053 1063 TComReferencePictureSet* rps; 1054 rps = rpcSlice->getLocalRPS();1055 rpcSlice->setRPS(rps);1056 1064 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 1057 1065 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 1058 1066 { 1067 rps = rpcSlice->getLocalRPS(); 1059 1068 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 1069 rpcSlice->setRPS(rps); 1060 1070 } 1061 1071 else // use reference to short-term reference picture set in PPS … … 1074 1084 uiCode = 0; 1075 1085 } 1076 memcpy(rps,sps->getRPSList()->getReferencePictureSet(uiCode),sizeof(TComReferencePictureSet)); 1086 rpcSlice->setRPS(sps->getRPSList()->getReferencePictureSet(uiCode)); 1087 1088 rps = rpcSlice->getRPS(); 1077 1089 } 1078 1090 if(sps->getLongTermRefsPresent()) … … 1097 1109 rps->setNumberOfLongtermPictures(numOfLtrp); 1098 1110 Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); 1099 Int prev DeltaMSB = 0, deltaPocMSBCycleLT = 0;;1111 Int prevLSB = 0, prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; 1100 1112 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 1101 1113 { … … 1124 1136 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 1125 1137 Bool deltaFlag = false; 1126 // First LTRP || First LTRP from SH 1127 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) )1138 // First LTRP || First LTRP from SH || curr LSB != prev LSB 1139 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) || (pocLsbLt != prevLSB) ) 1128 1140 { 1129 1141 deltaFlag = true; … … 1150 1162 rps->setCheckLTMSBPresent(j,false); 1151 1163 } 1164 prevLSB = pocLsbLt; 1152 1165 prevDeltaMSB = deltaPocMSBCycleLT; 1153 1166 } … … 1155 1168 rps->setNumberOfPictures(offset); 1156 1169 } 1157 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA _W_LP1158 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA _W_RADL1170 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA 1171 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT 1159 1172 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 1160 1173 { … … 1216 1229 } 1217 1230 } 1218 // } 1231 // } 1219 1232 TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); 1220 1221 1233 if(!rpcSlice->isIntra()) 1222 1234 { … … 1389 1401 if(!rpcSlice->getDeblockingFilterDisable()) 1390 1402 { 1391 READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 1392 assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 1393 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 1394 READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 1395 assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 1396 rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 1403 READ_SVLC( iCode, "beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 1404 READ_SVLC( iCode, "tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 1397 1405 } 1398 1406 } … … 1426 1434 } 1427 1435 1436 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 1437 { 1428 1438 UInt *entryPointOffset = NULL; 1429 1439 UInt numEntryPointOffsets, offsetLenMinus1; 1430 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 1431 { 1440 1432 1441 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); 1433 1442 if (numEntryPointOffsets>0) … … 1446 1455 #endif 1447 1456 } 1448 }1449 else1450 {1451 rpcSlice->setNumEntryPointOffsets ( 0 );1452 }1453 1454 if(pps->getSliceHeaderExtensionPresentFlag())1455 {1456 READ_UVLC(uiCode,"slice_header_extension_length");1457 for(Int i=0; i<uiCode; i++)1458 {1459 UInt ignore;1460 READ_CODE(8,ignore,"slice_header_extension_data_byte");1461 }1462 }1463 m_pcBitstream->readByteAlignment();1464 1465 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )1466 {1467 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();1468 Int curEntryPointOffset = 0;1469 Int prevEntryPointOffset = 0;1470 for (UInt idx=0; idx<numEntryPointOffsets; idx++)1471 {1472 curEntryPointOffset += entryPointOffset[ idx ];1473 1474 Int emulationPreventionByteCount = 0;1475 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )1476 {1477 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) &&1478 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) )1479 {1480 emulationPreventionByteCount++;1481 }1482 }1483 1484 entryPointOffset[ idx ] -= emulationPreventionByteCount;1485 prevEntryPointOffset = curEntryPointOffset;1486 }1487 1457 1488 1458 if ( pps->getTilesEnabledFlag() ) … … 1520 1490 } 1521 1491 } 1522 1492 else 1493 { 1494 rpcSlice->setNumEntryPointOffsets ( 0 ); 1495 } 1496 1497 if(pps->getSliceHeaderExtensionPresentFlag()) 1498 { 1499 READ_UVLC(uiCode,"slice_header_extension_length"); 1500 for(Int i=0; i<uiCode; i++) 1501 { 1502 UInt ignore; 1503 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 1504 } 1505 } 1506 m_pcBitstream->readByteAlignment(); 1523 1507 return; 1524 1508 } … … 1771 1755 // ==================================================================================================================== 1772 1756 1757 1758 /** Parse PCM alignment zero bits. 1759 * \returns Void 1760 */ 1761 Void TDecCavlc::xReadPCMAlignZero( ) 1762 { 1763 UInt uiNumberOfBits = m_pcBitstream->getNumBitsUntilByteAligned(); 1764 1765 if(uiNumberOfBits) 1766 { 1767 UInt uiBits; 1768 UInt uiSymbol; 1769 1770 for(uiBits = 0; uiBits < uiNumberOfBits; uiBits++) 1771 { 1772 xReadFlag( uiSymbol ); 1773 assert( uiSymbol == 0 ); 1774 } 1775 } 1776 } 1777 1778 Void TDecCavlc::xReadUnaryMaxSymbol( UInt& ruiSymbol, UInt uiMaxSymbol ) 1779 { 1780 if (uiMaxSymbol == 0) 1781 { 1782 ruiSymbol = 0; 1783 return; 1784 } 1785 1786 xReadFlag( ruiSymbol ); 1787 1788 if (ruiSymbol == 0 || uiMaxSymbol == 1) 1789 { 1790 return; 1791 } 1792 1793 UInt uiSymbol = 0; 1794 UInt uiCont; 1795 1796 do 1797 { 1798 xReadFlag( uiCont ); 1799 uiSymbol++; 1800 } 1801 while( uiCont && (uiSymbol < uiMaxSymbol-1) ); 1802 1803 if( uiCont && (uiSymbol == uiMaxSymbol-1) ) 1804 { 1805 uiSymbol++; 1806 } 1807 1808 ruiSymbol = uiSymbol; 1809 } 1810 1811 Void TDecCavlc::xReadExGolombLevel( UInt& ruiSymbol ) 1812 { 1813 UInt uiSymbol ; 1814 UInt uiCount = 0; 1815 do 1816 { 1817 xReadFlag( uiSymbol ); 1818 uiCount++; 1819 } 1820 while( uiSymbol && (uiCount != 13)); 1821 1822 ruiSymbol = uiCount-1; 1823 1824 if( uiSymbol ) 1825 { 1826 xReadEpExGolomb( uiSymbol, 0 ); 1827 ruiSymbol += uiSymbol+1; 1828 } 1829 1830 return; 1831 } 1832 1833 Void TDecCavlc::xReadEpExGolomb( UInt& ruiSymbol, UInt uiCount ) 1834 { 1835 UInt uiSymbol = 0; 1836 UInt uiBit = 1; 1837 1838 1839 while( uiBit ) 1840 { 1841 xReadFlag( uiBit ); 1842 uiSymbol += uiBit << uiCount++; 1843 } 1844 1845 uiCount--; 1846 while( uiCount-- ) 1847 { 1848 xReadFlag( uiBit ); 1849 uiSymbol += uiBit << uiCount; 1850 } 1851 1852 ruiSymbol = uiSymbol; 1853 1854 return; 1855 } 1856 1857 UInt TDecCavlc::xGetBit() 1858 { 1859 UInt ruiCode; 1860 m_pcBitstream->read( 1, ruiCode ); 1861 return ruiCode; 1862 } 1863 1864 1773 1865 /** parse explicit wp tables 1774 1866 * \param TComSlice* pcSlice … … 1787 1879 // decode delta_luma_log2_weight_denom : 1788 1880 READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom 1789 assert( uiLog2WeightDenomLuma <= 7 );1790 1881 if( bChroma ) 1791 1882 { 1792 1883 READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom 1793 1884 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); 1794 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7);1795 1885 uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); 1796 1886 } … … 1831 1921 Int iDeltaWeight; 1832 1922 READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] 1833 assert( iDeltaWeight >= -128 );1834 assert( iDeltaWeight <= 127 );1835 1923 wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); 1836 1924 READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] 1837 assert( wp[0].iOffset >= -128 );1838 assert( wp[0].iOffset <= 127 );1839 1925 } 1840 1926 else … … 1851 1937 Int iDeltaWeight; 1852 1938 READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] 1853 assert( iDeltaWeight >= -128 );1854 assert( iDeltaWeight <= 127 );1855 1939 wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); 1856 1940 1857 1941 Int iDeltaChroma; 1858 1942 READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] 1859 assert( iDeltaChroma >= -512 );1860 assert( iDeltaChroma <= 511 );1861 1943 Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 1862 1944 wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) );
Note: See TracChangeset for help on using the changeset viewer.