From 06783ab4aec157779c3097c4ba935a4cbd1f2b01 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 4 Nov 2014 02:57:52 +0000 Subject: [PATCH 1/2] Fix diff between color space and pel format when showing pel values --- source/app/ViewArea.cpp | 48 ++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 2986598..3d0c4a9 100644 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -372,10 +372,9 @@ void ViewArea::paintEvent( QPaintEvent *event ) QPoint pixelTopLeft( i, j ); QRect pixelRect( viewToWindow( pixelTopLeft ), QSize( m_zoomFactor, m_zoomFactor ) ); + Int frFormat = m_pcCurrFrame->getColorSpace(); - Int frFormat = m_pcCurrFrame->getPelFormat(); - - if( (frFormat==PlaYUVerFrame::COLOR_YUV) || (frFormat==PlaYUVerFrame::COLOR_GRAY) ) + if( frFormat == PlaYUVerFrame::COLOR_YUV ) { sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_YUV ); @@ -384,32 +383,41 @@ void ViewArea::paintEvent( QPaintEvent *event ) else painter.setPen( QColor( Qt::black ) ); - painter.drawText( pixelRect, Qt::AlignCenter, "Y: " + QString::number( sPixelValue.Luma ) + "\n" + - "U: " + QString::number( sPixelValue.ChromaU ) + "\n" + - "V: " + QString::number( sPixelValue.ChromaV )); + painter.drawText( pixelRect, Qt::AlignCenter, + "Y: " + QString::number( sPixelValue.Luma ) + "\n" + "U: " + QString::number( sPixelValue.ChromaU ) + "\n" + "V: " + + QString::number( sPixelValue.ChromaV ) ); } - else + if( frFormat == PlaYUVerFrame::COLOR_GRAY ) { - if( (frFormat==PlaYUVerFrame::COLOR_RGB) ) - { - sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_RGB ); + sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_YUV ); - if( ( sPixelValue.ColorR + sPixelValue.ColorG + sPixelValue.ColorB ) < 128*3 ) - painter.setPen( QColor( Qt::white ) ); - else - painter.setPen( QColor( Qt::black ) ); - - painter.drawText( pixelRect, Qt::AlignCenter, "R: " + QString::number( sPixelValue.ColorR ) + "\n" + - "G: " + QString::number( sPixelValue.ColorG ) + "\n" + - "B: " + QString::number( sPixelValue.ColorB )); - } + if( sPixelValue.Luma < 128 ) + painter.setPen( QColor( Qt::white ) ); else - assert(0); + painter.setPen( QColor( Qt::black ) ); + + painter.drawText( pixelRect, Qt::AlignCenter, + "Y: " + QString::number( sPixelValue.Luma ) ); } + if( ( frFormat == PlaYUVerFrame::COLOR_RGB ) ) + { + sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_RGB ); + + if( ( sPixelValue.ColorR + sPixelValue.ColorG + sPixelValue.ColorB ) < 128 * 3 ) + painter.setPen( QColor( Qt::white ) ); + else + painter.setPen( QColor( Qt::black ) ); + + painter.drawText( pixelRect, Qt::AlignCenter, + "R: " + QString::number( sPixelValue.ColorR ) + "\n" + "G: " + QString::number( sPixelValue.ColorG ) + "\n" + "B: " + + QString::number( sPixelValue.ColorB ) ); + } } + } + QColor color( Qt::white ); QPen mainPen = QPen( color, 1, Qt::SolidLine ); painter.setPen( mainPen ); From 46852ed15c6043d5c4e8f89db45e26e0788f01d9 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Wed, 5 Nov 2014 18:53:31 +0000 Subject: [PATCH 2/2] Fix seek problems and minor changes in PlaYUVerFrame --- source/app/ViewArea.cpp | 1 - source/app/plaYUVerApp.cpp | 10 ++++++++-- source/lib/PlaYUVerFrame.cpp | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 3d0c4a9..1fdf627 100644 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -268,7 +268,6 @@ void ViewArea::updateOffset() { m_xOffset = 0; } - if( height() > m_pixmap.height() * m_zoomFactor ) { m_yOffset = ( height() - m_pixmap.height() * m_zoomFactor ) / 2; diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index ea7ed47..6a0c17d 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -694,9 +694,13 @@ Void plaYUVerApp::seekEvent( Int direction ) { if( m_acPlayingSubWindows.contains( m_pcCurrentSubWindow ) ) { - for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + Int frame_num = m_pcCurrentSubWindow->getInputStream()->getCurrFrameNum(); + if( !( (frame_num + 1) >= getMaxFrameNumber() && direction > 0 ) ) { - m_acPlayingSubWindows.at( i )->seekRelativeEvent( direction > 0 ? true : false ); + for( Int i = 0; i < m_acPlayingSubWindows.size(); i++ ) + { + m_acPlayingSubWindows.at( i )->seekRelativeEvent( direction > 0 ? true : false ); + } } } else @@ -745,6 +749,8 @@ Void plaYUVerApp::lockButtonEvent() m_acPlayingSubWindows.clear(); } } + updateCurrFrameNum(); + updateTotalFrameNum(); } Void plaYUVerApp::videoSelectionButtonEvent() diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index 5717018..653d04c 100644 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -144,7 +144,7 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format ) getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, 1, 2 ); break; case GRAY: - getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, 4, 4 ); + getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, 99, 99 ); break; case RGB8: getMem3ImageComponents( &m_pppcInputPel, m_uiHeight, m_uiWidth, 1, 1 ); @@ -338,12 +338,12 @@ Void PlaYUVerFrame::FrametoRGB8() for( UInt y = 0; y < m_uiHeight; y++ ) for( UInt x = 0; x < m_uiWidth; x++ ) { - iY = *pInputPelY++; - //yuvToRgb( iY, iY, iY, iR, iG, iB ); + iY = *pInputPelY; iR = iG = iB = iY; *pcRGBPelInterlaced++ = iR; *pcRGBPelInterlaced++ = iG; *pcRGBPelInterlaced++ = iB; + pInputPelY++; } break; case RGB8: @@ -401,7 +401,7 @@ Void PlaYUVerFrame::FrameFromBuffer( Pel *input_buffer, Int pel_format ) } break; case GRAY: - memcpy( &m_pppcInputPel[LUMA][0][0], input_buffer + frame_bytes_input * 0, frame_bytes_input * sizeof(Pel) ); + memcpy( &m_pppcInputPel[LUMA][0][0], input_buffer, frame_bytes_input * sizeof(Pel) ); break; case RGB8: memcpy( pcRGBPelInterlaced, input_buffer, frame_bytes_input * sizeof(Pel) * 3 );