diff --git a/CMakeLists.txt b/CMakeLists.txt index 94f5ce9..cc9af27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ OPTION( USE_FERVOR "Add Fervor support" OFF ) OPTION( USE_WERROR "Warnings as errors" OFF ) OPTION( USE_STATIC "Use static libs" ON ) OPTION( USE_QT4 "Build with Qt4" OFF ) -OPTION( USE_QTDBUS "Build with QtDBus" OFF ) +OPTION( USE_QTDBUS "Build with QtDBus" ON ) OPTION( USE_DYNLOAD "Use dynamic load of modules" ON ) # To be switched on when releasing. OPTION(RELEASE_BUILD "Remove Git revision from program version (use for stable releases)" ON) diff --git a/app/PlaYUVerAppModuleIf.cpp b/app/PlaYUVerAppModuleIf.cpp index 600900b..e71b17d 100644 --- a/app/PlaYUVerAppModuleIf.cpp +++ b/app/PlaYUVerAppModuleIf.cpp @@ -71,7 +71,10 @@ Bool PlaYUVerAppModuleIf::apply( Bool isPlaying, Bool disableThreads ) { #ifdef PLAYUVER_THREADED_MODULES if( !disableThreads ) + { + wait(); start(); + } else #endif { diff --git a/app/PlaYUVerAppModuleIf.h b/app/PlaYUVerAppModuleIf.h index 817055b..3bfb424 100644 --- a/app/PlaYUVerAppModuleIf.h +++ b/app/PlaYUVerAppModuleIf.h @@ -40,7 +40,7 @@ class QAction; namespace plaYUVer { -//#define PLAYUVER_THREADED_MODULES +#define PLAYUVER_THREADED_MODULES class VideoSubWindow; diff --git a/app/PlaYUVerSubWindowHandle.cpp b/app/PlaYUVerSubWindowHandle.cpp index 530443a..b2e1248 100644 --- a/app/PlaYUVerSubWindowHandle.cpp +++ b/app/PlaYUVerSubWindowHandle.cpp @@ -44,7 +44,7 @@ public: { m_acLogMessages.push_front( msg ); if( m_acLogMessages.size() > 5 ) - m_acLogMessages.removeLast(); + m_acLogMessages.remove( m_acLogMessages.size() - 1 ); update(); } protected: diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index f4e3066..8210de0 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -576,6 +576,7 @@ Void VideoSubWindow::disableModule( PlaYUVerAppModuleIf* pcModule ) pcModule = m_pcCurrentDisplayModule; m_pcCurrentDisplayModule = 0; ModulesHandle::destroyModuleIf( pcModule ); + setWindowName( QFileInfo( m_cFilename ).fileName() ); bRefresh |= true; } } diff --git a/lib/LibAvContextHandle.cpp b/lib/LibAvContextHandle.cpp index 9d44b2b..f941cf4 100644 --- a/lib/LibAvContextHandle.cpp +++ b/lib/LibAvContextHandle.cpp @@ -35,7 +35,7 @@ namespace plaYUVer std::vector LibAvContextHandle::supportedReadFormats() { INI_REGIST_PLAYUVER_SUPPORTED_FMT; - REGIST_PLAYUVER_SUPPORTED_FMT( "Portable Grayscale Map ", "pgm" ); + REGIST_PLAYUVER_SUPPORTED_FMT( "Portable Grayscale Map", "pgm" ); REGIST_PLAYUVER_SUPPORTED_FMT( "Portable Network Graphics", "png" ); REGIST_PLAYUVER_SUPPORTED_FMT( "Joint Photographic Experts Group", "jpg" ); REGIST_PLAYUVER_SUPPORTED_FMT( "Windows Bitmap", "bmp" ); @@ -43,6 +43,8 @@ std::vector LibAvContextHandle::supportedReadFormats() REGIST_PLAYUVER_SUPPORTED_FMT( "Windows media video", "wmv" ); REGIST_PLAYUVER_SUPPORTED_FMT( "MPEG4", "mp4" ); REGIST_PLAYUVER_SUPPORTED_FMT( "Matroska Multimedia Container", "mkv" ); + REGIST_PLAYUVER_SUPPORTED_FMT( "H.264 streams", "h264" ); + REGIST_PLAYUVER_SUPPORTED_FMT( "HEVC streams", "hevc" ); END_REGIST_PLAYUVER_SUPPORTED_FMT; } @@ -110,7 +112,8 @@ Void LibAvContextHandle::closeAvFormat() m_bHasStream = false; } -Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt& height, Int& pixel_format, Double& frame_rate, UInt64& num_frames ) +Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& bits_pel, Double& frame_rate, + UInt64& num_frames ) { fmt_ctx = NULL; video_dec_ctx = NULL; @@ -209,6 +212,13 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt& num_frames = num_frames == 0 ? 1 : num_frames; Int pix_fmt = video_dec_ctx->pix_fmt; + + // Set bits per pixel to default (8 bits) + bits_pel = 8; + + /** + * Auxiliar conversation to re-use similar pixfmt + */ switch( pix_fmt ) { case AV_PIX_FMT_YUVJ420P: @@ -220,6 +230,11 @@ Bool LibAvContextHandle::initAvFormat( const char* filename, UInt& width, UInt& case AV_PIX_FMT_YUVJ444P: pix_fmt = AV_PIX_FMT_YUV444P; break; + case AV_PIX_FMT_GRAY16LE: + case AV_PIX_FMT_GRAY16BE: + bits_pel = 16; + pix_fmt = AV_PIX_FMT_GRAY8; + break; } width = video_dec_ctx->width; diff --git a/lib/LibAvContextHandle.h b/lib/LibAvContextHandle.h index 5a5506e..646c6a6 100644 --- a/lib/LibAvContextHandle.h +++ b/lib/LibAvContextHandle.h @@ -65,7 +65,7 @@ public: m_bHasStream( false ) { } - Bool initAvFormat( const char* filename, UInt& width, UInt& height, Int& pixel_format, Double& frame_rate, UInt64& num_frames ); + Bool initAvFormat( const char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& bits_pel, Double& frame_rate, UInt64& num_frames ); Void closeAvFormat(); Bool decodeAvFormat(); diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 9c2e83c..cb443fb 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -142,11 +142,11 @@ Void PlaYUVerStream::findHandler() { m_iStreamHandler = INVALID_HANDLER; - if( m_uiBitsPerPixel != 8 ) - { - m_iStreamHandler = YUV_IO; - return; - } +// if( m_uiBitsPerPixel != 8 ) +// { +// m_iStreamHandler = YUV_IO; +// return; +// } std::string currExt = m_cFilename.substr( m_cFilename.find_last_of( "." ) + 1 ); currExt = lowercase( currExt ); @@ -246,7 +246,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in #ifdef USE_FFMPEG if( m_iStreamHandler == FFMPEG ) { - if( !m_cLibAvContext->initAvFormat( m_pchFilename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_dFrameRate, m_uiTotalFrameNum ) ) + if( !m_cLibAvContext->initAvFormat( m_pchFilename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiBitsPerPixel, m_dFrameRate, m_uiTotalFrameNum ) ) { throw "Cannot open file using FFmpeg libs"; } @@ -369,7 +369,7 @@ Bool PlaYUVerStream::reload() if( m_iStreamHandler == FFMPEG ) { m_cLibAvContext->closeAvFormat(); - if( !m_cLibAvContext->initAvFormat( m_pchFilename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_dFrameRate, m_uiTotalFrameNum ) ) + if( !m_cLibAvContext->initAvFormat( m_pchFilename, m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiBitsPerPixel, m_dFrameRate, m_uiTotalFrameNum ) ) { throw "Cannot open file using FFmpeg libs"; } @@ -524,7 +524,7 @@ Void PlaYUVerStream::loadAll() Void PlaYUVerStream::getDuration( Int* duration_array ) { - Int hours, mins, secs; + Int hours, mins, secs = 0; #ifdef USE_FFMPEG if( m_iStreamHandler == FFMPEG ) { @@ -533,7 +533,6 @@ Void PlaYUVerStream::getDuration( Int* duration_array ) else #endif if( m_iStreamHandler == YUV_IO ) - { secs = m_uiTotalFrameNum / m_dFrameRate; } diff --git a/modules/FrameShift.cpp b/modules/FrameShift.cpp index 726602e..13f9b54 100644 --- a/modules/FrameShift.cpp +++ b/modules/FrameShift.cpp @@ -43,7 +43,8 @@ FrameShift::FrameShift() ( "ShiftVertical", m_iShiftVer, "Amount of pixels to shift in vertical direction" ); m_pcProcessedFrame = NULL; - m_iShiftHor = 10; + m_iShiftHor = 0; + m_iShiftVer = 0; } Bool FrameShift::create( std::vector apcFrameList ) @@ -51,7 +52,8 @@ Bool FrameShift::create( std::vector apcFrameList ) _BASIC_MODULE_API_2_CHECK_ m_pcProcessedFrame = new PlaYUVerFrame( apcFrameList[0], false ); - m_iShiftHor = ( ( m_iShiftHor + 1 ) >> 1 ) << 1; +// m_iShiftHor = ( ( m_iShiftHor + 1 ) >> 1 ) << 1; +// m_iShiftVer = ( ( m_iShiftVer + 1 ) >> 1 ) << 1; return true; } @@ -64,18 +66,16 @@ PlaYUVerFrame* FrameShift::process( std::vector apcFrameList ) UInt xStartIn = m_iShiftHor >= 0 ? 0 : -m_iShiftHor; UInt xEndOut = m_iShiftHor >= 0 ? m_pcProcessedFrame->getWidth() : m_pcProcessedFrame->getWidth() + m_iShiftHor; - UInt yStartOut = m_iShiftVer >= 0 ? 0 : -m_iShiftVer; - UInt yStartIn = m_iShiftVer >= 0 ? m_iShiftVer : 0; - UInt yEndOut = m_iShiftVer >= 0 ? m_pcProcessedFrame->getHeight() - m_iShiftVer : m_pcProcessedFrame->getHeight(); - - UInt numberLines = yEndOut - yStartOut; + UInt yStartOut = m_iShiftVer >= 0 ? m_iShiftVer : 0; + UInt yStartIn = m_iShiftVer >= 0 ? 0 : -m_iShiftVer; + UInt yEndOut = m_iShiftVer >= 0 ? m_pcProcessedFrame->getHeight() : m_pcProcessedFrame->getHeight() + m_iShiftVer; m_pcProcessedFrame->clear(); - for( UInt y = 0; y < numberLines; y++ ) + for( UInt y = yStartOut, yIn = yStartIn; y < yEndOut; y++, yIn++ ) { - pPelInput = &( apcFrameList[0]->getPelBufferYUV()[LUMA][y + yStartIn][xStartIn] ); - pPelOut = &( m_pcProcessedFrame->getPelBufferYUV()[LUMA][y + yStartOut][xStartOut] ); + pPelInput = &( apcFrameList[0]->getPelBufferYUV()[LUMA][yIn][xStartIn] ); + pPelOut = &( m_pcProcessedFrame->getPelBufferYUV()[LUMA][y][xStartOut] ); for( UInt x = xStartOut; x < xEndOut; x++ ) { *pPelOut = *pPelInput; @@ -91,18 +91,17 @@ PlaYUVerFrame* FrameShift::process( std::vector apcFrameList ) xStartIn = iShiftHorChroma >= 0 ? 0 : -iShiftHorChroma; xEndOut = iShiftHorChroma >= 0 ? m_pcProcessedFrame->getChromaWidth() : m_pcProcessedFrame->getChromaWidth() + iShiftHorChroma; - yStartOut = iShiftVerChroma >= 0 ? 0 : -iShiftVerChroma; - yStartIn = iShiftVerChroma >= 0 ? iShiftVerChroma : 0; - yEndOut = iShiftVerChroma >= 0 ? m_pcProcessedFrame->getChromaHeight() - iShiftVerChroma : m_pcProcessedFrame->getChromaHeight(); + yStartOut = iShiftVerChroma >= 0 ? iShiftVerChroma : 0; + yStartIn = iShiftVerChroma >= 0 ? 0 : -iShiftVerChroma; + yEndOut = iShiftVerChroma >= 0 ? m_pcProcessedFrame->getChromaHeight() : m_pcProcessedFrame->getChromaHeight() + iShiftVerChroma; - numberLines = yEndOut - yStartOut; for( UInt c = 1; c < m_pcProcessedFrame->getNumberChannels(); c++ ) { - for( UInt y = 0; y < numberLines; y++ ) + for( UInt y = yStartOut, yIn = yStartIn; y < yEndOut; y++, yIn++ ) { - pPelInput = &( apcFrameList[0]->getPelBufferYUV()[c][y + yStartIn][xStartIn] ); - pPelOut = &( m_pcProcessedFrame->getPelBufferYUV()[c][y + yStartOut][xStartOut] ); + pPelInput = &( apcFrameList[0]->getPelBufferYUV()[c][yIn][xStartIn] ); + pPelOut = &( m_pcProcessedFrame->getPelBufferYUV()[c][y][xStartOut] ); for( UInt x = xStartOut; x < xEndOut; x++ ) { *pPelOut = *pPelInput; @@ -118,12 +117,22 @@ Bool FrameShift::keyPressed( enum Module_Key_Supported value ) { if( value == MODULE_KEY_LEFT ) { - m_iShiftHor -= 2; + m_iShiftHor -= 1; return true; } if( value == MODULE_KEY_RIGHT ) { - m_iShiftHor += 2; + m_iShiftHor += 1; + return true; + } + if( value == MODULE_KEY_UP ) + { + m_iShiftVer -= 1; + return true; + } + if( value == MODULE_KEY_DOWN ) + { + m_iShiftVer += 1; return true; } if( value == MODULE_KEY_DOWN )