Changeset 1199 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibEncoder
- Timestamp:
- 8 Jul 2015, 20:02:01 (10 years ago)
- Location:
- branches/SHM-dev/source/Lib/TLibEncoder
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibEncoder/TEncCavlc.cpp
r1198 r1199 1844 1844 { 1845 1845 // Derive the value of PocMsbValRequiredFlag 1846 #if P0297_VPS_POC_LSB_ALIGNED_FLAG1847 1846 slice->setPocMsbValRequiredFlag( (slice->getCraPicFlag() || slice->getBlaPicFlag()) 1848 1847 && (!slice->getVPS()->getVpsPocLsbAlignedFlag() || 1849 1848 (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0)) 1850 1849 ); 1851 #else1852 slice->setPocMsbValRequiredFlag( slice->getCraPicFlag() || slice->getBlaPicFlag() );1853 #endif1854 1850 1855 1851 // Determine value of SH extension length. … … 1868 1864 } 1869 1865 1870 1871 #if P0297_VPS_POC_LSB_ALIGNED_FLAG1872 1866 if (!slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag()) 1873 #else1874 if (!slice->getPocMsbValRequiredFlag() /* && vps_poc_lsb_aligned_flag */)1875 #endif1876 1867 { 1877 1868 shExtnLengthInBit++; … … 1889 1880 } 1890 1881 1891 #if P0297_VPS_POC_LSB_ALIGNED_FLAG1892 1882 if (slice->getPocMsbNeeded()) 1893 1883 { 1894 1884 slice->setPocMsbValPresentFlag(true); 1895 1885 } 1896 #endif1897 1886 1898 1887 if (slice->getPocMsbValPresentFlag()) … … 1930 1919 } 1931 1920 1932 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1933 if (!slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag()) 1934 #else 1935 if (!slice->getPocMsbValRequiredFlag() /* && vps_poc_lsb_aligned_flag */) 1936 #endif 1937 { 1938 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1921 if( !slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag() ) 1922 { 1939 1923 WRITE_FLAG( slice->getPocMsbValPresentFlag(), "poc_msb_cycle_val_present_flag" ); 1940 #else 1941 WRITE_FLAG( slice->getPocMsbValPresentFlag(), "poc_msb_val_present_flag" ); 1942 #endif 1943 } 1944 if (slice->getPocMsbValPresentFlag()) 1924 } 1925 1926 if( slice->getPocMsbValPresentFlag() ) 1945 1927 { 1946 1928 assert(slice->getPocMsbVal() % maxPocLsb == 0); 1947 #if P0297_VPS_POC_LSB_ALIGNED_FLAG1948 1929 WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_cycle_val"); 1949 #else 1950 WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_val"); 1951 #endif 1952 } 1930 } 1931 1953 1932 for (Int i = 0; i < shExtnAdditionalBits; i++) 1954 1933 { … … 1956 1935 } 1957 1936 } 1937 1958 1938 shBitsWrittenTillNow += ( getNumberOfWrittenBits() - tmpBitsBeforeWriting ); 1959 1939 … … 2189 2169 2190 2170 WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag"); 2191 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2171 2192 2172 WRITE_FLAG(vps->getVpsPocLsbAlignedFlag(), "vps_poc_lsb_aligned_flag"); 2193 #endif2194 2173 2195 2174 for( i = 1; i< vps->getMaxLayers(); i++ ) -
branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp
r1185 r1199 49 49 #include <time.h> 50 50 #include <math.h> 51 #if P0297_VPS_POC_LSB_ALIGNED_FLAG51 #if SVC_EXTENSION 52 52 #include <limits.h> 53 53 #endif … … 1146 1146 determinePocResetIdc(pocCurr, pcSlice); 1147 1147 1148 #if P0297_VPS_POC_LSB_ALIGNED_FLAG1149 1148 Bool pocResettingFlag = false; 1150 1149 … … 1164 1163 } 1165 1164 } 1166 #endif1167 1165 1168 1166 // If reset, do the following steps: 1169 #if P0297_VPS_POC_LSB_ALIGNED_FLAG1170 1167 if( pocResettingFlag ) 1171 #else1172 if( pcSlice->getPocResetIdc() )1173 #endif1174 1168 { 1175 1169 updatePocValuesOfPics(pocCurr, pcSlice); … … 3457 3451 #if SVC_EXTENSION 3458 3452 pcPicYuvRecOut->setReconstructed(true); 3459 #endif3460 #if P0297_VPS_POC_LSB_ALIGNED_FLAG3461 3453 m_pcEncTop->setFirstPicInLayerDecodedFlag(true); 3462 3454 #endif 3455 3463 3456 pcPic->setReconMark ( true ); 3464 3457 m_bFirst = false; … … 4643 4636 #endif 4644 4637 4645 4646 4638 #if POC_RESET_IDC_ENCODER 4647 4639 Void TEncGOP::determinePocResetIdc(Int const pocCurr, TComSlice *const slice) … … 4650 4642 // If BL picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 2 4651 4643 // If BL picture is IRAP, and another picture is non-IRAP, then the poc_reset_idc is equal to 1 or 2. 4652 #if P0297_VPS_POC_LSB_ALIGNED_FLAG4653 4644 slice->setPocMsbNeeded(false); 4654 #endif 4645 4655 4646 if( slice->getSliceIdx() == 0 ) // First slice - compute, copy for other slices 4656 4647 { … … 4678 4669 } 4679 4670 } 4680 4671 4681 4672 if( !needReset )// No need reset due to base layer IRAP 4682 4673 { … … 4685 4676 { 4686 4677 Bool idrFlag = ( (m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshType() == 2) 4687 4688 4678 && ( pocCurr % m_ppcTEncTop[i]->getGOPEncoder()->getIntraRefreshInterval() == 0 ) 4679 ); 4689 4680 for(Int j = 0; j < slice->getVPS()->getMaxLayers(); j++) 4690 4681 { … … 4695 4686 4696 4687 Bool idrOtherPicFlag = ( (m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshType() == 2) 4697 4698 4688 && ( pocCurr % m_ppcTEncTop[j]->getGOPEncoder()->getIntraRefreshInterval() == 0 ) 4689 ); 4699 4690 4700 4691 if( idrFlag != idrOtherPicFlag ) … … 4713 4704 { 4714 4705 slice->setPocResetIdc( 2 ); // Full reset needed 4715 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4716 if (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0)4706 4707 if( slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0 ) 4717 4708 { 4718 4709 slice->setPocMsbNeeded(true); // Force msb writing 4719 4710 } 4720 #endif4721 4711 } 4722 4712 else … … 4736 4726 m_lastPocPeriodId = (periodId == m_lastPocPeriodId) ? (periodId + 1) % 64 : periodId ; 4737 4727 4738 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4739 for (UInt i = 0; i < MAX_LAYERS; i++) 4728 for( UInt i = 0; i < MAX_LAYERS; i++ ) 4740 4729 { 4741 4730 m_ppcTEncTop[i]->setPocDecrementedInDPBFlag(false); 4742 4731 } 4743 #endif4744 4732 } 4745 4733 else … … 4758 4746 Void TEncGOP::updatePocValuesOfPics(Int const pocCurr, TComSlice *const slice) 4759 4747 { 4760 #if P0297_VPS_POC_LSB_ALIGNED_FLAG4761 4748 UInt affectedLayerList[MAX_NUM_LAYER_IDS]; 4762 4749 Int numAffectedLayers; … … 4773 4760 numAffectedLayers = m_pcEncTop->getVPS()->getNumPredictedLayers(m_layerId) + 1; 4774 4761 } 4775 #endif4776 4762 4777 4763 Int pocAdjustValue = pocCurr - m_pcEncTop->getPocAdjustmentValue(); … … 4782 4768 maxPocLsb = 1 << slice->getSPS()->getBitsForPOC(); 4783 4769 4784 #if P0297_VPS_POC_LSB_ALIGNED_FLAG4785 4770 Int adjustedPocValue = pocCurr; 4786 4771 4787 4772 if (m_pcEncTop->getFirstPicInLayerDecodedFlag()) 4788 4773 { 4789 #endif 4790 4791 pocLsbVal = (slice->getPocResetIdc() == 3) 4792 ? slice->getPocLsbVal() 4793 : pocAdjustValue % maxPocLsb; 4794 pocMsbDelta = pocAdjustValue - pocLsbVal; 4795 pocLsbDelta = (slice->getPocResetIdc() == 2 || ( slice->getPocResetIdc() == 3 && slice->getFullPocResetFlag() )) 4796 ? pocLsbVal 4797 : 0; 4798 deltaPocVal = pocMsbDelta + pocLsbDelta; 4799 4800 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4801 Int origDeltaPocVal = deltaPocVal; // original value needed when updating POC adjustment value 4802 4803 if (slice->getPocMsbNeeded()) // IDR picture in base layer, non-IDR picture in other layers, poc_lsb_aligned_flag = 1 4804 { 4805 if (slice->getLayerId() == 0) 4806 { 4807 Int highestPoc = INT_MIN; 4808 // Find greatest POC in DPB for layer 0 4809 for (TComList<TComPic*>::iterator iterPic = m_pcEncTop->getListPic()->begin(); iterPic != m_pcEncTop->getListPic()->end(); ++iterPic) 4810 { 4811 TComPic *dpbPic = *iterPic; 4812 if (dpbPic->getReconMark() && dpbPic->getLayerId() == 0 && dpbPic->getPOC() > highestPoc) 4813 { 4814 highestPoc = dpbPic->getPOC(); 4815 } 4816 } 4817 deltaPocVal = (highestPoc - (highestPoc & (maxPocLsb - 1))) + 1*maxPocLsb; 4818 m_pcEncTop->setCurrPocMsb(deltaPocVal); 4819 } 4820 else 4821 { 4822 deltaPocVal = m_ppcTEncTop[0]->getCurrPocMsb(); // copy from base layer 4823 } 4824 slice->setPocMsbVal(deltaPocVal); 4825 } 4826 4827 for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++) 4828 { 4829 UInt lIdx = slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx]); 4830 4831 if (!m_ppcTEncTop[lIdx]->getPocDecrementedInDPBFlag()) 4832 { 4833 m_ppcTEncTop[lIdx]->setPocDecrementedInDPBFlag(true); 4834 4835 // Decrement value of associatedIrapPoc of the TEncGop object 4836 m_ppcTEncTop[lIdx]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal; 4837 4838 // Decrememnt the value of m_pocCRA 4839 m_ppcTEncTop[lIdx]->getGOPEncoder()->m_pocCRA -= deltaPocVal; 4840 4841 TComList<TComPic*>::iterator iterPic = m_ppcTEncTop[lIdx]->getListPic()->begin(); 4842 while (iterPic != m_ppcTEncTop[lIdx]->getListPic()->end()) 4843 #else 4844 // Decrement value of associatedIrapPoc of the TEncGop object 4845 this->m_associatedIRAPPOC -= deltaPocVal; 4846 4847 // Decrememnt the value of m_pocCRA 4848 this->m_pocCRA -= deltaPocVal; 4849 4850 // Iterate through all pictures in the DPB 4851 TComList<TComPic*>::iterator iterPic = getListPic()->begin(); 4852 while( iterPic != getListPic()->end() ) 4853 #endif 4854 { 4855 TComPic *dpbPic = *iterPic; 4856 4857 if( dpbPic->getReconMark() ) 4858 { 4859 for(Int i = dpbPic->getNumAllocatedSlice() - 1; i >= 0; i--) 4860 { 4861 TComSlice *dpbPicSlice = dpbPic->getSlice( i ); 4862 TComReferencePictureSet *dpbPicRps = dpbPicSlice->getRPS(); 4863 4864 // Decrement POC of slice 4865 dpbPicSlice->setPOC( dpbPicSlice->getPOC() - deltaPocVal ); 4866 4867 // Decrement POC value stored in the RPS of each such slice 4868 for( Int j = dpbPicRps->getNumberOfPictures() - 1; j >= 0; j-- ) 4869 { 4870 dpbPicRps->setPOC( j, dpbPicRps->getPOC(j) - deltaPocVal ); 4871 } 4872 4873 // Decrement value of refPOC 4874 dpbPicSlice->decrementRefPocValues( deltaPocVal ); 4875 4876 // Update value of associatedIrapPoc of each slice 4877 dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal ); 4878 4879 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4880 if (slice->getPocMsbNeeded()) 4881 { 4882 // this delta value is needed when computing delta POCs in reference picture set initialization 4883 dpbPicSlice->setPocResetDeltaPoc(dpbPicSlice->getPocResetDeltaPoc() + (deltaPocVal - pocLsbVal)); 4884 } 4885 #endif 4886 } 4887 } 4888 iterPic++; 4889 } 4890 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4891 } 4892 } 4893 #endif 4894 4895 // Actual POC value before reset 4896 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4897 adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue(); 4898 #else 4899 Int adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue(); 4900 #endif 4901 4902 // Set MSB value before reset 4903 Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1); 4904 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4905 if (!slice->getPocMsbNeeded()) // set poc msb normally if special msb handling is not needed 4906 { 4907 #endif 4908 slice->setPocMsbVal(adjustedPocValue - tempLsbVal); 4909 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4910 } 4911 #endif 4912 4913 // Set LSB value before reset - this is needed in the case of resetIdc = 2 4914 slice->setPicOrderCntLsb( tempLsbVal ); 4915 4916 // Cumulative delta 4917 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4918 deltaPocVal = origDeltaPocVal; // restore deltaPoc for correct adjustment value update 4919 #endif 4920 m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal ); 4921 4922 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 4923 } 4924 #endif 4774 pocLsbVal = (slice->getPocResetIdc() == 3) 4775 ? slice->getPocLsbVal() 4776 : pocAdjustValue % maxPocLsb; 4777 pocMsbDelta = pocAdjustValue - pocLsbVal; 4778 pocLsbDelta = (slice->getPocResetIdc() == 2 || ( slice->getPocResetIdc() == 3 && slice->getFullPocResetFlag() )) 4779 ? pocLsbVal 4780 : 0; 4781 deltaPocVal = pocMsbDelta + pocLsbDelta; 4782 4783 Int origDeltaPocVal = deltaPocVal; // original value needed when updating POC adjustment value 4784 4785 // IDR picture in base layer, non-IDR picture in other layers, poc_lsb_aligned_flag = 1 4786 if( slice->getPocMsbNeeded() ) 4787 { 4788 if (slice->getLayerId() == 0) 4789 { 4790 Int highestPoc = INT_MIN; 4791 4792 // Find greatest POC in DPB for layer 0 4793 for (TComList<TComPic*>::iterator iterPic = m_pcEncTop->getListPic()->begin(); iterPic != m_pcEncTop->getListPic()->end(); ++iterPic) 4794 { 4795 TComPic *dpbPic = *iterPic; 4796 if (dpbPic->getReconMark() && dpbPic->getLayerId() == 0 && dpbPic->getPOC() > highestPoc) 4797 { 4798 highestPoc = dpbPic->getPOC(); 4799 } 4800 } 4801 deltaPocVal = (highestPoc - (highestPoc & (maxPocLsb - 1))) + 1*maxPocLsb; 4802 m_pcEncTop->setCurrPocMsb(deltaPocVal); 4803 } 4804 else 4805 { 4806 deltaPocVal = m_ppcTEncTop[0]->getCurrPocMsb(); // copy from base layer 4807 } 4808 slice->setPocMsbVal(deltaPocVal); 4809 } 4810 4811 for( UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++ ) 4812 { 4813 UInt lIdx = slice->getVPS()->getLayerIdxInVps(affectedLayerList[layerIdx]); 4814 4815 if( !m_ppcTEncTop[lIdx]->getPocDecrementedInDPBFlag() ) 4816 { 4817 m_ppcTEncTop[lIdx]->setPocDecrementedInDPBFlag(true); 4818 4819 // Decrement value of associatedIrapPoc of the TEncGop object 4820 m_ppcTEncTop[lIdx]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal; 4821 4822 // Decrememnt the value of m_pocCRA 4823 m_ppcTEncTop[lIdx]->getGOPEncoder()->m_pocCRA -= deltaPocVal; 4824 4825 TComList<TComPic*>::iterator iterPic = m_ppcTEncTop[lIdx]->getListPic()->begin(); 4826 while (iterPic != m_ppcTEncTop[lIdx]->getListPic()->end()) 4827 { 4828 TComPic *dpbPic = *iterPic; 4829 4830 if( dpbPic->getReconMark() ) 4831 { 4832 for( Int i = dpbPic->getNumAllocatedSlice() - 1; i >= 0; i-- ) 4833 { 4834 TComSlice *dpbPicSlice = dpbPic->getSlice( i ); 4835 TComReferencePictureSet *dpbPicRps = dpbPicSlice->getRPS(); 4836 4837 // Decrement POC of slice 4838 dpbPicSlice->setPOC( dpbPicSlice->getPOC() - deltaPocVal ); 4839 4840 // Decrement POC value stored in the RPS of each such slice 4841 for( Int j = dpbPicRps->getNumberOfPictures() - 1; j >= 0; j-- ) 4842 { 4843 dpbPicRps->setPOC( j, dpbPicRps->getPOC(j) - deltaPocVal ); 4844 } 4845 4846 // Decrement value of refPOC 4847 dpbPicSlice->decrementRefPocValues( deltaPocVal ); 4848 4849 // Update value of associatedIrapPoc of each slice 4850 dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal ); 4851 4852 if( slice->getPocMsbNeeded() ) 4853 { 4854 // this delta value is needed when computing delta POCs in reference picture set initialization 4855 dpbPicSlice->setPocResetDeltaPoc(dpbPicSlice->getPocResetDeltaPoc() + (deltaPocVal - pocLsbVal)); 4856 } 4857 } 4858 } 4859 iterPic++; 4860 } 4861 } 4862 } 4863 4864 // Actual POC value before reset 4865 adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue(); 4866 4867 // Set MSB value before reset 4868 Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1); 4869 if (!slice->getPocMsbNeeded()) // set poc msb normally if special msb handling is not needed 4870 { 4871 slice->setPocMsbVal(adjustedPocValue - tempLsbVal); 4872 } 4873 4874 // Set LSB value before reset - this is needed in the case of resetIdc = 2 4875 slice->setPicOrderCntLsb( tempLsbVal ); 4876 4877 // Cumulative delta 4878 deltaPocVal = origDeltaPocVal; // restore deltaPoc for correct adjustment value update 4879 4880 m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal ); 4881 } 4925 4882 4926 4883 // New LSB value, after reset … … 4940 4897 { 4941 4898 Int picOrderCntMsb = slice->getCurrMsb( newLsbVal, 4942 4943 4944 4899 slice->getFullPocResetFlag() ? 0 : slice->getPocLsbVal(), 4900 0, 4901 maxPocLsb ); 4945 4902 slice->setPOC( picOrderCntMsb + newLsbVal ); 4946 4903 } … … 4951 4908 } 4952 4909 #endif 4953 4954 4910 4955 4911 #if O0164_MULTI_LAYER_HRD -
branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp
r1185 r1199 94 94 m_noOutputOfPriorPicsFlags = false; 95 95 #endif 96 #if P0297_VPS_POC_LSB_ALIGNED_FLAG97 96 m_pocDecrementedInDPBFlag = false; 98 #endif99 97 #endif //SVC_EXTENSION 100 98 } -
branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.h
r1172 r1199 148 148 #endif 149 149 Int m_numAddLayerSets; 150 #if P0297_VPS_POC_LSB_ALIGNED_FLAG151 150 Bool m_pocDecrementedInDPBFlag; 152 151 Int m_currPocMsb; 153 #endif154 152 Bool m_prevPicHasEos; 155 153 #endif //SVC_EXTENSION … … 270 268 Void setNumAddLayerSets(Int x) { m_numAddLayerSets = x; } 271 269 Int getNumAddLayerSets() { return m_numAddLayerSets; } 272 #if P0297_VPS_POC_LSB_ALIGNED_FLAG273 270 Void setPocDecrementedInDPBFlag(Bool x) { m_pocDecrementedInDPBFlag = x; } 274 271 Bool getPocDecrementedInDPBFlag() { return m_pocDecrementedInDPBFlag; } 275 272 Void setCurrPocMsb(Int poc) { m_currPocMsb = poc; } 276 273 Int getCurrPocMsb() { return m_currPocMsb; } 277 #endif278 274 #else //SVC_EXTENSION 279 275 Void encode( Bool bEos,
Note: See TracChangeset for help on using the changeset viewer.