From f911894aca41a178767289c108cda5500ed49d18 Mon Sep 17 00:00:00 2001 From: xlxiangli <xlxiangli@google.com> Date: Thu, 6 Oct 2022 23:20:14 +0000 Subject: [PATCH] Fix a Y4M bug (chroma scaling is not considered) --- source/App/DecoderApp/DecApp.cpp | 6 ++++-- source/App/EncoderApp/EncApp.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp index ae1d37e5e6..7892c5d0a2 100644 --- a/source/App/DecoderApp/DecApp.cpp +++ b/source/App/DecoderApp/DecApp.cpp @@ -457,8 +457,10 @@ uint32_t DecApp::decode() } const auto pps = pcListPic->front()->cs->pps; auto confWindow = pps->getConformanceWindow(); - const int picWidth = pps->getPicWidthInLumaSamples() - confWindow.getWindowLeftOffset() - confWindow.getWindowRightOffset(); - const int picHeight = pps->getPicHeightInLumaSamples() - confWindow.getWindowTopOffset() - confWindow.getWindowBottomOffset(); + const auto sx = SPS::getWinUnitX(sps->getChromaFormatIdc()); + const auto sy = SPS::getWinUnitY(sps->getChromaFormatIdc()); + const int picWidth = pps->getPicWidthInLumaSamples() - (confWindow.getWindowLeftOffset() + confWindow.getWindowRightOffset()) * sx; + const int picHeight = pps->getPicHeightInLumaSamples() - (confWindow.getWindowTopOffset() + confWindow.getWindowBottomOffset()) * sy; m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].setOutputY4mInfo(picWidth, picHeight, frameRate, frameScale, m_outputBitDepth[0], sps->getChromaFormatIdc()); } m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].open( reconFileName, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index e76a0cad6d..650b41827a 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -1432,8 +1432,10 @@ void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList, const int layerId ) } if (isY4mFileExt(reconFileName)) { - m_cVideoIOYuvReconFile.setOutputY4mInfo(m_sourceWidth - m_confWinLeft - m_confWinRight, - m_sourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate, 1, m_internalBitDepth[0], m_chromaFormatIDC); + const auto sx = SPS::getWinUnitX(m_chromaFormatIDC); + const auto sy = SPS::getWinUnitY(m_chromaFormatIDC); + m_cVideoIOYuvReconFile.setOutputY4mInfo(m_sourceWidth - (m_confWinLeft + m_confWinRight) * sx, + m_sourceHeight - (m_confWinTop + m_confWinBottom) * sy, m_iFrameRate, 1, m_internalBitDepth[0], m_chromaFormatIDC); } m_cVideoIOYuvReconFile.open( reconFileName, true, m_outputBitDepth, m_outputBitDepth, m_internalBitDepth ); // write mode } -- GitLab