diff --git a/source/app/InputStream.cpp b/source/app/InputStream.cpp index 7257cba..e9d0e80 100755 --- a/source/app/InputStream.cpp +++ b/source/app/InputStream.cpp @@ -304,6 +304,8 @@ cv::Mat InputStream::getFrameCvMat() Void InputStream::seekInput( Int new_frame_num ) { + if( new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum ) + return; #ifdef USE_FFMPEG if( m_cLibAvContext.getStatus() ) { diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index 16a5308..5771969 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -208,15 +208,21 @@ bool SubWindowHandle::playEvent() return false; } -Void SubWindowHandle::seekEvent( UInt new_frame_num ) +Void SubWindowHandle::seekAbsoluteEvent( UInt new_frame_num ) { m_pCurrStream->seekInput( new_frame_num ); refreshFrame(); } +Void SubWindowHandle::seekRelativeEvent( Bool bIsFoward ) +{ + m_pCurrStream->seekInput( m_pCurrStream->getCurrFrameNum() + ( bIsFoward ? 1 : -1 ) ); + refreshFrame(); +} + Void SubWindowHandle::stopEvent() { - seekEvent( 0 ); + seekAbsoluteEvent( 0 ); return; } diff --git a/source/app/SubWindowHandle.h b/source/app/SubWindowHandle.h index 32c7ce7..c9ee0f3 100644 --- a/source/app/SubWindowHandle.h +++ b/source/app/SubWindowHandle.h @@ -67,7 +67,8 @@ public: Bool save(); Void stopEvent(); - Void seekEvent( UInt new_frame_num ); + Void seekAbsoluteEvent( UInt new_frame_num ); + Void seekRelativeEvent( Bool bIsFoward ); QImage* FrameToQImage( PlaYUVerFrame* curr_frame ); diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index 295f98f..0bb6548 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -220,11 +220,19 @@ void plaYUVerApp::playEvent() } } +void plaYUVerApp::seekEvent( int direction ) +{ + if( activeSubWindow() ) + { + activeSubWindow()->seekRelativeEvent( direction > 0 ? true : false ); + } +} + void plaYUVerApp::seekSliderEvent( int new_frame_num ) { if( activeSubWindow() ) { - activeSubWindow()->seekEvent( new_frame_num ); + activeSubWindow()->seekAbsoluteEvent( (UInt)new_frame_num ); } } @@ -543,10 +551,17 @@ Void plaYUVerApp::createActions() actionVideoStop->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaStop ) ) ); connect( actionVideoStop, SIGNAL( triggered() ), this, SLOT( stop() ) ); + mapperSeekVideo = new QSignalMapper( this ); + connect( mapperSeekVideo, SIGNAL( mapped(int) ), this, SLOT( seekEvent(int) ) ); + actionVideoBackward = new QAction( "VideoBackward", this ); actionVideoBackward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekBackward ) ) ); + connect( actionVideoBackward, SIGNAL( triggered() ), mapperSeekVideo, SLOT( map() ) ); + mapperSeekVideo->setMapping( actionVideoBackward, 0 ); actionVideoForward = new QAction( "VideoForward", this ); actionVideoForward->setIcon( QIcon( style()->standardIcon( QStyle::SP_MediaSeekForward ) ) ); + connect( actionVideoForward, SIGNAL( triggered() ), mapperSeekVideo, SLOT( map() ) ); + mapperSeekVideo->setMapping( actionVideoForward, 1 ); actionVideoLoop = new QAction( "Repeat", this ); actionVideoLoop->setCheckable( true ); diff --git a/source/app/plaYUVerApp.h b/source/app/plaYUVerApp.h index 0cc6bf7..b80f739 100644 --- a/source/app/plaYUVerApp.h +++ b/source/app/plaYUVerApp.h @@ -65,6 +65,7 @@ private Q_SLOTS: void stop(); void playEvent(); void seekSliderEvent( int new_frame_num ); + void seekEvent( int direction ); void selectModule( QAction * ); @@ -118,6 +119,7 @@ private: QSlider *m_pcFrameSlider; QSignalMapper *mapperZoom; + QSignalMapper *mapperSeekVideo; QSignalMapper *mapperWindow; /**