diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index df7fc6b6d674da6748e9b948c4bba4e4632d2441..0c29bd61d92707fb797dafd219d91399fa3cf7d9 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -266,8 +266,10 @@ void EncApp::xInitLibCfg( int layerIdx ) m_confWinRight / SPS::getWinUnitX(m_inputChromaFormatIDC), m_confWinTop / SPS::getWinUnitY(m_inputChromaFormatIDC), m_confWinBottom / SPS::getWinUnitY(m_inputChromaFormatIDC)); +#if SCALING_WINDOW_ENABLED m_cEncLib.setExplicitScalingWindowEnabled ( m_explicitScalingWindowEnabled ); m_cEncLib.setScalingWindow ( m_scalWinLeft / SPS::getWinUnitX( m_inputChromaFormatIDC ), m_scalWinRight / SPS::getWinUnitX( m_inputChromaFormatIDC ), m_scalWinTop / SPS::getWinUnitY( m_inputChromaFormatIDC ), m_scalWinBottom / SPS::getWinUnitY( m_inputChromaFormatIDC ) ); +#endif m_cEncLib.setScalingRatio ( m_scalingRatioHor, m_scalingRatioVer ); m_cEncLib.setGOPBasedRPREnabledFlag (m_gopBasedRPREnabledFlag); m_cEncLib.setGOPBasedRPRQPThreshold (m_gopBasedRPRQPThreshold); @@ -1981,7 +1983,11 @@ void EncApp::xWriteOutput(int numEncoded, std::list<PelUnitBuf *> &recBufList) } else { +#if SCALING_WINDOW_ENABLED ppsID = ((sps.getMaxPicWidthInLumaSamples() != pcPicYuvRec->get(COMPONENT_Y).width || sps.getMaxPicHeightInLumaSamples() != pcPicYuvRec->get(COMPONENT_Y).height) && !m_explicitScalingWindowEnabled) ? m_resChangeInClvsEnabled ? ENC_PPS_ID_RPR : layerId : layerId; +#else + ppsID = (sps.getMaxPicWidthInLumaSamples() != pcPicYuvRec->get(COMPONENT_Y).width || sps.getMaxPicHeightInLumaSamples() != pcPicYuvRec->get(COMPONENT_Y).height) ? ENC_PPS_ID_RPR : layerId; +#endif } const PPS& pps = *m_cEncLib.getPPS(ppsID); if( m_cEncLib.isResChangeInClvsEnabled() && m_cEncLib.getUpscaledOutput() ) diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index 600f84f411a9127d1119c3431e794cbdfd614e40..70144614f1d0d8fc7f73ed721bd0f9592d5d0f8e 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -821,11 +821,13 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("ConfWinRight", m_confWinRight, 0, "Right offset for window conformance mode 3") ("ConfWinTop", m_confWinTop, 0, "Top offset for window conformance mode 3") ("ConfWinBottom", m_confWinBottom, 0, "Bottom offset for window conformance mode 3") +#if SCALING_WINDOW_ENABLED ("ScalingWindow", m_explicitScalingWindowEnabled, false, "Enable scaling window") ("ScalWinLeft,-swl", m_scalWinLeft, 0, "Left offset for scaling window") ("ScalWinRight,-swr", m_scalWinRight, 0, "Right offset for scaling window") ("ScalWinTop,-swt", m_scalWinTop, 0, "Top offset for scaling window") ("ScalWinBottom,-swb", m_scalWinBottom, 0, "Bottom offset for scaling window") +#endif ("AccessUnitDelimiter", m_AccessUnitDelimiter, false, "Enable Access Unit Delimiter NALUs") ("EnablePictureHeaderInSliceHeader", m_enablePictureHeaderInSliceHeader, true, "Enable Picture Header in Slice Header") ("FrameRate,-fr", frameRate, std::to_string(0), "Frame rate") @@ -4292,6 +4294,7 @@ bool EncAppCfg::xCheckParameter() "Top conformance window offset must be an integer multiple of the specified chroma subsampling"); xConfirmPara(m_confWinBottom % SPS::getWinUnitY(m_chromaFormatIdc) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling"); +#if SCALING_WINDOW_ENABLED xConfirmPara(m_explicitScalingWindowEnabled && (m_scalingRatioHor != 1.0 || m_scalingRatioVer != 1.0 || m_gopBasedRPREnabledFlag), "ScalingWindow cannot be enabled when GOPBasedRPR is enabled"); xConfirmPara(m_scalWinLeft % SPS::getWinUnitX(m_chromaFormatIdc) != 0, "Left scaling window offset must be an integer multiple of the specified chroma subsampling"); xConfirmPara(m_scalWinRight % SPS::getWinUnitX(m_chromaFormatIdc) != 0, "Right scaling window offset must be an integer multiple of the specified chroma subsampling"); @@ -4309,6 +4312,7 @@ bool EncAppCfg::xCheckParameter() "The values of SubWidthC * (pps_scaling_win_left_offset + pps_scaling_win_right_offset) shall be greater than or equal to -pps_pic_width_in_luma_samples * 15 and less than pps_pic_width_in_luma_samples"); xConfirmPara(((m_scalWinTop+m_scalWinBottom) < -m_sourceHeight * 15) || ((m_scalWinTop+m_scalWinBottom) >= m_sourceHeight), "The values of SubHeightC * (pps_scaling_win_top_offset + pps_scaling_win_bottom_offset) shall be greater than or equal to -pps_pic_height_in_luma_samples * 15 and less than pps_pic_height_in_luma_samples"); +#endif // max CU width and height should be power of 2 diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h index f299330058bb619091a65572989fe7ce3b41865d..5d7d1422620f676db1c7abdf8362f0e0b125479c 100644 --- a/source/App/EncoderApp/EncAppCfg.h +++ b/source/App/EncoderApp/EncAppCfg.h @@ -111,11 +111,13 @@ protected: int m_confWinRight; int m_confWinTop; int m_confWinBottom; +#if SCALING_WINDOW_ENABLED bool m_explicitScalingWindowEnabled; int m_scalWinLeft; int m_scalWinRight; int m_scalWinTop; int m_scalWinBottom; +#endif int m_sourcePadding[2]; ///< number of padded pixels for width and height int m_firstValidFrame; int m_lastValidFrame; diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index c5f23c85fb555f5b5a9eca64246390202b67a2f7..73a0f12835cd7c12db9c09074398b7c6e0acf653 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -148,6 +148,10 @@ #define ENABLE_USER_DEFINED_WEIGHTS 0 // User can specify weights for both current and previous picture, such that their sum = 1 #endif +#ifndef SCALING_WINDOW_ENABLED +#define SCALING_WINDOW_ENABLED 1 +#endif + // clang-format on // ==================================================================================================================== diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index 85da8462dde9b590df3919b49dd1a474763ffda3..c0a1988b50b2962816ef3b8cc4d1b420f0f41f8c 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -161,8 +161,10 @@ protected: int m_sourceWidth; int m_sourceHeight; Window m_conformanceWindow; +#if SCALING_WINDOW_ENABLED bool m_explicitScalingWindowEnabled; Window m_scalingWindow; +#endif int m_sourcePadding[2]; int m_framesToBeEncoded; int m_firstValidFrame; @@ -1225,8 +1227,10 @@ public: Window &getConformanceWindow() { return m_conformanceWindow; } void setConformanceWindow (int confLeft, int confRight, int confTop, int confBottom ) { m_conformanceWindow.setWindow (confLeft, confRight, confTop, confBottom); } +#if SCALING_WINDOW_ENABLED void setExplicitScalingWindowEnabled(bool enabled) { m_explicitScalingWindowEnabled = enabled; } void setScalingWindow (int scalingLeft, int scalingRight, int scalingTop, int scalingBottom ) { m_scalingWindow.setWindow (scalingLeft, scalingRight, scalingTop, scalingBottom); } +#endif void setFramesToBeEncoded ( int i ) { m_framesToBeEncoded = i; } diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 3a36f4d96d8c3036169555caa2ec21ffd9881ab3..7c4c28a6708e9a141c4a3e72c98d402d934cd776 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -197,11 +197,13 @@ void EncLib::init(AUWriterIf *auWriterIf) pps0.setConformanceWindow( m_conformanceWindow ); pps0.setConformanceWindowFlag( m_conformanceWindow.getWindowEnabledFlag() ); } +#if SCALING_WINDOW_ENABLED if (m_explicitScalingWindowEnabled) { pps0.setExplicitScalingWindowFlag(true); pps0.setScalingWindow(m_scalingWindow); } +#endif if (!pps0.getExplicitScalingWindowFlag()) { pps0.setScalingWindow(pps0.getConformanceWindow()); @@ -1456,6 +1458,7 @@ void EncLib::xInitSPS( SPS& sps ) sps.setMaxPicWidthInLumaSamples( m_sourceWidth ); sps.setMaxPicHeightInLumaSamples( m_sourceHeight ); +#if SCALING_WINDOW_ENABLED bool scalingWindowResChanged = false; if (m_multiLayerEnabledFlag && m_vps->getMaxLayers() > 0) { @@ -1505,6 +1508,7 @@ void EncLib::xInitSPS( SPS& sps ) sps.setMaxPicWidthInLumaSamples(maxPicWidth); sps.setMaxPicHeightInLumaSamples(maxPicHeight); } +#endif if (m_resChangeInClvsEnabled) { @@ -1793,8 +1797,13 @@ void EncLib::xInitSPS( SPS& sps ) sps.setInterLayerPresentFlag( m_layerId > 0 && m_vps->getMaxLayers() > 1 && !m_vps->getAllIndependentLayersFlag() && !m_vps->getIndependentLayerFlag( m_vps->getGeneralLayerIdx( m_layerId ) ) ); CHECK( m_vps->getIndependentLayerFlag( m_vps->getGeneralLayerIdx( m_layerId ) ) && sps.getInterLayerPresentFlag(), " When vps_independent_layer_flag[GeneralLayerIdx[nuh_layer_id ]] is equal to 1, the value of inter_layer_ref_pics_present_flag shall be equal to 0." ); +#if SCALING_WINDOW_ENABLED sps.setResChangeInClvsEnabledFlag(m_resChangeInClvsEnabled || m_constrainedRaslEncoding || scalingWindowResChanged); sps.setRprEnabledFlag(m_rprEnabledFlag || m_explicitScalingWindowEnabled || scalingWindowResChanged); +#else + sps.setResChangeInClvsEnabledFlag(m_resChangeInClvsEnabled || m_constrainedRaslEncoding); + sps.setRprEnabledFlag(m_rprEnabledFlag); +#endif #if JVET_AD0045 sps.setGOPBasedRPREnabledFlag(m_gopBasedRPREnabledFlag); #endif