Commit 98ed159a authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Reworked size changes handling

parent 4571f3fa
......@@ -47,11 +47,9 @@ void WorkflowFileRenderer::run()
m_mainWorkflow->setCurrentFrame( 0, MainWorkflow::Renderer );
//Ugly hack to update render parameter.
//We don't really care if anything has changed as WorkflowFileRenderer is called
//only once, and is deleted then.
parametersChanged();
setupRenderer();
m_width = width();
m_height = height();
setupRenderer( m_width, m_height, m_outputFps );
//Media as already been created and mainly initialized by the WorkflowRenderer
QString transcodeStr = ":sout=#transcode{vcodec=h264,vb=800,acodec=a52,ab=128,no-hurry-up}"
......@@ -62,11 +60,6 @@ void WorkflowFileRenderer::run()
// sprintf( buffer, ":sout-transcode-fps=%f", m_outputFps );
// m_media->addOption( buffer );
//Clean any previous render.
memcpy( m_renderVideoFrame,
(*MainWorkflow::blackOutput)->frame.octets,
(*MainWorkflow::blackOutput)->nboctets );
m_mediaPlayer->setMedia( m_media );
connect( m_mainWorkflow, SIGNAL( mainWorkflowEndReached() ), this, SLOT( stop() ) );
......@@ -82,7 +75,7 @@ void WorkflowFileRenderer::run()
setupDialog();
m_mainWorkflow->setFullSpeedRender( true );
m_mainWorkflow->startRender( width(), height() );
m_mainWorkflow->startRender( m_width, m_height );
m_mediaPlayer->play();
}
......
......@@ -79,7 +79,7 @@ WorkflowRenderer::~WorkflowRenderer()
}
void
WorkflowRenderer::setupRenderer()
WorkflowRenderer::setupRenderer( quint32 width, quint32 height, double fps )
{
char videoString[512];
char inputSlave[256];
......@@ -88,10 +88,12 @@ WorkflowRenderer::setupRenderer()
if ( m_renderVideoFrame != NULL )
delete m_renderVideoFrame;
m_renderVideoFrame = new unsigned char[m_width * m_height * Pixel::NbComposantes];
m_renderVideoFrame = new unsigned char[width * height * Pixel::NbComposantes];
//Clean any previous render.
memset( m_renderVideoFrame, 0, m_width * m_height * Pixel::NbComposantes );
sprintf( videoString, "width=%i:height=%i:dar=%s:fps=%s:data=%lld:codec=%s:cat=2:caching=0",
m_width, m_height, "16/9", "30/1",
width, height, "16/9", "30/1",
(qint64)m_videoEsHandler, "RV24" );
sprintf( audioParameters, "data=%lld:cat=1:codec=f32l:samplerate=%u:channels=%u:caching=0",
(qint64)m_audioEsHandler, m_rate, m_nbChannels );
......@@ -210,8 +212,13 @@ void WorkflowRenderer::startPreview()
{
if ( m_mainWorkflow->getLengthFrame() <= 0 )
return ;
if ( parametersChanged() == true )
setupRenderer();
if ( paramsHasChanged( m_width, m_height, m_outputFps ) == true )
{
m_width = width();
m_height = height();
m_outputFps = outputFps();
setupRenderer( m_width, m_height, m_outputFps );
}
m_mediaPlayer->setMedia( m_media );
//Media player part: to update PreviewWidget
......@@ -220,11 +227,6 @@ void WorkflowRenderer::startPreview()
//FIXME:: check if this doesn't require Qt::QueuedConnection
connect( m_mediaPlayer, SIGNAL( stopped() ), this, SIGNAL( endReached() ) );
//Clean any previous render.
memcpy( m_renderVideoFrame,
(*MainWorkflow::blackOutput)->frame.octets,
(*MainWorkflow::blackOutput)->nboctets );
m_mainWorkflow->setFullSpeedRender( false );
m_mainWorkflow->startRender( m_width, m_height );
m_isRendering = true;
......@@ -365,21 +367,14 @@ WorkflowRenderer::outputFps() const
}
bool
WorkflowRenderer::parametersChanged()
WorkflowRenderer::paramsHasChanged( quint32 width, quint32 height, double fps )
{
quint32 newWidth = width();
quint32 newHeight = height();
quint32 newWidth = this->width();
quint32 newHeight = this->height();
float newOutputFps = outputFps();
if ( newWidth != m_width || newHeight != m_height ||
newOutputFps != m_outputFps )
{
m_width = newWidth;
m_height = newHeight;
m_outputFps = newOutputFps;
return true;
}
return false;
return ( newWidth != width || newHeight != height ||
newOutputFps != fps );
}
/////////////////////////////////////////////////////////////////////
......
......@@ -242,14 +242,13 @@ class WorkflowRenderer : public GenericRenderer
/**
* \brief Configure the production chain.
*/
void setupRenderer();
void setupRenderer( quint32 width, quint32 height, double fps );
/**
* \brief Check for parameters modification, and update them if
* necessary.
* \brief Check for parameters modification.
* \return true if some render parameters has changed.
* Parameters include : width, height, fps.
*/
bool parametersChanged();
bool paramsHasChanged( quint32 width, quint32 height,
double fps );
protected:
MainWorkflow* m_mainWorkflow;
LibVLCpp::Media* m_media;
......
......@@ -61,10 +61,6 @@ MainWorkflow::MainWorkflow( int trackCount ) :
m_currentFrame[i] = 0;
}
m_outputBuffers = new OutputBuffers;
blackOutput = new LightVideoFrame( m_width, m_height);
// FIX ME vvvvvv , It doesn't update meta info (nbpixels, nboctets, etc.
memset( (*blackOutput)->frame.octets, 0, (*blackOutput)->nboctets );
}
MainWorkflow::~MainWorkflow()
......@@ -121,6 +117,11 @@ MainWorkflow::startRender( quint32 width, quint32 height )
m_renderStarted = true;
m_width = width;
m_height = height;
if ( blackOutput != NULL )
delete blackOutput;
blackOutput = new LightVideoFrame( m_width, m_height );
// FIX ME vvvvvv , It doesn't update meta info (nbpixels, nboctets, etc.
memset( (*blackOutput)->frame.octets, 0, (*blackOutput)->nboctets );
for ( unsigned int i = 0; i < MainWorkflow::NbTrackType; ++i )
m_tracks[i]->startRender();
computeLength();
......
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