diff --git a/app/FramePropertiesSidebar.cpp b/app/FramePropertiesSidebar.cpp index bdbef5e..bd271f3 100644 --- a/app/FramePropertiesSidebar.cpp +++ b/app/FramePropertiesSidebar.cpp @@ -235,7 +235,7 @@ FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent, Bool* pbMainPla connect( renderingButtonGroup, SIGNAL( buttonClicked(int) ), this, SLOT( slotRenderingChanged(int) ) ); connect( histogramWidget, SIGNAL( signalIntervalChanged( int, int ) ), this, SLOT( slotUpdateInterval(int, int) ) ); connect( histogramWidget, SIGNAL( signalMaximumValueChanged(int) ), this, SLOT( slotUpdateIntervRange(int) ) ); - connect( histogramWidget, SIGNAL( signalHistogramComputationDone(bool) ), this, SLOT( slotRefreshOptions(bool) ) ); + connect( histogramWidget, SIGNAL( signalHistogramComputationDone(int) ), this, SLOT( slotRefreshOptions(int) ) ); connect( histogramWidget, SIGNAL( signalHistogramComputationFailed(void) ), this, SLOT( slotHistogramComputationFailed(void) ) ); connect( minInterv, SIGNAL( valueChanged (int) ), this, SLOT( slotMinValueChanged(int) ) ); connect( maxInterv, SIGNAL( valueChanged (int) ), this, SLOT( slotMaxValueChanged(int) ) ); @@ -339,9 +339,6 @@ Void FramePropertiesSideBar::setData( PlaYUVerFrame* pcFrame, Bool isPlaying ) colorsLabel->hide(); } } - UInt rangePel = ( 1 << pcFrame->getBitsPel() ) - 1; - minInterv->setRange( 0, rangePel ); - maxInterv->setRange( 0, rangePel ); setEnabled( true ); if( m_pcFrame || !( *pbMainPlaySwitch ) ) { @@ -456,7 +453,7 @@ Void FramePropertiesSideBar::stopHistogram() // SLOTS //////////////////////////////////////////////////////////////////////////////// -Void FramePropertiesSideBar::slotRefreshOptions( bool /*depth*/) +Void FramePropertiesSideBar::slotRefreshOptions( int range ) { if( !isVisible() ) return; diff --git a/app/FramePropertiesSidebar.h b/app/FramePropertiesSidebar.h index 71a9b0f..7120acf 100644 --- a/app/FramePropertiesSidebar.h +++ b/app/FramePropertiesSidebar.h @@ -116,7 +116,7 @@ private: Void updateDataHistogram(); private Q_SLOTS: - void slotRefreshOptions( bool sixteenBit ); + void slotRefreshOptions( int range ); void slotHistogramComputationFailed( void ); void slotChannelChanged( int channel ); void slotScaleChanged( int scale ); diff --git a/app/HistogramWidget.cpp b/app/HistogramWidget.cpp index d1502bf..6e06867 100644 --- a/app/HistogramWidget.cpp +++ b/app/HistogramWidget.cpp @@ -125,7 +125,7 @@ public: HistogramWidgetPrivate() { blinkTimer = 0; - sixteenBits = false; + imageBits = 8; inSelected = false; blinkFlag = false; clearFlag = HistogramNone; @@ -146,7 +146,7 @@ public: // Image informations Int imageChannels; Int imageColorSpace; - bool sixteenBits; + Int imageBits; bool guideVisible; // Display color guide. bool statisticsVisible; // Display tooltip histogram statistics. @@ -313,7 +313,7 @@ Void HistogramWidget::customEvent( QEvent *event ) setUpdatesEnabled( false ); notifyValuesChanged(); - emit signalHistogramComputationDone( d->sixteenBits ); + emit signalHistogramComputationDone( d->range ); setUpdatesEnabled( true ); update(); @@ -397,7 +397,7 @@ Void HistogramWidget::stopHistogramComputation() Void HistogramWidget::updateData( const PlaYUVerFrame *pcFrame, const PlaYUVerFrame *pcFrameSelection ) { - d->sixteenBits = false; + d->imageBits = pcFrame->getBitsPel(); //d->imageColorSpace = image.getPelFormat(); d->imageColorSpace = pcFrame->getColorSpace(); d->imageChannels = pcFrame->getNumberChannels(); @@ -409,7 +409,7 @@ Void HistogramWidget::updateData( const PlaYUVerFrame *pcFrame, const PlaYUVerFr // Do not using PlaYUVerFrameStatistics::getHistogramSegment() // method here because histogram hasn't yet been computed. - d->range = d->sixteenBits ? 65535 : 255; + d->range = ( 1 << d->imageBits ) - 1; emit signalMaximumValueChanged( d->range ); m_imageHistogram = ( PlaYUVerFrameStats* )pcFrame; diff --git a/app/HistogramWidget.h b/app/HistogramWidget.h index 393f63f..a5242ec 100644 --- a/app/HistogramWidget.h +++ b/app/HistogramWidget.h @@ -152,7 +152,7 @@ public: Q_SIGNALS: void signalIntervalChanged( int min, int max ); void signalMaximumValueChanged( int ); - void signalHistogramComputationDone( bool ); + void signalHistogramComputationDone( int ); void signalHistogramComputationFailed( void ); public Q_SLOTS: diff --git a/app/VideoSubWindow.cpp b/app/VideoSubWindow.cpp index 839a58e..1449627 100644 --- a/app/VideoSubWindow.cpp +++ b/app/VideoSubWindow.cpp @@ -43,8 +43,8 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array out << d.m_cFilename << d.m_uiWidth << d.m_uiHeight << d.m_iPelFormat - << d.m_uiFrameRate << d.m_uiBitsPelPixel + << d.m_uiFrameRate << d.m_uiFileSize; } return out; diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index 82bb1bf..dbb78f8 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -197,13 +197,14 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel m_pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[pel_format] ); m_bHasRGBPel = false; + UInt m_uiWidthBytes = m_uiWidth * ( ( m_iBitsPel - 1 ) / 8 + 1 ); if( m_pcPelFormat->colorSpace == COLOR_GRAY ) { - getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, 1, 1 ); + getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidthBytes, 1, 1 ); } else { - getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, m_pcPelFormat->log2ChromaHeight, m_pcPelFormat->log2ChromaWidth ); + getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidthBytes, m_pcPelFormat->log2ChromaHeight, m_pcPelFormat->log2ChromaWidth ); } getMem1D( &m_pcARGB32, m_uiHeight * m_uiWidth * 4 ); @@ -229,7 +230,7 @@ UInt64 PlaYUVerFrame::getBytesPerFrame() UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, Int bitsPixel ) { PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[iPixelFormat] ); - UInt bytesPerPixel = bitsPixel / 8; + UInt bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1; UInt64 numberBytes = uiWidth * uiHeight; if( pcPelFormat->numberChannels > 1 ) { @@ -261,6 +262,7 @@ Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize ) Pel* ppBuff[MAX_NUMBER_PLANES]; Pel* pTmpPel, *pTmpBuff; + UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1; Int ratioH, ratioW, step; UInt i, ch; @@ -281,7 +283,7 @@ Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize ) pTmpPel = m_pppcInputPel[ch][0]; pTmpBuff = ppBuff[m_pcPelFormat->comp[ch].plane] + ( m_pcPelFormat->comp[ch].offset_plus1 - 1 ); - for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ ) + for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * bytesPixel; i++ ) { *pTmpPel++ = *pTmpBuff; pTmpBuff += step; @@ -294,6 +296,7 @@ Void PlaYUVerFrame::frameFromBuffer( Pel *Buff, UInt64 uiBuffSize ) Void PlaYUVerFrame::frameToBuffer( Pel *output_buffer ) { + UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1; Pel* ppBuff[MAX_NUMBER_PLANES]; Pel* pTmpPel, *pTmpBuff; Int ratioH, ratioW, step; @@ -316,7 +319,7 @@ Void PlaYUVerFrame::frameToBuffer( Pel *output_buffer ) pTmpPel = m_pppcInputPel[ch][0]; pTmpBuff = ppBuff[m_pcPelFormat->comp[ch].plane]; - for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ); i++ ) + for( i = 0; i < CHROMASHIFT( m_uiHeight, ratioH ) * CHROMASHIFT( m_uiWidth, ratioW ) * bytesPixel; i++ ) { *pTmpBuff = *pTmpPel++; pTmpBuff += step; @@ -329,13 +332,26 @@ Void PlaYUVerFrame::fillRGBBuffer() { if( m_bHasRGBPel ) return; - if( m_pcPelFormat->colorSpace == COLOR_RGB ) + UInt bytesPixel = ( m_iBitsPel - 1 ) / 8 + 1; + Int iR, iG, iB; + UInt* pARGB = ( UInt* )m_pcARGB32; + if( m_pcPelFormat->colorSpace == COLOR_GRAY ) + { + Pel* pY = m_pppcInputPel[LUMA][0]; + for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ ) + { + iR = *pY++; + iG = *pY++; + iB = *pY++; + *pARGB++ = PEL_RGB( iR, iG, iB ); + } + } + else if( m_pcPelFormat->colorSpace == COLOR_RGB ) { Pel* pR = m_pppcInputPel[COLOR_R][0]; Pel* pG = m_pppcInputPel[COLOR_G][0]; Pel* pB = m_pppcInputPel[COLOR_B][0]; - Int iR, iG, iB; - UInt* pARGB = ( UInt* )m_pcARGB32; + for( UInt i = 0; i < m_uiHeight * m_uiWidth; i++ ) { iR = *pR++; @@ -346,7 +362,7 @@ Void PlaYUVerFrame::fillRGBBuffer() } else { - m_pcPelFormat->fillARGB32buffer( m_pppcInputPel, m_pcARGB32, m_uiWidth, m_uiHeight ); + m_pcPelFormat->fillARGB32buffer( m_pppcInputPel, m_pcARGB32, m_uiWidth, m_uiHeight, bytesPixel ); } m_bHasRGBPel = true; } diff --git a/lib/PlaYUVerFramePixelFormats.cpp b/lib/PlaYUVerFramePixelFormats.cpp index 2ad9565..ae8a8bc 100644 --- a/lib/PlaYUVerFramePixelFormats.cpp +++ b/lib/PlaYUVerFramePixelFormats.cpp @@ -52,8 +52,7 @@ namespace plaYUVer #define ADD_FFMPEG_PEL_FMT( fmt ) 0 #endif - -Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt ratioChromaHor, UInt ratioChromaVer ) +Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt depth, UInt ratioChromaHor, UInt ratioChromaVer ) { Pel* pLineY = in[LUMA][0]; Pel* pLineU = in[CHROMA_U][0]; @@ -78,7 +77,7 @@ Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt r { iU = *pU++; iV = *pV++; - for( Int j = 0; j < 1 << ratioChromaHor; j++ ) + for( Int j = 0; j < ( 1 << ratioChromaHor ) * depth; j++ ) { iY = *pY++; YUV2RGB( iY, iU, iV, iR, iG, iB ); @@ -93,7 +92,7 @@ Void fillARGB32bufferYUV( Pel*** in, UChar* out, UInt width, UInt height, UInt r } } -Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height ) +Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ) { #ifdef USE_SSE if( ( width % 16 ) == 0 ) @@ -184,14 +183,14 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height ) b00 = _mm_srai_epi16( _mm_add_epi16( y00r0, bu00 ), 6 ); b01 = _mm_srai_epi16( _mm_add_epi16( y01r0, bu01 ), 6 ); - r00 = _mm_packus_epi16( r00, r01 ); // rrrr.. saturated - g00 = _mm_packus_epi16( g00, g01 ); // gggg.. saturated - b00 = _mm_packus_epi16( b00, b01 ); // bbbb.. saturated + r00 = _mm_packus_epi16( r00, r01 );// rrrr.. saturated + g00 = _mm_packus_epi16( g00, g01 );// gggg.. saturated + b00 = _mm_packus_epi16( b00, b01 );// bbbb.. saturated - r01 = _mm_unpacklo_epi8( r00, zero ); // 0r0r.. - gbgb = _mm_unpacklo_epi8( b00, g00 ); // gbgb.. - rgb0123 = _mm_unpacklo_epi16( gbgb, r01 ); // 0rgb0rgb.. - rgb4567 = _mm_unpackhi_epi16( gbgb, r01 ); // 0rgb0rgb.. + r01 = _mm_unpacklo_epi8( r00, zero );// 0r0r.. + gbgb = _mm_unpacklo_epi8( b00, g00 );// gbgb.. + rgb0123 = _mm_unpacklo_epi16( gbgb, r01 );// 0rgb0rgb.. + rgb4567 = _mm_unpackhi_epi16( gbgb, r01 );// 0rgb0rgb.. r01 = _mm_unpackhi_epi8( r00, zero ); gbgb = _mm_unpackhi_epi8( b00, g00 ); @@ -211,14 +210,14 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height ) b00 = _mm_srai_epi16( _mm_add_epi16( y00r1, bu00 ), 6 ); b01 = _mm_srai_epi16( _mm_add_epi16( y01r1, bu01 ), 6 ); - r00 = _mm_packus_epi16( r00, r01 ); // rrrr.. saturated - g00 = _mm_packus_epi16( g00, g01 ); // gggg.. saturated - b00 = _mm_packus_epi16( b00, b01 ); // bbbb.. saturated + r00 = _mm_packus_epi16( r00, r01 );// rrrr.. saturated + g00 = _mm_packus_epi16( g00, g01 );// gggg.. saturated + b00 = _mm_packus_epi16( b00, b01 );// bbbb.. saturated - r01 = _mm_unpacklo_epi8( r00, zero ); // 0r0r.. - gbgb = _mm_unpacklo_epi8( b00, g00 ); // gbgb.. - rgb0123 = _mm_unpacklo_epi16( gbgb, r01 ); // 0rgb0rgb.. - rgb4567 = _mm_unpackhi_epi16( gbgb, r01 ); // 0rgb0rgb.. + r01 = _mm_unpacklo_epi8( r00, zero );// 0r0r.. + gbgb = _mm_unpacklo_epi8( b00, g00 );// gbgb.. + rgb0123 = _mm_unpacklo_epi16( gbgb, r01 );// 0rgb0rgb.. + rgb4567 = _mm_unpackhi_epi16( gbgb, r01 );// 0rgb0rgb.. r01 = _mm_unpackhi_epi8( r00, zero ); gbgb = _mm_unpackhi_epi8( b00, g00 ); @@ -236,50 +235,20 @@ Void fillARGB32bufferYUV420p( Pel*** in, UChar* out, UInt width, UInt height ) else #endif { - fillARGB32bufferYUV( in, out, width, height, 1, 1 ); + fillARGB32bufferYUV( in, out, width, height, depth, 1, 1 ); } } -Void fillARGB32bufferYUV444p( Pel*** in, UChar* out, UInt width, UInt height ) +Void fillARGB32bufferYUV444p( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ) { - fillARGB32bufferYUV( in, out, width, height, 0, 0 ); + fillARGB32bufferYUV( in, out, width, height, depth, 0, 0 ); } -Void fillARGB32bufferYUV422( Pel*** in, UChar* out, UInt width, UInt height ) +Void fillARGB32bufferYUV422( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ) { - fillARGB32bufferYUV( in, out, width, height, 1, 0 ); + fillARGB32bufferYUV( in, out, width, height, depth, 1, 0 ); } -Void fillARGB32bufferGray( Pel*** in, UChar* out, UInt width, UInt height ) -{ - Pel *inPel = in[0][0]; - Pel iY; - UInt* buff = ( UInt* )out; - for( UInt i = 0; i < height * width; i++ ) - { - iY = *inPel; - *buff++ = PEL_RGB( iY, iY, iY ); - inPel++; - } -} - -Void fillARGB32bufferRGB( Pel*** in, UChar* out, UInt width, UInt height ) -{ - Pel* pR = in[COLOR_R][0]; - Pel* pG = in[COLOR_G][0]; - Pel* pB = in[COLOR_B][0]; - Int iR, iG, iB; - UInt* buff = ( UInt* )out; - for( UInt i = 0; i < height * width; i++ ) - { - iR = *pR++; - iG = *pG++; - iB = *pB++; - *buff++ = PEL_RGB( iR, iG, iB ); - } -} - - PlaYUVerPixFmtDescriptor yuv420p = { "YUV420p", @@ -290,12 +259,26 @@ PlaYUVerPixFmtDescriptor yuv420p = 1, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV420P ), { - { 0, 0, 1, 0, 7 }, /* Y */ - { 1, 0, 1, 0, 7 }, /* U */ - { 2, 0, 1, 0, 7 }, /* V */ + { + 0, + 0, + 1, + 0, + 7 }, /* Y */ + { + 1, + 0, + 1, + 0, + 7 }, /* U */ + { + 2, + 0, + 1, + 0, + 7 }, /* V */ }, - fillARGB32bufferYUV420p, -}; + fillARGB32bufferYUV420p, }; PlaYUVerPixFmtDescriptor yuv422p = { @@ -307,12 +290,26 @@ PlaYUVerPixFmtDescriptor yuv422p = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV422P ), { - { 0, 0, 1, 0, 7 }, /* Y */ - { 1, 0, 1, 0, 7 }, /* U */ - { 2, 0, 1, 0, 7 }, /* V */ + { + 0, + 0, + 1, + 0, + 7 }, /* Y */ + { + 1, + 0, + 1, + 0, + 7 }, /* U */ + { + 2, + 0, + 1, + 0, + 7 }, /* V */ }, - fillARGB32bufferYUV422, -}; + fillARGB32bufferYUV422, }; PlaYUVerPixFmtDescriptor yuv444p = { @@ -324,12 +321,26 @@ PlaYUVerPixFmtDescriptor yuv444p = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUV444P ), { - { 0, 0, 1, 0, 7 }, /* Y */ - { 1, 0, 1, 0, 7 }, /* U */ - { 2, 0, 1, 0, 7 }, /* V */ + { + 0, + 0, + 1, + 0, + 7 }, /* Y */ + { + 1, + 0, + 1, + 0, + 7 }, /* U */ + { + 2, + 0, + 1, + 0, + 7 }, /* V */ }, - fillARGB32bufferYUV444p, -}; + fillARGB32bufferYUV444p, }; PlaYUVerPixFmtDescriptor yuyv422 = { @@ -341,12 +352,26 @@ PlaYUVerPixFmtDescriptor yuyv422 = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_YUYV422 ), { - { 0, 1, 1, 0, 7 }, /* Y */ - { 0, 3, 2, 0, 7 }, /* U */ - { 0, 3, 4, 0, 7 }, /* V */ + { + 0, + 1, + 1, + 0, + 7 }, /* Y */ + { + 0, + 3, + 2, + 0, + 7 }, /* U */ + { + 0, + 3, + 4, + 0, + 7 }, /* V */ }, - fillARGB32bufferYUV422, -}; + fillARGB32bufferYUV422, }; PlaYUVerPixFmtDescriptor gray = { @@ -357,9 +382,14 @@ PlaYUVerPixFmtDescriptor gray = 0, 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_GRAY8 ), - { { 0, 0, 1, 0, 7 } }, /* Y */ - fillARGB32bufferGray, -}; + { + { + 0, + 0, + 1, + 0, + 7 } }, /* Y */ + NULL, }; PlaYUVerPixFmtDescriptor RGB24 = { @@ -371,12 +401,26 @@ PlaYUVerPixFmtDescriptor RGB24 = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_RGB24 ), { - { 0, 2, 1, 0, 7 }, /* R */ - { 0, 2, 2, 0, 7 }, /* G */ - { 0, 2, 3, 0, 7 }, /* B */ + { + 0, + 2, + 1, + 0, + 7 }, /* R */ + { + 0, + 2, + 2, + 0, + 7 }, /* G */ + { + 0, + 2, + 3, + 0, + 7 }, /* B */ }, - fillARGB32bufferRGB, -}; + NULL, }; PlaYUVerPixFmtDescriptor BGR24 = { @@ -388,12 +432,26 @@ PlaYUVerPixFmtDescriptor BGR24 = 0, ADD_FFMPEG_PEL_FMT( AV_PIX_FMT_BGR24 ), { - { 0, 2, 3, 0, 7 }, /* R */ - { 0, 2, 2, 0, 7 }, /* G */ - { 0, 2, 1, 0, 7 }, /* B */ + { + 0, + 2, + 3, + 0, + 7 }, /* R */ + { + 0, + 2, + 2, + 0, + 7 }, /* G */ + { + 0, + 2, + 1, + 0, + 7 }, /* B */ }, - fillARGB32bufferRGB, -}; + NULL, }; PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS] = { @@ -403,7 +461,6 @@ PlaYUVerPixFmtDescriptor g_PlaYUVerPixFmtDescriptorsList[PLAYUVER_NUMBER_FORMATS yuyv422, gray, RGB24, - BGR24, -}; + BGR24, }; } // NAMESPACE diff --git a/lib/PlaYUVerFramePixelFormats.h b/lib/PlaYUVerFramePixelFormats.h index 1052ade..c84c71e 100644 --- a/lib/PlaYUVerFramePixelFormats.h +++ b/lib/PlaYUVerFramePixelFormats.h @@ -156,7 +156,7 @@ typedef struct PlaYUVerPixFmtDescriptor */ PlaYUVerComponentDescriptor comp[4]; - Void (*fillARGB32buffer)( Pel*** in, UChar* out, UInt width, UInt height ); + Void (*fillARGB32buffer)( Pel*** in, UChar* out, UInt width, UInt height, UInt depth ); } PlaYUVerPixFmtDescriptor;