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