Change functions in PlaYUVerFrame and PropertiesSidebar
Add new contructor to PlaYUVerFrame to improve the copy of frames Add support to stop histogram when frames are removed
This commit is contained in:
1 parent
945d0334c1
commit
dc1827946f
6 files changed
+107
-130
No files matched your search
@@ -402,7 +402,7 @@ void HistogramWidget::updateData( const PlaYUVerFrame *playuver_frame, const Pla
|
||||
// Calc new histogram data
|
||||
m_imageHistogram = new PlaYUVerFrameStatistics( playuver_frame, this );
|
||||
|
||||
if( playuver_selection->isValid() )
|
||||
if( playuver_selection )
|
||||
m_selectionHistogram = new PlaYUVerFrameStatistics( playuver_selection, this );
|
||||
else
|
||||
m_selectionHistogram = NULL;
|
||||
|
||||
@@ -376,9 +376,9 @@ Void InputStream::setNextFrame()
|
||||
PlaYUVerFrame* InputStream::getCurrFrame( PlaYUVerFrame *pyuv_image )
|
||||
{
|
||||
if( pyuv_image == NULL )
|
||||
pyuv_image = new PlaYUVerFrame( m_pcCurrFrame->getWidth(), m_pcCurrFrame->getHeight(), m_pcCurrFrame->getPelFormat() );
|
||||
|
||||
pyuv_image->CopyFrom( m_pcCurrFrame );
|
||||
pyuv_image = new PlaYUVerFrame( m_pcCurrFrame );
|
||||
else
|
||||
pyuv_image->copyFrom( m_pcCurrFrame );
|
||||
return pyuv_image;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,14 @@
|
||||
namespace plaYUVer
|
||||
{
|
||||
|
||||
static inline QSize bestSize( QSize currSize );
|
||||
static inline QSize bestSize( QSize currSize )
|
||||
{
|
||||
QSize bestSize( 180, currSize.height() );
|
||||
if( currSize.width() < bestSize.width() )
|
||||
return bestSize;
|
||||
else
|
||||
return currSize;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// StreamPropertiesSideBar
|
||||
@@ -164,6 +171,7 @@ FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent ) :
|
||||
{
|
||||
// -------------- Variables definition --------------
|
||||
m_pcFrame = NULL;
|
||||
m_pcFrameSelection = NULL;
|
||||
m_iLastFrameType = -1;
|
||||
|
||||
// Histogram area -----------------------------------------------------
|
||||
@@ -374,10 +382,8 @@ FramePropertiesSideBar::~FramePropertiesSideBar()
|
||||
// If there is a currently histogram computation when dialog is closed,
|
||||
// stop it before the image data are deleted automatically!
|
||||
histogramWidget->stopHistogramComputation();
|
||||
|
||||
if( histogramWidget )
|
||||
delete histogramWidget;
|
||||
|
||||
}
|
||||
|
||||
QSize FramePropertiesSideBar::sizeHint() const
|
||||
@@ -385,25 +391,6 @@ QSize FramePropertiesSideBar::sizeHint() const
|
||||
return bestSize( size() );
|
||||
}
|
||||
|
||||
void FramePropertiesSideBar::slotUpdateHistogram()
|
||||
{
|
||||
if( m_pcFrame->isValid() && isVisible() )
|
||||
{
|
||||
// If a selection area is done in Image Editor and if the current
|
||||
// image is the same in Image Viewer, then compute too the histogram
|
||||
// for this selection.
|
||||
histogramWidget->updateData( m_pcFrame, new PlaYUVerFrame );
|
||||
fullImageButton->hide();
|
||||
selectionImageButton->hide();
|
||||
updateInformations();
|
||||
}
|
||||
else
|
||||
{
|
||||
histogramWidget->setLoadingFailed();
|
||||
slotHistogramComputationFailed();
|
||||
}
|
||||
}
|
||||
|
||||
Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame )
|
||||
{
|
||||
if( !pcFrame )
|
||||
@@ -483,14 +470,10 @@ Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame )
|
||||
}
|
||||
setEnabled( true );
|
||||
m_pcFrame = pcFrame;
|
||||
slotUpdateHistogram();
|
||||
slotUpdateDataHistogram();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Set Selection
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Void FramePropertiesSideBar::setSelection( const QRect &selectionArea )
|
||||
{
|
||||
// This is necessary to stop computation because image.bits() is
|
||||
@@ -503,12 +486,7 @@ Void FramePropertiesSideBar::setSelection( const QRect &selectionArea )
|
||||
|
||||
histogramWidget->stopHistogramComputation();
|
||||
|
||||
m_pcFrame->CopyFrom( m_pcFrameSelection );
|
||||
// histogramWidget->updateSelectionData( imageSelection.bits(),
|
||||
// imageSelection.width(),
|
||||
// imageSelection.height(),
|
||||
// imageSelection.bitsPerChannel(),
|
||||
// imageSelection.colorSpace() );
|
||||
m_pcFrameSelection->copyFrom( m_pcFrame );
|
||||
histogramWidget->updateSelectionData( m_pcFrameSelection );
|
||||
fullImageButton->show();
|
||||
selectionImageButton->show();
|
||||
@@ -521,10 +499,72 @@ Void FramePropertiesSideBar::setSelection( const QRect &selectionArea )
|
||||
slotRenderingChanged( HistogramWidget::FullImageHistogram );
|
||||
}
|
||||
}
|
||||
|
||||
Void FramePropertiesSideBar::updateStatistiques()
|
||||
{
|
||||
QString value;
|
||||
|
||||
int min = minInterv->value();
|
||||
int max = maxInterv->value();
|
||||
int channel = histogramWidget->m_channelType;
|
||||
//int channel = channelCB->currentIndex();
|
||||
|
||||
if( channel == HistogramWidget::ColorChannelsHistogram )
|
||||
channel = colorsCB->currentIndex() + 1;
|
||||
|
||||
PlaYUVerFrameStatistics *histogram;
|
||||
|
||||
if( histogramWidget->m_renderingType == HistogramWidget::FullImageHistogram )
|
||||
histogram = histogramWidget->m_imageHistogram;
|
||||
else
|
||||
histogram = histogramWidget->m_selectionHistogram;
|
||||
|
||||
double mean = histogram->getMean( channel, min, max );
|
||||
labelMeanValue->setText( value.setNum( mean, 'f', 1 ) );
|
||||
|
||||
double pixels = histogram->getPixels();
|
||||
labelPixelsValue->setText( value.setNum( ( float )pixels, 'f', 0 ) );
|
||||
|
||||
double stddev = histogram->getStdDev( channel, min, max );
|
||||
labelStdDevValue->setText( value.setNum( stddev, 'f', 1 ) );
|
||||
|
||||
double counts = histogram->getCount( channel, min, max );
|
||||
labelCountValue->setText( value.setNum( ( float )counts, 'f', 0 ) );
|
||||
|
||||
double median = histogram->getMedian( channel, min, max );
|
||||
labelMedianValue->setText( value.setNum( median, 'f', 1 ) );
|
||||
|
||||
double percentile = ( pixels > 0 ? ( 100.0 * counts / pixels ) : 0.0 );
|
||||
labelPercentileValue->setText( value.setNum( percentile, 'f', 1 ) );
|
||||
}
|
||||
|
||||
Void FramePropertiesSideBar::stopHistogram()
|
||||
{
|
||||
histogramWidget->stopHistogramComputation();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SLOTS
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void FramePropertiesSideBar::slotUpdateDataHistogram()
|
||||
{
|
||||
if( m_pcFrame && isVisible() )
|
||||
{
|
||||
// If a selection area is done in Image Editor and if the current
|
||||
// image is the same in Image Viewer, then compute too the histogram
|
||||
// for this selection.
|
||||
histogramWidget->updateData( m_pcFrame, NULL );
|
||||
fullImageButton->hide();
|
||||
selectionImageButton->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
histogramWidget->setLoadingFailed();
|
||||
slotHistogramComputationFailed();
|
||||
}
|
||||
}
|
||||
|
||||
void FramePropertiesSideBar::slotRefreshOptions( bool /*depth*/)
|
||||
{
|
||||
if( !isVisible() )
|
||||
@@ -545,7 +585,6 @@ void FramePropertiesSideBar::slotRefreshOptions( bool /*depth*/)
|
||||
slotRenderingChanged( HistogramWidget::FullImageHistogram );
|
||||
else if( selectionImageButton->isChecked() )
|
||||
slotRenderingChanged( HistogramWidget::ImageSelectionHistogram );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -673,82 +712,6 @@ void FramePropertiesSideBar::slotUpdateIntervRange( int range )
|
||||
maxInterv->setMaximum( range );
|
||||
maxInterv->blockSignals( false );
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Informations
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void FramePropertiesSideBar::updateInformations()
|
||||
{
|
||||
#if 0
|
||||
QString value;
|
||||
switch( image.colorMode() )
|
||||
{
|
||||
case SImage::BlackWhite:
|
||||
value = tr( "Black and White" );
|
||||
break;
|
||||
case SImage::Gray:
|
||||
value = tr( "Grayscale" );
|
||||
break;
|
||||
default:
|
||||
value = tr( "Color" );
|
||||
break;
|
||||
}
|
||||
colorModeValueLabel->setText( value );
|
||||
value = tr( "%n bit(s)", "", image.depth() );
|
||||
depthValueLabel->setText( value );
|
||||
alphaValueLabel->setText( image.hasAlpha() ? tr( "Yes" ) : tr( "No" ) );
|
||||
#endif
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Statistiques
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void FramePropertiesSideBar::updateStatistiques()
|
||||
{
|
||||
QString value;
|
||||
|
||||
int min = minInterv->value();
|
||||
int max = maxInterv->value();
|
||||
int channel = histogramWidget->m_channelType;
|
||||
//int channel = channelCB->currentIndex();
|
||||
|
||||
if( channel == HistogramWidget::ColorChannelsHistogram )
|
||||
channel = colorsCB->currentIndex() + 1;
|
||||
|
||||
PlaYUVerFrameStatistics *histogram;
|
||||
|
||||
if( histogramWidget->m_renderingType == HistogramWidget::FullImageHistogram )
|
||||
histogram = histogramWidget->m_imageHistogram;
|
||||
else
|
||||
histogram = histogramWidget->m_selectionHistogram;
|
||||
|
||||
double mean = histogram->getMean( channel, min, max );
|
||||
labelMeanValue->setText( value.setNum( mean, 'f', 1 ) );
|
||||
|
||||
double pixels = histogram->getPixels();
|
||||
labelPixelsValue->setText( value.setNum( ( float )pixels, 'f', 0 ) );
|
||||
|
||||
double stddev = histogram->getStdDev( channel, min, max );
|
||||
labelStdDevValue->setText( value.setNum( stddev, 'f', 1 ) );
|
||||
|
||||
double counts = histogram->getCount( channel, min, max );
|
||||
labelCountValue->setText( value.setNum( ( float )counts, 'f', 0 ) );
|
||||
|
||||
double median = histogram->getMedian( channel, min, max );
|
||||
labelMedianValue->setText( value.setNum( median, 'f', 1 ) );
|
||||
|
||||
double percentile = ( pixels > 0 ? ( 100.0 * counts / pixels ) : 0.0 );
|
||||
labelPercentileValue->setText( value.setNum( percentile, 'f', 1 ) );
|
||||
}
|
||||
|
||||
static inline QSize bestSize( QSize currSize )
|
||||
{
|
||||
QSize bestSize( 180, currSize.height() );
|
||||
if( currSize.width() < bestSize.width() )
|
||||
return bestSize;
|
||||
else
|
||||
return currSize;
|
||||
}
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -73,6 +73,8 @@ public:
|
||||
Void setData( PlaYUVerFrame* m_pcStream );
|
||||
Void setSelection( const QRect &selectionArea );
|
||||
|
||||
Void stopHistogram();
|
||||
|
||||
private:
|
||||
enum ColorChannel
|
||||
{
|
||||
@@ -132,11 +134,10 @@ private:
|
||||
HistogramWidget *histogramWidget;
|
||||
|
||||
private:
|
||||
void updateInformations();
|
||||
void updateStatistiques();
|
||||
Void updateStatistiques();
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotUpdateHistogram();
|
||||
void slotUpdateDataHistogram();
|
||||
void slotRefreshOptions( bool sixteenBit );
|
||||
void slotHistogramComputationFailed( void );
|
||||
void slotChannelChanged( int channel );
|
||||
|
||||
@@ -31,6 +31,28 @@ namespace plaYUVer
|
||||
{
|
||||
|
||||
PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pel_format )
|
||||
{
|
||||
init( width, height, pel_format );
|
||||
}
|
||||
|
||||
PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other )
|
||||
{
|
||||
init( other->getWidth(), other->getHeight(), other->getPelFormat() );
|
||||
copyFrom(other);
|
||||
}
|
||||
|
||||
PlaYUVerFrame::~PlaYUVerFrame()
|
||||
{
|
||||
if( m_pppcInputPel )
|
||||
freeMem3ImageComponents<Pel>( m_pppcInputPel );
|
||||
|
||||
if( m_pcRGBPelInterlaced )
|
||||
freeMem1D<UChar>( m_pcRGBPelInterlaced );
|
||||
|
||||
closePixfc();
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format )
|
||||
{
|
||||
m_pppcInputPel = NULL;
|
||||
m_pcRGBPelInterlaced = NULL;
|
||||
@@ -74,17 +96,6 @@ PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pel_format )
|
||||
openPixfc();
|
||||
}
|
||||
|
||||
PlaYUVerFrame::~PlaYUVerFrame()
|
||||
{
|
||||
if( m_pppcInputPel )
|
||||
freeMem3ImageComponents<Pel>( m_pppcInputPel );
|
||||
|
||||
if( m_pcRGBPelInterlaced )
|
||||
freeMem1D<UChar>( m_pcRGBPelInterlaced );
|
||||
|
||||
closePixfc();
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::openPixfc()
|
||||
{
|
||||
#ifdef USE_PIXFC
|
||||
@@ -345,7 +356,7 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format )
|
||||
}
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::CopyFrom( PlaYUVerFrame* input_frame )
|
||||
Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame )
|
||||
{
|
||||
if( m_iPixelFormat != input_frame->getPelFormat() )
|
||||
return;
|
||||
|
||||
@@ -54,6 +54,7 @@ class PlaYUVerFrame
|
||||
{
|
||||
public:
|
||||
PlaYUVerFrame( UInt width = 0, UInt height = 0, Int pel_format = 0 );
|
||||
PlaYUVerFrame( PlaYUVerFrame *other );
|
||||
~PlaYUVerFrame();
|
||||
|
||||
enum ColorSpace
|
||||
@@ -115,7 +116,7 @@ public:
|
||||
|
||||
Void FrameFromBuffer( Pel *input_buffer, Int pel_format );
|
||||
|
||||
Void CopyFrom( PlaYUVerFrame* );
|
||||
Void copyFrom( PlaYUVerFrame* );
|
||||
|
||||
UInt64 getBytesPerFrame();
|
||||
UInt getChromaLength() const;
|
||||
@@ -179,6 +180,7 @@ private:
|
||||
Pel*** m_pppcInputPel;
|
||||
UChar* m_pcRGBPelInterlaced;
|
||||
|
||||
Void init( UInt width, UInt height, Int pel_format );
|
||||
Void openPixfc();
|
||||
Void closePixfc();
|
||||
#ifdef USE_PIXFC
|
||||
|
||||
Reference in new issue
Block a user