Ticket #1070: lf_fix.patch
File lf_fix.patch, 14.0 KB (added by pieterkapsenberg, 11 years ago) |
---|
-
App/TAppDecoder/TAppDecTop.cpp
126 126 127 127 // call actual decoding function 128 128 Bool bNewPicture = false; 129 Bool bPicComplete = false; 129 130 if (nalUnit.empty()) 130 131 { 131 132 /* this can happen if the following occur: … … 152 153 } 153 154 else 154 155 { 155 bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay); 156 bNewPicture = m_cTDecTop.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay, bPicComplete); 157 if(bPicComplete) 158 { 159 m_cTDecTop.executeLoopFilters(poc, pcListPic); 160 } 156 161 if (bNewPicture) 157 162 { 158 163 bitstreamFile.clear(); … … 166 171 bPreviousPictureDecoded = true; 167 172 } 168 173 } 169 if (bNewPicture || !bitstreamFile)170 {171 m_cTDecTop.executeLoopFilters(poc, pcListPic);172 }173 174 174 if( pcListPic ) 175 175 { 176 176 if ( m_pchReconFile && !recon_opened ) -
Lib/TLibDecoder/TDecGop.cpp
40 40 #include "TDecSbac.h" 41 41 #include "TDecBinCoder.h" 42 42 #include "TDecBinCoderCABAC.h" 43 #include "libmd5/MD5.h"44 #include "TLibCommon/SEI.h"45 43 46 44 #include <time.h> 47 45 48 extern Bool g_md5_mismatch; ///< top level flag to signal when there is a decode problem49 50 46 //! \ingroup TLibDecoder 51 47 //! \{ 52 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI); 48 53 49 // ==================================================================================================================== 54 50 // Constructor / destructor / initialization / destroy 55 51 // ==================================================================================================================== … … 102 98 // Public member functions 103 99 // ==================================================================================================================== 104 100 105 Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic*& rpcPic )101 Void TDecGop::decompressSlice(TComInputBitstream* pcBitstream, TComPic*& rpcPic, Bool& bPicComplete) 106 102 { 107 103 TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx()); 108 104 // Table of extracted substreams. … … 152 148 m_LFCrossSliceBoundaryFlag.push_back( pcSlice->getLFCrossSliceBoundaryFlag()); 153 149 } 154 150 m_pcSbacDecoders[0].load(m_pcSbacDecoder); 155 m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders );151 m_pcSliceDecoder->decompressSlice( ppcSubstreams, rpcPic, m_pcSbacDecoder, m_pcSbacDecoders, bPicComplete); 156 152 m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiNumSubstreams-1] ); 157 153 // deallocate all created substreams, including internal buffers. 158 154 for (UInt ui = 0; ui < uiNumSubstreams; ui++) … … 227 223 } 228 224 printf ("] "); 229 225 } 230 if (m_decodedPictureHashSEIEnabled)231 {232 SEIMessages pictureHashes = getSeisByType(rpcPic->getSEIs(), SEI::DECODED_PICTURE_HASH );233 const SEIDecodedPictureHash *hash = ( pictureHashes.size() > 0 ) ? (SEIDecodedPictureHash*) *(pictureHashes.begin()) : NULL;234 if (pictureHashes.size() > 1)235 {236 printf ("Warning: Got multiple decoded picture hash SEI messages. Using first.");237 }238 calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash);239 }240 226 241 227 rpcPic->setOutputMark(true); 242 228 rpcPic->setReconMark(true); … … 244 230 m_LFCrossSliceBoundaryFlag.clear(); 245 231 } 246 232 247 /**248 * Calculate and print hash for pic, compare to picture_digest SEI if249 * present in seis. seis may be NULL. Hash is printed to stdout, in250 * a manner suitable for the status line. Theformat is:251 * [Hash_type:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,(yyy)]252 * Where, x..x is the hash253 * yyy has the following meanings:254 * OK - calculated hash matches the SEI message255 * ***ERROR*** - calculated hash does not match the SEI message256 * unk - no SEI message was available for comparison257 */258 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI)259 {260 /* calculate MD5sum for entire reconstructed picture */261 UChar recon_digest[3][16];262 Int numChar=0;263 const Char* hashType = "\0";264 233 265 if (pictureHashSEI)266 {267 switch (pictureHashSEI->method)268 {269 case SEIDecodedPictureHash::MD5:270 {271 hashType = "MD5";272 calcMD5(pic, recon_digest);273 numChar = 16;274 break;275 }276 case SEIDecodedPictureHash::CRC:277 {278 hashType = "CRC";279 calcCRC(pic, recon_digest);280 numChar = 2;281 break;282 }283 case SEIDecodedPictureHash::CHECKSUM:284 {285 hashType = "Checksum";286 calcChecksum(pic, recon_digest);287 numChar = 4;288 break;289 }290 default:291 {292 assert (!"unknown hash type");293 }294 }295 }296 297 /* compare digest against received version */298 const Char* ok = "(unk)";299 Bool mismatch = false;300 301 if (pictureHashSEI)302 {303 ok = "(OK)";304 for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++)305 {306 for (UInt i = 0; i < numChar; i++)307 {308 if (recon_digest[yuvIdx][i] != pictureHashSEI->digest[yuvIdx][i])309 {310 ok = "(***ERROR***)";311 mismatch = true;312 }313 }314 }315 }316 317 printf("[%s:%s,%s] ", hashType, digestToString(recon_digest, numChar), ok);318 319 if (mismatch)320 {321 g_md5_mismatch = true;322 printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI->digest, numChar));323 }324 }325 234 //! \} -
Lib/TLibDecoder/TDecGop.h
80 80 81 81 TComSampleAdaptiveOffset* m_pcSAO; 82 82 Double m_dDecTime; 83 Int m_decodedPictureHashSEIEnabled; ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message84 83 85 84 //! list that contains the CU address of each slice plus the end address 86 85 std::vector<Int> m_sliceStartCUAddress; … … 100 99 ); 101 100 Void create (); 102 101 Void destroy (); 103 Void decompressSlice(TComInputBitstream* pcBitstream, TComPic*& rpcPic 102 Void decompressSlice(TComInputBitstream* pcBitstream, TComPic*& rpcPic, Bool &bPicComplete); 104 103 Void filterPicture (TComPic*& rpcPic ); 105 104 106 void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; }107 105 108 106 }; 109 107 -
Lib/TLibDecoder/TDecSlice.cpp
105 105 m_pcCuDecoder = pcCuDecoder; 106 106 } 107 107 108 Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders )108 Void TDecSlice::decompressSlice(TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders, Bool& bPicComplete) 109 109 { 110 110 TComDataCU* pcCU; 111 111 UInt uiIsLast = 0; … … 381 381 CTXMem[0]->loadContexts( pcSbacDecoder );//ctx end of dep.slice 382 382 return; 383 383 } 384 bPicComplete = iCUAddr == (rpcPic->getNumCUsInFrame()-1); 384 385 } 385 386 } 386 387 -
Lib/TLibDecoder/TDecSlice.h
80 80 Void create (); 81 81 Void destroy (); 82 82 83 Void decompressSlice ( TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders );83 Void decompressSlice ( TComInputBitstream** ppcSubstreams, TComPic*& rpcPic, TDecSbac* pcSbacDecoder, TDecSbac* pcSbacDecoders, Bool& bPicComplete ); 84 84 Void initCtxMem( UInt i ); 85 85 Void setCtxMem( TDecSbac* sb, Int b ) { CTXMem[b] = sb; } 86 86 }; -
Lib/TLibDecoder/TDecTop.cpp
37 37 38 38 #include "NALread.h" 39 39 #include "TDecTop.h" 40 #include "libmd5/MD5.h" 41 #include "TLibCommon/SEI.h" 40 42 41 43 //! \ingroup TLibDecoder 44 extern Bool g_md5_mismatch; ///< top level flag to signal when there is a decode problem 45 46 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI); 47 42 48 //! \{ 43 49 44 50 TDecTop::TDecTop() … … 282 288 m_cLoopFilter. create( g_uiMaxCUDepth ); 283 289 } 284 290 285 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay )291 Bool TDecTop::xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool &bPicComplete ) 286 292 { 287 293 TComPic*& pcPic = m_pcPic; 288 294 m_apcSlicePilot->initSlice(); … … 570 576 } 571 577 572 578 // Decode a picture 573 m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic );574 579 m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic, bPicComplete); 580 575 581 m_bFirstSliceInPicture = false; 576 582 m_uiSliceIdx++; 577 583 … … 618 624 if(nalUnitType == NAL_UNIT_SEI_SUFFIX) 619 625 { 620 626 m_seiReader.parseSEImessage( bs, m_pcPic->getSEIs(), nalUnitType, m_parameterSetManagerDecoder.getActiveSPS() ); 627 if (m_decodedPictureHashSEIEnabled) 628 { 629 SEIMessages pictureHashes = getSeisByType(m_pcPic->getSEIs(), SEI::DECODED_PICTURE_HASH ); 630 const SEIDecodedPictureHash *hash = ( pictureHashes.size() > 0 ) ? (SEIDecodedPictureHash*) *(pictureHashes.begin()) : NULL; 631 if (pictureHashes.size() > 1) 632 { 633 printf ("Warning: Got multiple decoded picture hash SEI messages. Using first."); 634 } 635 calcAndPrintHashStatus(*m_pcPic->getPicYuvRec(), hash); 636 } 621 637 } 622 638 else 623 639 { … … 636 652 } 637 653 } 638 654 639 Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay )655 Bool TDecTop::decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool& bPicComplete) 640 656 { 641 657 // Initialize entropy decoder 642 658 m_cEntropyDecoder.setEntropyDecoder (&m_cCavlcDecoder); … … 677 693 case NAL_UNIT_CODED_SLICE_DLP: 678 694 case NAL_UNIT_CODED_SLICE_RASL_N: 679 695 case NAL_UNIT_CODED_SLICE_TFD: 680 return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay );696 return xDecodeSlice(nalu, iSkipFrame, iPOCLastDisplay, bPicComplete); 681 697 break; 682 698 default: 683 699 assert (1); … … 757 773 return false; 758 774 } 759 775 776 /** 777 * Calculate and print hash for pic, compare to picture_digest SEI if 778 * present in seis. seis may be NULL. Hash is printed to stdout, in 779 * a manner suitable for the status line. Theformat is: 780 * [Hash_type:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,(yyy)] 781 * Where, x..x is the hash 782 * yyy has the following meanings: 783 * OK - calculated hash matches the SEI message 784 * ***ERROR*** - calculated hash does not match the SEI message 785 * unk - no SEI message was available for comparison 786 */ 787 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI) 788 { 789 /* calculate MD5sum for entire reconstructed picture */ 790 UChar recon_digest[3][16]; 791 Int numChar=0; 792 const Char* hashType = "\0"; 793 794 if (pictureHashSEI) 795 { 796 switch (pictureHashSEI->method) 797 { 798 case SEIDecodedPictureHash::MD5: 799 { 800 hashType = "MD5"; 801 calcMD5(pic, recon_digest); 802 numChar = 16; 803 break; 804 } 805 case SEIDecodedPictureHash::CRC: 806 { 807 hashType = "CRC"; 808 calcCRC(pic, recon_digest); 809 numChar = 2; 810 break; 811 } 812 case SEIDecodedPictureHash::CHECKSUM: 813 { 814 hashType = "Checksum"; 815 calcChecksum(pic, recon_digest); 816 numChar = 4; 817 break; 818 } 819 default: 820 { 821 assert (!"unknown hash type"); 822 } 823 } 824 } 825 826 /* compare digest against received version */ 827 const Char* ok = "(unk)"; 828 Bool mismatch = false; 829 830 if (pictureHashSEI) 831 { 832 ok = "(OK)"; 833 for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) 834 { 835 for (UInt i = 0; i < numChar; i++) 836 { 837 if (recon_digest[yuvIdx][i] != pictureHashSEI->digest[yuvIdx][i]) 838 { 839 ok = "(***ERROR***)"; 840 mismatch = true; 841 } 842 } 843 } 844 } 845 846 printf("[%s:%s,%s] ", hashType, digestToString(recon_digest, numChar), ok); 847 848 if (mismatch) 849 { 850 g_md5_mismatch = true; 851 printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI->digest, numChar)); 852 } 853 } 854 760 855 //! \} -
Lib/TLibDecoder/TDecTop.h
97 97 Int m_prevPOC; 98 98 Bool m_bFirstSliceInPicture; 99 99 Bool m_bFirstSliceInSequence; 100 Int m_decodedPictureHashSEIEnabled; ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message 100 101 101 102 public: 102 103 TDecTop(); … … 105 106 Void create (); 106 107 Void destroy (); 107 108 108 void setDecodedPictureHashSEIEnabled(Int enabled) { m_ cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }109 void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; } 109 110 110 111 Void init(); 111 Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay );112 Bool decode(InputNALUnit& nalu, Int& iSkipFrame, Int& iPOCLastDisplay, Bool &bPicComplete); 112 113 113 114 Void deletePicBuffer(); 114 115 … … 119 120 Void xCreateLostPicture (Int iLostPOC); 120 121 121 122 Void xActivateParameterSets(); 122 Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay );123 Bool xDecodeSlice(InputNALUnit &nalu, Int &iSkipFrame, Int iPOCLastDisplay, Bool &bPicComplete); 123 124 Void xDecodeVPS(); 124 125 Void xDecodeSPS(); 125 126 Void xDecodePPS();