Commit 398c6a8e authored by Karsten Suehring's avatar Karsten Suehring
Browse files

Merge branch 'cropping_cleanup' into 'master'

Update Conformance Window code (backport from VTM)

See merge request !48
parents 25a3497d 0b61a88d
......@@ -787,8 +787,8 @@ Bool TAppEncCfg::parseCfg( Int argc, TChar* 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)")
......@@ -814,14 +814,9 @@ Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
("xPSNRCrWeight,-xPS2", m_dXPSNRWeight[COMPONENT_Cr], ( Double )1.0, "xPSNR weighting factor for Cr (default: 1.0)")
("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")
......@@ -1382,8 +1377,8 @@ Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
/*
* Set any derived parameters
*/
m_inputFileWidth = m_iSourceWidth;
m_inputFileHeight = m_iSourceHeight;
m_inputFileWidth = m_sourceWidth;
m_inputFileHeight = m_sourceHeight;
if (!inputPathPrefix.empty() && inputPathPrefix.back() != '/' && inputPathPrefix.back() != '\\' )
{
......@@ -1396,9 +1391,9 @@ Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
if(m_isField)
{
//Frame height
m_iSourceHeightOrg = m_iSourceHeight;
m_sourceHeightOrg = m_sourceHeight;
//Field height
m_iSourceHeight = m_iSourceHeight >> 1;
m_sourceHeight = m_sourceHeight >> 1;
//number of fields to encode
m_framesToBeEncoded *= 2;
}
......@@ -1671,56 +1666,66 @@ Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
break;
}
m_inputColourSpaceConvert = stringToInputColourSpaceConvert(inputColourSpaceConvert, true);
// Picture width and height must be multiples of 8 and minCuSize
const Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1);
const Int minResolutionMultiple = std::max(8, minCuSize);
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
Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1);
if (m_iSourceWidth % minCuSize)
if (m_sourceWidth % minResolutionMultiple)
{
m_aiPad[0] = m_confWinRight = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - 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 % minCuSize)
if (m_sourceHeight % minResolutionMultiple)
{
m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - 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_sourceHeightOrg += m_confWinBottom << 1;
m_sourcePadding[1] = m_confWinBottom << 1;
}
}
if (m_aiPad[0] % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0)
if (m_sourcePadding[0] % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0)
{
fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n");
exit(EXIT_FAILURE);
}
if (m_aiPad[1] % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0)
if (m_sourcePadding[1] % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0)
{
fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n");
exit(EXIT_FAILURE);
}
if (m_sourcePadding[0])
{
fprintf(stderr, "Info: Conformance window automatically enabled. Adding %i lumal pel horizontally\n", m_sourcePadding[0]);
}
if (m_sourcePadding[1])
{
fprintf(stderr, "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:
......@@ -1730,14 +1735,19 @@ Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
{
fprintf(stderr, "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))
{
fprintf(stderr, "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;
}
}
if ((m_sourceWidth% minResolutionMultiple) || (m_sourceHeight % minResolutionMultiple))
{
fprintf(stderr, "Picture width or height (after padding) is not a multiple of 8 or minCuSize, please use ConformanceWindowMode=1 for automatic adjustment or ConformanceWindowMode=2 to specify padding manually!\n");
exit(EXIT_FAILURE);
}
if (tmpSliceMode<0 || tmpSliceMode>=Int(NUMBER_OF_SLICE_CONSTRAINT_MODES))
{
......@@ -2008,8 +2018,8 @@ Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
info.m_fisheyeSceneRadius = cfg_fviSEIFisheyeSceneRadius.values[i];
// check rectangular region is within the conformance window.
if ( (!( info.m_fisheyeRectRegionHeight >= 1 && m_confWinTop <= info.m_fisheyeRectRegionTop && info.m_fisheyeRectRegionTop + info.m_fisheyeRectRegionHeight < m_iSourceHeight -m_confWinBottom ) ) ||
(!( info.m_fisheyeRectRegionWidth >= 1 && m_confWinLeft <= info.m_fisheyeRectRegionLeft && info.m_fisheyeRectRegionLeft + info.m_fisheyeRectRegionWidth < m_iSourceWidth -m_confWinRight ) ) )
if ( (!( info.m_fisheyeRectRegionHeight >= 1 && m_confWinTop <= info.m_fisheyeRectRegionTop && info.m_fisheyeRectRegionTop + info.m_fisheyeRectRegionHeight < m_sourceHeight -m_confWinBottom ) ) ||
(!( info.m_fisheyeRectRegionWidth >= 1 && m_confWinLeft <= info.m_fisheyeRectRegionLeft && info.m_fisheyeRectRegionLeft + info.m_fisheyeRectRegionWidth < m_sourceWidth -m_confWinRight ) ) )
{
fprintf(stderr, "Fisheye region is not within visible area\n");
exit (EXIT_FAILURE);
......@@ -2365,8 +2375,8 @@ Void TAppEncCfg::xCheckParameter()
xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8");
xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16");
xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16");
xConfirmPara( (m_iSourceWidth % (m_uiMaxCUWidth >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame width must be a multiple of the minimum CU size");
xConfirmPara( (m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame height must be a multiple of the minimum CU size");
xConfirmPara( (m_sourceWidth % (m_uiMaxCUWidth >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame width must be a multiple of the minimum CU size");
xConfirmPara( (m_sourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth-1)))!=0, "Resulting coded frame height must be a multiple of the minimum CU size");
xConfirmPara( m_uiQuadtreeTULog2MinSize < 2, "QuadtreeTULog2MinSize must be 2 or greater.");
xConfirmPara( m_uiQuadtreeTULog2MaxSize > 5, "QuadtreeTULog2MaxSize must be 5 or smaller.");
......@@ -2414,11 +2424,11 @@ Void TAppEncCfg::xCheckParameter()
xConfirmPara( tileFlag && m_entropyCodingSyncEnabledFlag, "Tiles and entropy-coding-sync (Wavefronts) can not be applied together, except in the High Throughput Intra 4:4:4 16 profile");
}
xConfirmPara( m_iSourceWidth % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
xConfirmPara( m_sourceWidth % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
xConfirmPara( m_sourceHeight % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
xConfirmPara( m_aiPad[0] % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
xConfirmPara( m_sourcePadding[0] % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
xConfirmPara( m_sourcePadding[1] % TComSPS::getWinUnitY(m_chromaFormatIDC) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
xConfirmPara( m_confWinLeft % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
xConfirmPara( m_confWinRight % TComSPS::getWinUnitX(m_chromaFormatIDC) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
......@@ -2785,7 +2795,7 @@ Void TAppEncCfg::xCheckParameter()
#if DPB_ENCODER_USAGE_CHECK
// Check DPB Usage:
Int dpbSize=profileLevelTierFeatures.getMaxDPBNumFrames(m_iSourceWidth*m_iSourceHeight);
Int dpbSize=profileLevelTierFeatures.getMaxDPBNumFrames(m_sourceWidth*m_sourceHeight);
if (dpbSize!=-1)
{
Int dpbUsage=xDPBUsage(0);
......@@ -2800,13 +2810,13 @@ Void TAppEncCfg::xCheckParameter()
if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
{
Int PicSizeInSamplesY = m_iSourceWidth * m_iSourceHeight;
Int PicSizeInSamplesY = m_sourceWidth * m_sourceHeight;
if(tileFlag)
{
Int maxTileWidth = 0;
Int maxTileHeight = 0;
Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth;
Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight;
Int widthInCU = (m_sourceWidth % m_uiMaxCUWidth) ? m_sourceWidth/m_uiMaxCUWidth + 1: m_sourceWidth/m_uiMaxCUWidth;
Int heightInCU = (m_sourceHeight % m_uiMaxCUHeight) ? m_sourceHeight/m_uiMaxCUHeight + 1: m_sourceHeight/m_uiMaxCUHeight;
if(m_tileUniformSpacingFlag)
{
maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_numTileColumnsMinus1)/(m_numTileColumnsMinus1+1));
......@@ -2815,20 +2825,20 @@ Void TAppEncCfg::xCheckParameter()
// the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
if(!((heightInCU-1)%(m_numTileRowsMinus1+1)))
{
maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_sourceHeight % m_uiMaxCUHeight);
}
// if only the last tile-column is one treeblock wider than the others
// the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others
if(!((widthInCU-1)%(m_numTileColumnsMinus1+1)))
{
maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_sourceWidth % m_uiMaxCUWidth);
}
}
else // not uniform spacing
{
if(m_numTileColumnsMinus1<1)
{
maxTileWidth = m_iSourceWidth;
maxTileWidth = m_sourceWidth;
}
else
{
......@@ -2842,7 +2852,7 @@ Void TAppEncCfg::xCheckParameter()
}
if(m_numTileRowsMinus1<1)
{
maxTileHeight = m_iSourceHeight;
maxTileHeight = m_sourceHeight;
}
else
{
......@@ -2860,7 +2870,7 @@ Void TAppEncCfg::xCheckParameter()
}
else if(m_entropyCodingSyncEnabledFlag)
{
m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/((2*m_iSourceHeight+m_iSourceWidth)*m_uiMaxCUHeight)-4;
m_minSpatialSegmentationIdc = 4*PicSizeInSamplesY/((2*m_sourceHeight+m_sourceWidth)*m_uiMaxCUHeight)-4;
}
else if(m_sliceMode == FIXED_NUMBER_OF_CTU)
{
......@@ -3138,8 +3148,8 @@ Void TAppEncCfg::xPrintParameter()
printf("Input File : %s\n", m_inputFileName.c_str() );
printf("Bitstream File : %s\n", m_bitstreamFileName.c_str() );
printf("Reconstruction File : %s\n", m_reconFileName.c_str() );
printf("Real Format : %dx%d %gHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, (Double)m_iFrameRate/m_temporalSubsampleRatio );
printf("Internal Format : %dx%d %gHz\n", m_iSourceWidth, m_iSourceHeight, (Double)m_iFrameRate/m_temporalSubsampleRatio );
printf("Real Format : %dx%d %gHz\n", m_sourceWidth - m_confWinLeft - m_confWinRight, m_sourceHeight - m_confWinTop - m_confWinBottom, (Double)m_iFrameRate/m_temporalSubsampleRatio );
printf("Internal Format : %dx%d %gHz\n", m_sourceWidth, m_sourceHeight, (Double)m_iFrameRate/m_temporalSubsampleRatio );
printf("Sequence PSNR output : %s\n", (m_printMSEBasedSequencePSNR ? "Linear average, MSE-based" : "Linear average only") );
printf("Sequence MSE output : %s\n", (m_printSequenceMSE ? "Enabled" : "Disabled") );
printf("Frame MSE output : %s\n", (m_printFrameMSE ? "Enabled" : "Disabled") );
......@@ -3329,7 +3339,7 @@ Void TAppEncCfg::xPrintParameter()
printf("WPP:%d ", (Int)m_useWeightedPred);
printf("WPB:%d ", (Int)m_useWeightedBiPred);
printf("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;
printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_entropyCodingSyncEnabledFlag?1:0, iWaveFrontSubstreams);
printf(" ScalingList:%d ", m_useScalingListId );
printf("TMVPMode:%d ", m_TMVPModeId );
......
......@@ -84,12 +84,12 @@ protected:
Int m_iFrameRate; ///< source frame-rates (Hz)
UInt m_FrameSkip; ///< number of skipped frames from the beginning
UInt 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)
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)
Int m_iSourceHeightOrg; ///< original source height in pixel (when interlaced = frame height)
Int m_sourceHeightOrg; ///< original source height in pixel (when interlaced = frame height)
Bool m_isField; ///< enable field coding
Bool m_isTopFieldFirst;
......@@ -101,8 +101,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
InputColourSpaceConversion m_inputColourSpaceConvert; ///< colour space conversion to apply to input video
Bool m_snrInternalColourSpace; ///< if true, then no colour space conversion is applied for snr calculation, otherwise inverse of input is applied.
......
......@@ -117,8 +117,8 @@ Void TAppEncTop::xInitLibCfg()
m_cTEncTop.setFrameRate ( m_iFrameRate );
m_cTEncTop.setFrameSkip ( m_FrameSkip );
m_cTEncTop.setTemporalSubsampleRatio ( m_temporalSubsampleRatio );
m_cTEncTop.setSourceWidth ( m_iSourceWidth );
m_cTEncTop.setSourceHeight ( m_iSourceHeight );
m_cTEncTop.setSourceWidth ( m_sourceWidth );
m_cTEncTop.setSourceHeight ( m_sourceHeight );
m_cTEncTop.setConformanceWindow ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
m_cTEncTop.setFramesToBeEncoded ( m_framesToBeEncoded );
......@@ -145,7 +145,7 @@ Void TAppEncTop::xInitLibCfg()
m_cTEncTop.setIntraQPOffset ( m_intraQPOffset );
m_cTEncTop.setLambdaFromQPEnable ( m_lambdaFromQPEnable );
m_cTEncTop.setPad ( m_aiPad );
m_cTEncTop.setSourcePadding ( m_sourcePadding );
m_cTEncTop.setAccessUnitDelimiter ( m_AccessUnitDelimiter );
......@@ -631,13 +631,13 @@ Void TAppEncTop::encode()
// allocate original YUV buffer
if( m_isField )
{
pcPicYuvOrg->create ( m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true);
pcPicYuvOrg->create ( m_sourceWidth, m_sourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
cPicYuvTrueOrg.create(m_sourceWidth, m_sourceHeightOrg, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true);
}
else
{
pcPicYuvOrg->create ( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
cPicYuvTrueOrg.create(m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
pcPicYuvOrg->create ( m_sourceWidth, m_sourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
cPicYuvTrueOrg.create(m_sourceWidth, m_sourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
}
#if EXTENSION_360_VIDEO
......@@ -646,8 +646,8 @@ Void TAppEncTop::encode()
TEncTemporalFilter temporalFilter;
if (m_gopBasedTemporalFilterEnabled)
{
temporalFilter.init(m_FrameSkip, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth, m_iSourceWidth, m_iSourceHeight,
m_aiPad, m_framesToBeEncoded, m_bClipInputVideoToRec709Range, m_inputFileName, m_chromaFormatIDC,
temporalFilter.init(m_FrameSkip, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth, m_sourceWidth, m_sourceHeight,
m_sourcePadding, m_framesToBeEncoded, m_bClipInputVideoToRec709Range, m_inputFileName, m_chromaFormatIDC,
m_inputColourSpaceConvert, m_iQP, m_iGOPSize, m_gopBasedTemporalFilterStrengths,
m_gopBasedTemporalFilterFutureReference);
}
......@@ -664,10 +664,10 @@ Void TAppEncTop::encode()
}
else
{
m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_sourcePadding, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
}
#else
m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
m_cTVideoIOYuvInputFile.read( pcPicYuvOrg, &cPicYuvTrueOrg, ipCSC, m_sourcePadding, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
#endif
if (m_gopBasedTemporalFilterEnabled)
......@@ -757,7 +757,7 @@ Void TAppEncTop::xGetBuffer( TComPicYuv*& rpcPicYuvRec)
{
rpcPicYuvRec = new TComPicYuv;
rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
rpcPicYuvRec->create( m_sourceWidth, m_sourceHeight, m_chromaFormatIDC, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxTotalCUDepth, true );
}
m_cListPicYuvRec.pushBack( rpcPicYuvRec );
......
......@@ -959,13 +959,13 @@ public:
Int getWindowBottomOffset() const { return m_enabledFlag ? m_winBottomOffset: 0; }
Void setWindowBottomOffset(Int val) { m_winBottomOffset = val; m_enabledFlag = true; }
Void setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom)
Void setWindow(Int offsetLeft, Int offsetRight, Int offsetTop, Int offsetBottom)
{
m_enabledFlag = true;
m_enabledFlag = (offsetLeft || offsetRight || offsetTop || offsetBottom);
m_winLeftOffset = offsetLeft;
m_winRightOffset = offsetLRight;
m_winTopOffset = offsetLTop;
m_winBottomOffset = offsetLBottom;
m_winRightOffset = offsetRight;
m_winTopOffset = offsetTop;
m_winBottomOffset = offsetBottom;
}
Bool operator == (const Window &rhs) const
{
......
......@@ -175,7 +175,7 @@ protected:
Int m_iQP; // if (AdaptiveQP == OFF)
Int m_intraQPOffset; ///< QP offset for intra slice (integer)
Int m_lambdaFromQPEnable; ///< enable lambda derivation from QP
Int m_aiPad[2];
Int m_sourcePadding[2];
Bool m_AccessUnitDelimiter; ///< add Access Unit Delimiter NAL units
......@@ -607,7 +607,7 @@ public:
Void setQP ( Int i ) { m_iQP = i; }
Void setIntraQPOffset ( Int i ) { m_intraQPOffset = i; }
Void setLambdaFromQPEnable ( Bool b ) { m_lambdaFromQPEnable = b; }
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; }
......@@ -723,7 +723,7 @@ protected:
Int getBaseQP () const { return m_iQP; } // public should use getQPForPicture.
public:
Int getQPForPicture (const UInt gopIndex, const TComSlice *pSlice) const; // Function actually defined in TEncTop.cpp
Int getPad ( Int i ) { assert (i < 2 ); return m_aiPad[i]; }
Int getSourcePadding ( Int i ) const { assert (i < 2 ); return m_sourcePadding[i]; }
Bool getAccessUnitDelimiter() const { return m_AccessUnitDelimiter; }
Void setAccessUnitDelimiter(Bool val){ m_AccessUnitDelimiter = val; }
......
......@@ -2307,8 +2307,8 @@ Void TEncGOP::xCalculateAddPSNR( TComPic* pcPic, TComPicYuv* pcPicD, const Acces
iOrgStride[ch] = pOrgPicYuv->getStride(ch);
iRecStride[ch] = picd.getStride(ch);
iWidth[ch] = pcPicD->getWidth (ch) - (m_pcEncTop->getPad(0) >> pcPic->getComponentScaleX(ch));
iHeight[ch] = pcPicD->getHeight(ch) - ((m_pcEncTop->getPad(1) >> (pcPic->isField()?1:0)) >> pcPic->getComponentScaleY(ch));
iWidth[ch] = pcPicD->getWidth (ch) - (m_pcEncTop->getSourcePadding(0) >> pcPic->getComponentScaleX(ch));
iHeight[ch] = pcPicD->getHeight(ch) - ((m_pcEncTop->getSourcePadding(1) >> (pcPic->isField()?1:0)) >> pcPic->getComponentScaleY(ch));
iSize[ch] = iWidth[ch]*iHeight[ch];
uiSSDtemp[ch] = 0;
uiShiftWidth[ch] = (ch == COMPONENT_Y || pcPicD->getChromaFormat() == CHROMA_444) ? 0 : 1;
......@@ -2378,8 +2378,8 @@ Void TEncGOP::xCalculateAddPSNR( TComPic* pcPic, TComPicYuv* pcPicD, const Acces
const Int iOrgStride = pOrgPicYuv->getStride(ch);
Pel* pRec = picd.getAddr(ch);
const Int iRecStride = picd.getStride(ch);
const Int iWidth = pcPicD->getWidth (ch) - (m_pcEncTop->getPad(0) >> pcPic->getComponentScaleX(ch));
const Int iHeight = pcPicD->getHeight(ch) - ((m_pcEncTop->getPad(1) >> (pcPic->isField()?1:0)) >> pcPic->getComponentScaleY(ch));
const Int iWidth = pcPicD->getWidth (ch) - (m_pcEncTop->getSourcePadding(0) >> pcPic->getComponentScaleX(ch));
const Int iHeight = pcPicD->getHeight(ch) - ((m_pcEncTop->getSourcePadding(1) >> (pcPic->isField()?1:0)) >> pcPic->getComponentScaleY(ch));
Int iSize = iWidth*iHeight;
......@@ -2414,8 +2414,8 @@ Void TEncGOP::xCalculateAddPSNR( TComPic* pcPic, TComPicYuv* pcPicD, const Acces
const Int orgStride = pOrgPicYuv->getStride(ch);
const Pel* pRec = picd.getAddr(ch);
const Int recStride = picd.getStride(ch);
const Int width = pcPicD->getWidth (ch) - (m_pcEncTop->getPad(0) >> pcPic->getComponentScaleX(ch));
const Int height = pcPicD->getHeight(ch) - ((m_pcEncTop->getPad(1) >> (pcPic->isField()?1:0)) >> pcPic->getComponentScaleY(ch));
const Int width = pcPicD->getWidth (ch) - (m_pcEncTop->getSourcePadding(0) >> pcPic->getComponentScaleX(ch));
const Int height = pcPicD->getHeight(ch) - ((m_pcEncTop->getSourcePadding(1) >> (pcPic->isField()?1:0)) >> pcPic->getComponentScaleY(ch));
const UInt bitDepth = pcPic->getPicSym()->getSPS().getBitDepth(toChannelType(ch));
result.MSSSIM[ch] = xCalculateMSSSIM (pOrg, orgStride, pRec, recStride, width, height, bitDepth);
......@@ -2777,8 +2777,8 @@ Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgFirstField, TComPic*
const ComponentID ch=ComponentID(chan);
iOrgStride[ch] = pOrgPicYuv->getStride(ch);
iRecStride[ch] = pcPicD->getStride(ch);
iWidth[ch] = pcPicD->getWidth (ch) - (m_pcEncTop->getPad(0) >> pcPic->getComponentScaleX(ch));
iHeight[ch] = pcPicD->getHeight(ch) - ((m_pcEncTop->getPad(1) >> 1) >> pcPic->getComponentScaleY(ch));
iWidth[ch] = pcPicD->getWidth (ch) - (m_pcEncTop->getSourcePadding(0) >> pcPic->getComponentScaleX(ch));
iHeight[ch] = pcPicD->getHeight(ch) - ((m_pcEncTop->getSourcePadding(1) >> 1) >> pcPic->getComponentScaleY(ch));
iSize[ch] = iWidth[ch]*iHeight[ch];
uiSSDtemp[ch] = 0;
uiShiftWidth[ch] = (ch == COMPONENT_Y || pcPicD->getChromaFormat() == CHROMA_444) ? 0 : 1;
......@@ -2847,8 +2847,8 @@ Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgFirstField, TComPic*
assert(apcPicRecFields[0]->getHeight(ch)==apcPicRecFields[1]->getHeight(ch));
UInt64 uiSSDtemp=0;
const Int iWidth = apcPicRecFields[0]->getWidth (ch) - (m_pcEncTop->getPad(0) >> apcPicRecFields[0]->getComponentScaleX(ch));
const Int iHeight = apcPicRecFields[0]->getHeight(ch) - ((m_pcEncTop->getPad(1) >> 1) >> apcPicRecFields[0]->getComponentScaleY(ch));
const Int iWidth = apcPicRecFields[0]->getWidth (ch) - (m_pcEncTop->getSourcePadding(0) >> apcPicRecFields[0]->getComponentScaleX(ch));
const Int iHeight = apcPicRecFields[0]->getHeight(ch) - ((m_pcEncTop->getSourcePadding(1) >> 1) >> apcPicRecFields[0]->getComponentScaleY(ch));
Int iSize = iWidth*iHeight;
......@@ -2889,8 +2889,8 @@ Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgFirstField, TComPic*
assert(apcPicRecFields[0]->getHeight(ch)==apcPicRecFields[1]->getHeight(ch));
Double sumOverFieldsMSSSIM = 0.0;
const Int width = apcPicRecFields[0]->getWidth (ch) - ( m_pcEncTop->getPad(0) >> apcPicRecFields[0]->getComponentScaleX(ch));
const Int height = apcPicRecFields[0]->getHeight(ch) - ((m_pcEncTop->getPad(1) >> 1) >> apcPicRecFields[0]->getComponentScaleY(ch));
const Int width = apcPicRecFields[0]->getWidth (ch) - ( m_pcEncTop->getSourcePadding(0) >> apcPicRecFields[0]->getComponentScaleX(ch));
const Int height = apcPicRecFields[0]->getHeight(ch) - ((m_pcEncTop->getSourcePadding(1) >> 1) >> apcPicRecFields[0]->getComponentScaleY(ch));
for(UInt fieldNum=0; fieldNum<2; fieldNum++)
{
......
......@@ -94,7 +94,7 @@ void TEncTemporalFilter::init(const Int frameSkip,
const Int internalBitDepth[MAX_NUM_CHANNEL_TYPE],
const Int width,
const Int height,
const Int *pad,
const Int *padding,
const Int frames,
const Bool Rec709,
const std::string &filename,
......@@ -117,7 +117,7 @@ void TEncTemporalFilter::init(const Int frameSkip,
m_sourceHeight = height;
for (Int i = 0; i < 2; i++)
{
m_aiPad[i] = pad[i];
m_sourcePadding[i] = padding[i];
}
m_framesToBeEncoded = frames; // NOT USED.
m_bClipInputVideoToRec709Range = Rec709;
......@@ -155,7 +155,7 @@ Bool TEncTemporalFilter::filter(TComPicYuv *orgPic, Int receivedPoc)
Int offset = m_FrameSkip;
TVideoIOYuv yuvFrames;
yuvFrames.open(m_inputFileName, false, m_inputBitDepth, m_MSBExtendedBitDepth, m_internalBitDepth);
yuvFrames.skipFrames(std::max(offset + receivedPoc - s_range, 0), m_sourceWidth - m_aiPad[0], m_sourceHeight - m_aiPad[1], m_chromaFormatIDC);
yuvFrames.skipFrames(std::max(offset + receivedPoc - s_range, 0), m_sourceWidth - m_sourcePadding[0], m_sourceHeight - m_sourcePadding[1], m_chromaFormatIDC);
std::deque<TemporalFilterSourcePicInfo> srcFrameInfo;
......@@ -191,7 +191,7 @@ Bool TEncTemporalFilter::filter(TComPicYuv *orgPic, Int receivedPoc)
}
else if (poc == offset + receivedPoc)
{ // hop over frame that will be filtered
yuvFrames.skipFrames(1, m_sourceWidth - m_aiPad[0], m_sourceHeight - m_aiPad[1], m_chromaFormatIDC);
yuvFrames.skipFrames(1, m_sourceWidth - m_sourcePadding[0], m_sourceHeight - m_sourcePadding[1], m_chromaFormatIDC);
origOffset++;
continue;
}
......@@ -201,7 +201,7 @@ Bool TEncTemporalFilter::filter(TComPicYuv *orgPic, Int receivedPoc)
TComPicYuv dummyPicBufferTO; // Only used temporary in yuvFrames.read
srcPic.picBuffer.createWithoutCUInfo(m_sourceWidth, m_sourceHeight, m_chromaFormatIDC, true, s_padding, s_padding);
dummyPicBufferTO.createWithoutCUInfo(m_sourceWidth, m_sourceHeight, m_chromaFormatIDC, true, s_padding, s_padding);
if (!yuvFrames.read(&srcPic.picBuffer, &dummyPicBufferTO, m_inputColourSpaceConvert, m_aiPad, m_chromaFormatIDC, m_bClipInputVideoToRec709Range))
if (!yuvFrames.read(&srcPic.picBuffer, &dummyPicBufferTO, m_inputColourSpaceConvert, m_sourcePadding, m_chromaFormatIDC, m_bClipInputVideoToRec709Range))
{
return false; // eof or read fail
}
......
......@@ -143,7 +143,7 @@ private:
Int m_QP;
Int m_GOPSize;
std::map<Int, Double> m_temporalFilterStrengths;
Int m_aiPad[2];
Int m_sourcePadding[2];
Int m_framesToBeEncoded;
Bool m_bClipInputVideoToRec709Range;
InputColourSpaceConversion m_inputColourSpaceConvert;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment