Improve histogram measurement and display.

Now it is possible to show histogram of luminance in RGB frames
This commit is contained in:
jfmcarreira committed 2018-02-06 01:10:16 +00:00
1 parent 2d6ba03d4a
commit 8ba512f4d0
13 files changed
+463 -600

No files matched your search

+1 -1
View File
@@ -91,7 +91,7 @@ SortIncludes: true
SpacesInParentheses: true SpacesInParentheses: true
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
Standard: Auto Standard: Auto
TabWidth: 8 TabWidth: 2
UseTab: Never UseTab: Never
... ...
+31 -72
View File
@@ -42,8 +42,8 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
channelLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight ); channelLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
channelCB = new QComboBox; channelCB = new QComboBox;
channelCB->addItem( tr( "Luminance" ) ); //channelCB->addItem( tr( "Luminance" ) );
channelCB->setItemIcon( 0, QIcon( ":/images/channel-luma.png" ) ); //channelCB->setItemIcon( 0, QIcon( ":/images/channel-luma.png" ) );
channelCB->setWhatsThis( tr( "<p>Select here the histogram channel to display:<p>" channelCB->setWhatsThis( tr( "<p>Select here the histogram channel to display:<p>"
"<b>Luminance</b>: Display luminance (perceived brightness).<p>" "<b>Luminance</b>: Display luminance (perceived brightness).<p>"
@@ -218,8 +218,6 @@ FramePropertiesDock::FramePropertiesDock( QWidget* parent, Bool* pbMainPlaySwitc
statisticsLayout->addWidget( labelStdDevValue, gridRow++, 1 ); statisticsLayout->addWidget( labelStdDevValue, gridRow++, 1 );
statisticsLayout->addWidget( medianLabel, gridRow, 0 ); statisticsLayout->addWidget( medianLabel, gridRow, 0 );
statisticsLayout->addWidget( labelMedianValue, gridRow++, 1 ); statisticsLayout->addWidget( labelMedianValue, gridRow++, 1 );
// statisticsLayout->addWidget( percentileLabel, 5, 0 );
// statisticsLayout->addWidget( labelPercentileValue, 5, 1 );
QGroupBox* statisticsGroup = new QGroupBox( tr( "Statistics" ) ); QGroupBox* statisticsGroup = new QGroupBox( tr( "Statistics" ) );
statisticsGroup->setLayout( statisticsLayout ); statisticsGroup->setLayout( statisticsLayout );
@@ -298,21 +296,20 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
if( colorSpace == PlaYUVerPixel::COLOR_RGB || colorSpace == PlaYUVerPixel::COLOR_RGBA ) if( colorSpace == PlaYUVerPixel::COLOR_RGB || colorSpace == PlaYUVerPixel::COLOR_RGBA )
{ {
channelCB->clear(); channelCB->clear();
channelCB->clear(); channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA );
channelCB->insertItem( LuminosityChannel, QIcon( ":/images/channel-luma.png" ), "Luminance" ); channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Red", PlaYUVerFrame::HIST_COLOR_R );
channelCB->insertItem( FirstChannel, QIcon( ":/images/channel-red.png" ), "Red" ); channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Green", PlaYUVerFrame::HIST_COLOR_G );
channelCB->insertItem( SecondChannel, QIcon( ":/images/channel-green.png" ), "Green" ); channelCB->addItem( QIcon( ":/images/channel-blue.png" ), "Blue", PlaYUVerFrame::HIST_COLOR_B );
channelCB->insertItem( ThirdChannel, QIcon( ":/images/channel-blue.png" ), "Blue" );
if( colorSpace == PlaYUVerPixel::COLOR_RGBA ) if( colorSpace == PlaYUVerPixel::COLOR_RGBA )
{ {
channelCB->insertItem( AlphaChannel, QIcon( ":/images/channel-alpha.png" ), "Alpha" ); channelCB->addItem( QIcon( ":/images/channel-alpha.png" ), "Alpha", PlaYUVerFrame::HIST_COLOR_A );
} }
channelCB->insertItem( ColorChannels, QIcon( ":/images/channel-all.png" ), "Colors" ); channelCB->addItem( QIcon( ":/images/channel-all.png" ), "Colors", PlaYUVerFrame::HIST_ALL_CHANNELS );
colorsCB->clear(); colorsCB->clear();
colorsCB->addItem( "Red" ); colorsCB->addItem( "Red", PlaYUVerFrame::HIST_COLOR_R );
colorsCB->addItem( "Green" ); colorsCB->addItem( "Green", PlaYUVerFrame::HIST_COLOR_G );
colorsCB->addItem( "Blue" ); colorsCB->addItem( "Blue", PlaYUVerFrame::HIST_COLOR_B );
colorsCB->setEnabled( false ); colorsCB->setEnabled( false );
colorsCB->setWhatsThis( tr( "<p>Select here the main color displayed with Colors Channel mode:" colorsCB->setWhatsThis( tr( "<p>Select here the main color displayed with Colors Channel mode:"
"<p><b>Red</b>: Draw the Red image channel in the foreground.<p>" "<p><b>Red</b>: Draw the Red image channel in the foreground.<p>"
@@ -324,15 +321,15 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
else if( colorSpace == PlaYUVerPixel::COLOR_YUV ) else if( colorSpace == PlaYUVerPixel::COLOR_YUV )
{ {
channelCB->clear(); channelCB->clear();
channelCB->insertItem( FirstChannel, QIcon( ":/images/channel-luma.png" ), "Luminance" ); channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA );
channelCB->insertItem( SecondChannel, QIcon( ":/images/channel-red.png" ), "Chroma U" ); channelCB->addItem( QIcon( ":/images/channel-red.png" ), "Chroma U", PlaYUVerFrame::HIST_CHROMA_U );
channelCB->insertItem( ThirdChannel, QIcon( ":/images/channel-green.png" ), "Chroma V" ); channelCB->addItem( QIcon( ":/images/channel-green.png" ), "Chroma V", PlaYUVerFrame::HIST_CHROMA_V );
channelCB->insertItem( ColorChannels, QIcon( ":/images/channel-all.png" ), "All Channels" ); channelCB->addItem( QIcon( ":/images/channel-all.png" ), "All Channels", PlaYUVerFrame::HIST_ALL_CHANNELS );
colorsCB->clear(); colorsCB->clear();
colorsCB->addItem( "Luminance" ); colorsCB->addItem( "Luminance", PlaYUVerFrame::HIST_LUMA );
colorsCB->addItem( "Chroma U" ); colorsCB->addItem( "Chroma U", PlaYUVerFrame::HIST_CHROMA_U );
colorsCB->addItem( "Chroma V" ); colorsCB->addItem( "Chroma V", PlaYUVerFrame::HIST_CHROMA_V );
colorsCB->setEnabled( false ); colorsCB->setEnabled( false );
colorsCB->setWhatsThis( tr( "<p>Select here the main color displayed with Colors Channel mode:" colorsCB->setWhatsThis( tr( "<p>Select here the main color displayed with Colors Channel mode:"
"<p><b>Luminance</b>: DraupdateDataw the Luminance channel in the " "<p><b>Luminance</b>: DraupdateDataw the Luminance channel in the "
@@ -346,8 +343,7 @@ Void FramePropertiesDock::setFrame( PlaYUVerFrame* pcFrame )
else else
{ {
channelCB->clear(); channelCB->clear();
channelCB->addItem( tr( "Luminance" ) ); channelCB->addItem( QIcon( ":/images/channel-luma.png" ), "Luminance", PlaYUVerFrame::HIST_LUMA );
channelCB->setItemIcon( 0, QIcon( ":/images/channel-luma.png" ) );
colorsCB->hide(); colorsCB->hide();
colorsLabel->hide(); colorsLabel->hide();
} }
@@ -436,8 +432,8 @@ Void FramePropertiesDock::updateStatistiques()
Int max = maxInterv->value(); Int max = maxInterv->value();
Int channel = histogramWidget->m_channelType; Int channel = histogramWidget->m_channelType;
if( channel == HistogramWidget::ColorChannelsHistogram ) if( channel == PlaYUVerFrame::HIST_ALL_CHANNELS )
channel = colorsCB->currentIndex(); channel = colorsCB->itemData( colorsCB->currentIndex() ).toInt();
PlaYUVerFrame* frame; PlaYUVerFrame* frame;
@@ -449,7 +445,7 @@ Void FramePropertiesDock::updateStatistiques()
if( frame ) if( frame )
{ {
QString rangeText = QString rangeText =
"[" + QString::number( frame->getMin( channel ) ) + ":" + QString::number( frame->getMax( channel ) ) + "]"; "[" + QString::number( frame->getMinimumPelValue( channel ) ) + ":" + QString::number( frame->getMaximumPelValue( channel ) ) + "]";
labelRangeValue->setText( rangeText ); labelRangeValue->setText( rangeText );
double mean = frame->getMean( channel, min, max ); double mean = frame->getMean( channel, min, max );
@@ -461,7 +457,7 @@ Void FramePropertiesDock::updateStatistiques()
double stddev = frame->getStdDev( channel, min, max ); double stddev = frame->getStdDev( channel, min, max );
labelStdDevValue->setText( value.setNum( stddev, 'f', 1 ) ); labelStdDevValue->setText( value.setNum( stddev, 'f', 1 ) );
double counts = frame->getCount( channel, min, max ); double counts = frame->getNumPixelsRange( channel, min, max );
labelCountValue->setText( value.setNum( (float)counts, 'f', 0 ) ); labelCountValue->setText( value.setNum( (float)counts, 'f', 0 ) );
double median = frame->getMedian( channel, min, max ); double median = frame->getMedian( channel, min, max );
@@ -509,41 +505,15 @@ Void FramePropertiesDock::slotHistogramComputationFailed()
m_pcFrame = NULL; m_pcFrame = NULL;
} }
Void FramePropertiesDock::slotChannelChanged( Int channel ) Void FramePropertiesDock::slotChannelChanged( Int index )
{ {
if( m_pcFrame->getColorSpace() == PlaYUVerPixel::COLOR_YUV ) Int channel = channelCB->itemData( index ).toInt();
channel += 1;
if( channel == AlphaChannel && m_pcFrame->getColorSpace() != PlaYUVerPixel::COLOR_RGBA )
channel = ColorChannels;
switch( channel ) histogramWidget->m_channelType = channel;
{ if( channel == PlaYUVerFrame::HIST_ALL_CHANNELS )
case FirstChannel:
histogramWidget->m_channelType = HistogramWidget::FirstChannelHistogram;
colorsCB->setEnabled( false );
break;
case SecondChannel:
histogramWidget->m_channelType = HistogramWidget::SecondChannelHistogram;
colorsCB->setEnabled( false );
break;
case ThirdChannel:
histogramWidget->m_channelType = HistogramWidget::ThirdChannelHistogram;
colorsCB->setEnabled( false );
break;
case AlphaChannel:
histogramWidget->m_channelType = HistogramWidget::AlphaChannelHistogram;
colorsCB->setEnabled( false );
break;
case ColorChannels:
histogramWidget->m_channelType = HistogramWidget::ColorChannelsHistogram;
colorsCB->setEnabled( true ); colorsCB->setEnabled( true );
break; else
default: // Luminance.
// histogramWidget->m_channelType = HistogramWidget::LumaHistogram;
histogramWidget->m_channelType = HistogramWidget::FirstChannelHistogram;
colorsCB->setEnabled( false ); colorsCB->setEnabled( false );
break;
}
histogramWidget->update(); histogramWidget->update();
updateStatistiques(); updateStatistiques();
} }
@@ -554,21 +524,10 @@ Void FramePropertiesDock::slotScaleChanged( Int scale )
histogramWidget->update(); histogramWidget->update();
} }
Void FramePropertiesDock::slotColorsChanged( Int color ) Void FramePropertiesDock::slotColorsChanged( Int index )
{ {
switch( color ) Int color = colorsCB->itemData( index ).toInt();
{ histogramWidget->m_colorType = color;
case AllColorsGreen:
histogramWidget->m_colorType = HistogramWidget::SecondChannelColor;
break;
case AllColorsBlue:
histogramWidget->m_colorType = HistogramWidget::ThirdChannelColor;
break;
default: // Red.
histogramWidget->m_colorType = HistogramWidget::FirstChannelColor;
break;
}
histogramWidget->update(); histogramWidget->update();
updateStatistiques(); updateStatistiques();
} }
+2 -19
View File
@@ -48,23 +48,6 @@ public:
Void stopHistogram(); Void stopHistogram();
private: private:
enum ColorChannel
{
LuminosityChannel = 0,
FirstChannel = 1,
SecondChannel = 2,
ThirdChannel = 3,
ColorChannels = 4,
AlphaChannel = 5,
};
enum AllColorsColorType
{
AllColorsRed = 0,
AllColorsGreen,
AllColorsBlue
};
PlaYUVerFrame* m_pcFrame; PlaYUVerFrame* m_pcFrame;
PlaYUVerFrame* m_pcSelectedFrame; PlaYUVerFrame* m_pcSelectedFrame;
Int m_iLastFrameType; Int m_iLastFrameType;
@@ -106,9 +89,9 @@ private:
private Q_SLOTS: private Q_SLOTS:
void slotRefreshOptions( int range ); void slotRefreshOptions( int range );
void slotHistogramComputationFailed( void ); void slotHistogramComputationFailed( void );
void slotChannelChanged( int channel ); void slotChannelChanged( int index );
void slotScaleChanged( int scale ); void slotScaleChanged( int scale );
void slotColorsChanged( int color ); void slotColorsChanged( int index );
void slotRenderingChanged( int rendering ); void slotRenderingChanged( int rendering );
void slotMinValueChanged( int ); void slotMinValueChanged( int );
void slotMaxValueChanged( int ); void slotMaxValueChanged( int );
+105 -146
View File
@@ -79,8 +79,8 @@ public:
} }
/** /**
* Custom Event * Custom Event
*/ */
class EventData : public QEvent class EventData : public QEvent
{ {
public: public:
@@ -154,13 +154,13 @@ public:
bool statisticsVisible; // Display tooltip histogram statistics. bool statisticsVisible; // Display tooltip histogram statistics.
bool inSelected; bool inSelected;
bool selectMode; // If true, a part of the histogram can be bool selectMode; // If true, a part of the histogram can be
// selected ! // selected !
bool blinkFlag; bool blinkFlag;
bool blinkComputation; // If true, a message will be displayed during bool blinkComputation; // If true, a message will be displayed during
// histogram computation, else nothing (limit // histogram computation, else nothing (limit
// flicker effect in widget especially for small // flicker effect in widget especially for small
// image/computation time). // image/computation time).
bool lumaChannel; // Compute luminance channel if true. bool lumaChannel; // Compute luminance channel if true.
bool inInitialRepaintWait; bool inInitialRepaintWait;
QTimer* blinkTimer; QTimer* blinkTimer;
@@ -180,10 +180,9 @@ HistogramWidget::HistogramWidget( Int width, Int height, QWidget* parent )
d = new HistogramWidgetPrivate; d = new HistogramWidgetPrivate;
// m_channelType = LumaHistogram; m_channelType = PlaYUVerFrame::HIST_LUMA;
m_channelType = FirstChannelHistogram;
m_scaleType = LogScaleHistogram; m_scaleType = LogScaleHistogram;
m_colorType = FirstChannelColor; m_colorType = -1;
m_renderingType = FullImageHistogram; m_renderingType = FullImageHistogram;
setOptions( HistogramWidget::BlinkComputation | HistogramWidget::SelectMode | HistogramWidget::ShowLumaChannel ); setOptions( HistogramWidget::BlinkComputation | HistogramWidget::SelectMode | HistogramWidget::ShowLumaChannel );
@@ -211,12 +210,6 @@ HistogramWidget::~HistogramWidget()
{ {
d->blinkTimer->stop(); d->blinkTimer->stop();
// if( m_imageHistogram )
// delete m_imageHistogram;
//
// if( m_selectionHistogram )
// delete m_selectionHistogram;
delete m_imageWorker; delete m_imageWorker;
delete m_selectionWorker; delete m_selectionWorker;
@@ -327,16 +320,6 @@ Void HistogramWidget::customEvent( QEvent* event )
// Remove old histogram data from memory. // Remove old histogram data from memory.
m_fullImage = NULL; m_fullImage = NULL;
m_selectionImage = NULL; m_selectionImage = NULL;
// if( m_imageHistogram )
// {
// delete m_imageHistogram;
// m_imageHistogram = 0;
// }
// if( m_selectionHistogram )
// {
// delete m_selectionHistogram;
// m_selectionHistogram = 0;
// }
emit signalHistogramComputationFailed(); emit signalHistogramComputationFailed();
} }
} }
@@ -519,34 +502,12 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
yb = 0; yb = 0;
max = 0.0; max = 0.0;
switch( m_channelType ) max = frame->getMaximum( m_channelType );
{
case HistogramWidget::FirstChannelHistogram: // Y channel.
max = frame->getMaximum( LUMA );
break;
case HistogramWidget::SecondChannelHistogram: // Cb channel.
max = frame->getMaximum( CHROMA_U );
break;
case HistogramWidget::ThirdChannelHistogram: // Cr channel.
max = frame->getMaximum( CHROMA_V );
break;
case HistogramWidget::AlphaChannelHistogram: // Alpha channel.
max = frame->getMaximum( COLOR_A );
break;
case HistogramWidget::ColorChannelsHistogram: // All color channels.
max = qMax( qMax( frame->getMaximum( LUMA ), frame->getMaximum( CHROMA_U ) ), frame->getMaximum( CHROMA_V ) );
break;
// case HistogramWidget::LumaHistogram: // Luminance.
// max = frame->getMaximum( LUMA );
// break;
}
switch( m_scaleType ) switch( m_scaleType )
{ {
case HistogramWidget::LinScaleHistogram: case HistogramWidget::LinScaleHistogram:
break; break;
case HistogramWidget::LogScaleHistogram: case HistogramWidget::LogScaleHistogram:
if( max > 0.0 ) if( max > 0.0 )
max = log( max ); max = log( max );
@@ -569,8 +530,8 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
double value_r = 0.0, value_g = 0.0, value_b = 0.0; // For all channels. double value_r = 0.0, value_g = 0.0, value_b = 0.0; // For all channels.
int i, j; int i, j;
i = ( x * frame->getHistogramSegment() ) / wWidth; i = ( x * frame->getNumHistogramSegment() ) / wWidth;
j = ( ( x + 1 ) * frame->getHistogramSegment() ) / wWidth; j = ( ( x + 1 ) * frame->getNumHistogramSegment() ) / wWidth;
do do
{ {
@@ -582,37 +543,12 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
vg = 0.0; vg = 0.0;
vb = 0.0; vb = 0.0;
switch( m_channelType ) if( m_channelType == PlaYUVerFrame::HIST_ALL_CHANNELS )
{ {
case HistogramWidget::FirstChannelHistogram: // Y channel. vr = frame->getHistogramValue( PlaYUVerFrame::HIST_CHAN_ONE, i );
v = frame->getHistogramValue( LUMA, i++ ); vg = frame->getHistogramValue( PlaYUVerFrame::HIST_CHAN_TWO, i );
break; vb = frame->getHistogramValue( PlaYUVerFrame::HIST_CHAN_THREE, i );
case HistogramWidget::SecondChannelHistogram: // Cb channel.
v = frame->getHistogramValue( CHROMA_U, i++ );
break;
case HistogramWidget::ThirdChannelHistogram: // Cr channel.
v = frame->getHistogramValue( CHROMA_V, i++ );
break;
case HistogramWidget::AlphaChannelHistogram: // Alpha channel.
v = frame->getHistogramValue( COLOR_A, i++ );
break;
case HistogramWidget::ColorChannelsHistogram: // All color.
vr = frame->getHistogramValue( LUMA, i );
vg = frame->getHistogramValue( CHROMA_U, i );
vb = frame->getHistogramValue( CHROMA_V, i++ );
break;
// case HistogramWidget::LumaHistogram: // Luminance.
// v = frame->getHistogramValue( LUMA, i++ );
// break;
}
if( m_channelType != HistogramWidget::ColorChannelsHistogram )
{
if( v > value )
value = v;
}
else
{
if( vr > value_r ) if( vr > value_r )
value_r = vr; value_r = vr;
if( vg > value_g ) if( vg > value_g )
@@ -620,9 +556,16 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
if( vb > value_b ) if( vb > value_b )
value_b = vb; value_b = vb;
} }
else
{
v = frame->getHistogramValue( m_channelType, i );
if( v > value )
value = v;
}
i++;
} while( i < j ); } while( i < j );
if( m_channelType != HistogramWidget::ColorChannelsHistogram ) if( m_channelType != PlaYUVerFrame::HIST_ALL_CHANNELS )
{ {
switch( m_scaleType ) switch( m_scaleType )
{ {
@@ -673,7 +616,7 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
// Drawing the histogram + selection or only the histogram. // Drawing the histogram + selection or only the histogram.
if( m_channelType != HistogramWidget::ColorChannelsHistogram ) if( m_channelType != PlaYUVerFrame::HIST_ALL_CHANNELS )
{ {
if( d->selectMode == true ) // Selection mode enable ? if( d->selectMode == true ) // Selection mode enable ?
{ {
@@ -726,17 +669,23 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
// colors channel mode? // colors channel mode?
switch( m_colorType ) switch( m_colorType )
{ {
case HistogramWidget::FirstChannelColor: case PlaYUVerFrame::HIST_LUMA:
case PlaYUVerFrame::HIST_COLOR_R:
p1.drawLine( x, wHeight, x, wHeight - yr ); p1.drawLine( x, wHeight, x, wHeight - yr );
break; break;
case HistogramWidget::SecondChannelColor: case PlaYUVerFrame::HIST_CHROMA_U:
case PlaYUVerFrame::HIST_COLOR_G:
p1.drawLine( x, wHeight, x, wHeight - yg ); p1.drawLine( x, wHeight, x, wHeight - yg );
break; break;
default: case PlaYUVerFrame::HIST_CHROMA_V:
case PlaYUVerFrame::HIST_COLOR_B:
p1.drawLine( x, wHeight, x, wHeight - yb ); p1.drawLine( x, wHeight, x, wHeight - yb );
break; break;
default:
Q_ASSERT( 0 );
} }
} }
else else
@@ -745,12 +694,13 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
// colors channel mode? // colors channel mode?
switch( m_colorType ) switch( m_colorType )
{ {
case HistogramWidget::FirstChannelColor: case PlaYUVerFrame::HIST_LUMA:
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) ); case PlaYUVerFrame::HIST_COLOR_R:
p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yg ); p1.drawLine( x, wHeight, x, wHeight - yg );
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yb ); p1.drawLine( x, wHeight, x, wHeight - yb );
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yr ); p1.drawLine( x, wHeight, x, wHeight - yr );
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) ); p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
@@ -762,12 +712,13 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
break; break;
case HistogramWidget::SecondChannelColor: case PlaYUVerFrame::HIST_CHROMA_U:
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) ); case PlaYUVerFrame::HIST_COLOR_G:
p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yb ); p1.drawLine( x, wHeight, x, wHeight - yb );
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yr ); p1.drawLine( x, wHeight, x, wHeight - yr );
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yg ); p1.drawLine( x, wHeight, x, wHeight - yg );
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) ); p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
@@ -778,23 +729,25 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg ); p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
break; break;
case PlaYUVerFrame::HIST_CHROMA_V:
case PlaYUVerFrame::HIST_COLOR_B:
p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yr );
p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yg );
p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yb );
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
break;
default: default:
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) ); Q_ASSERT( 0 );
p1.drawLine( x, wHeight, x, wHeight - yr );
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yg );
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yb );
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
break;
} }
if( x == wWidth / 4 || x == wWidth / 2 || x == 3 * wWidth / 4 ) if( x == wWidth / 4 || x == wWidth / 2 || x == 3 * wWidth / 4 )
@@ -810,15 +763,16 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
// colors channel mode? // colors channel mode?
switch( m_colorType ) switch( m_colorType )
{ {
case HistogramWidget::FirstChannelColor: case PlaYUVerFrame::HIST_LUMA:
case PlaYUVerFrame::HIST_COLOR_R:
p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) ); p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yg ); p1.drawLine( x, wHeight, x, wHeight - yg );
p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) ); p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yb ); p1.drawLine( x, wHeight, x, wHeight - yb );
p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) ); p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yr ); p1.drawLine( x, wHeight, x, wHeight - yr );
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) ); p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
@@ -830,15 +784,16 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
break; break;
case HistogramWidget::SecondChannelColor: case PlaYUVerFrame::HIST_CHROMA_U:
case PlaYUVerFrame::HIST_COLOR_G:
p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) ); p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yb ); p1.drawLine( x, wHeight, x, wHeight - yb );
p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) ); p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yr ); p1.drawLine( x, wHeight, x, wHeight - yr );
p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) ); p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) ); p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yg ); p1.drawLine( x, wHeight, x, wHeight - yg );
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) ); p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
@@ -850,25 +805,28 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
break; break;
case PlaYUVerFrame::HIST_CHROMA_V:
case PlaYUVerFrame::HIST_COLOR_B:
p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][0], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yr );
p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][1], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yg );
p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][2], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yb );
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
break;
default: default:
p1.setPen( QPen( Qt::red, 1, Qt::SolidLine ) ); Q_ASSERT( 0 );
p1.setPen( QPen( g_eColorPallet[pallet][FirstChannelColor], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yr );
p1.setPen( QPen( Qt::green, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][SecondChannelColor], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yg );
p1.setPen( QPen( Qt::blue, 1, Qt::SolidLine ) );
p1.setPen( QPen( g_eColorPallet[pallet][ThirdChannelColor], 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight, x, wHeight - yb );
p1.setPen( QPen( Qt::white, 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight - qMax( qMax( yr, yg ), yb ), x, 0 );
p1.setPen( QPen( Qt::gray, 1, Qt::SolidLine ) );
p1.drawLine( x, wHeight - yr - 1, x, wHeight - yr );
p1.drawLine( x, wHeight - yg - 1, x, wHeight - yg );
p1.drawLine( x, wHeight - yb - 1, x, wHeight - yb );
break;
} }
if( x == wWidth / 4 || x == wWidth / 2 || x == 3 * wWidth / 4 ) if( x == wWidth / 4 || x == wWidth / 2 || x == 3 * wWidth / 4 )
@@ -889,22 +847,23 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
{ {
switch( m_channelType ) switch( m_channelType )
{ {
case HistogramWidget::FirstChannelHistogram: case PlaYUVerFrame::HIST_CHROMA_V:
case PlaYUVerFrame::HIST_COLOR_R:
guidePos = d->colorGuide.red(); guidePos = d->colorGuide.red();
break; break;
case HistogramWidget::SecondChannelHistogram: case PlaYUVerFrame::HIST_COLOR_G:
guidePos = d->colorGuide.green(); guidePos = d->colorGuide.green();
break; break;
case HistogramWidget::ThirdChannelHistogram: case PlaYUVerFrame::HIST_CHROMA_U:
case PlaYUVerFrame::HIST_COLOR_B:
guidePos = d->colorGuide.blue(); guidePos = d->colorGuide.blue();
break; break;
// case HistogramWidget::LumaHistogram: case PlaYUVerFrame::HIST_LUMA:
// guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green() guidePos = qMax( qMax( d->colorGuide.red(), d->colorGuide.green() ), d->colorGuide.blue() );
// ), d->colorGuide.blue() ); break;
// break;
default: // Alpha. default: // Alpha.
guidePos = -1; guidePos = -1;
@@ -913,7 +872,7 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
if( guidePos != -1 ) if( guidePos != -1 )
{ {
int xGuide = ( guidePos * wWidth ) / frame->getHistogramSegment(); int xGuide = ( guidePos * wWidth ) / frame->getNumHistogramSegment();
p1.drawLine( xGuide, 0, xGuide, wHeight ); p1.drawLine( xGuide, 0, xGuide, wHeight );
QString string = tr( "x:%1" ).arg( guidePos ); QString string = tr( "x:%1" ).arg( guidePos );
@@ -950,7 +909,7 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
tipText = "<table cellspacing=0 cellpadding=0>"; tipText = "<table cellspacing=0 cellpadding=0>";
tipText += cellBeg + tr( "Mean:" ) + cellMid; tipText += cellBeg + tr( "Mean:" ) + cellMid;
double mean = frame->getMean( m_channelType, 0, frame->getHistogramSegment() - 1 ); double mean = frame->getMean( m_channelType, 0, frame->getNumHistogramSegment() - 1 );
tipText += value.setNum( mean, 'f', 1 ) + cellEnd; tipText += value.setNum( mean, 'f', 1 ) + cellEnd;
tipText += cellBeg + tr( "Pixels:" ) + cellMid; tipText += cellBeg + tr( "Pixels:" ) + cellMid;
@@ -958,15 +917,15 @@ Void HistogramWidget::paintEvent( QPaintEvent* )
tipText += value.setNum( (float)pixels, 'f', 0 ) + cellEnd; tipText += value.setNum( (float)pixels, 'f', 0 ) + cellEnd;
tipText += cellBeg + tr( "Std dev.:" ) + cellMid; tipText += cellBeg + tr( "Std dev.:" ) + cellMid;
double stddev = frame->getStdDev( m_channelType, 0, frame->getHistogramSegment() - 1 ); double stddev = frame->getStdDev( m_channelType, 0, frame->getNumHistogramSegment() - 1 );
tipText += value.setNum( stddev, 'f', 1 ) + cellEnd; tipText += value.setNum( stddev, 'f', 1 ) + cellEnd;
tipText += cellBeg + tr( "Selected:" ) + cellMid; tipText += cellBeg + tr( "Selected:" ) + cellMid;
double counts = frame->getCount( m_channelType, 0, frame->getHistogramSegment() - 1 ); double counts = frame->getNumPixelsRange( m_channelType, 0, frame->getNumHistogramSegment() - 1 );
tipText += value.setNum( (float)counts, 'f', 0 ) + cellEnd; tipText += value.setNum( (float)counts, 'f', 0 ) + cellEnd;
tipText += cellBeg + tr( "Median:" ) + cellMid; tipText += cellBeg + tr( "Median:" ) + cellMid;
double median = frame->getMedian( m_channelType, 0, frame->getHistogramSegment() - 1 ); double median = frame->getMedian( m_channelType, 0, frame->getNumHistogramSegment() - 1 );
tipText += value.setNum( median, 'f', 1 ) + cellEnd; tipText += value.setNum( median, 'f', 1 ) + cellEnd;
tipText += cellBeg + tr( "Percent:" ) + cellMid; tipText += cellBeg + tr( "Percent:" ) + cellMid;
-22
View File
@@ -43,20 +43,6 @@ class HistogramWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
enum HistogramChannel
{
/** Luminance */
// LumaHistogram = 0,
/** Channels */
FirstChannelHistogram = 0,
SecondChannelHistogram,
ThirdChannelHistogram,
/** Alpha channel */
AlphaChannelHistogram,
/** All color channels */
ColorChannelsHistogram,
};
enum HistogramScale enum HistogramScale
{ {
/** Linear scale */ /** Linear scale */
@@ -65,14 +51,6 @@ public:
LogScaleHistogram LogScaleHistogram
}; };
enum HistogramAllColorMode
{
// Select wich component is shown in foreground
FirstChannelColor,
SecondChannelColor,
ThirdChannelColor,
};
enum HistogramRendering enum HistogramRendering
{ {
/** Full image histogram rendering */ /** Full image histogram rendering */
+1 -1
View File
@@ -990,7 +990,7 @@ Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos )
strStatus = QString( "(%1,%2) " ).arg( posX ).arg( posY ); strStatus = QString( "(%1,%2) " ).arg( posX ).arg( posY );
Int colorSpace = m_pcCurrFrame->getColorSpace(); Int colorSpace = m_pcCurrFrame->getColorSpace();
PlaYUVerPixel pixelValue = m_pcCurrFrame->getPixelValue( pos.x(), pos.y() ); PlaYUVerPixel pixelValue = m_pcCurrFrame->getPixel( pos.x(), pos.y() );
switch( colorSpace ) switch( colorSpace )
{ {
case PlaYUVerPixel::COLOR_GRAY: case PlaYUVerPixel::COLOR_GRAY:
+22 -15
View File
@@ -487,7 +487,7 @@ Void ViewArea::paintEvent( QPaintEvent* event )
{ {
Int imageWidth = m_pixmap.width(); Int imageWidth = m_pixmap.width();
Int imageHeight = m_pixmap.height(); Int imageHeight = m_pixmap.height();
PlaYUVerPixel sPixelValue; PlaYUVerPixel pixelValue;
QFont font( "Helvetica" ); QFont font( "Helvetica" );
font.setPixelSize( 12 ); font.setPixelSize( 12 );
@@ -508,51 +508,58 @@ Void ViewArea::paintEvent( QPaintEvent* event )
if( frFormat == PlaYUVerPixel::COLOR_YUV ) if( frFormat == PlaYUVerPixel::COLOR_YUV )
{ {
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() ); pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() );
if( sPixelValue.Y() < m_uiPixelHalfScale ) if( pixelValue.Y() < m_uiPixelHalfScale )
paInter.setPen( QColor( Qt::white ) ); paInter.setPen( QColor( Qt::white ) );
else else
paInter.setPen( QColor( Qt::black ) ); paInter.setPen( QColor( Qt::black ) );
paInter.drawText( pixelRect, Qt::AlignCenter, paInter.drawText( pixelRect, Qt::AlignCenter,
"Y: " + QString::number( sPixelValue.Y() ) + "\n" + "Y: " + QString::number( pixelValue.Y() ) + "\n" +
"U: " + QString::number( sPixelValue.Cb() ) + "\n" + "U: " + QString::number( pixelValue.Cb() ) + "\n" +
"V: " + QString::number( sPixelValue.Cr() ) ); "V: " + QString::number( pixelValue.Cr() ) );
} }
if( frFormat == PlaYUVerPixel::COLOR_GRAY ) if( frFormat == PlaYUVerPixel::COLOR_GRAY )
{ {
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() ); pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() );
if( sPixelValue.Y() < m_uiPixelHalfScale ) if( pixelValue.Y() < m_uiPixelHalfScale )
paInter.setPen( QColor( Qt::white ) ); paInter.setPen( QColor( Qt::white ) );
else else
paInter.setPen( QColor( Qt::black ) ); paInter.setPen( QColor( Qt::black ) );
paInter.drawText( pixelRect, Qt::AlignCenter, "Y: " + QString::number( sPixelValue.Y() ) ); paInter.drawText( pixelRect, Qt::AlignCenter, "Y: " + QString::number( pixelValue.Y() ) );
} }
if( ( frFormat == PlaYUVerPixel::COLOR_RGB ) ) if( ( frFormat == PlaYUVerPixel::COLOR_RGB ) )
{ {
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() ); pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() );
if( ( sPixelValue.R() + sPixelValue.G() + sPixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) ) if( ( pixelValue.R() + pixelValue.G() + pixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) )
paInter.setPen( QColor( Qt::white ) ); paInter.setPen( QColor( Qt::white ) );
else else
paInter.setPen( QColor( Qt::black ) ); paInter.setPen( QColor( Qt::black ) );
paInter.drawText( pixelRect, Qt::AlignCenter, "R: " + QString::number( sPixelValue.R() ) + "\nG: " + QString::number( sPixelValue.G() ) + "\nB: " + QString::number( sPixelValue.B() ) ); paInter.drawText( pixelRect, Qt::AlignCenter,
"R: " + QString::number( pixelValue.R() ) +
"\nG: " + QString::number( pixelValue.G() ) +
"\nB: " + QString::number( pixelValue.B() ) );
} }
if( ( frFormat == PlaYUVerPixel::COLOR_RGBA ) ) if( ( frFormat == PlaYUVerPixel::COLOR_RGBA ) )
{ {
sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft.x(), pixelTopLeft.y() ); pixelValue = m_pcCurrFrame->getPixel( pixelTopLeft.x(), pixelTopLeft.y() );
if( ( sPixelValue.R() + sPixelValue.G() + sPixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) ) if( ( pixelValue.R() + pixelValue.G() + pixelValue.B() ) < ( m_uiPixelHalfScale * 3 ) )
paInter.setPen( QColor( Qt::white ) ); paInter.setPen( QColor( Qt::white ) );
else else
paInter.setPen( QColor( Qt::black ) ); paInter.setPen( QColor( Qt::black ) );
paInter.drawText( pixelRect, Qt::AlignCenter, "R: " + QString::number( sPixelValue.R() ) + "\nG: " + QString::number( sPixelValue.G() ) + "\nB: " + QString::number( sPixelValue.B() ) + "\nA: " + QString::number( sPixelValue.A() ) ); paInter.drawText( pixelRect, Qt::AlignCenter,
"R: " + QString::number( pixelValue.R() ) +
"\nG: " + QString::number( pixelValue.G() ) +
"\nB: " + QString::number( pixelValue.B() ) +
"\nA: " + QString::number( pixelValue.A() ) );
} }
} }
} }
+189 -251
View File
@@ -293,27 +293,46 @@ PlaYUVerPixel PlaYUVerPixel::operator*( const Double& op )
PlaYUVerPixel PlaYUVerPixel::ConvertPixel( ColorSpace eOutputSpace ) PlaYUVerPixel PlaYUVerPixel::ConvertPixel( ColorSpace eOutputSpace )
{ {
Int outA, outB, outC; if( d->iColorSpace == eOutputSpace )
PlaYUVerPixel outPixel( COLOR_INVALID, 0, 0, 0 );
if( ColorSpace() == eOutputSpace || eOutputSpace == COLOR_RGBA || eOutputSpace == COLOR_GRAY )
return *this; return *this;
if( eOutputSpace == COLOR_RGB ) Int outA = 0;
Int outB = 0;
Int outC = 0;
Int outD = 0;
if( d->iColorSpace == COLOR_YUV )
{ {
yuvToRgb( Y(), Cb(), Cr(), outA, outB, outC ); switch( eOutputSpace )
outPixel.R() = outA; {
outPixel.G() = outB; case COLOR_GRAY:
outPixel.B() = outC; outA = Y();
break;
case COLOR_RGBA:
outD = 255;
case COLOR_RGB:
yuvToRgb( Y(), Cb(), Cr(), outA, outB, outC );
break;
default:
break;
}
} }
if( eOutputSpace == COLOR_YUV ) if( d->iColorSpace == COLOR_RGB )
{ {
rgbToYuv( R(), G(), B(), outA, outB, outC ); switch( eOutputSpace )
outPixel.Y() = outA; {
outPixel.Cb() = outB; case COLOR_GRAY:
outPixel.Cr() = outC; rgbToYuv( R(), G(), B(), outA, outB, outC );
case COLOR_YUV:
rgbToYuv( R(), G(), B(), outA, outB, outC );
break;
case COLOR_RGBA:
outD = 255;
break;
default:
break;
}
} }
return outPixel; return PlaYUVerPixel( eOutputSpace, outA, outB, outC, outD );
} }
struct PlaYUVerFramePrivate struct PlaYUVerFramePrivate
@@ -425,6 +444,38 @@ struct PlaYUVerFramePrivate
m_bInit = true; m_bInit = true;
} }
Int getRealHistogramChannel( Int channel )
{
Int realChannel = -1;
if( channel == PlaYUVerFrame::HIST_ALL_CHANNELS )
{
realChannel = channel;
}
else if( channel >= 0 && channel < 4 )
{
realChannel = channel;
}
else if( m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_YUV )
{
if( channel >= 10 && channel < 13 )
{
realChannel = channel - 10;
}
}
else if( m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB || m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGBA )
{
if( channel == PlaYUVerFrame::HIST_LUMA )
{
realChannel = m_uiHistoChannels - 1;
}
if( channel >= 20 && channel < 24 )
{
realChannel = channel - 20;
}
}
return realChannel;
}
~PlaYUVerFramePrivate() ~PlaYUVerFramePrivate()
{ {
while( m_bHistogramRunning ) while( m_bHistogramRunning )
@@ -685,7 +736,7 @@ UChar* PlaYUVerFrame::getRGBBuffer()
return d->m_pcARGB32; return d->m_pcARGB32;
} }
PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos ) PlaYUVerPixel PlaYUVerFrame::getPixel( Int xPos, Int yPos )
{ {
PlaYUVerPixel PixelValue( d->m_pcPelFormat->colorSpace ); PlaYUVerPixel PixelValue( d->m_pcPelFormat->colorSpace );
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
@@ -697,7 +748,7 @@ PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos )
return PixelValue; return PixelValue;
} }
PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, PlaYUVerPixel::ColorSpace eColorSpace ) PlaYUVerPixel PlaYUVerFrame::getPixel( Int xPos, Int yPos, PlaYUVerPixel::ColorSpace eColorSpace )
{ {
PlaYUVerPixel PixelValue( d->m_pcPelFormat->colorSpace ); PlaYUVerPixel PixelValue( d->m_pcPelFormat->colorSpace );
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
@@ -710,7 +761,7 @@ PlaYUVerPixel PlaYUVerFrame::getPixelValue( Int xPos, Int yPos, PlaYUVerPixel::C
return PixelValue; return PixelValue;
} }
Void PlaYUVerFrame::setPixelValue( Int xPos, Int yPos, PlaYUVerPixel pixel ) Void PlaYUVerFrame::setPixel( Int xPos, Int yPos, PlaYUVerPixel pixel )
{ {
for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ ) for( UInt ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
{ {
@@ -982,207 +1033,152 @@ Void PlaYUVerFrame::calcHistogram()
xMemSet( UInt, d->m_uiHistoSegments * d->m_uiHistoChannels, d->m_puiHistogram ); xMemSet( UInt, d->m_uiHistoSegments * d->m_uiHistoChannels, d->m_puiHistogram );
UInt i, j;
UInt numberChannels = d->m_pcPelFormat->numberChannels; UInt numberChannels = d->m_pcPelFormat->numberChannels;
Int colorSpace = d->m_pcPelFormat->colorSpace; for( UInt ch = 0; ch < numberChannels; ch++ )
if( colorSpace == PlaYUVerPixel::COLOR_YUV )
{ {
const Pel* data[3]; UInt size = CHROMASHIFT( d->m_uiWidth, ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0 ) *
data[LUMA] = d->m_pppcInputPel[LUMA][0]; CHROMASHIFT( d->m_uiHeight, ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0 );
data[CHROMA_U] = d->m_pppcInputPel[CHROMA_U][0];
data[CHROMA_V] = d->m_pppcInputPel[CHROMA_V][0]; Pel* chPel = &( d->m_pppcInputPel[ch][0][0] );
for( i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ ) for( UInt i = 0; i < size; i++ )
{ {
d->m_puiHistogram[*( data[LUMA] ) + LUMA * d->m_uiHistoSegments]++; d->m_puiHistogram[*chPel + ch * d->m_uiHistoSegments]++;
data[LUMA] += 1; chPel++;
}
for( i = 0; ( i < getChromaLength() ); i++ )
{
for( j = 1; j < numberChannels; j++ )
{
d->m_puiHistogram[*( data[j] ) + j * d->m_uiHistoSegments]++;
data[j] += 1;
}
} }
} }
else
{
const Pel* data[3];
Pel luma;
data[COLOR_R] = d->m_pppcInputPel[COLOR_R][0];
data[COLOR_G] = d->m_pppcInputPel[COLOR_G][0];
data[COLOR_B] = d->m_pppcInputPel[COLOR_B][0];
for( i = 0; ( i < d->m_uiHeight * d->m_uiWidth ); i++ ) if( d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGB ||
{ d->m_pcPelFormat->colorSpace == PlaYUVerPixel::COLOR_RGBA )
for( j = 0; j < numberChannels; j++ ) {
for( UInt y = 0; y < d->m_uiHeight; y++ )
for( UInt x = 0; x < d->m_uiWidth; x++ )
{ {
d->m_puiHistogram[*( data[j] ) + j * d->m_uiHistoSegments]++; Pel luma = getPixel( x, y ).ConvertPixel( PlaYUVerPixel::COLOR_YUV ).Y();
d->m_puiHistogram[luma + ( d->m_uiHistoChannels - 1 ) * d->m_uiHistoSegments]++;
} }
if( ( colorSpace == PlaYUVerPixel::COLOR_RGB || colorSpace == PlaYUVerPixel::COLOR_RGBA ) )
{
PlaYUVerPixel currPixel( colorSpace, *( data[COLOR_R] ), *( data[COLOR_G] ), *( data[COLOR_B] ) );
luma = currPixel.ConvertPixel( PlaYUVerPixel::COLOR_YUV ).Y();
d->m_puiHistogram[luma + j * d->m_uiHistoSegments]++;
}
for( j = 0; j < numberChannels; j++ )
data[j] += 1;
}
} }
d->m_bHasHistogram = true; d->m_bHasHistogram = true;
d->m_bHistogramRunning = false; d->m_bHistogramRunning = false;
} }
Int PlaYUVerFrame::getHistogramSegment() Int PlaYUVerFrame::getNumHistogramSegment()
{ {
return d->m_uiHistoSegments; return d->m_uiHistoSegments;
} }
Int getRealHistoChannel( Int colorSpace, Int channel ) UInt PlaYUVerFrame::getMinimumPelValue( Int channel )
{ {
Int histoChannel;
switch( colorSpace )
{
case PlaYUVerPixel::COLOR_GRAY:
if( channel != LUMA )
{
return -1;
}
histoChannel = 0;
break;
case PlaYUVerPixel::COLOR_RGB:
if( channel != COLOR_R && channel != COLOR_G && channel != COLOR_B && channel != LUMA )
{
return -1;
}
else
{
// if( channel == LUMA )
// {
// histoChannel = 3;
// }
// else
{
histoChannel = channel;
}
}
break;
case PlaYUVerPixel::COLOR_RGBA:
if( channel != COLOR_R && channel != COLOR_G && channel != COLOR_B && channel != COLOR_A && channel != LUMA )
{
return -1;
}
else
{
if( channel == LUMA )
{
histoChannel = 4;
}
else
{
histoChannel = channel;
}
}
break;
case PlaYUVerPixel::COLOR_YUV:
if( channel != LUMA && channel != CHROMA_U && channel != CHROMA_V )
{
return -1;
}
else
{
histoChannel = channel;
}
break;
default:
histoChannel = -1;
}
return histoChannel;
}
UInt PlaYUVerFrame::getMin( Int channel )
{
UInt value;
Int histoChannel;
Int indexStart;
if( !d->m_bHasHistogram ) if( !d->m_bHasHistogram )
{
return 0; return 0;
channel = d->getRealHistogramChannel( channel );
if( channel < 0 )
return 0;
Int indexStart;
Int indexEnd;
if( channel == HIST_ALL_CHANNELS )
{
indexStart = 0;
indexEnd = d->m_uiHistoChannels * d->m_uiHistoSegments;
}
else
{
indexStart = channel * d->m_uiHistoSegments;
indexEnd = indexStart + d->m_uiHistoSegments;
} }
histoChannel = getRealHistoChannel( getColorSpace(), channel ); for( Int i = indexStart; i < indexEnd; i++ )
if( histoChannel == -1 )
{ {
return 0; if( d->m_puiHistogram[i] > 0 )
}
indexStart = histoChannel * d->m_uiHistoSegments;
for( value = 0; value <= d->m_uiHistoSegments; value++ )
{
if( d->m_puiHistogram[indexStart + value] > 0 )
{ {
break; return i - indexStart;
} }
} }
return value; return 0;
} }
UInt PlaYUVerFrame::getMax( Int channel ) UInt PlaYUVerFrame::getMaximumPelValue( Int channel )
{ {
Int value;
Int histoChannel;
Int indexStart;
if( !d->m_bHasHistogram ) if( !d->m_bHasHistogram )
{
return 0; return 0;
channel = d->getRealHistogramChannel( channel );
if( channel < 0 )
return 0;
Int indexStart;
Int indexEnd;
if( channel == HIST_ALL_CHANNELS )
{
indexStart = d->m_uiHistoChannels * d->m_uiHistoSegments;
indexEnd = 0;
}
else
{
indexStart = ( channel + 1 ) * d->m_uiHistoSegments - 1;
indexEnd = indexStart - d->m_uiHistoSegments;
} }
histoChannel = getRealHistoChannel( getColorSpace(), channel ); for( Int i = indexStart; i > indexEnd; i-- )
if( histoChannel == -1 )
{ {
return 0; if( d->m_puiHistogram[i] > 0 )
}
indexStart = histoChannel * d->m_uiHistoSegments;
for( value = d->m_uiHistoSegments - 1; value >= 0; value-- )
{
if( d->m_puiHistogram[indexStart + value] > 0 )
{ {
break; return i - indexEnd + 1;
} }
} }
return value; return 0;
} }
UInt PlaYUVerFrame::getCount( Int channel, UInt start, UInt end ) UInt PlaYUVerFrame::getMaximum( Int channel )
{ {
UInt i; if( !d->m_bHasHistogram )
Int histoChannel; return 0;
Int indexStart;
UInt count = 0;
channel = d->getRealHistogramChannel( channel );
if( channel < 0 )
return 0;
UInt maxValue = 0;
Int indexStart;
Int indexEnd;
if( channel == HIST_ALL_CHANNELS )
{
indexStart = 0;
indexEnd = d->m_uiHistoChannels * d->m_uiHistoSegments;
}
else
{
indexStart = channel * d->m_uiHistoSegments;
indexEnd = indexStart + d->m_uiHistoSegments;
}
for( Int x = indexStart; x < indexEnd; x++ )
{
if( d->m_puiHistogram[x] > maxValue )
{
maxValue = d->m_puiHistogram[x];
}
}
return maxValue;
}
UInt PlaYUVerFrame::getNumPixelsRange( Int channel, UInt start, UInt end )
{
if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end ) if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end )
{ {
return 0.0; return 0;
} }
channel = d->getRealHistogramChannel( channel );
histoChannel = getRealHistoChannel( getColorSpace(), channel ); if( channel < 0 )
if( histoChannel == -1 )
{ {
return 0; return 0;
} }
indexStart = histoChannel * d->m_uiHistoSegments; UInt count = 0;
Int indexStart;
for( i = start; i <= end; i++ ) indexStart = channel * d->m_uiHistoSegments;
for( UInt i = start; i <= end; i++ )
{ {
count += d->m_puiHistogram[indexStart + i]; count += d->m_puiHistogram[indexStart + i];
} }
@@ -1191,31 +1187,25 @@ UInt PlaYUVerFrame::getCount( Int channel, UInt start, UInt end )
Double PlaYUVerFrame::getMean( Int channel, UInt start, UInt end ) Double PlaYUVerFrame::getMean( Int channel, UInt start, UInt end )
{ {
Int indexStart;
Int histoChannel;
Double mean = 0.0;
Double count;
if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end ) if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end )
{ {
return 0.0; return 0.0;
} }
channel = d->getRealHistogramChannel( channel );
histoChannel = getRealHistoChannel( getColorSpace(), channel ); if( channel < 0 )
if( histoChannel == -1 )
{ {
return 0.0; return 0.0;
} }
indexStart = histoChannel * d->m_uiHistoSegments; Double mean = 0.0;
Double count;
Int indexStart = channel * d->m_uiHistoSegments;
for( UInt i = start; i <= end; i++ ) for( UInt i = start; i <= end; i++ )
{ {
mean += i * d->m_puiHistogram[indexStart + i]; mean += i * d->m_puiHistogram[indexStart + i];
} }
count = getCount( channel, start, end ); count = getNumPixelsRange( channel, start, end );
if( count > 0.0 ) if( count > 0.0 )
{ {
@@ -1227,27 +1217,20 @@ Double PlaYUVerFrame::getMean( Int channel, UInt start, UInt end )
Int PlaYUVerFrame::getMedian( Int channel, UInt start, UInt end ) Int PlaYUVerFrame::getMedian( Int channel, UInt start, UInt end )
{ {
Int histoChannel;
Int indexStart;
Double sum = 0.0;
Double count;
if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end ) if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end )
{ {
return 0; return 0;
} }
histoChannel = getRealHistoChannel( getColorSpace(), channel ); channel = d->getRealHistogramChannel( channel );
if( channel < 0 )
if( histoChannel == -1 )
{ {
return 0; return 0;
} }
indexStart = histoChannel * d->m_uiHistoSegments; Double sum = 0.0;
Int indexStart = channel * d->m_uiHistoSegments;
count = getCount( channel, start, end ); Double count = getNumPixelsRange( channel, start, end );
for( UInt i = start; i <= end; i++ ) for( UInt i = start; i <= end; i++ )
{ {
sum += d->m_puiHistogram[indexStart + i]; sum += d->m_puiHistogram[indexStart + i];
@@ -1260,28 +1243,21 @@ Int PlaYUVerFrame::getMedian( Int channel, UInt start, UInt end )
Double PlaYUVerFrame::getStdDev( Int channel, UInt start, UInt end ) Double PlaYUVerFrame::getStdDev( Int channel, UInt start, UInt end )
{ {
Int histoChannel;
Int indexStart;
Double dev = 0.0;
Double count;
Double mean;
if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end ) if( !d->m_bHasHistogram || start < 0 || end > d->m_uiHistoSegments - 1 || start > end )
{ {
return 0.0; return 0.0;
} }
histoChannel = getRealHistoChannel( getColorSpace(), channel ); channel = d->getRealHistogramChannel( channel );
if( channel < 0 )
if( histoChannel == -1 )
{ {
return 0.0; return 0.0;
} }
indexStart = histoChannel * d->m_uiHistoSegments; Int indexStart = channel * d->m_uiHistoSegments;
mean = getMean( channel, start, end ); Double mean = getMean( channel, start, end );
count = getCount( channel, start, end ); Double count = getNumPixelsRange( channel, start, end );
Double dev = 0.0;
if( count == 0.0 ) if( count == 0.0 )
count = 1.0; count = 1.0;
@@ -1306,55 +1282,17 @@ Double PlaYUVerFrame::getStdDev( Int channel, UInt start, UInt end )
Double PlaYUVerFrame::getHistogramValue( Int channel, UInt bin ) Double PlaYUVerFrame::getHistogramValue( Int channel, UInt bin )
{ {
Double value;
Int histoChannel;
Int indexStart;
if( !d->m_bHasHistogram || bin < 0 || bin > d->m_uiHistoSegments - 1 ) if( !d->m_bHasHistogram || bin < 0 || bin > d->m_uiHistoSegments - 1 )
return 0.0; return 0.0;
histoChannel = getRealHistoChannel( getColorSpace(), channel ); channel = d->getRealHistogramChannel( channel );
if( channel < 0 )
if( histoChannel == -1 )
{ {
return 0.0; return 0;
} }
indexStart = histoChannel * d->m_uiHistoSegments; Int indexStart = channel * d->m_uiHistoSegments;
return d->m_puiHistogram[indexStart + bin];
value = d->m_puiHistogram[indexStart + bin];
return value;
}
Double PlaYUVerFrame::getMaximum( Int channel )
{
Double max = 0.0;
Int histoChannel;
Int indexStart;
if( !d->m_bHasHistogram )
return 0.0;
histoChannel = getRealHistoChannel( getColorSpace(), channel );
if( histoChannel == -1 )
{
return 0.0;
}
indexStart = histoChannel * d->m_uiHistoSegments;
for( UInt x = 0; x < d->m_uiHistoSegments; x++ )
{
if( d->m_puiHistogram[indexStart + x] > max )
{
max = d->m_puiHistogram[indexStart + x];
}
}
return max;
} }
/* /*
+26 -9
View File
@@ -117,7 +117,7 @@ class PlaYUVerFrame
{ {
public: public:
/** ColorSpace Enum /** ColorSpace Enum
* List of supported pixel formats - do not change order * List of supported pixel formats
*/ */
enum PixelFormats enum PixelFormats
{ {
@@ -288,9 +288,9 @@ public:
UChar* getRGBBuffer() const; UChar* getRGBBuffer() const;
UChar* getRGBBuffer(); UChar* getRGBBuffer();
PlaYUVerPixel getPixelValue( Int xPos, Int yPos ); PlaYUVerPixel getPixel( Int xPos, Int yPos );
PlaYUVerPixel getPixelValue( Int xPos, Int yPos, PlaYUVerPixel::ColorSpace eColorSpace ); PlaYUVerPixel getPixel( Int xPos, Int yPos, PlaYUVerPixel::ColorSpace eColorSpace );
Void setPixelValue( Int xPos, Int yPos, PlaYUVerPixel pixel ); Void setPixel( Int xPos, Int yPos, PlaYUVerPixel pixel );
Void copyFrom( const PlaYUVerFrame& ); Void copyFrom( const PlaYUVerFrame& );
Void copyFrom( const PlaYUVerFrame* ); Void copyFrom( const PlaYUVerFrame* );
@@ -306,18 +306,35 @@ public:
/** /**
* Histogram * Histogram
*/ */
enum HistogramChannels
{
HIST_CHAN_ONE = 0,
HIST_CHAN_TWO,
HIST_CHAN_THREE,
HIST_CHAN_FOUR,
HIST_LUMA = 10,
HIST_CHROMA_U,
HIST_CHROMA_V,
HIST_COLOR_R = 20,
HIST_COLOR_G,
HIST_COLOR_B,
HIST_COLOR_A,
HIST_ALL_CHANNELS = 254,
HISTOGRAM_MAX = 255,
};
Void calcHistogram(); Void calcHistogram();
UInt getMin( Int channel ); UInt getMinimumPelValue( Int channel );
UInt getMax( Int channel ); UInt getMaximumPelValue( Int channel );
UInt getCount( Int channel, UInt start, UInt end ); UInt getMaximum( Int channel );
UInt getNumPixelsRange( Int channel, UInt start, UInt end );
Double getMean( Int channel, UInt start, UInt end ); Double getMean( Int channel, UInt start, UInt end );
Int getMedian( Int channel, UInt start, UInt end ); Int getMedian( Int channel, UInt start, UInt end );
Double getStdDev( Int channel, UInt start, UInt end ); Double getStdDev( Int channel, UInt start, UInt end );
Double getHistogramValue( Int channel, UInt bin ); Double getHistogramValue( Int channel, UInt bin );
Double getMaximum( Int channel ); Int getNumHistogramSegment();
Int getHistogramSegment();
/** /**
* Interface with OpenCV lib * Interface with OpenCV lib
+55 -55
View File
@@ -40,6 +40,59 @@
#include <cstdio> #include <cstdio>
std::vector<PlaYUVerSupportedFormat> PlaYUVerStream::supportedReadFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerRaw, Read );
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerPortableMap, Read );
//#ifdef USE_OPENCV
// APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerOpenCV, Read );
//#endif
#ifdef USE_FFMPEG
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerLibav, Read );
#endif
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
std::vector<PlaYUVerSupportedFormat> PlaYUVerStream::supportedWriteFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerRaw, Write );
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerPortableMap, Write );
#ifdef USE_FFMPEG
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerLibav, Write );
#endif
#ifdef USE_OPENCV
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerOpenCV, Write );
#endif
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
std::vector<PlaYUVerStdResolution> PlaYUVerStream::stdResolutionSizes()
{
#define REGIST_PLAYUVER_STANDARD_RESOLUTION( name, width, height ) \
stdResElement.shortName = name; \
stdResElement.uiWidth = width; \
stdResElement.uiHeight = height; \
stdResList.push_back( stdResElement );
std::vector<PlaYUVerStdResolution> stdResList;
PlaYUVerStdResolution stdResElement;
REGIST_PLAYUVER_STANDARD_RESOLUTION( "CIF", 352, 288 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "VGA", 640, 480 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "WVGA", 832, 480 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "XVGA", 1024, 768 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "HD", 1280, 720 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "SXGA-", 1280, 900 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "SXGA", 1280, 1024 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "WSXGA", 1440, 900 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "FullHD", 1920, 1080 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "WQXGA", 2560, 1600 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "UltraHD", 3840, 2160 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "8K", 8192, 4608 );
return stdResList;
}
class PlaYUVerStreamBufferPrivate class PlaYUVerStreamBufferPrivate
{ {
private: private:
@@ -112,34 +165,6 @@ struct PlaYUVerStreamPrivate
} }
}; };
std::vector<PlaYUVerSupportedFormat> PlaYUVerStream::supportedReadFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerRaw, Read );
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerPortableMap, Read );
#ifdef USE_FFMPEG
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerLibav, Read );
#endif
#ifdef USE_OPENCV
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerOpenCV, Read );
#endif
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
std::vector<PlaYUVerSupportedFormat> PlaYUVerStream::supportedWriteFormats()
{
INI_REGIST_PLAYUVER_SUPPORTED_FMT;
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerRaw, Write );
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerPortableMap, Write );
#ifdef USE_FFMPEG
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerLibav, Write );
#endif
#ifdef USE_OPENCV
APPEND_PLAYUVER_SUPPORTED_FMT( StreamHandlerOpenCV, Write );
#endif
END_REGIST_PLAYUVER_SUPPORTED_FMT;
}
std::vector<String> PlaYUVerSupportedFormat::getExts() std::vector<String> PlaYUVerSupportedFormat::getExts()
{ {
std::vector<String> arrayExt; std::vector<String> arrayExt;
@@ -154,31 +179,6 @@ std::vector<String> PlaYUVerSupportedFormat::getExts()
return arrayExt; return arrayExt;
} }
std::vector<PlaYUVerStdResolution> PlaYUVerStream::stdResolutionSizes()
{
#define REGIST_PLAYUVER_STANDARD_RESOLUTION( name, width, height ) \
stdResElement.shortName = name; \
stdResElement.uiWidth = width; \
stdResElement.uiHeight = height; \
stdResList.push_back( stdResElement );
std::vector<PlaYUVerStdResolution> stdResList;
PlaYUVerStdResolution stdResElement;
REGIST_PLAYUVER_STANDARD_RESOLUTION( "CIF", 352, 288 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "VGA", 640, 480 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "WVGA", 832, 480 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "XVGA", 1024, 768 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "HD", 1280, 720 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "SXGA-", 1280, 900 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "SXGA", 1280, 1024 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "WSXGA", 1440, 900 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "FullHD", 1920, 1080 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "WQXGA", 2560, 1600 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "UltraHD", 3840, 2160 );
REGIST_PLAYUVER_STANDARD_RESOLUTION( "8K", 8192, 4608 );
return stdResList;
}
CreateStreamHandlerFn PlaYUVerStream::findStreamHandler( String strFilename, bool bRead ) CreateStreamHandlerFn PlaYUVerStream::findStreamHandler( String strFilename, bool bRead )
{ {
String currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 ); String currExt = strFilename.substr( strFilename.find_last_of( "." ) + 1 );
@@ -208,7 +208,7 @@ CreateStreamHandlerFn PlaYUVerStream::findStreamHandler( String strFilename, boo
} }
} }
} }
return &StreamHandlerRaw::Create; return &StreamHandlerLibav::Create;
} }
PlaYUVerStream::PlaYUVerStream() PlaYUVerStream::PlaYUVerStream()
@@ -298,7 +298,7 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f
if( d->handler->m_uiWidth <= 0 || d->handler->m_uiHeight <= 0 || d->handler->m_iPixelFormat < 0 ) if( d->handler->m_uiWidth <= 0 || d->handler->m_uiHeight <= 0 || d->handler->m_iPixelFormat < 0 )
{ {
close(); close();
throw PlaYUVerFailure( "PlaYUVerStream", "Incorrect configuration: width, height or pixel format" ); //throw PlaYUVerFailure( "PlaYUVerStream", "Incorrect configuration: width, height or pixel format" );
return d->isInit; return d->isInit;
} }
+26 -4
View File
@@ -43,7 +43,7 @@ std::vector<PlaYUVerSupportedFormat> StreamHandlerLibav::supportedReadFormats()
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Joint Photographic Experts Group", "jpg,jpeg" ); REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Joint Photographic Experts Group", "jpg,jpeg" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Windows Bitmap", "bmp" ); REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Windows Bitmap", "bmp" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Tagged Image File Format", "tiff" ); REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Tagged Image File Format", "tiff" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, " Graphics Interchange Format", "gif" ); REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Graphics Interchange Format", "gif" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Audio video interleaved", "avi" ); REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Audio video interleaved", "avi" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Windows media video", "wmv" ); REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "Windows media video", "wmv" );
REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "MPEG-4", "mp4" ); REGIST_PLAYUVER_SUPPORTED_FMT( &StreamHandlerLibav::Create, "MPEG-4", "mp4" );
@@ -209,8 +209,6 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
} }
if( m_iPixelFormat == PlaYUVerFrame::NO_FMT ) if( m_iPixelFormat == PlaYUVerFrame::NO_FMT )
{ {
Int newPelFmt = PlaYUVerFrame::findPixelFormat( "YUV444p" );
m_iPixelFormat = newPelFmt;
m_bNative = false; m_bNative = false;
//throw PlaYUVerFailure( "StreamHandlerLibav", "Cannot open file using FFmpeg libs - unsupported pixel format" ); //throw PlaYUVerFailure( "StreamHandlerLibav", "Cannot open file using FFmpeg libs - unsupported pixel format" );
//return false; //return false;
@@ -252,6 +250,30 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
if( !m_bNative ) if( !m_bNative )
{ {
Int newPelFmt = -1;
const AVPixFmtDescriptor* ffPelDesc = av_pix_fmt_desc_get( AVPixelFormat( m_ffPixFmt ) );
if( ffPelDesc->flags & AV_PIX_FMT_FLAG_PAL )
{
newPelFmt = PlaYUVerFrame::RGB24;
}
else if( ffPelDesc->flags & AV_PIX_FMT_FLAG_ALPHA )
{
newPelFmt = PlaYUVerFrame::RGBA;
}
else if( ffPelDesc->flags & AV_PIX_FMT_FLAG_RGB )
{
newPelFmt = PlaYUVerFrame::RGB24;
}
else if( ffPelDesc->nb_components == 1 )
{
newPelFmt = PlaYUVerFrame::GRAY;
}
else
{
newPelFmt = PlaYUVerFrame::YUV444p;
}
m_iPixelFormat = newPelFmt;
AVPixelFormat newAvFmt = AVPixelFormat( g_PlaYUVerPixFmtDescriptorsMap.at( m_iPixelFormat ).ffmpegPelFormat ); AVPixelFormat newAvFmt = AVPixelFormat( g_PlaYUVerPixFmtDescriptorsMap.at( m_iPixelFormat ).ffmpegPelFormat );
/* create scaling context */ /* create scaling context */
@@ -267,7 +289,7 @@ Bool StreamHandlerLibav::openHandler( String strFilename, Bool bInput )
} }
if( av_image_alloc( m_cConvertedFrame->data, m_cConvertedFrame->linesize, if( av_image_alloc( m_cConvertedFrame->data, m_cConvertedFrame->linesize,
m_uiWidth, m_uiHeight, newAvFmt, 1 ) < 0 ) m_uiWidth, m_uiHeight, newAvFmt, 16 ) < 0 )
{ {
closeHandler(); closeHandler();
return false; return false;
+3 -3
View File
@@ -97,11 +97,11 @@ PlaYUVerFrame* FrameMask::process( std::vector<PlaYUVerFrame*> apcFrameList )
{ {
for( UInt x = 0; x < m_pcFrameProcessed->getWidth(); x++ ) for( UInt x = 0; x < m_pcFrameProcessed->getWidth(); x++ )
{ {
pixelImg = InputFrame->getPixelValue( x, y ); pixelImg = InputFrame->getPixel( x, y );
pixelMask = MaskFrame->getPixelValue( x, y ); pixelMask = MaskFrame->getPixel( x, y );
pixelOut = pixelImg * ( 10 - m_iWeight ) + pixelMask * m_iWeight; pixelOut = pixelImg * ( 10 - m_iWeight ) + pixelMask * m_iWeight;
pixelOut = pixelOut * 0.1; pixelOut = pixelOut * 0.1;
m_pcFrameProcessed->setPixelValue( x, y, pixelOut ); m_pcFrameProcessed->setPixel( x, y, pixelOut );
} }
} }
return m_pcFrameProcessed; return m_pcFrameProcessed;
+2 -2
View File
@@ -102,8 +102,8 @@ PlaYUVerFrame* FrameRotate::process( std::vector<PlaYUVerFrame*> apcFrameList )
inY = x; inY = x;
break; break;
} }
pixel = InputFrame->getPixelValue( inX, inY ); pixel = InputFrame->getPixel( inX, inY );
m_pcFrameProcessed->setPixelValue( x, y, pixel ); m_pcFrameProcessed->setPixel( x, y, pixel );
} }
} }
return m_pcFrameProcessed; return m_pcFrameProcessed;