Generalise adjustSelectedAreaDims using PlaYUVerFramePelFormat
This commit is contained in:
1 parent
b20bc6dc4e
commit
7ccc608d34
4 files changed
+25
-54
No files matched your search
@@ -496,7 +496,9 @@ Void FramePropertiesSideBar::setSelection( const QRect &selectionArea )
|
||||
if( selectionArea.isValid() )
|
||||
{
|
||||
histogramWidget->stopHistogramComputation();
|
||||
histogramWidget->updateSelectionData( new PlaYUVerFrame(m_pcFrame, selectionArea));
|
||||
histogramWidget->updateSelectionData( new PlaYUVerFrame(m_pcFrame,
|
||||
selectionArea.x(), selectionArea.y(),
|
||||
selectionArea.width(), selectionArea.height() ) );
|
||||
fullImageButton->show();
|
||||
selectionImageButton->show();
|
||||
selectionImageButton->click();
|
||||
|
||||
@@ -230,7 +230,8 @@ Bool SubWindowHandle::save( QString filename )
|
||||
PlaYUVerFrame* saveFrame = m_pcCurrFrame;
|
||||
if( m_cSelectedArea.isValid() )
|
||||
{
|
||||
saveFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea );
|
||||
saveFrame = new PlaYUVerFrame( m_pcCurrFrame, m_cSelectedArea.x(), m_cSelectedArea.y(),
|
||||
m_cSelectedArea.width(), m_cSelectedArea.height() );
|
||||
}
|
||||
if( !saveFrame )
|
||||
{
|
||||
|
||||
+17
-51
@@ -82,11 +82,11 @@ PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other )
|
||||
copyFrom( other );
|
||||
}
|
||||
|
||||
PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, QRect area )
|
||||
PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, UInt posX, UInt posY, UInt areaWidth, UInt areaHeight )
|
||||
{
|
||||
adjustSelectedAreaDims( area, other->getPelFormat() );
|
||||
init( area.width(), area.height(), other->getPelFormat() );
|
||||
copyFrom( other, area.x(), area.y() );
|
||||
adjustSelectedAreaDims( posX, posY, areaWidth, areaHeight, other->getPelFormat() );
|
||||
init( areaWidth, areaHeight, other->getPelFormat() );
|
||||
copyFrom( other, posX, posY );
|
||||
}
|
||||
|
||||
PlaYUVerFrame::~PlaYUVerFrame()
|
||||
@@ -100,53 +100,6 @@ PlaYUVerFrame::~PlaYUVerFrame()
|
||||
closePixfc();
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::adjustSelectedAreaDims( QRect &area, Int pel_format )
|
||||
{
|
||||
Int posX = area.x();
|
||||
Int posY = area.y();
|
||||
Int width = area.width();
|
||||
Int height = area.height();
|
||||
|
||||
switch( pel_format )
|
||||
{
|
||||
case YUV420p:
|
||||
if( posX % 2 )
|
||||
area.setX( posX - 1 );
|
||||
if( posY % 2 )
|
||||
area.setY( posY - 1 );
|
||||
|
||||
if( ( posX + width ) % 2 )
|
||||
area.setWidth( ( posX + width ) - area.x() + 1 );
|
||||
else
|
||||
area.setWidth( ( posX + width ) - area.x() );
|
||||
|
||||
if( ( posY + height ) % 2 )
|
||||
area.setHeight( ( posY + height ) - area.y() + 1 );
|
||||
else
|
||||
area.setHeight( ( posY + height ) - area.y() );
|
||||
|
||||
break;
|
||||
case YUV444p:
|
||||
break;
|
||||
case YUV422p:
|
||||
case YUYV422:
|
||||
if( posX % 2 )
|
||||
area.setX( posX - 1 );
|
||||
|
||||
if( ( posX + width ) % 2 )
|
||||
area.setWidth( ( posX + width ) - area.x() + 1 );
|
||||
else
|
||||
area.setWidth( ( posX + width ) - area.x() );
|
||||
|
||||
break;
|
||||
case GRAY:
|
||||
break;
|
||||
case RGB8:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format )
|
||||
{
|
||||
@@ -252,6 +205,19 @@ Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame )
|
||||
memcpy( *m_pppcInputPel[LUMA], input_frame->getPelBufferYUV()[LUMA][0], getBytesPerFrame() * sizeof(Pel) );
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::adjustSelectedAreaDims( UInt& posX, UInt& posY, UInt& areaWidth, UInt& areaHeight, Int pelFormat )
|
||||
{
|
||||
PlaYUVerFramePelFormat* pcPelFormat = &( g_PlaYUVerFramePelFormatsList[pelFormat] );
|
||||
if( posX % pcPelFormat->ratioChromaWidth )
|
||||
posX--;
|
||||
if( posY % pcPelFormat->ratioChromaHeight )
|
||||
posY--;
|
||||
if( ( posX + areaWidth ) % 2 )
|
||||
areaWidth++;
|
||||
if( ( posY + areaHeight ) % 2 )
|
||||
areaHeight++;
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::copyFrom( PlaYUVerFrame* input_frame, UInt xPos, UInt yPos )
|
||||
{
|
||||
if( m_iPixelFormat != input_frame->getPelFormat() )
|
||||
|
||||
+3
-1
@@ -95,7 +95,7 @@ public:
|
||||
|
||||
PlaYUVerFrame( UInt width = 0, UInt height = 0, Int pel_format = 0 );
|
||||
PlaYUVerFrame( PlaYUVerFrame * );
|
||||
PlaYUVerFrame( PlaYUVerFrame *, QRect area );
|
||||
PlaYUVerFrame( PlaYUVerFrame *other, UInt posX, UInt posY, UInt areaWidth, UInt areaHeight );
|
||||
~PlaYUVerFrame();
|
||||
|
||||
UInt64 getBytesPerFrame();
|
||||
@@ -113,6 +113,8 @@ public:
|
||||
Void fillRGBBuffer();
|
||||
|
||||
Void copyFrom( PlaYUVerFrame* );
|
||||
|
||||
static Void adjustSelectedAreaDims( UInt& posX, UInt& posY, UInt& areaWidth, UInt& areaHeight, Int pelFormat );
|
||||
Void copyFrom( PlaYUVerFrame*, UInt, UInt );
|
||||
|
||||
PlaYUVerFrame::Pixel getPixelValue( Int, Int, Int );
|
||||
|
||||
Reference in new issue
Block a user