Skip to content
Snippets Groups Projects
Commit 9b93350c authored by Vadim Seregin's avatar Vadim Seregin
Browse files

move to class members

parent 7f9227b6
No related branches found
No related tags found
1 merge request!1044Fix for #615 independent layer implementation
......@@ -65,6 +65,9 @@ EncApp::EncApp()
#if JVET_O0756_CALCULATE_HDRMETRICS
m_metricTime = std::chrono::milliseconds(0);
#endif
#if JVET_N0278_FIXES
m_numEncoded = 0;
#endif
}
EncApp::~EncApp()
......@@ -701,10 +704,19 @@ void EncApp::xInitLib(bool isFieldCoding)
// ====================================================================================================================
#if JVET_N0278_FIXES
std::list<PelUnitBuf*> recBufList;
void EncApp::createLib()
{
const int sourceHeight = m_isField ? m_iSourceHeightOrg : m_iSourceHeight;
UnitArea unitArea( m_chromaFormatIDC, Area( 0, 0, m_iSourceWidth, sourceHeight ) );
m_orgPic = new PelStorage;
m_trueOrgPic = new PelStorage;
m_orgPic->create( unitArea );
m_trueOrgPic->create( unitArea );
#if EXTENSION_360_VIDEO
m_ext360 = new TExt360AppEncTop( *this, m_cEncLib.getGOPEncoder()->getExt360Data(), *( m_cEncLib.getGOPEncoder() ), orgPic );
#endif
m_bitstream.open( m_bitstreamFileName.c_str(), fstream::binary | fstream::out );
if( !m_bitstream )
{
......@@ -713,8 +725,7 @@ void EncApp::createLib()
// initialize internal class & member variables
xInitLibCfg();
xCreateLib( recBufList
);
xCreateLib( m_recBufList );
xInitLib( m_isField );
printChromaFormat();
......@@ -727,104 +738,96 @@ void EncApp::destroyLib()
// delete used buffers in encoder class
m_cEncLib.deletePicBuffer();
for( auto &p : recBufList )
for( auto &p : m_recBufList )
{
delete p;
}
recBufList.clear();
m_recBufList.clear();
xDestroyLib();
m_bitstream.close();
m_orgPic->destroy();
m_trueOrgPic->destroy();
delete m_trueOrgPic;
delete m_orgPic;
#if EXTENSION_360_VIDEO
m_ext360->destroy();
delete m_ext360;
#endif
printRateSummary();
}
void EncApp::encode()
bool EncApp::encode()
{
// main encoder loop
int iNumEncoded = 0;
bool bEos = false;
const InputColourSpaceConversion ipCSC = m_inputColourSpaceConvert;
const InputColourSpaceConversion snrCSC = ( !m_snrInternalColourSpace ) ? m_inputColourSpaceConvert : IPCOLOURSPACE_UNCHANGED;
PelStorage trueOrgPic;
PelStorage orgPic;
const int sourceHeight = m_isField ? m_iSourceHeightOrg : m_iSourceHeight;
UnitArea unitArea( m_chromaFormatIDC, Area( 0, 0, m_iSourceWidth, sourceHeight ) );
orgPic.create( unitArea );
trueOrgPic.create( unitArea );
// read input YUV file
#if EXTENSION_360_VIDEO
TExt360AppEncTop ext360( *this, m_cEncLib.getGOPEncoder()->getExt360Data(), *( m_cEncLib.getGOPEncoder() ), orgPic );
#endif
while( !bEos )
if( m_ext360->isEnabled() )
{
// read input YUV file
#if EXTENSION_360_VIDEO
if( ext360.isEnabled() )
{
ext360.read( m_cVideoIOYuvInputFile, orgPic, trueOrgPic, ipCSC );
}
else
{
m_cVideoIOYuvInputFile.read( orgPic, trueOrgPic, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
}
m_ext360->read( m_cVideoIOYuvInputFile, orgPic, trueOrgPic, ipCSC );
}
else
{
m_cVideoIOYuvInputFile.read( *m_orgPic, *m_trueOrgPic, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
}
#else
m_cVideoIOYuvInputFile.read( orgPic, trueOrgPic, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
m_cVideoIOYuvInputFile.read( *m_orgPic, *m_trueOrgPic, ipCSC, m_aiPad, m_InputChromaFormatIDC, m_bClipInputVideoToRec709Range );
#endif
// increase number of received frames
m_iFrameRcvd++;
// increase number of received frames
m_iFrameRcvd++;
bEos = ( m_isField && ( m_iFrameRcvd == ( m_framesToBeEncoded >> 1 ) ) ) || ( !m_isField && ( m_iFrameRcvd == m_framesToBeEncoded ) );
bEos = ( m_isField && ( m_iFrameRcvd == ( m_framesToBeEncoded >> 1 ) ) ) || ( !m_isField && ( m_iFrameRcvd == m_framesToBeEncoded ) );
bool flush = 0;
// if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
if( m_cVideoIOYuvInputFile.isEof() )
{
flush = true;
bEos = true;
m_iFrameRcvd--;
m_cEncLib.setFramesToBeEncoded( m_iFrameRcvd );
}
bool flush = 0;
// if end of file (which is only detected on a read failure) flush the encoder of any queued pictures
if( m_cVideoIOYuvInputFile.isEof() )
{
flush = true;
bEos = true;
m_iFrameRcvd--;
m_cEncLib.setFramesToBeEncoded( m_iFrameRcvd );
}
// call encoding function for one frame
if( m_isField )
{
m_cEncLib.encode( bEos, flush ? 0 : &orgPic, flush ? 0 : &trueOrgPic, snrCSC, recBufList,
iNumEncoded, m_isTopFieldFirst );
// call encoding function for one frame
if( m_isField )
{
m_cEncLib.encode( bEos, flush ? 0 : m_orgPic, flush ? 0 : m_trueOrgPic, snrCSC, m_recBufList, m_numEncoded, m_isTopFieldFirst );
#if JVET_O0756_CALCULATE_HDRMETRICS
m_metricTime = m_cEncLib.getMetricTime();
m_metricTime = m_cEncLib.getMetricTime();
#endif
}
else
{
m_cEncLib.encode( bEos, flush ? 0 : &orgPic, flush ? 0 : &trueOrgPic, snrCSC, recBufList,
iNumEncoded );
}
else
{
m_cEncLib.encode( bEos, flush ? 0 : m_orgPic, flush ? 0 : m_trueOrgPic, snrCSC, m_recBufList, m_numEncoded );
#if JVET_O0756_CALCULATE_HDRMETRICS
m_metricTime = m_cEncLib.getMetricTime();
m_metricTime = m_cEncLib.getMetricTime();
#endif
}
}
// write bistream to file if necessary
if( iNumEncoded > 0 )
{
xWriteOutput( iNumEncoded, recBufList
);
}
// temporally skip frames
if( m_temporalSubsampleRatio > 1 )
{
// write bistream to file if necessary
if( m_numEncoded > 0 )
{
xWriteOutput( m_numEncoded, m_recBufList );
}
// temporally skip frames
if( m_temporalSubsampleRatio > 1 )
{
#if EXTENSION_360_VIDEO
m_cVideoIOYuvInputFile.skipFrames( m_temporalSubsampleRatio - 1, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC );
m_cVideoIOYuvInputFile.skipFrames( m_temporalSubsampleRatio - 1, m_inputFileWidth, m_inputFileHeight, m_InputChromaFormatIDC );
#else
m_cVideoIOYuvInputFile.skipFrames( m_temporalSubsampleRatio - 1, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC );
m_cVideoIOYuvInputFile.skipFrames( m_temporalSubsampleRatio - 1, m_iSourceWidth - m_aiPad[0], m_iSourceHeight - m_aiPad[1], m_InputChromaFormatIDC );
#endif
}
}
return bEos;
}
#else
/**
......
......@@ -88,6 +88,16 @@ private:
void printRateSummary ();
void printChromaFormat();
#if JVET_N0278_FIXES
std::list<PelUnitBuf*> m_recBufList;
int m_numEncoded;
PelStorage* m_trueOrgPic;
PelStorage* m_orgPic;
#if EXTENSION_360_VIDEO
TExt360AppEncTop* m_ext360;
#endif
#endif
public:
EncApp();
virtual ~EncApp();
......@@ -96,7 +106,7 @@ public:
int getMaxLayers() const { return m_maxLayers; }
void createLib(); ///< main encoding function
void destroyLib(); ///< main encoding function
void encode(); ///< main encoding function
bool encode(); ///< main encoding function
#else
void encode(); ///< main encoding function
#endif
......
......@@ -185,26 +185,31 @@ int main(int argc, char* argv[])
// call encoding function
#if JVET_N0278_FIXES
for( auto & encApp : pcEncApp )
bool eos = false;
while( !eos )
{
#ifndef _DEBUG
try
for( auto & encApp : pcEncApp )
{
#ifndef _DEBUG
try
{
#endif
encApp->encode();
eos = encApp->encode();
#ifndef _DEBUG
}
catch( Exception &e )
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
catch( const std::bad_alloc &e )
{
std::cout << "Memory allocation failed: " << e.what() << std::endl;
return EXIT_FAILURE;
}
}
catch( Exception &e )
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
catch( const std::bad_alloc &e )
{
std::cout << "Memory allocation failed: " << e.what() << std::endl;
return EXIT_FAILURE;
}
#endif
}
}
#else
#ifndef _DEBUG
......@@ -252,6 +257,8 @@ int main(int argc, char* argv[])
// destroy ROM
destroyROM();
pcEncApp.clear();
#else
// destroy application encoder class
pcEncApp->destroy();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment