From 8bf04c28447b0f2b7b972bd733f83ea04cac28e5 Mon Sep 17 00:00:00 2001 From: Brian Heng <brian.heng@broadcom.com> Date: Mon, 16 Nov 2020 17:00:30 -0800 Subject: [PATCH] Update output YUV shift if the bitdepth changes between two sequences. --- source/App/DecoderApp/DecApp.cpp | 11 +++++++++++ source/Lib/Utilities/VideoIOYuv.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp index e2fa972b0d..85f63bb0f7 100644 --- a/source/App/DecoderApp/DecApp.cpp +++ b/source/App/DecoderApp/DecApp.cpp @@ -325,6 +325,17 @@ uint32_t DecApp::decode() m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].open( reconFileName, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode } } + // update file bitdepth shift if recon bitdepth changed between sequences + for( uint32_t channelType = 0; channelType < MAX_NUM_CHANNEL_TYPE; channelType++ ) + { + int reconBitdepth = pcListPic->front()->cs->sps->getBitDepth((ChannelType)channelType); + int fileBitdepth = m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].getFileBitdepth(channelType); + int bitdepthShift = m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].getBitdepthShift(channelType); + if( fileBitdepth + bitdepthShift != reconBitdepth ) + { + m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].setBitdepthShift(channelType, reconBitdepth - fileBitdepth); + } + } // write reconstruction to file if( bNewPicture ) { diff --git a/source/Lib/Utilities/VideoIOYuv.h b/source/Lib/Utilities/VideoIOYuv.h index 52656b5f18..bf2c470560 100644 --- a/source/Lib/Utilities/VideoIOYuv.h +++ b/source/Lib/Utilities/VideoIOYuv.h @@ -96,6 +96,9 @@ public: bool isEof (); ///< check for end-of-file bool isFail(); ///< check for failure bool isOpen() { return m_cHandle.is_open(); } + void setBitdepthShift( int ch, int bd ) { m_bitdepthShift[ch] = bd; } + int getBitdepthShift( int ch ) { return m_bitdepthShift[ch]; } + int getFileBitdepth( int ch ) { return m_fileBitdepth[ch]; } bool writeUpscaledPicture( const SPS& sps, const PPS& pps, const CPelUnitBuf& pic, const InputColourSpaceConversion ipCSC, const bool bPackedYUVOutputMode, int outputChoice = 0, ChromaFormat format = NUM_CHROMA_FORMAT, const bool bClipToRec709 = false ); ///< write one upsaled YUV frame -- GitLab