diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 74aad147872caf65e666d98677df6e124bee6ed4..1a6768c438ee5dfc419927a45a6085572851ceaa 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -256,8 +256,8 @@ void EncApp::xInitLibCfg() m_cEncLib.setFrameRate ( m_iFrameRate ); m_cEncLib.setFrameSkip ( m_FrameSkip ); m_cEncLib.setTemporalSubsampleRatio ( m_temporalSubsampleRatio ); - m_cEncLib.setSourceWidth ( m_iSourceWidth ); - m_cEncLib.setSourceHeight ( m_iSourceHeight ); + m_cEncLib.setSourceWidth ( m_sourceWidth ); + m_cEncLib.setSourceHeight ( m_sourceHeight ); m_cEncLib.setConformanceWindow ( m_confWinLeft / SPS::getWinUnitX( m_InputChromaFormatIDC ), m_confWinRight / SPS::getWinUnitX( m_InputChromaFormatIDC ), m_confWinTop / SPS::getWinUnitY( m_InputChromaFormatIDC ), m_confWinBottom / SPS::getWinUnitY( m_InputChromaFormatIDC ) ); m_cEncLib.setScalingRatio ( m_scalingRatioHor, m_scalingRatioVer ); m_cEncLib.setRprEnabled (m_rprEnabledFlag); @@ -553,9 +553,9 @@ void EncApp::xInitLibCfg() m_cEncLib.setIntraQPOffset ( m_intraQPOffset ); m_cEncLib.setLambdaFromQPEnable ( m_lambdaFromQPEnable ); #endif - m_cEncLib.setChromaQpMappingTableParams (m_chromaQpMappingTableParams); + m_cEncLib.setChromaQpMappingTableParams (m_chromaQpMappingTableParams); - m_cEncLib.setPad ( m_aiPad ); + m_cEncLib.setSourcePadding ( m_sourcePadding ); m_cEncLib.setAccessUnitDelimiter ( m_AccessUnitDelimiter ); m_cEncLib.setEnablePictureHeaderInSliceHeader ( m_enablePictureHeaderInSliceHeader ); @@ -1108,18 +1108,18 @@ void EncApp::xCreateLib( std::list<PelUnitBuf*>& recBufList, const int layerId ) #if EXTENSION_360_VIDEO m_cVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC); #else - const int sourceHeight = m_isField ? m_iSourceHeightOrg : m_iSourceHeight; - m_cVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_iSourceWidth - m_aiPad[0], sourceHeight - m_aiPad[1], m_InputChromaFormatIDC); + const int sourceHeight = m_isField ? m_iSourceHeightOrg : m_sourceHeight; + m_cVideoIOYuvInputFile.skipFrames(m_FrameSkip, m_sourceWidth - m_sourcePadding[0], sourceHeight - m_sourcePadding[1], m_InputChromaFormatIDC); #endif if (!m_reconFileName.empty()) { if (m_packedYUVMode && ((m_outputBitDepth[CH_L] != 10 && m_outputBitDepth[CH_L] != 12) - || ((m_iSourceWidth & (1 + (m_outputBitDepth[CH_L] & 3))) != 0))) + || ((m_sourceWidth & (1 + (m_outputBitDepth[CH_L] & 3))) != 0))) { EXIT ("Invalid output bit-depth or image width for packed YUV output, aborting\n"); } if (m_packedYUVMode && (m_chromaFormatIDC != CHROMA_400) && ((m_outputBitDepth[CH_C] != 10 && m_outputBitDepth[CH_C] != 12) - || (((m_iSourceWidth / SPS::getWinUnitX (m_chromaFormatIDC)) & (1 + (m_outputBitDepth[CH_C] & 3))) != 0))) + || (((m_sourceWidth / SPS::getWinUnitX (m_chromaFormatIDC)) & (1 + (m_outputBitDepth[CH_C] & 3))) != 0))) { EXIT ("Invalid chroma output bit-depth or image width for packed YUV output, aborting\n"); } @@ -1171,8 +1171,8 @@ void EncApp::xInitLib() void EncApp::createLib( const int layerIdx ) { - const int sourceHeight = m_isField ? m_iSourceHeightOrg : m_iSourceHeight; - UnitArea unitArea( m_chromaFormatIDC, Area( 0, 0, m_iSourceWidth, sourceHeight ) ); + const int sourceHeight = m_isField ? m_iSourceHeightOrg : m_sourceHeight; + UnitArea unitArea( m_chromaFormatIDC, Area( 0, 0, m_sourceWidth, sourceHeight ) ); m_orgPic = new PelStorage; m_trueOrgPic = new PelStorage; @@ -1207,8 +1207,8 @@ void EncApp::createLib( const int layerIdx ) if( m_gopBasedTemporalFilterEnabled ) { - m_temporalFilter.init( m_FrameSkip, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth, m_iSourceWidth, sourceHeight, - m_aiPad, m_bClipInputVideoToRec709Range, m_inputFileName, m_chromaFormatIDC, + m_temporalFilter.init( m_FrameSkip, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth, m_sourceWidth, sourceHeight, + m_sourcePadding, m_bClipInputVideoToRec709Range, m_inputFileName, m_chromaFormatIDC, m_inputColourSpaceConvert, m_iQP, m_gopBasedTemporalFilterStrengths, m_gopBasedTemporalFilterFutureReference ); } @@ -1266,10 +1266,10 @@ bool EncApp::encodePrep( bool& eos ) } else { - m_cVideoIOYuvInputFile.read( *m_orgPic, *m_trueOrgPic, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range ); + m_cVideoIOYuvInputFile.read( *m_orgPic, *m_trueOrgPic, ipCSC, m_sourcePadding, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range ); } #else - m_cVideoIOYuvInputFile.read( *m_orgPic, *m_trueOrgPic, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range ); + m_cVideoIOYuvInputFile.read( *m_orgPic, *m_trueOrgPic, ipCSC, m_sourcePadding, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range ); #endif if( m_gopBasedTemporalFilterEnabled ) @@ -1340,8 +1340,8 @@ bool EncApp::encode() #if EXTENSION_360_VIDEO m_cVideoIOYuvInputFile.skipFrames( m_temporalSubsampleRatio - 1, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC ); #else - const int sourceHeight = m_isField ? m_iSourceHeightOrg : m_iSourceHeight; - m_cVideoIOYuvInputFile.skipFrames( m_temporalSubsampleRatio - 1, m_iSourceWidth - m_aiPad[0], sourceHeight - m_aiPad[1], m_InputChromaFormatIDC ); + const int sourceHeight = m_isField ? m_iSourceHeightOrg : m_sourceHeight; + m_cVideoIOYuvInputFile.skipFrames( m_temporalSubsampleRatio - 1, m_sourceWidth - m_sourcePadding[0], sourceHeight - m_sourcePadding[1], m_InputChromaFormatIDC ); #endif } } diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 1fc3b526fee3a1f793afa6c1eca7ad11b3b15233..411793a7f6c80a7860baee57b8d960efc719ce73 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -716,8 +716,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("InputPathPrefix,-ipp", inputPathPrefix, string(""), "pathname to prepend to input filename") ("BitstreamFile,b", m_bitstreamFileName, string(""), "Bitstream output file name") ("ReconFile,o", m_reconFileName, string(""), "Reconstructed YUV output file name") - ("SourceWidth,-wdt", m_iSourceWidth, 0, "Source picture width") - ("SourceHeight,-hgt", m_iSourceHeight, 0, "Source picture height") + ("SourceWidth,-wdt", m_sourceWidth, 0, "Source picture width") + ("SourceHeight,-hgt", m_sourceHeight, 0, "Source picture height") ("InputBitDepth", m_inputBitDepth[CHANNEL_TYPE_LUMA], 8, "Bit-depth of input file") ("OutputBitDepth", m_outputBitDepth[CHANNEL_TYPE_LUMA], 0, "Bit-depth of output file (default:InternalBitDepth)") ("MSBExtendedBitDepth", m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA], 0, "bit depth of luma component after addition of MSBs of value 0 (used for synthesising High Dynamic Range source material). (default:InputBitDepth)") @@ -739,14 +739,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("PrintWPSNR", m_printWPSNR, false, "0 (default) do not print HDR-PQ based wPSNR, 1 = print HDR-PQ based wPSNR") ("CabacZeroWordPaddingEnabled", m_cabacZeroWordPaddingEnabled, true, "0 do not add conforming cabac-zero-words to bit streams, 1 (default) = add cabac-zero-words as required") ("ChromaFormatIDC,-cf", tmpChromaFormat, 0, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)") - ("ConformanceMode", m_conformanceWindowMode, 0, "Deprecated alias of ConformanceWindowMode") - ("ConformanceWindowMode", m_conformanceWindowMode, 0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance") - ("HorizontalPadding,-pdx", m_aiPad[0], 0, "Horizontal source padding for conformance window mode 2") - ("VerticalPadding,-pdy", m_aiPad[1], 0, "Vertical source padding for conformance window mode 2") - ("ConfLeft", m_confWinLeft, 0, "Deprecated alias of ConfWinLeft") - ("ConfRight", m_confWinRight, 0, "Deprecated alias of ConfWinRight") - ("ConfTop", m_confWinTop, 0, "Deprecated alias of ConfWinTop") - ("ConfBottom", m_confWinBottom, 0, "Deprecated alias of ConfWinBottom") + ("ConformanceWindowMode", m_conformanceWindowMode, 0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding parameters specified, 3:conformance window parameters specified") + ("HorizontalPadding,-pdx", m_sourcePadding[0], 0, "Horizontal source padding for conformance window mode 2") + ("VerticalPadding,-pdy", m_sourcePadding[1], 0, "Vertical source padding for conformance window mode 2") ("ConfWinLeft", m_confWinLeft, 0, "Left offset for window conformance mode 3") ("ConfWinRight", m_confWinRight, 0, "Right offset for window conformance mode 3") ("ConfWinTop", m_confWinTop, 0, "Top offset for window conformance mode 3") @@ -1691,9 +1686,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) if(m_isField) { //Frame height - m_iSourceHeightOrg = m_iSourceHeight; + m_iSourceHeightOrg = m_sourceHeight; //Field height - m_iSourceHeight = m_iSourceHeight >> 1; + m_sourceHeight = m_sourceHeight >> 1; //number of fields to encode m_framesToBeEncoded *= 2; } @@ -1733,8 +1728,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) m_subPicId[i] = cfg_subPicId.values[i]; } } - uint32_t tmpWidthVal = (m_iSourceWidth + m_uiCTUSize - 1) / m_uiCTUSize; - uint32_t tmpHeightVal = (m_iSourceHeight + m_uiCTUSize - 1) / m_uiCTUSize; + uint32_t tmpWidthVal = (m_sourceWidth + m_uiCTUSize - 1) / m_uiCTUSize; + uint32_t tmpHeightVal = (m_sourceHeight + m_uiCTUSize - 1) / m_uiCTUSize; if (!m_subPicSameSizeFlag) { for (int i = 0; i < m_numSubPics; i++) @@ -1772,10 +1767,10 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) if (m_virtualBoundariesPresentFlag) { - if (m_iSourceWidth <= 8) + if (m_sourceWidth <= 8) CHECK(m_numVerVirtualBoundaries != 0, "The number of vertical virtual boundaries shall be 0 when the picture width is less than or equal to 8"); - if (m_iSourceHeight <= 8) + if (m_sourceHeight <= 8) CHECK(m_numHorVirtualBoundaries != 0, "The number of horizontal virtual boundaries shall be 0 when the picture height is less than or equal to 8"); } @@ -1990,51 +1985,59 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) // Picture width and height must be multiples of 8 and minCuSize const int minResolutionMultiple = std::max(8, 1 << m_log2MinCuSize); - CHECK(((m_iSourceWidth% minResolutionMultiple) || (m_iSourceHeight % minResolutionMultiple)) && m_conformanceWindowMode != 1, "Picture width or height is not a multiple of 8 or minCuSize, please use ConformanceMode 1!"); + CHECK(((m_sourceWidth% minResolutionMultiple) || (m_sourceHeight % minResolutionMultiple)) && m_conformanceWindowMode != 1, "Picture width or height is not a multiple of 8 or minCuSize, please use ConformanceWindowMode=1!"); switch (m_conformanceWindowMode) { case 0: { // no conformance or padding m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0; - m_aiPad[1] = m_aiPad[0] = 0; + m_sourcePadding[1] = m_sourcePadding[0] = 0; break; } case 1: { // automatic padding to minimum CU size - if (m_iSourceWidth % minResolutionMultiple) + if (m_sourceWidth % minResolutionMultiple) { - m_aiPad[0] = m_confWinRight = ((m_iSourceWidth / minResolutionMultiple) + 1) * minResolutionMultiple - m_iSourceWidth; - m_iSourceWidth += m_confWinRight; + m_sourcePadding[0] = m_confWinRight = ((m_sourceWidth / minResolutionMultiple) + 1) * minResolutionMultiple - m_sourceWidth; + m_sourceWidth += m_confWinRight; } - if (m_iSourceHeight % minResolutionMultiple) + if (m_sourceHeight % minResolutionMultiple) { - m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minResolutionMultiple) + 1) * minResolutionMultiple - m_iSourceHeight; - m_iSourceHeight += m_confWinBottom; + m_sourcePadding[1] = m_confWinBottom = ((m_sourceHeight / minResolutionMultiple) + 1) * minResolutionMultiple - m_sourceHeight; + m_sourceHeight += m_confWinBottom; if ( m_isField ) { m_iSourceHeightOrg += m_confWinBottom << 1; - m_aiPad[1] = m_confWinBottom << 1; + m_sourcePadding[1] = m_confWinBottom << 1; } } - if (m_aiPad[0] % SPS::getWinUnitX(m_chromaFormatIDC) != 0) + if (m_sourcePadding[0] % SPS::getWinUnitX(m_chromaFormatIDC) != 0) { EXIT( "Error: picture width is not an integer multiple of the specified chroma subsampling"); } - if (m_aiPad[1] % SPS::getWinUnitY(m_chromaFormatIDC) != 0) + if (m_sourcePadding[1] % SPS::getWinUnitY(m_chromaFormatIDC) != 0) { EXIT( "Error: picture height is not an integer multiple of the specified chroma subsampling"); } + if (m_sourcePadding[0]) + { + msg( INFO, "Info: Conformance window automatically enabled. Adding %i lumal pel horizontally\n", m_sourcePadding[0]); + } + if (m_sourcePadding[1]) + { + msg( INFO, "Info: Conformance window automatically enabled. Adding %i lumal pel vertically\n", m_sourcePadding[1]); + } break; } case 2: { //padding - m_iSourceWidth += m_aiPad[0]; - m_iSourceHeight += m_aiPad[1]; - m_confWinRight = m_aiPad[0]; - m_confWinBottom = m_aiPad[1]; + m_sourceWidth += m_sourcePadding[0]; + m_sourceHeight += m_sourcePadding[1]; + m_confWinRight = m_sourcePadding[0]; + m_confWinBottom = m_sourcePadding[1]; break; } case 3: @@ -2044,11 +2047,11 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) { msg( ERROR, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n"); } - if ((m_aiPad[1] != 0) || (m_aiPad[0]!=0)) + if ((m_sourcePadding[1] != 0) || (m_sourcePadding[0]!=0)) { msg( ERROR, "Warning: Conformance window enabled, padding parameters will be ignored\n"); } - m_aiPad[1] = m_aiPad[0] = 0; + m_sourcePadding[1] = m_sourcePadding[0] = 0; break; } } @@ -2057,11 +2060,11 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) { for(int i = 0; i < m_numSubPics; i++) { - CHECK( (m_subPicCtuTopLeftX[i] * m_uiCTUSize) >= (m_iSourceWidth - m_confWinRight * SPS::getWinUnitX(m_chromaFormatIDC)), + CHECK( (m_subPicCtuTopLeftX[i] * m_uiCTUSize) >= (m_sourceWidth - m_confWinRight * SPS::getWinUnitX(m_chromaFormatIDC)), "No subpicture can be located completely outside of the conformance cropping window"); CHECK( ((m_subPicCtuTopLeftX[i] + m_subPicWidth[i]) * m_uiCTUSize) <= (m_confWinLeft * SPS::getWinUnitX(m_chromaFormatIDC)), "No subpicture can be located completely outside of the conformance cropping window" ); - CHECK( (m_subPicCtuTopLeftY[i] * m_uiCTUSize) >= (m_iSourceHeight - m_confWinBottom * SPS::getWinUnitY(m_chromaFormatIDC)), + CHECK( (m_subPicCtuTopLeftY[i] * m_uiCTUSize) >= (m_sourceHeight - m_confWinBottom * SPS::getWinUnitY(m_chromaFormatIDC)), "No subpicture can be located completely outside of the conformance cropping window"); CHECK( ((m_subPicCtuTopLeftY[i] + m_subPicHeight[i]) * m_uiCTUSize) <= (m_confWinTop * SPS::getWinUnitY(m_chromaFormatIDC)), "No subpicture can be located completely outside of the conformance cropping window"); @@ -2304,7 +2307,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } for (unsigned i = 0; i < m_numVerVirtualBoundaries; i++) { - CHECK( m_virtualBoundariesPosX[i] == 0 || m_virtualBoundariesPosX[i] >= m_iSourceWidth, "The vertical virtual boundary must be within the picture" ); + CHECK( m_virtualBoundariesPosX[i] == 0 || m_virtualBoundariesPosX[i] >= m_sourceWidth, "The vertical virtual boundary must be within the picture" ); CHECK( m_virtualBoundariesPosX[i] % 8, "The vertical virtual boundary must be a multiple of 8 luma samples" ); if (i > 0) { @@ -2318,7 +2321,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } for (unsigned i = 0; i < m_numHorVirtualBoundaries; i++) { - CHECK( m_virtualBoundariesPosY[i] == 0 || m_virtualBoundariesPosY[i] >= m_iSourceHeight, "The horizontal virtual boundary must be within the picture" ); + CHECK( m_virtualBoundariesPosY[i] == 0 || m_virtualBoundariesPosY[i] >= m_sourceHeight, "The horizontal virtual boundary must be within the picture" ); CHECK( m_virtualBoundariesPosY[i] % 8, "The horizontal virtual boundary must be a multiple of 8 luma samples" ); if (i > 0) { @@ -2475,7 +2478,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } m_reshapeCW.binCW.resize(3); m_reshapeCW.rspFps = m_iFrameRate; - m_reshapeCW.rspPicSize = m_iSourceWidth*m_iSourceHeight; + m_reshapeCW.rspPicSize = m_sourceWidth*m_sourceHeight; m_reshapeCW.rspFpsToIp = std::max(16, 16 * (int)(round((double)m_iFrameRate /16.0))); m_reshapeCW.rspBaseQP = m_iQP; m_reshapeCW.updateCtrl = m_updateCtrl; @@ -2501,14 +2504,14 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) #if ENABLE_QPA_SUB_CTU #if QP_SWITCHING_FOR_PARALLEL - if ((m_iQP < 38) && m_bUsePerceptQPA && !m_bUseAdaptiveQP && (m_iSourceWidth <= 2048) && (m_iSourceHeight <= 1280) + if ((m_iQP < 38) && m_bUsePerceptQPA && !m_bUseAdaptiveQP && (m_sourceWidth <= 2048) && (m_sourceHeight <= 1280) #else if (((int)m_fQP < 38) && m_bUsePerceptQPA && !m_bUseAdaptiveQP && (m_iSourceWidth <= 2048) && (m_iSourceHeight <= 1280) #endif #if WCG_EXT && ER_CHROMA_QP_WCG_PPS && (!m_wcgChromaQpControl.enabled) #endif - && ((1 << (m_log2MaxTbSize + 1)) == m_uiCTUSize) && (m_iSourceWidth > 512 || m_iSourceHeight > 320)) + && ((1 << (m_log2MaxTbSize + 1)) == m_uiCTUSize) && (m_sourceWidth > 512 || m_sourceHeight > 320)) { m_cuQpDeltaSubdiv = 2; } @@ -2662,7 +2665,7 @@ bool EncAppCfg::xCheckParameter() { const int minCUSize = 1 << m_log2MinCuSize; xConfirmPara(m_wrapAroundOffset <= m_uiCTUSize + minCUSize, "Wrap-around offset must be greater than CtbSizeY + MinCbSize"); - xConfirmPara(m_wrapAroundOffset > m_iSourceWidth, "Wrap-around offset must not be greater than the source picture width"); + xConfirmPara(m_wrapAroundOffset > m_sourceWidth, "Wrap-around offset must not be greater than the source picture width"); xConfirmPara( m_wrapAroundOffset % minCUSize != 0, "Wrap-around offset must be an integer multiple of the specified minimum CU size" ); } @@ -2908,7 +2911,7 @@ bool EncAppCfg::xCheckParameter() xConfirmPara( m_uiMaxTT[2] > 64, "Maximum TT size for chroma block in I slice should be smaller than or equal to 64"); xConfirmPara( m_uiMinQT[0] < minCuSize, "Min Luma QT size in I slices should be larger than or equal to minCuSize"); xConfirmPara( m_uiMinQT[1] < minCuSize, "Min Luma QT size in non-I slices should be larger than or equal to minCuSize"); - xConfirmPara((m_iSourceWidth % minCuSize ) || (m_iSourceHeight % minCuSize), "Picture width or height is not a multiple of minCuSize"); + xConfirmPara((m_sourceWidth % minCuSize ) || (m_sourceHeight % minCuSize), "Picture width or height is not a multiple of minCuSize"); const int minDiff = (int)floorLog2(m_uiMinQT[2]) - std::max(MIN_CU_LOG2, (int)m_log2MinCuSize - (int)getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, m_chromaFormatIDC)); xConfirmPara( minDiff < 0 , "Min Chroma QT size in I slices is smaller than Min Luma CU size even considering color format"); xConfirmPara( (m_uiMinQT[2] << (int)getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, m_chromaFormatIDC)) > std::min(64, (int)m_uiCTUSize), @@ -2932,8 +2935,8 @@ bool EncAppCfg::xCheckParameter() xConfirmPara( m_uiMaxTT[2] < (m_uiMinQT[2] << (int)getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, m_chromaFormatIDC)), "Maximum TT size for chroma block in I slice should be larger than minimum QT size"); xConfirmPara( m_uiMaxTT[2] > m_uiCTUSize, "Maximum TT size for chroma block in I slice should be smaller than or equal to CTUSize"); - xConfirmPara( (m_iSourceWidth % (std::max(8u, m_log2MinCuSize))) != 0, "Resulting coded frame width must be a multiple of Max(8, the minimum CU size)"); - xConfirmPara( (m_iSourceHeight % (std::max(8u, m_log2MinCuSize))) != 0, "Resulting coded frame height must be a multiple of Max(8, the minimum CU size)"); + xConfirmPara( (m_sourceWidth % (std::max(8u, m_log2MinCuSize))) != 0, "Resulting coded frame width must be a multiple of Max(8, the minimum CU size)"); + xConfirmPara( (m_sourceHeight % (std::max(8u, m_log2MinCuSize))) != 0, "Resulting coded frame height must be a multiple of Max(8, the minimum CU size)"); if (m_uiMaxMTTHierarchyDepthI == 0) { xConfirmPara(m_uiMaxBT[0] != m_uiMinQT[0], "MaxBTLumaISlice shall be equal to MinQTLumaISlice when MaxMTTHierarchyDepthISliceL is 0."); @@ -2985,11 +2988,11 @@ bool EncAppCfg::xCheckParameter() } - xConfirmPara( m_iSourceWidth % SPS::getWinUnitX(m_chromaFormatIDC) != 0, "Picture width must be an integer multiple of the specified chroma subsampling"); - xConfirmPara( m_iSourceHeight % SPS::getWinUnitY(m_chromaFormatIDC) != 0, "Picture height must be an integer multiple of the specified chroma subsampling"); + xConfirmPara( m_sourceWidth % SPS::getWinUnitX(m_chromaFormatIDC) != 0, "Picture width must be an integer multiple of the specified chroma subsampling"); + xConfirmPara( m_sourceHeight % SPS::getWinUnitY(m_chromaFormatIDC) != 0, "Picture height must be an integer multiple of the specified chroma subsampling"); - xConfirmPara( m_aiPad[0] % SPS::getWinUnitX(m_chromaFormatIDC) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling"); - xConfirmPara( m_aiPad[1] % SPS::getWinUnitY(m_chromaFormatIDC) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling"); + xConfirmPara( m_sourcePadding[0] % SPS::getWinUnitX(m_chromaFormatIDC) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling"); + xConfirmPara( m_sourcePadding[1] % SPS::getWinUnitY(m_chromaFormatIDC) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling"); xConfirmPara( m_confWinLeft % SPS::getWinUnitX(m_chromaFormatIDC) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling"); xConfirmPara( m_confWinRight % SPS::getWinUnitX(m_chromaFormatIDC) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling"); @@ -3427,8 +3430,8 @@ bool EncAppCfg::xCheckParameter() uint32_t colIdx, rowIdx; uint32_t remSize; - pps.setPicWidthInLumaSamples( m_iSourceWidth ); - pps.setPicHeightInLumaSamples( m_iSourceHeight ); + pps.setPicWidthInLumaSamples( m_sourceWidth ); + pps.setPicHeightInLumaSamples( m_sourceHeight ); pps.setLog2CtuSize( floorLog2(m_uiCTUSize) ); // set default tile column if not provided @@ -3904,8 +3907,8 @@ void EncAppCfg::xPrintParameter() msg( DETAILS, "Input File : %s\n", m_inputFileName.c_str() ); msg( DETAILS, "Bitstream File : %s\n", m_bitstreamFileName.c_str() ); msg( DETAILS, "Reconstruction File : %s\n", m_reconFileName.c_str() ); - msg( DETAILS, "Real Format : %dx%d %gHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, (double)m_iFrameRate / m_temporalSubsampleRatio ); - msg( DETAILS, "Internal Format : %dx%d %gHz\n", m_iSourceWidth, m_iSourceHeight, (double)m_iFrameRate / m_temporalSubsampleRatio ); + msg( DETAILS, "Real Format : %dx%d %gHz\n", m_sourceWidth - m_confWinLeft - m_confWinRight, m_sourceHeight - m_confWinTop - m_confWinBottom, (double)m_iFrameRate / m_temporalSubsampleRatio ); + msg( DETAILS, "Internal Format : %dx%d %gHz\n", m_sourceWidth, m_sourceHeight, (double)m_iFrameRate / m_temporalSubsampleRatio ); msg( DETAILS, "Sequence PSNR output : %s\n", ( m_printMSEBasedSequencePSNR ? "Linear average, MSE-based" : "Linear average only" ) ); msg( DETAILS, "Hexadecimal PSNR output : %s\n", ( m_printHexPsnr ? "Enabled" : "Disabled" ) ); msg( DETAILS, "Sequence MSE output : %s\n", ( m_printSequenceMSE ? "Enabled" : "Disabled" ) ); @@ -4092,7 +4095,7 @@ void EncAppCfg::xPrintParameter() msg( VERBOSE, "WPP:%d ", (int)m_useWeightedPred); msg( VERBOSE, "WPB:%d ", (int)m_useWeightedBiPred); msg( VERBOSE, "PME:%d ", m_log2ParallelMergeLevel); - const int iWaveFrontSubstreams = m_entropyCodingSyncEnabledFlag ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1; + const int iWaveFrontSubstreams = m_entropyCodingSyncEnabledFlag ? (m_sourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1; msg( VERBOSE, " WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_entropyCodingSyncEnabledFlag?1:0, iWaveFrontSubstreams); msg( VERBOSE, " ScalingList:%d ", m_useScalingListId ); msg( VERBOSE, "TMVPMode:%d ", m_TMVPModeId ); diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h index 0e9af316f2959d6cdf81505016d128422b94e697..2461c99863d45d433180bff3fb00036bd2354c01 100644 --- a/source/App/EncoderApp/EncAppCfg.h +++ b/source/App/EncoderApp/EncAppCfg.h @@ -95,8 +95,8 @@ protected: int m_iFrameRate; ///< source frame-rates (Hz) uint32_t m_FrameSkip; ///< number of skipped frames from the beginning uint32_t m_temporalSubsampleRatio; ///< temporal subsample ratio, 2 means code every two frames - int m_iSourceWidth; ///< source width in pixel - int m_iSourceHeight; ///< source height in pixel (when interlaced = field height) + int m_sourceWidth; ///< source width in pixel + int m_sourceHeight; ///< source height in pixel (when interlaced = field height) #if EXTENSION_360_VIDEO int m_inputFileWidth; ///< width of image in input file (this is equivalent to sourceWidth, if sourceWidth is not subsequently altered due to padding) int m_inputFileHeight; ///< height of image in input file (this is equivalent to sourceHeight, if sourceHeight is not subsequently altered due to padding) @@ -113,8 +113,8 @@ protected: int m_confWinRight; int m_confWinTop; int m_confWinBottom; + int m_sourcePadding[2]; ///< number of padded pixels for width and height int m_framesToBeEncoded; ///< number of encoded frames - int m_aiPad[2]; ///< number of padded pixels for width and height bool m_AccessUnitDelimiter; ///< add Access Unit Delimiter NAL units bool m_enablePictureHeaderInSliceHeader; ///< Enable Picture Header in Slice Header InputColourSpaceConversion m_inputColourSpaceConvert; ///< colour space conversion to apply to input video diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index d4380404858ceef3f820c5cde1b1ca82cd60984e..118d0a36784d4b88e5252bb93fa4f23911e12915 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -161,9 +161,10 @@ protected: int m_iFrameRate; int m_FrameSkip; uint32_t m_temporalSubsampleRatio; - int m_iSourceWidth; - int m_iSourceHeight; + int m_sourceWidth; + int m_sourceHeight; Window m_conformanceWindow; + int m_sourcePadding[2]; int m_framesToBeEncoded; double m_adLambdaModifier[ MAX_TLAYER ]; std::vector<double> m_adIntraLambdaModifier; @@ -277,7 +278,6 @@ protected: int m_intraQPOffset; ///< QP offset for intra slice (integer) int m_lambdaFromQPEnable; ///< enable lambda derivation from QP #endif - int m_aiPad[2]; bool m_AccessUnitDelimiter; ///< add Access Unit Delimiter NAL units bool m_enablePictureHeaderInSliceHeader; ///< Enable Picture Header in Slice Header @@ -912,8 +912,8 @@ public: void setFrameRate ( int i ) { m_iFrameRate = i; } void setFrameSkip ( uint32_t i ) { m_FrameSkip = i; } void setTemporalSubsampleRatio ( uint32_t i ) { m_temporalSubsampleRatio = i; } - void setSourceWidth ( int i ) { m_iSourceWidth = i; } - void setSourceHeight ( int i ) { m_iSourceHeight = i; } + void setSourceWidth ( int i ) { m_sourceWidth = i; } + void setSourceHeight ( int i ) { m_sourceHeight = i; } Window &getConformanceWindow() { return m_conformanceWindow; } void setConformanceWindow (int confLeft, int confRight, int confTop, int confBottom ) { m_conformanceWindow.setWindow (confLeft, confRight, confTop, confBottom); } @@ -982,7 +982,7 @@ public: #endif void setChromaQpMappingTableParams (const ChromaQpMappingTableParams ¶ms) { m_chromaQpMappingTableParams = params; } - void setPad ( int* iPad ) { for ( int i = 0; i < 2; i++ ) m_aiPad[i] = iPad[i]; } + void setSourcePadding ( int* padding) { for ( int i = 0; i < 2; i++ ) m_sourcePadding[i] = padding[i]; } int getMaxRefPicNum () { return m_iMaxRefPicNum; } void setMaxRefPicNum ( int iMaxRefPicNum ) { m_iMaxRefPicNum = iMaxRefPicNum; } @@ -1312,8 +1312,8 @@ public: int getFrameRate () const { return m_iFrameRate; } uint32_t getFrameSkip () const { return m_FrameSkip; } uint32_t getTemporalSubsampleRatio () const { return m_temporalSubsampleRatio; } - int getSourceWidth () const { return m_iSourceWidth; } - int getSourceHeight () const { return m_iSourceHeight; } + int getSourceWidth () const { return m_sourceWidth; } + int getSourceHeight () const { return m_sourceHeight; } int getFramesToBeEncoded () const { return m_framesToBeEncoded; } //====== Lambda Modifiers ======== @@ -1341,7 +1341,7 @@ public: #else int getBaseQP () { return m_iQP; } #endif - int getPad ( int i ) { CHECK(i >= 2, "Invalid index"); return m_aiPad[i]; } + int getSourcePadding ( int i ) { CHECK(i >= 2, "Invalid index"); return m_sourcePadding[i]; } bool getAccessUnitDelimiter() const { return m_AccessUnitDelimiter; } void setAccessUnitDelimiter(bool val){ m_AccessUnitDelimiter = val; } diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 210b55010b13193554a0f1b28afbcc2b915b0837..20b9d1084774e5d2e4ab7d97af8e1a930355b841 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -4353,8 +4353,8 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni CHECK(!( p.width == o.width), "Unspecified error"); CHECK(!( p.height == o.height), "Unspecified error"); - int padX = m_pcEncLib->getPad( 0 ); - int padY = m_pcEncLib->getPad( 1 ); + int padX = m_pcEncLib->getSourcePadding( 0 ); + int padY = m_pcEncLib->getSourcePadding( 1 ); // when RPR is enabled, picture padding is picture specific due to possible different picture resoluitons, however only full resolution padding is stored in EncLib // get per picture padding from the conformance window, in this case if conformance window is set not equal to the padding then PSNR results may be inaccurate @@ -4400,8 +4400,8 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni { const CPelBuf& upscaledOrg = (sps.getUseLmcs() || m_pcCfg->getGopBasedTemporalFilterEnabled()) ? pcPic->M_BUFS( 0, PIC_TRUE_ORIGINAL_INPUT).get( compID ) : pcPic->M_BUFS( 0, PIC_ORIGINAL_INPUT).get( compID ); - const uint32_t upscaledWidth = upscaledOrg.width - ( m_pcEncLib->getPad( 0 ) >> ::getComponentScaleX( compID, format ) ); - const uint32_t upscaledHeight = upscaledOrg.height - ( m_pcEncLib->getPad( 1 ) >> ( !!bPicIsField + ::getComponentScaleY( compID, format ) ) ); + const uint32_t upscaledWidth = upscaledOrg.width - ( m_pcEncLib->getSourcePadding( 0 ) >> ::getComponentScaleX( compID, format ) ); + const uint32_t upscaledHeight = upscaledOrg.height - ( m_pcEncLib->getSourcePadding( 1 ) >> ( !!bPicIsField + ::getComponentScaleY( compID, format ) ) ); // create new buffers with correct dimensions const CPelBuf upscaledRecPB( upscaledRec.get( compID ).bufAt( 0, 0 ), upscaledRec.get( compID ).stride, upscaledWidth, upscaledHeight ); @@ -4998,8 +4998,8 @@ void EncGOP::xCalculateInterlacedAddPSNR( Picture* pcPicOrgFirstField, Picture* CHECK(!(acPicRecFields[0].get(ch).height==acPicRecFields[0].get(ch).height), "Unspecified error"); uint64_t uiSSDtemp=0; - const uint32_t width = acPicRecFields[0].get(ch).width - (m_pcEncLib->getPad(0) >> ::getComponentScaleX(ch, format)); - const uint32_t height = acPicRecFields[0].get(ch).height - ((m_pcEncLib->getPad(1) >> 1) >> ::getComponentScaleY(ch, format)); + const uint32_t width = acPicRecFields[0].get(ch).width - (m_pcEncLib->getSourcePadding(0) >> ::getComponentScaleX(ch, format)); + const uint32_t height = acPicRecFields[0].get(ch).height - ((m_pcEncLib->getSourcePadding(1) >> 1) >> ::getComponentScaleY(ch, format)); const uint32_t bitDepth = sps.getBitDepth(toChannelType(ch)); double sumOverFieldsMSSSIM = 0; diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 06607866a729df46835c3d7f048adc1ee38b0124..d13a3ca808890417600e2937b121fd1e374ac15a 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -117,7 +117,7 @@ void EncLib::create( const int layerId ) } if ( m_RCEnableRateControl ) { - m_cRateCtrl.init(m_framesToBeEncoded, m_RCTargetBitrate, (int)((double)m_iFrameRate / m_temporalSubsampleRatio + 0.5), m_iGOPSize, m_iSourceWidth, m_iSourceHeight, + m_cRateCtrl.init(m_framesToBeEncoded, m_RCTargetBitrate, (int)((double)m_iFrameRate / m_temporalSubsampleRatio + 0.5), m_iGOPSize, m_sourceWidth, m_sourceHeight, m_maxCUWidth, m_maxCUHeight, getBitDepth(CHANNEL_TYPE_LUMA), m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList); } @@ -184,8 +184,8 @@ void EncLib::init(AUWriterIf *auWriterIf) m_cRdCost.setCostMode ( m_costMode ); // initialize PPS - pps0.setPicWidthInLumaSamples( m_iSourceWidth ); - pps0.setPicHeightInLumaSamples( m_iSourceHeight ); + pps0.setPicWidthInLumaSamples( m_sourceWidth ); + pps0.setPicHeightInLumaSamples( m_sourceHeight ); if (pps0.getPicWidthInLumaSamples() == sps0.getMaxPicWidthInLumaSamples() && pps0.getPicHeightInLumaSamples() == sps0.getMaxPicHeightInLumaSamples()) { pps0.setConformanceWindow( sps0.getConformanceWindow() ); @@ -1142,12 +1142,12 @@ void EncLib::xInitSPS( SPS& sps ) sps.setGDREnabledFlag(false); #endif - sps.setMaxPicWidthInLumaSamples( m_iSourceWidth ); - sps.setMaxPicHeightInLumaSamples( m_iSourceHeight ); + sps.setMaxPicWidthInLumaSamples( m_sourceWidth ); + sps.setMaxPicHeightInLumaSamples( m_sourceHeight ); if (m_resChangeInClvsEnabled) { - int maxPicWidth = std::max(m_iSourceWidth, (int)((double)m_iSourceWidth / m_scalingRatioHor + 0.5)); - int maxPicHeight = std::max(m_iSourceHeight, (int)((double)m_iSourceHeight / m_scalingRatioVer + 0.5)); + int maxPicWidth = std::max(m_sourceWidth, (int)((double)m_sourceWidth / m_scalingRatioHor + 0.5)); + int maxPicHeight = std::max(m_sourceHeight, (int)((double)m_sourceHeight / m_scalingRatioVer + 0.5)); const int minCuSize = std::max(8, 1 << m_log2MinCUSize); if (maxPicWidth % minCuSize) { @@ -1352,7 +1352,7 @@ void EncLib::xInitSPS( SPS& sps ) sps.setSubPicSameSizeFlag(m_subPicSameSizeFlag); if (m_subPicSameSizeFlag) { - uint32_t numSubpicCols = (m_iSourceWidth + m_CTUSize - 1) / m_CTUSize / m_subPicWidth[0]; + uint32_t numSubpicCols = (m_sourceWidth + m_CTUSize - 1) / m_CTUSize / m_subPicWidth[0]; for (unsigned int i = 0; i < m_numSubPics; i++) { sps.setSubPicCtuTopLeftX(i, (i % numSubpicCols) * m_subPicWidth[0]); @@ -1386,8 +1386,8 @@ void EncLib::xInitSPS( SPS& sps ) sps.setNumSubPics(1); sps.setSubPicCtuTopLeftX(0, 0); sps.setSubPicCtuTopLeftY(0, 0); - sps.setSubPicWidth(0, m_iSourceWidth); - sps.setSubPicHeight(0, m_iSourceHeight); + sps.setSubPicWidth(0, m_sourceWidth); + sps.setSubPicHeight(0, m_sourceHeight); sps.setSubPicTreatedAsPicFlag(0, 1); sps.setLoopFilterAcrossSubpicEnabledFlag(0, 0); sps.setSubPicIdLen(0);