From caa58bf422464280afea69062550329157805763 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 5 Apr 2014 01:32:41 +0100 Subject: [PATCH 1/7] CMakeLists changes Require version 2.8.7 of cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a08e4f..eae568f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ # Project Definition ###################################################################################### -cmake_minimum_required( VERSION 2.8.9 ) +cmake_minimum_required( VERSION 2.8.7 ) INCLUDE( cmake/CMakeMacros.cmake ) From ec401aec56c40596ffa52ca45b636a06aae82c69 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 5 Apr 2014 01:36:16 +0100 Subject: [PATCH 2/7] Revert last commit --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eae568f..5a08e4f 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ # Project Definition ###################################################################################### -cmake_minimum_required( VERSION 2.8.7 ) +cmake_minimum_required( VERSION 2.8.9 ) INCLUDE( cmake/CMakeMacros.cmake ) From 0ca911b518cdd3ce93b0c3b4bdcc054074485495 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 5 Apr 2014 01:36:48 +0100 Subject: [PATCH 3/7] Remove travis ci file --- .travis.yml | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 99fe61e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: c -compiler: - - gcc - - clang -before_script: - - mkdir build - - cd build - - cmake -DCMAKE_BUILD_TYPE=Release -DUSE_QT4=OFF -DUSE_FFMPEG=ON .. -script: make From b3990dade44b3fb5baedd7f9c7326e09b107f70d Mon Sep 17 00:00:00 2001 From: jcarreira Date: Sat, 5 Apr 2014 01:40:49 +0100 Subject: [PATCH 4/7] Update build instructions Add instructions to build with FFmpeg support --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 059fdab..1e29085 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Install using cmake ``` mkdir build cd build -cmake ../ +cmake -DUSE_FFMPEG=ON .. (for FFmpeg support) make +make install ``` From 4cdcfd6db049e02b094a0f61937e08124d92fab2 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 5 Apr 2014 02:19:52 +0100 Subject: [PATCH 5/7] Add YUYV422 pixel support and remove from the list the formats not implemented --- source/lib/PlaYUVerFrame.cpp | 60 ++++++++++++++++++------------------ source/lib/PlaYUVerFrame.h | 8 ++--- 2 files changed, 33 insertions(+), 35 deletions(-) diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index dfcaed8..6348740 100755 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -48,11 +48,9 @@ PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pel_format ) getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, 1, 1 ); break; case YUV422p: + case YUYV422: getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, 1, 2 ); break; - case YUV410p: - case YUV411p: - break; case GRAY: getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, 4, 4 ); break; @@ -110,11 +108,9 @@ inline Void PlaYUVerFrame::FrametoRGB8Pixfc() case YUV422p: break; case YUV444p: + case YUYV422: m_pcPixfc->convert(m_pcPixfc, m_pppcInputPel, m_pcRGBPelInterlaced); break; - case YUV410p: - case YUV411p: - break; case GRAY: break; case RGB8: @@ -243,6 +239,7 @@ Void PlaYUVerFrame::FrametoRGB8() } break; case YUV422p: + case YUYV422: for( UInt y = 0; y < m_uiHeight; y += 1 ) for( UInt x = 0; x < m_uiWidth; x += 2 ) { @@ -275,9 +272,6 @@ Void PlaYUVerFrame::FrametoRGB8() *pcRGBPelInterlaced++ = iB; } break; - case YUV410p: - case YUV411p: - break; case GRAY: for( UInt y = 0; y < m_uiHeight; y++ ) for( UInt x = 0; x < m_uiWidth; x++ ) @@ -302,11 +296,20 @@ Void PlaYUVerFrame::FrametoRGB8() Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format ) { - Pel* pcRGBPelInterlaced = m_pcRGBPelInterlaced; if( m_iPixelFormat != pel_format ) { return; } + Pel* pcRGBPelInterlaced = m_pcRGBPelInterlaced; + Pel* pInputPelY = m_pppcInputPel[LUMA][0]; + + Pel *pInputPelU = NULL, *pInputPelV = NULL; + if( m_pppcInputPel[CHROMA_U] ) + { + pInputPelU = m_pppcInputPel[CHROMA_U][0]; + pInputPelV = m_pppcInputPel[CHROMA_V][0]; + } + m_bHasRGBPel = false; UInt64 frame_bytes_input = m_uiWidth * m_uiHeight; switch( m_iPixelFormat ) @@ -326,21 +329,26 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format ) memcpy( &m_pppcInputPel[CHROMA_U][0][0], input_buffer + frame_bytes_input * 1, frame_bytes_input / 2 * sizeof(Pel) ); memcpy( &m_pppcInputPel[CHROMA_V][0][0], input_buffer + frame_bytes_input * 3 / 2, frame_bytes_input / 2 * sizeof(Pel) ); break; - case YUV410p: - case YUV411p: + case YUYV422: + for( UInt i = 0; i < m_uiHeight * m_uiWidth/2; i++ ) + { + *pInputPelY++ = *input_buffer++; + *pInputPelU++ = *input_buffer++; + *pInputPelY++ = *input_buffer++; + *pInputPelV++ = *input_buffer++; + } break; case GRAY: memcpy( &m_pppcInputPel[LUMA][0][0], input_buffer + frame_bytes_input * 0, frame_bytes_input * sizeof(Pel) ); break; case RGB8: memcpy( pcRGBPelInterlaced, input_buffer, frame_bytes_input * sizeof(Pel) * 3 ); - for( UInt y = 0; y < m_uiHeight; y++ ) - for( UInt x = 0; x < m_uiWidth; x++ ) - { - m_pppcInputPel[COLOR_R][y][x] = *pcRGBPelInterlaced++; - m_pppcInputPel[COLOR_G][y][x] = *pcRGBPelInterlaced++; - m_pppcInputPel[COLOR_B][y][x] = *pcRGBPelInterlaced++; - } + for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ ) + { + *pInputPelY++ = *pcRGBPelInterlaced++; + *pInputPelU++ = *pcRGBPelInterlaced++; + *pInputPelV++ = *pcRGBPelInterlaced++; + } m_bHasRGBPel = true; break; } @@ -367,11 +375,10 @@ Void PlaYUVerFrame::CopyFrom( PlaYUVerFrame* input_frame ) memcpy( &m_pppcInputPel[CHROMA_V][0][0], &( input_frame->getPelBufferYUV()[CHROMA_V][0][0] ), num_bytes * sizeof(Pel) ); break; case YUV422p: + case YUYV422: memcpy( &m_pppcInputPel[LUMA][0][0], &( input_frame->getPelBufferYUV()[LUMA][0][0] ), num_bytes * sizeof(Pel) ); memcpy( &m_pppcInputPel[CHROMA_U][0][0], &( input_frame->getPelBufferYUV()[CHROMA_U][0][0] ), num_bytes / 2 * sizeof(Pel) ); memcpy( &m_pppcInputPel[CHROMA_V][0][0], &( input_frame->getPelBufferYUV()[CHROMA_V][0][0] ), num_bytes / 2 * sizeof(Pel) ); - case YUV410p: - case YUV411p: break; case GRAY: memcpy( &m_pppcInputPel[LUMA][0][0], &( input_frame->getPelBufferYUV()[LUMA][0][0] ), num_bytes * sizeof(Pel) ); @@ -396,11 +403,9 @@ UInt64 PlaYUVerFrame::getBytesPerFrame() return m_uiWidth * m_uiHeight * 3; break; case YUV422p: + case YUYV422: return m_uiWidth * m_uiHeight * 2; break; - case YUV410p: - return m_uiWidth * m_uiHeight * 1.25; - break; case GRAY: return m_uiWidth * m_uiHeight; break; @@ -453,17 +458,12 @@ Pixel PlaYUVerFrame::getPixelValue( const QPoint &pos, ColorSpace space ) pixel_value.ChromaV = m_pppcInputPel[CHROMA_V][pos.y()][pos.x()]; break; case YUV422p: + case YUYV422: pixel_value.color_space = COLOR_YUV; pixel_value.Luma = m_pppcInputPel[LUMA][pos.y()][pos.x()]; pixel_value.ChromaU = m_pppcInputPel[CHROMA_U][pos.y()][pos.x() >> 1]; pixel_value.ChromaV = m_pppcInputPel[CHROMA_V][pos.y()][pos.x() >> 1]; break; - case YUV410p: - pixel_value.color_space = COLOR_YUV; - pixel_value.Luma = m_pppcInputPel[LUMA][pos.y()][pos.x()]; - pixel_value.ChromaU = m_pppcInputPel[CHROMA_U][pos.y() >> 2][pos.x() >> 2]; - pixel_value.ChromaV = m_pppcInputPel[CHROMA_V][pos.y() >> 2][pos.x() >> 2]; - break; case GRAY: pixel_value.color_space = COLOR_YUV; pixel_value.Luma = m_pppcInputPel[LUMA][pos.y()][pos.x()]; diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index 05f7fe2..7f912b9 100755 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -63,8 +63,7 @@ public: YUV420p = 0, YUV444p, YUV422p, - YUV411p, - YUV410p, + YUYV422, GRAY, RGB8, NUMBER_FORMATS @@ -75,9 +74,8 @@ public: QStringList formats; formats << "YUV420p" << "YUV444p" - << "YUV411p" - << "YUV411p" - << "YUV410p" + << "YUV422p" + << "YUYV422" << "GRAY" << "RGB8" // RGB 3*8 bits per pixel ; From 9df1f6cf12391fba92d5f7a7f7ad0b85a7f17d9e Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 5 Apr 2014 02:46:50 +0100 Subject: [PATCH 6/7] Bugfix in LibAvContextHandle decodeAvFormat was decoding one extra frame each time --- source/lib/ffmpeg/LibAvContextHandle.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/source/lib/ffmpeg/LibAvContextHandle.cpp b/source/lib/ffmpeg/LibAvContextHandle.cpp index 807dcf7..1c284bb 100755 --- a/source/lib/ffmpeg/LibAvContextHandle.cpp +++ b/source/lib/ffmpeg/LibAvContextHandle.cpp @@ -178,9 +178,18 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height case AV_PIX_FMT_YUV420P: pixel_format = PlaYUVerFrame::YUV420p; break; + case AV_PIX_FMT_YUV422P: + pixel_format = PlaYUVerFrame::YUV422p; + break; + case AV_PIX_FMT_YUYV422: + pixel_format = PlaYUVerFrame::YUYV422; + break; case AV_PIX_FMT_GRAY8: pixel_format = PlaYUVerFrame::GRAY; break; + case AV_PIX_FMT_RGB24: + pixel_format = PlaYUVerFrame::RGB8; + break; default: break; } @@ -220,10 +229,8 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height Bool LibAvContextHandle::decodeAvFormat() { Int got_frame; - Bool bRet = false; /* read frames from the file */ - - while( av_read_frame( fmt_ctx, &pkt ) >= 0 && !bRet ) + while( av_read_frame( fmt_ctx, &pkt ) >= 0 ) { if( pkt.stream_index == video_stream_idx ) { @@ -232,7 +239,7 @@ Bool LibAvContextHandle::decodeAvFormat() if( ret < 0 ) { fprintf( stderr, "Error decoding video frame\n" ); - return bRet; + return false; } if( got_frame ) @@ -241,13 +248,13 @@ Bool LibAvContextHandle::decodeAvFormat() * this is required since rawvideo expects non aligned data */ av_image_copy( video_dst_data, video_dst_linesize, ( const uint8_t ** )( frame->data ), frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width, video_dec_ctx->height ); - - bRet = true; } } av_free_packet( &pkt ); + if( got_frame ) + return true; } - return bRet; + return false; // /* flush cached frames */ // pkt.data = NULL; // pkt.size = 0; From bda951126d37fd40d4898a0b8f9ba95820f3bfc4 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 5 Apr 2014 03:12:12 +0100 Subject: [PATCH 7/7] Show codec and format inforamtion in sidebar and title bar --- source/app/InputStream.cpp | 9 ++++++--- source/app/InputStream.h | 5 +++++ source/app/PropertiesSidebar.cpp | 24 ++++++++++++++++++------ source/app/PropertiesSidebar.h | 1 + 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/source/app/InputStream.cpp b/source/app/InputStream.cpp index 20cf1a7..cbab9f8 100755 --- a/source/app/InputStream.cpp +++ b/source/app/InputStream.cpp @@ -134,8 +134,8 @@ Bool InputStream::open( QString filename, UInt width, UInt height, Int input_for if( QFileInfo( filename ).completeSuffix().compare( QString( "yuv" ) ) ) { avStatus = m_cLibAvContext.initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate ); - m_cFormatName = QString::fromUtf8( m_cLibAvContext.getCodecName() ); - + m_cFormatName = QFileInfo( filename ).completeSuffix().toUpper(); + m_cCodedName = QString::fromUtf8( m_cLibAvContext.getCodecName() ).toUpper(); m_uiTotalFrameNum = 100; } #endif @@ -173,7 +173,8 @@ Bool InputStream::open( QString filename, UInt width, UInt height, Int input_for fseek( m_pFile, 0, SEEK_END ); m_uiTotalFrameNum = ftell( m_pFile ) / ( frame_bytes_input ); fseek( m_pFile, 0, SEEK_SET ); - m_cFormatName = QString::fromUtf8( "Raw Video" ); + m_cFormatName = QString::fromUtf8( "YUV" ); + m_cCodedName = QString::fromUtf8( "Raw Video" ); } if( !getMem1D( &m_pInputBuffer, m_pcCurrFrame->getBytesPerFrame() ) ) { @@ -184,6 +185,8 @@ Bool InputStream::open( QString filename, UInt width, UInt height, Int input_for m_cStreamInformationString = QString( "[" ); m_cStreamInformationString.append( m_cFormatName ); m_cStreamInformationString.append( QString( " / " ) ); + m_cStreamInformationString.append( m_cCodedName ); + m_cStreamInformationString.append( QString( " / " ) ); m_cStreamInformationString.append( PlaYUVerFrame::supportedPixelFormatList().at( m_iPixelFormat ) ); m_cStreamInformationString.append( "] " ); m_cStreamInformationString.append( QFileInfo( m_cFilename ).fileName() ); diff --git a/source/app/InputStream.h b/source/app/InputStream.h index 0dc1636..9915a85 100755 --- a/source/app/InputStream.h +++ b/source/app/InputStream.h @@ -62,6 +62,7 @@ private: QString m_cFilename; QString m_cFormatName; + QString m_cCodedName; QString m_cStreamInformationString; QTime m_cTimer; @@ -142,6 +143,10 @@ public: { return m_cFormatName; } + QString getCodecName() + { + return m_cCodedName; + } UInt getFrameNum() { return m_uiTotalFrameNum; diff --git a/source/app/PropertiesSidebar.cpp b/source/app/PropertiesSidebar.cpp index 8b67963..a72deb1 100755 --- a/source/app/PropertiesSidebar.cpp +++ b/source/app/PropertiesSidebar.cpp @@ -53,6 +53,11 @@ StreamPropertiesSideBar::StreamPropertiesSideBar( QWidget* parent ) : labelFormatValue = new QLabel; labelFormatValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); + QLabel *codecLabel = new QLabel( tr( "Codec:" ) ); + codecLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); + labelCodecValue = new QLabel; + labelCodecValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); + QLabel *sizeLabel = new QLabel( tr( "Size (pixels):" ) ); sizeLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); labelSizeValue = new QLabel; @@ -64,12 +69,18 @@ StreamPropertiesSideBar::StreamPropertiesSideBar( QWidget* parent ) : labelColorSpaceValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); QGridLayout *propertiesLayout = new QGridLayout; - propertiesLayout->addWidget( formatLabel, 0, 0 ); - propertiesLayout->addWidget( labelFormatValue, 0, 1 ); - propertiesLayout->addWidget( sizeLabel, 1, 0 ); - propertiesLayout->addWidget( labelSizeValue, 1, 1 ); - propertiesLayout->addWidget( colorSpaceLabel, 2, 0 ); - propertiesLayout->addWidget( labelColorSpaceValue, 2, 1 ); + Int layout_line = 0; + propertiesLayout->addWidget( formatLabel, layout_line, 0 ); + propertiesLayout->addWidget( labelFormatValue, layout_line, 1 ); + layout_line++; + propertiesLayout->addWidget( codecLabel, layout_line, 0 ); + propertiesLayout->addWidget( labelCodecValue, layout_line, 1 ); + layout_line++; + propertiesLayout->addWidget( sizeLabel, layout_line, 0 ); + propertiesLayout->addWidget( labelSizeValue, layout_line, 1 ); + layout_line++; + propertiesLayout->addWidget( colorSpaceLabel, layout_line, 0 ); + propertiesLayout->addWidget( labelColorSpaceValue, layout_line, 1 ); QGroupBox *propertiesGroup = new QGroupBox( tr( "Properties" ) ); propertiesGroup->setLayout( propertiesLayout ); @@ -110,6 +121,7 @@ Void StreamPropertiesSideBar::setData( InputStream* pcStream ) QString value; labelFormatValue->setText( m_pcStream->getFormatName() ); + labelCodecValue->setText( m_pcStream->getCodecName() ); uint width = m_pcStream->getWidth(); uint height = m_pcStream->getHeight(); value = QString( tr( "%1 x %2" ) ).arg( width ).arg( height ); diff --git a/source/app/PropertiesSidebar.h b/source/app/PropertiesSidebar.h index d645641..35855c9 100755 --- a/source/app/PropertiesSidebar.h +++ b/source/app/PropertiesSidebar.h @@ -52,6 +52,7 @@ private: InputStream* m_pcStream; QLabel* labelFormatValue; + QLabel* labelCodecValue; QLabel* labelSizeValue; QLabel* labelColorSpaceValue; };