Ticket #1126: Suggested_fix_for_#1126.patch
File Suggested_fix_for_#1126.patch, 14.2 KB (added by rickard, 10 years ago) |
---|
-
source/Lib/TLibCommon/TComSlice.cpp
519 519 } 520 520 } 521 521 522 Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic)522 Void TComSlice::checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic) 523 523 { 524 524 for(Int i = 0; i < pReferencePictureSet->getNumberOfNegativePictures()+pReferencePictureSet->getNumberOfPositivePictures(); i++) 525 525 { … … 545 545 if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) // IDR picture found 546 546 { 547 547 pocCRA = getPOC(); 548 prevRAPisBLA = false;548 associatedIRAPType = getNalUnitType(); 549 549 } 550 550 else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) // CRA picture found 551 551 { 552 552 pocCRA = getPOC(); 553 prevRAPisBLA = false;553 associatedIRAPType = getNalUnitType(); 554 554 } 555 555 else if ( getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 556 556 || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 557 557 || getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) // BLA picture found 558 558 { 559 559 pocCRA = getPOC(); 560 prevRAPisBLA = true;560 associatedIRAPType = getNalUnitType(); 561 561 } 562 562 } 563 563 … … 795 795 return true; 796 796 } 797 797 798 799 Void TComSlice::checkLeadingPictureRestrictions(TComList<TComPic*>& rcListPic) 800 { 801 TComPic* rpcPic; 802 803 Int nalUnitType = this->getNalUnitType(); 804 805 // When a picture is a leading picture, it shall be a RADL or RASL picture. 806 if(this->getAssociatedIRAPPOC() > this->getPOC()) 807 { 808 // Do not check IRAP pictures since they may get a POC lower than their associated IRAP 809 if(nalUnitType < NAL_UNIT_CODED_SLICE_BLA_W_LP || 810 nalUnitType > NAL_UNIT_RESERVED_IRAP_VCL23) 811 { 812 assert(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 813 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || 814 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 815 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R); 816 } 817 } 818 819 // When a picture is a trailing picture, it shall not be a RADL or RASL picture. 820 if(this->getAssociatedIRAPPOC() < this->getPOC()) 821 { 822 assert(nalUnitType != NAL_UNIT_CODED_SLICE_RASL_N && 823 nalUnitType != NAL_UNIT_CODED_SLICE_RASL_R && 824 nalUnitType != NAL_UNIT_CODED_SLICE_RADL_N && 825 nalUnitType != NAL_UNIT_CODED_SLICE_RADL_R); 826 } 827 828 // No RASL pictures shall be present in the bitstream that are associated 829 // with a BLA picture having nal_unit_type equal to BLA_W_RADL or BLA_N_LP. 830 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 831 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 832 { 833 assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_W_RADL && 834 this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP); 835 } 836 837 // No RASL pictures shall be present in the bitstream that are associated with 838 // an IDR picture. 839 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 840 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 841 { 842 assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP && 843 this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL); 844 } 845 846 // No RADL pictures shall be present in the bitstream that are associated with 847 // a BLA picture having nal_unit_type equal to BLA_N_LP or that are associated 848 // with an IDR picture having nal_unit_type equal to IDR_N_LP. 849 if(nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 850 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) 851 { 852 assert(this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_BLA_N_LP && 853 this->getAssociatedIRAPType() != NAL_UNIT_CODED_SLICE_IDR_N_LP); 854 } 855 856 // loop through all pictures in the reference picture buffer 857 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 858 while ( iterPic != rcListPic.end()) 859 { 860 rpcPic = *(iterPic++); 861 862 // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture 863 // in decoding order shall precede the IRAP picture in output order. 864 // (Note that any picture following in output order would be present in the DPB) 865 if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) 866 { 867 if(nalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP || 868 nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP || 869 nalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL || 870 nalUnitType == NAL_UNIT_CODED_SLICE_CRA || 871 nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP || 872 nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) 873 { 874 assert(rpcPic->getPOC() < this->getPOC()); 875 } 876 } 877 878 // Any picture that has PicOutputFlag equal to 1 that precedes an IRAP picture 879 // in decoding order shall precede any RADL picture associated with the IRAP 880 // picture in output order. 881 if(rpcPic->getSlice(0)->getPicOutputFlag() == 1) 882 { 883 if((nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 884 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R)) 885 { 886 // rpcPic precedes the IRAP in decoding order 887 if(this->getAssociatedIRAPPOC() > rpcPic->getSlice(0)->getAssociatedIRAPPOC()) 888 { 889 // rpcPic must not be the IRAP picture 890 if(this->getAssociatedIRAPPOC() != rpcPic->getPOC()) 891 { 892 assert(rpcPic->getPOC() < this->getPOC()); 893 } 894 } 895 } 896 } 897 898 // When a picture is a leading picture, it shall precede, in decoding order, 899 // all trailing pictures that are associated with the same IRAP picture. 900 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 901 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R || 902 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_N || 903 nalUnitType == NAL_UNIT_CODED_SLICE_RADL_R) 904 { 905 if(rpcPic->getSlice(0)->getAssociatedIRAPPOC() == this->getAssociatedIRAPPOC()) 906 { 907 // rpcPic is a picture that preceded the leading in decoding order since it exist in the DPB 908 // rpcPic would violate the constraint if it was a trailing picture 909 assert(rpcPic->getPOC() <= this->getAssociatedIRAPPOC()); 910 } 911 } 912 913 // Any RASL picture associated with a CRA or BLA picture shall precede any 914 // RADL picture associated with the CRA or BLA picture in output order 915 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 916 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 917 { 918 if((this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || 919 this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || 920 this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || 921 this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) && 922 this->getAssociatedIRAPPOC() == rpcPic->getSlice(0)->getAssociatedIRAPPOC()) 923 { 924 if(rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N || 925 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R) 926 { 927 assert(rpcPic->getPOC() > this->getPOC()); 928 } 929 } 930 } 931 932 // Any RASL picture associated with a CRA picture shall follow, in output 933 // order, any IRAP picture that precedes the CRA picture in decoding order. 934 if(nalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || 935 nalUnitType == NAL_UNIT_CODED_SLICE_RASL_R) 936 { 937 if(this->getAssociatedIRAPType() == NAL_UNIT_CODED_SLICE_CRA) 938 { 939 if(rpcPic->getSlice(0)->getPOC() < this->getAssociatedIRAPPOC() && 940 (rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP || 941 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP || 942 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL || 943 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || 944 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || 945 rpcPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) 946 { 947 assert(this->getPOC() > rpcPic->getSlice(0)->getPOC()); 948 } 949 } 950 } 951 } 952 } 953 954 955 798 956 /** Function for applying picture marking based on the Reference Picture Set in pReferencePictureSet. 799 957 */ 800 958 Void TComSlice::applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *pReferencePictureSet) … … 802 960 TComPic* rpcPic; 803 961 Int i, isReference; 804 962 963 checkLeadingPictureRestrictions(rcListPic); 964 805 965 // loop through all pictures in the reference picture buffer 806 966 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 807 967 while ( iterPic != rcListPic.end()) -
source/Lib/TLibCommon/TComSlice.h
1117 1117 Bool m_PicOutputFlag; ///< pic_output_flag 1118 1118 Int m_iPOC; 1119 1119 Int m_iLastIDR; 1120 Int m_iAssociatedIRAP; 1121 NalUnitType m_iAssociatedIRAPType; 1120 1122 static Int m_prevTid0POC; 1121 1123 TComReferencePictureSet *m_pcRPS; 1122 1124 TComReferencePictureSet m_LocalRPS; … … 1242 1244 TComRefPicListModification* getRefPicListModification() { return &m_RefPicListModification; } 1243 1245 Void setLastIDR(Int iIDRPOC) { m_iLastIDR = iIDRPOC; } 1244 1246 Int getLastIDR() { return m_iLastIDR; } 1247 Void setAssociatedIRAPPOC(Int iAssociatedIRAPPOC) { m_iAssociatedIRAP = iAssociatedIRAPPOC; } 1248 Int getAssociatedIRAPPOC() { return m_iAssociatedIRAP; } 1249 Void setAssociatedIRAPType(NalUnitType associatedIRAPType) { m_iAssociatedIRAPType = associatedIRAPType; } 1250 NalUnitType getAssociatedIRAPType() { return m_iAssociatedIRAPType; } 1245 1251 SliceType getSliceType () { return m_eSliceType; } 1246 1252 Int getPOC () { return m_iPOC; } 1247 1253 Int getSliceQp () { return m_iSliceQp; } … … 1280 1286 Bool getRapPicFlag (); 1281 1287 Bool getIdrPicFlag () { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; } 1282 1288 Bool isIRAP () const { return (getNalUnitType() >= 16) && (getNalUnitType() <= 23); } 1283 Void checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, Bool& prevRAPisBLA, TComList<TComPic *>& rcListPic);1289 Void checkCRA(TComReferencePictureSet *pReferencePictureSet, Int& pocCRA, NalUnitType& associatedIRAPType, TComList<TComPic *>& rcListPic); 1284 1290 Void decodingRefreshMarking(Int& pocCRA, Bool& bRefreshPending, TComList<TComPic*>& rcListPic); 1285 1291 Void setSliceType ( SliceType e ) { m_eSliceType = e; } 1286 1292 Void setSliceQp ( Int i ) { m_iSliceQp = i; } … … 1345 1351 1346 1352 Void setTLayerInfo( UInt uiTLayer ); 1347 1353 Void decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum ); 1354 Void checkLeadingPictureRestrictions( TComList<TComPic*>& rcListPic ); 1348 1355 Void applyReferencePictureSet( TComList<TComPic*>& rcListPic, TComReferencePictureSet *RPSList); 1349 1356 Bool isTemporalLayerSwitchingPoint( TComList<TComPic*>& rcListPic ); 1350 1357 Bool isStepwiseTemporalLayerSwitchingPointCandidate( TComList<TComPic*>& rcListPic ); -
source/Lib/TLibDecoder/TDecTop.cpp
50 50 g_bJustDoIt = g_bEncDecTraceDisable; 51 51 g_nSymbolCounter = 0; 52 52 #endif 53 m_associatedIRAPType = NAL_UNIT_INVALID; 53 54 m_pocCRA = 0; 54 m_prevRAPisBLA = false;55 55 m_pocRandomAccess = MAX_INT; 56 56 m_prevPOC = MAX_INT; 57 57 m_bFirstSliceInPicture = true; … … 334 334 335 335 m_cEntropyDecoder.decodeSliceHeader (m_apcSlicePilot, &m_parameterSetManagerDecoder); 336 336 337 m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); 338 m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); 339 337 340 // Skip pictures due to random access 338 341 if (isRandomAccessSkipPicture(iSkipFrame, iPOCLastDisplay)) 339 342 { … … 512 515 513 516 if (bNextSlice) 514 517 { 515 pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_ prevRAPisBLA, m_cListPic );518 pcSlice->checkCRA(pcSlice->getRPS(), m_pocCRA, m_associatedIRAPType, m_cListPic ); 516 519 // Set reference list 517 520 #if FIX1071 518 521 pcSlice->setRefPicList( m_cListPic, true ); … … 697 700 */ 698 701 Bool TDecTop::isSkipPictureForBLA(Int& iPOCLastDisplay) 699 702 { 700 if (m_prevRAPisBLA && m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) 703 if ((m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_N_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_LP || m_associatedIRAPType == NAL_UNIT_CODED_SLICE_BLA_W_RADL) && 704 m_apcSlicePilot->getPOC() < m_pocCRA && (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)) 701 705 { 702 706 iPOCLastDisplay++; 703 707 return true; -
source/Lib/TLibDecoder/TDecTop.h
66 66 private: 67 67 Int m_iMaxRefPicNum; 68 68 69 NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture 69 70 Int m_pocCRA; ///< POC number of the latest CRA picture 70 Bool m_prevRAPisBLA; ///< true if the previous RAP (CRA/CRANT/BLA/BLANT/IDR) picture is a BLA/BLANT picture71 71 Int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) 72 72 73 73 TComList<TComPic*> m_cListPic; // Dynamic buffer