diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index 194ccb8..d3f1029 100644 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -49,6 +49,7 @@ PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other ) PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, QRect area ) { + adjustSelectedAreaDims( area , other->getPelFormat() ); init( area.width(), area.height(), other->getPelFormat() ); copyFrom( other, area.x(), area.y() ); } @@ -64,6 +65,54 @@ 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 ) { m_pppcInputPel = NULL; diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index a52f42d..3ee9dc9 100644 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -211,6 +211,7 @@ private: Pel*** m_pppcInputPel; UChar* m_pcRGBPelInterlaced; + Void adjustSelectedAreaDims( QRect &area, Int pel_format ); Void init( UInt width, UInt height, Int pel_format ); Void openPixfc(); Void closePixfc();