Commit 1693f77e authored by FANGJUN PU's avatar FANGJUN PU
Browse files

Reduce memory allocation; Constrain SII-Processing only for multiple shutter...

Reduce memory allocation; Constrain SII-Processing only for multiple shutter intervals case (fixed shutter interval does regular coding)
parent 606a5b19
......@@ -142,7 +142,8 @@ Void TAppDecTop::decode()
Bool loopFiltered = false;
#if SHUTTER_INTERVAL_SEI_PROCESSING
Bool openedPostFile = false;
setShutterFilterFlag(false);
setShutterFilterFlag(!m_shutterIntervalPostFileName.empty()); // not apply shutter interval SEI processing if filename is not specified.
m_cTDecTop.setShutterFilterFlag(getShutterFilterFlag());
#endif
while (!!bitstreamFile)
......@@ -241,24 +242,38 @@ Void TAppDecTop::decode()
TComList<TComPic*>::iterator iterPic = pcListPic->begin();
TComPic* pcPic = *(iterPic);
SEIMessages shutterIntervalInfo = getSeisByType(pcPic->getSEIs(), SEI::SHUTTER_INTERVAL_INFO);
if (shutterIntervalInfo.size() > 0)
if (!m_shutterIntervalPostFileName.empty())
{
SEIShutterIntervalInfo *seiShutterIntervalInfo = (SEIShutterIntervalInfo*) *(shutterIntervalInfo.begin());
if (!seiShutterIntervalInfo->m_siiFixedSIwithinCLVS)
if (shutterIntervalInfo.size() > 0)
{
UInt arraySize = seiShutterIntervalInfo->m_siiMaxSubLayersMinus1 + 1;
UInt numUnitsLFR = seiShutterIntervalInfo->m_siiSubLayerNumUnitsInSI[0];
UInt numUnitsHFR = seiShutterIntervalInfo->m_siiSubLayerNumUnitsInSI[arraySize - 1];
setShutterFilterFlag(numUnitsLFR == 2 * numUnitsHFR);
const TComSPS* activeSPS = &(pcListPic->front()->getPicSym()->getSPS());
if (numUnitsLFR == 2 * numUnitsHFR && activeSPS->getMaxTLayers() == 1 && activeSPS->getMaxDecPicBuffering(0) == 1)
SEIShutterIntervalInfo *seiShutterIntervalInfo = (SEIShutterIntervalInfo*) *(shutterIntervalInfo.begin());
if (!seiShutterIntervalInfo->m_siiFixedSIwithinCLVS)
{
fprintf(stderr, "Warning: Shutter Interval SEI message processing is disabled for single TempLayer and single frame in DPB\n");
UInt arraySize = seiShutterIntervalInfo->m_siiMaxSubLayersMinus1 + 1;
UInt numUnitsLFR = seiShutterIntervalInfo->m_siiSubLayerNumUnitsInSI[0];
UInt numUnitsHFR = seiShutterIntervalInfo->m_siiSubLayerNumUnitsInSI[arraySize - 1];
setShutterFilterFlag(numUnitsLFR == 2 * numUnitsHFR);
const TComSPS* activeSPS = &(pcListPic->front()->getPicSym()->getSPS());
if (numUnitsLFR == 2 * numUnitsHFR && activeSPS->getMaxTLayers() == 1 && activeSPS->getMaxDecPicBuffering(0) == 1)
{
fprintf(stderr, "Warning: Shutter Interval SEI message processing is disabled for single TempLayer and single frame in DPB\n");
setShutterFilterFlag(false);
}
}
else
{
fprintf(stderr, "Warning: Shutter Interval SEI message processing is disabled for fixed shutter interval case\n");
setShutterFilterFlag(false);
}
}
else
{
fprintf(stderr, "Warning: Shutter Interval information should be specified in SII-SEI message\n");
setShutterFilterFlag(false);
}
}
if ((!m_shutterIntervalPostFileName.empty()) && (!openedPostFile) && getShutterFilterFlag())
{
const BitDepths &bitDepths = pcListPic->front()->getPicSym()->getSPS().getBitDepths();
......@@ -721,27 +736,33 @@ Void TAppDecTop::xFlushOutput( TComList<TComPic*>* pcListPic )
}
pcPic->setOutputMark(false);
}
#if !SHUTTER_INTERVAL_SEI_PROCESSING
#if SHUTTER_INTERVAL_SEI_PROCESSING
if (pcPic != NULL && (m_shutterIntervalPostFileName.empty() || !getShutterFilterFlag()))
#else
if(pcPic != NULL)
#endif
{
pcPic->destroy();
delete pcPic;
pcPic = NULL;
}
#endif
iterPic++;
}
#if SHUTTER_INTERVAL_SEI_PROCESSING
while (iterPic != pcListPic->end())
if (!m_shutterIntervalPostFileName.empty() && getShutterFilterFlag())
{
pcPic = *(iterPic);
if (pcPic != NULL)
iterPic = pcListPic->begin();
while (iterPic != pcListPic->end())
{
pcPic->destroy();
delete pcPic;
pcPic = NULL;
pcPic = *(iterPic);
if (pcPic != NULL)
{
pcPic->destroy();
delete pcPic;
pcPic = NULL;
}
iterPic++;
}
iterPic++;
}
#endif
}
......
......@@ -2041,7 +2041,7 @@ Bool TAppEncCfg::parseCfg( Int argc, TChar* argv[] )
}
else
{
printf("Warning: Input number of units in Sii SEI should be greater than 1 and number of LFR units should be 2 times of number of HFR units\n");
printf("Warning: SII-processing is applied for multiple shutter intervals and number of LFR units should be 2 times of number of HFR units\n");
}
#endif
}
......
......@@ -68,9 +68,17 @@ TComPic::~TComPic()
}
#if REDUCED_ENCODER_MEMORY
#if SHUTTER_INTERVAL_SEI_PROCESSING
Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction, const Bool bCreateForProcessedReconstruction )
#else
Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction )
#endif
#else
Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual)
#if SHUTTER_INTERVAL_SEI_PROCESSING
Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual, const Bool bCreateForProcessedReconstruction )
#else
Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual )
#endif
#endif
{
destroy();
......@@ -99,7 +107,10 @@ Void TComPic::create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirt
#endif
m_apcPicYuv[PIC_YUV_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
#if SHUTTER_INTERVAL_SEI_PROCESSING
m_apcPicYuv[PIC_YUV_POST_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_POST_REC]->create( iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true );
if (bCreateForProcessedReconstruction)
{
m_apcPicYuv[PIC_YUV_POST_REC] = new TComPicYuv; m_apcPicYuv[PIC_YUV_POST_REC]->create(iWidth, iHeight, chromaFormatIDC, uiMaxCuWidth, uiMaxCuHeight, uiMaxDepth, true);
}
#endif
#if REDUCED_ENCODER_MEMORY
}
......@@ -135,7 +146,11 @@ Void TComPic::prepareForEncoderSourcePicYuv()
}
}
#if SHUTTER_INTERVAL_SEI_PROCESSING
Void TComPic::prepareForReconstruction( const Bool bCreateForProcessedReconstruction )
#else
Void TComPic::prepareForReconstruction()
#endif
{
if (m_apcPicYuv[PIC_YUV_REC] == NULL)
{
......@@ -154,7 +169,7 @@ Void TComPic::prepareForReconstruction()
m_apcPicYuv[PIC_YUV_REC]->setBorderExtension(false);
#if SHUTTER_INTERVAL_SEI_PROCESSING
if (m_apcPicYuv[PIC_YUV_POST_REC] == NULL)
if (m_apcPicYuv[PIC_YUV_POST_REC] == NULL && bCreateForProcessedReconstruction)
{
const TComSPS &sps = m_picSym.getSPS();
const ChromaFormat chromaFormatIDC = sps.getChromaFormatIdc();
......@@ -168,7 +183,10 @@ Void TComPic::prepareForReconstruction()
}
// mark it should be extended
m_apcPicYuv[PIC_YUV_POST_REC]->setBorderExtension(false);
if (bCreateForProcessedReconstruction)
{
m_apcPicYuv[PIC_YUV_POST_REC]->setBorderExtension(false);
}
#endif
m_picSym.prepareForReconstruction();
......
......@@ -95,14 +95,26 @@ public:
virtual ~TComPic();
#if REDUCED_ENCODER_MEMORY
#if SHUTTER_INTERVAL_SEI_PROCESSING
Void create( const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction, const Bool bCreateForProcessedReconstruction );
#else
Void create( const TComSPS &sps, const TComPPS &pps, const Bool bCreateEncoderSourcePicYuv, const Bool bCreateForImmediateReconstruction );
#endif
Void prepareForEncoderSourcePicYuv();
#if SHUTTER_INTERVAL_SEI_PROCESSING
Void prepareForReconstruction( const Bool bCreateForProcessedReconstruction );
#else
Void prepareForReconstruction();
#endif
Void releaseReconstructionIntermediateData();
Void releaseAllReconstructionData();
Void releaseEncoderSourceImageData();
#else
#if SHUTTER_INTERVAL_SEI_PROCESSING
Void create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual /*= false*/, const Bool bCreateForProcessedReconstruction );
#else
Void create( const TComSPS &sps, const TComPPS &pps, const Bool bIsVirtual /*= false*/ );
#endif
#endif
virtual Void destroy();
......
......@@ -169,9 +169,17 @@ Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic
rpcPic = new TComPic();
#if REDUCED_ENCODER_MEMORY
#if SHUTTER_INTERVAL_SEI_PROCESSING
rpcPic->create ( sps, pps, false, true, getShutterFilterFlag() );
#else
rpcPic->create ( sps, pps, false, true);
#endif
#else
#if SHUTTER_INTERVAL_SEI_PROCESSING
rpcPic->create ( sps, pps, true, getShutterFilterFlag());
#else
rpcPic->create ( sps, pps, true);
#endif
#endif
m_cListPic.pushBack( rpcPic );
......@@ -210,10 +218,18 @@ Void TDecTop::xGetNewPicBuffer ( const TComSPS &sps, const TComPPS &pps, TComPic
}
rpcPic->destroy();
#if REDUCED_ENCODER_MEMORY
#if SHUTTER_INTERVAL_SEI_PROCESSING
rpcPic->create ( sps, pps, false, true, getShutterFilterFlag() );
#else
rpcPic->create ( sps, pps, false, true);
#endif
#else
#if SHUTTER_INTERVAL_SEI_PROCESSING
rpcPic->create ( sps, pps, true, getShutterFilterFlag() );
#else
rpcPic->create ( sps, pps, true);
#endif
#endif
}
Void TDecTop::executeLoopFilters(Int& poc, TComList<TComPic*>*& rpcListPic)
......
......@@ -107,6 +107,9 @@ private:
Int m_lastPOCNoOutputPriorPics;
Bool m_isNoOutputPriorPics;
Bool m_craNoRaslOutputFlag; //value of variable NoRaslOutputFlag of the last CRA pic
#if SHUTTER_INTERVAL_SEI_PROCESSING
Bool m_ShutterFilterEnable; // Shutter Interval SEI Processing
#endif
#if O0043_BEST_EFFORT_DECODING
UInt m_forceDecodeBitDepth;
#endif
......@@ -151,6 +154,10 @@ public:
Void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; }
Bool getFirstSliceInSequence () { return m_bFirstSliceInSequence; }
Void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; }
#if SHUTTER_INTERVAL_SEI_PROCESSING
Bool getShutterFilterFlag () const { return m_ShutterFilterEnable; }
Void setShutterFilterFlag (Bool value) { m_ShutterFilterEnable = value; }
#endif
#if O0043_BEST_EFFORT_DECODING
Void setForceDecodeBitDepth(UInt bitDepth) { m_forceDecodeBitDepth = bitDepth; }
#endif
......
......@@ -1264,7 +1264,11 @@ Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rc
xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField );
#if REDUCED_ENCODER_MEMORY
#if SHUTTER_INTERVAL_SEI_PROCESSING
pcPic->prepareForReconstruction( m_pcCfg->getShutterFilterFlag() );
#else
pcPic->prepareForReconstruction();
#endif
#endif
// Slice data initialization
......
......@@ -122,13 +122,25 @@ TEncPic::~TEncPic()
* \param bIsVirtual
*/
#if REDUCED_ENCODER_MEMORY
#if SHUTTER_INTERVAL_SEI_PROCESSING
Void TEncPic::create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth, const Bool bCreateForProcessedReconstruction )
{
TComPic::create( sps, pps, true, false, bCreateForProcessedReconstruction );
#else
Void TEncPic::create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth )
{
TComPic::create( sps, pps, true, false );
#endif
#else
#if SHUTTER_INTERVAL_SEI_PROCESSING
Void TEncPic::create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth, Bool bIsVirtual, const Bool bCreateForProcessedReconstruction )
{
TComPic::create( sps, pps, bIsVirtual, bCreateForProcessedReconstruction );
#else
Void TEncPic::create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth, Bool bIsVirtual )
{
TComPic::create( sps, pps, bIsVirtual );
#endif
#endif
const Int iWidth = sps.getPicWidthInLumaSamples();
const Int iHeight = sps.getPicHeightInLumaSamples();
......
......@@ -103,9 +103,17 @@ public:
virtual ~TEncPic();
#if REDUCED_ENCODER_MEMORY
#if SHUTTER_INTERVAL_SEI_PROCESSING
Void create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth, const Bool bCreateForProcessedReconstruction );
#else
Void create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth );
#endif
#else
#if SHUTTER_INTERVAL_SEI_PROCESSING
Void create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth, Bool bIsVirtual /* = false*/, const Bool bCreateForProcessedReconstruction );
#else
Void create( const TComSPS &sps, const TComPPS &pps, UInt uiMaxAdaptiveQPDepth, Bool bIsVirtual /* = false*/ );
#endif
#endif
virtual Void destroy();
......
......@@ -546,9 +546,17 @@ Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic, Int ppsId )
{
TEncPic* pcEPic = new TEncPic;
#if REDUCED_ENCODER_MEMORY
#if SHUTTER_INTERVAL_SEI_PROCESSING
pcEPic->create( sps, pps, pps.getMaxCuDQPDepth() + 1, getShutterFilterFlag() );
#else
pcEPic->create( sps, pps, pps.getMaxCuDQPDepth()+1);
#endif
#else
#if SHUTTER_INTERVAL_SEI_PROCESSING
pcEPic->create(sps, pps, pps.getMaxCuDQPDepth() + 1, false, getShutterFilterFlag() );
#else
pcEPic->create( sps, pps, pps.getMaxCuDQPDepth()+1, false);
#endif
#endif
rpcPic = pcEPic;
}
......@@ -556,9 +564,17 @@ Void TEncTop::xGetNewPicBuffer ( TComPic*& rpcPic, Int ppsId )
{
rpcPic = new TComPic;
#if REDUCED_ENCODER_MEMORY
#if SHUTTER_INTERVAL_SEI_PROCESSING
rpcPic->create( sps, pps, true, false, getShutterFilterFlag() );
#else
rpcPic->create( sps, pps, true, false );
#endif
#else
#if SHUTTER_INTERVAL_SEI_PROCESSING
rpcPic->create( sps, pps, false, getShutterFilterFlag() );
#else
rpcPic->create( sps, pps, false );
#endif
#endif
}
......
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