diff --git a/app/PlaYUVerAppModuleIf.h b/app/PlaYUVerAppModuleIf.h index dd598f7..0f09f80 100644 --- a/app/PlaYUVerAppModuleIf.h +++ b/app/PlaYUVerAppModuleIf.h @@ -101,6 +101,16 @@ public: return arraySubWindows; } + PlaYUVerModuleIf* getModule() + { + return m_pcModule; + } + + UInt getModuleRequirements() + { + return m_pcModule->m_uiModuleRequirements; + } + Void destroy(); protected: virtual void run(); diff --git a/app/SubWindowAbstract.cpp b/app/SubWindowAbstract.cpp index ab88e7a..1c8a659 100644 --- a/app/SubWindowAbstract.cpp +++ b/app/SubWindowAbstract.cpp @@ -39,7 +39,8 @@ SubWindowAbstract::SubWindowAbstract( QWidget * parent, UInt category ) : { setParent( parent ); setVisible( false ); - setFocusPolicy( Qt::WheelFocus ); + //setFocusPolicy( Qt::WheelFocus ); + setFocusPolicy(Qt::StrongFocus); setAttribute( Qt::WA_DeleteOnClose ); setBackgroundRole( QPalette::Background ); diff --git a/app/VideoHandle.cpp b/app/VideoHandle.cpp index afef0ee..777e39c 100644 --- a/app/VideoHandle.cpp +++ b/app/VideoHandle.cpp @@ -84,7 +84,7 @@ Void VideoHandle::createActions() m_arrayActions[VIDEO_BACKWARD_ACT] = new QAction( "Video Backward", this ); m_arrayActions[VIDEO_BACKWARD_ACT]->setStatusTip( "Seek backward" ); m_arrayActions[VIDEO_BACKWARD_ACT]->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) ); - m_arrayActions[VIDEO_BACKWARD_ACT]->setShortcut( Qt::Key_Left ); + //m_arrayActions[VIDEO_BACKWARD_ACT]->setShortcut( Qt::Key_Left ); connect( m_arrayActions[VIDEO_BACKWARD_ACT], SIGNAL( triggered() ), m_mapperVideoSeek, SLOT( map() ) ); m_mapperVideoSeek->setMapping( m_arrayActions[VIDEO_BACKWARD_ACT], 0 ); diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 44bab92..731cba6 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -46,12 +46,13 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array for( Int i = 0; i < array.size(); i++ ) { d = array.at( i ); - out << d.m_cFilename << d.m_uiWidth - << d.m_uiHeight - << d.m_iPelFormat - << d.m_uiBitsPelPixel - << d.m_uiFrameRate - << d.m_uiFileSize; + out << d.m_cFilename + << d.m_uiWidth + << d.m_uiHeight + << d.m_iPelFormat + << d.m_uiBitsPelPixel + << d.m_uiFrameRate + << d.m_uiFileSize; } return out; } @@ -196,6 +197,83 @@ VideoSubWindow::~VideoSubWindow() delete m_pCurrStream; } +/** + * Events handlers + */ + +Void VideoSubWindow::keyPressEvent( QKeyEvent* event ) +{ + if( checkCategory( MODULE_SUBWINDOW ) && m_pcCurrentDisplayModule ) + { + if( m_pcCurrentDisplayModule->getModuleRequirements() & MODULE_USES_KEYS ) + { + Bool bRet = false; + switch( event->key() ) + { + case Qt::Key_A: + bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_LEFT ); + break; + case Qt::Key_D: + bRet = m_pcCurrentDisplayModule->getModule()->keyPressed( MODULE_KEY_RIGHT ); + break; + } + if( bRet ) + { + refreshFrame(); + return; + } + } + } + QWidget::keyPressEvent( event ); +} + +Void VideoSubWindow::resizeEvent( QResizeEvent* event ) +{ + m_pcVideoInfo->resize( event->size() ); +} + +/** + * Size related handlers + */ + +QSize VideoSubWindow::sizeHint() const +{ + QSize maxSize; + + QWidget *p = parentWidget(); + if( p ) + { + maxSize = p->size(); + } + else + { + maxSize = QApplication::desktop()->availableGeometry().size(); + } + return sizeHint( maxSize ); +} + +QSize VideoSubWindow::sizeHint( const QSize & maxSize ) const +{ + QSize isize; + if( m_pcCurrFrame ) + isize = QSize( m_pcCurrFrame->getWidth() + 50, m_pcCurrFrame->getHeight() + 50 ); + else if( m_pCurrStream ) + isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 ); + +// If the VideoSubWindow needs more space that the avaiable, we'll give +// to the subwindow a reasonable size preserving the image aspect ratio. + if( !( isize.width() < maxSize.width() && isize.height() < maxSize.height() ) ) + { + isize.scale( maxSize, Qt::KeepAspectRatio ); + } + return isize; +} + +Void VideoSubWindow::updateWindowOnTimeout() +{ + m_pcVideoInfo->update(); +} + Void VideoSubWindow::loadAll() { QApplication::setOverrideCursor( Qt::WaitCursor ); @@ -272,7 +350,6 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) updateVideoWindowInfo(); - return true; } @@ -332,11 +409,11 @@ Void VideoSubWindow::updateVideoWindowInfo() QString m_cCodedName = QString::fromStdString( m_pCurrStream->getCodecName() ); m_cStreamInformation = m_cFormatName + " | " + m_cCodedName; } - if( m_pcCurrFrame ) - { - QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrame->getPelFmtName() ); - m_cStreamInformation += " | " + m_cPelFmtName; - } +// if( m_pcCurrFrame ) +// { +// QString m_cPelFmtName = QString::fromStdString( m_pcCurrFrame->getPelFmtName() ); +// m_cStreamInformation += " | " + m_cPelFmtName; +// } if( m_cStreamInformation.isEmpty() ) { m_cStreamInformation = " "; @@ -857,48 +934,6 @@ Void VideoSubWindow::updatePixelValueStatusBar( const QPoint& pos ) } } -QSize VideoSubWindow::sizeHint() const -{ - QSize maxSize; - - QWidget *p = parentWidget(); - if( p ) - { - maxSize = p->size(); - } - else - { - maxSize = QApplication::desktop()->availableGeometry().size(); - } - return sizeHint( maxSize ); -} - -QSize VideoSubWindow::sizeHint( const QSize & maxSize ) const -{ - QSize isize; - if( m_pcCurrFrame ) - isize = QSize( m_pcCurrFrame->getWidth() + 50, m_pcCurrFrame->getHeight() + 50 ); - else if( m_pCurrStream ) - isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 ); - -// If the VideoSubWindow needs more space that the avaiable, we'll give -// to the subwindow a reasonable size preserving the image aspect ratio. - if( !( isize.width() < maxSize.width() && isize.height() < maxSize.height() ) ) - { - isize.scale( maxSize, Qt::KeepAspectRatio ); - } - return isize; -} - -Void VideoSubWindow::updateWindowOnTimeout() -{ - m_pcVideoInfo->update(); -} -Void VideoSubWindow::resizeEvent( QResizeEvent* event ) -{ - m_pcVideoInfo->resize( event->size() ); -} - //Void VideoSubWindow::closeEvent( QCloseEvent *event ) //{ // Bool bAccept = m_bIsPlaying ? false : true; diff --git a/app/VideoSubWindow.h b/app/VideoSubWindow.h index 71752c6..977ed27 100644 --- a/app/VideoSubWindow.h +++ b/app/VideoSubWindow.h @@ -253,6 +253,7 @@ public: Void setFillWindow( Bool bFlag ); protected: + Void keyPressEvent( QKeyEvent* event ); Void resizeEvent( QResizeEvent* event ); //void closeEvent( QCloseEvent *event ); diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 0135399..be5453b 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -229,6 +229,22 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel m_cPelFmtName = PlaYUVerFrame::supportedPixelFormatListNames()[m_iPixelFormat].c_str(); } +Void PlaYUVerFrame::clear() +{ + Pel uiValue = 128; + for( UInt ch = 0; ch < m_pcPelFormat->numberChannels; ch++ ) + { + //uiValue = ch > 0 ? 0 : 128; + memset( m_pppcInputPel[ch][0], uiValue, + CHROMASHIFT( m_uiHeight, m_pcPelFormat->log2ChromaHeight ) * CHROMASHIFT( m_uiWidth, m_pcPelFormat->log2ChromaWidth ) * sizeof(Pel) ); + } +} + +std::string PlaYUVerFrame::getPelFmtName() +{ + return m_pcPelFormat->name; +} + Int PlaYUVerFrame::getColorSpace() const { return m_pcPelFormat->colorSpace; @@ -262,6 +278,16 @@ UInt PlaYUVerFrame::getPixels() const return ( m_uiWidth * m_uiHeight ); } +UInt8 PlaYUVerFrame::getChromaWidthRatio() const +{ + return m_pcPelFormat->log2ChromaWidth; +} + +UInt8 PlaYUVerFrame::getChromaHeightRatio() const +{ + return m_pcPelFormat->log2ChromaHeight; +} + UInt PlaYUVerFrame::getChromaWidth() const { if( m_pcPelFormat->colorSpace == GRAY ) diff --git a/lib/PlaYUVerFrame.h b/lib/PlaYUVerFrame.h index 4b4ef0a..a34615b 100644 --- a/lib/PlaYUVerFrame.h +++ b/lib/PlaYUVerFrame.h @@ -45,13 +45,15 @@ struct PlaYUVerPixFmtDescriptor; #define MAX_NUMBER_COMPONENTS 4 +#define CHROMASHIFT( SIZE, SHIFT ) UInt( -( ( - ( Int( SIZE ) ) ) >> SHIFT ) ) + /** * \class PlaYUVerFrame * \ingroup PlaYUVerLib PlaYUVerLib_Frame * \brief Frame handling class */ class PlaYUVerFrame - //: public PlaYUVerFrameStats +//: public PlaYUVerFrameStats { public: @@ -206,6 +208,8 @@ public: ~PlaYUVerFrame(); + Void clear(); + /** * Get number of bytes per frame of an existing frame * @return number of bytes per frame @@ -216,6 +220,8 @@ public: UInt getNumberChannels() const; UInt getPixels() const; + UInt8 getChromaWidthRatio() const; + UInt8 getChromaHeightRatio() const; UInt getChromaWidth() const; UInt getChromaHeight() const; UInt getChromaLength() const; @@ -259,16 +265,13 @@ public: return m_bHasHistogram; } - Void copyFrom( PlaYUVerFrame* ); Void copyFrom( PlaYUVerFrame*, UInt, UInt ); PlaYUVerFrame::Pixel getPixelValue( Int xPos, Int yPos, ColorSpace eColorSpace = COLOR_INVALID ); - std::string getPelFmtName() - { - return m_cPelFmtName; - } + std::string getPelFmtName(); + UInt getWidth() const { return m_uiWidth; diff --git a/lib/PlaYUVerFramePixelFormats.h b/lib/PlaYUVerFramePixelFormats.h index deede8b..82dba3c 100644 --- a/lib/PlaYUVerFramePixelFormats.h +++ b/lib/PlaYUVerFramePixelFormats.h @@ -36,8 +36,6 @@ namespace plaYUVer #define CHROMARATIO( SIZE, RATIO ) ( RATIO > 1 ? ( ( SIZE + 1 ) / RATIO ) : SIZE ) -#define CHROMASHIFT( SIZE, SHIFT ) UInt( -( ( - ( Int( SIZE ) ) ) >> SHIFT ) ) - #define CLAMP(X) X = X < 0 ? 0 : X > 255 ? 255 : X; #define YUV2RGB( iY, iU, iV, iR, iG, iB ) \ diff --git a/lib/PlaYUVerModuleIf.h b/lib/PlaYUVerModuleIf.h index faa69b0..2ca9e9b 100644 --- a/lib/PlaYUVerModuleIf.h +++ b/lib/PlaYUVerModuleIf.h @@ -74,14 +74,22 @@ enum Module_NumberOfFrames MODULE_REQUIRES_SIX_FRAMES, }; -enum Module_Requirements +enum Module_Features { MODULE_REQUIRES_NOTHING = 0, MODULE_REQUIRES_SKIP_WHILE_PLAY = 1, MODULE_REQUIRES_OPTIONS = 2, MODULE_REQUIRES_NEW_WINDOW = 4, + MODULE_USES_KEYS = 8, }; +enum Module_Key_Supported +{ + MODULE_KEY_LEFT, + MODULE_KEY_RIGHT, +}; + + class PlaYUVerModuleIf { public: @@ -139,6 +147,11 @@ public: return 0; } + virtual Bool keyPressed( enum Module_Key_Supported ) + { + return false; + } + }; } // NAMESPACE diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 17a1537..0460240 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -37,6 +37,7 @@ ADD_MODULE( FilterComponentChromaV "FilterComponent" ) ADD_MODULE( FrameDifference "FrameDifference" ) ADD_MODULE( AbsoluteFrameDifference "AbsoluteFrameDifference" ) ADD_MODULE( FrameBinarization "FrameBinarization" ) +ADD_MODULE( FrameShift "FrameShift" ) ADD_MODULE( SetChromaHalfScale "SetChromaHalfScale" ) ADD_MODULE( EightBitsSampling "EightBitsSampling" ) ADD_MODULE( FrameCrop "FrameCrop" ) diff --git a/modules/PlaYUVerModuleFactory.cpp b/modules/PlaYUVerModuleFactory.cpp index 68a28ab..6b0e01c 100644 --- a/modules/PlaYUVerModuleFactory.cpp +++ b/modules/PlaYUVerModuleFactory.cpp @@ -44,6 +44,7 @@ PlaYUVerModuleFactory::PlaYUVerModuleFactory() Register( "SetChromaHalfScale", &SetChromaHalfScale::Create ); Register( "FrameCrop", &FrameCrop::Create ); Register( "FrameBinarization", &FrameBinarization::Create ); + Register( "FrameShift", &FrameShift::Create ); Register( "EightBitsSampling", &EightBitsSampling::Create ); Register( "LumaAverage", &LumaAverage::Create ); #ifdef USE_OPENCV