diff --git a/source/app/InputStream.cpp b/source/app/InputStream.cpp index d074fc9..7257cba 100755 --- a/source/app/InputStream.cpp +++ b/source/app/InputStream.cpp @@ -54,6 +54,7 @@ InputStream::InputStream() m_cStreamInformationString = QString( "" ); m_pcCurrFrame = NULL; + m_pcNextFrame = NULL; m_ppcFrameBuffer = NULL; m_uiFrameBufferSize = 2; } @@ -163,8 +164,8 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for { m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); } - m_pcCurrFrame = m_ppcFrameBuffer[0]; - m_uiFrameBufferIndex = 1; + m_uiFrameBufferIndex = 0; + m_pcCurrFrame = m_pcNextFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex]; UInt64 frame_bytes_input = m_pcCurrFrame->getBytesPerFrame(); @@ -190,11 +191,8 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for } m_cStreamInformationString.append( QString("/ ")); - m_cStreamInformationString.append( PlaYUVerFrame::supportedPixelFormatList().at( m_iPixelFormat ) ); - m_cStreamInformationString.append( "] " ); - m_cStreamInformationString.append( QFileInfo( m_cFilename ).fileName() ); m_iCurrFrameNum = -1; @@ -250,7 +248,7 @@ Void InputStream::readNextFrame() if( m_cLibAvContext.getStatus() ) { m_cLibAvContext.decodeAvFormat(); - m_ppcFrameBuffer[!m_uiFrameBufferIndex]->FrameFromBuffer( m_cLibAvContext.video_dst_data[0], m_iPixelFormat ); + m_pcNextFrame->FrameFromBuffer( m_cLibAvContext.video_dst_data[0], m_iPixelFormat ); return; } #endif @@ -263,8 +261,7 @@ Void InputStream::readNextFrame() qDebug( ) << " Reading error !!!" << endl; return; } - m_ppcFrameBuffer[!m_uiFrameBufferIndex]->FrameFromBuffer( m_pInputBuffer, m_iPixelFormat ); - m_uiFrameBufferIndex = !m_uiFrameBufferIndex; + m_pcNextFrame->FrameFromBuffer( m_pInputBuffer, m_iPixelFormat ); return; } @@ -277,6 +274,8 @@ Bool InputStream::writeFrame( const QString& filename ) Void InputStream::setNextFrame() { m_pcCurrFrame = m_ppcFrameBuffer[m_uiFrameBufferIndex]; + m_pcNextFrame = m_ppcFrameBuffer[!m_uiFrameBufferIndex]; + m_uiFrameBufferIndex = !m_uiFrameBufferIndex; m_iCurrFrameNum++; } diff --git a/source/app/InputStream.h b/source/app/InputStream.h index 690d6a4..7e92558 100755 --- a/source/app/InputStream.h +++ b/source/app/InputStream.h @@ -75,6 +75,7 @@ private: UInt m_uiFrameBufferSize; PlaYUVerFrame **m_ppcFrameBuffer; PlaYUVerFrame *m_pcCurrFrame; + PlaYUVerFrame *m_pcNextFrame; UInt m_uiFrameBufferIndex; UInt m_uiWidth; diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index 48c53f3..16a5308 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -141,31 +141,19 @@ Void SubWindowHandle::disableModule() refreshFrame(); } -QImage* SubWindowHandle::FrameToQImage( PlaYUVerFrame* curr_frame ) -{ - curr_frame->FrametoRGB8(); -// Pel*** bufferRGB = curr_frame->getPelBufferRGB(); -// for( UInt y = 0; y < curr_frame->getHeight(); y++ ) -// { -// for( UInt x = 0; x < curr_frame->getWidth(); x++ ) -// { -// m_pCurrFrameQImage->setPixel( x, y, qRgb( bufferRGB[0][y][x], bufferRGB[1][y][x], bufferRGB[2][y][x] ) ); -// } -// } - return m_pCurrFrameQImage; -} - Void SubWindowHandle::refreshFrame() { + PlaYUVerFrame* CurrSubWindowFrame; if( m_pcCurrentModule ) { - FrameToQImage( m_pcCurrentModule->process( m_pCurrStream->getCurrFrame() ) ); + CurrSubWindowFrame = m_pcCurrentModule->process( m_pCurrStream->getCurrFrame() ); } else { - FrameToQImage( m_pCurrStream->getCurrFrame() ); + CurrSubWindowFrame = m_pCurrStream->getCurrFrame(); } - m_cViewArea->setImage( QPixmap::fromImage( *m_pCurrFrameQImage ) ); + CurrSubWindowFrame->FrametoRGB8(); + m_cViewArea->setImage( QPixmap::fromImage( QImage( CurrSubWindowFrame->getQImageBuffer(), CurrSubWindowFrame->getWidth(), CurrSubWindowFrame->getHeight(), QImage::Format_RGB888 ) ) ); } Bool SubWindowHandle::save()