/*read the movie frames from the input file */ int ReadMovie(const char *fname, int nFrame, unsigned int W, unsigned H, MOVIE *movie) { /* defining local variables */ int x; /* error checking */ assert(fname); assert(movie); for (x = 0; x < nFrame; x++) { AppendImage(movie->Frames, ReadOneFrame(fname, x, W, H)); } printf("The movie file %s has been read successfully! \n", fname); return 0; }
/* ReadPackets(). Thread function. */ void CContentDecoder::ReadPackets() { try { g_Log->Info( "Packet thread started..." ); if( !NextSheepForPlaying() ) return; while( true ) { this_thread::interruption_point(); int32 nextForced = NextForced(); if (nextForced != 0) ForceNext( 0 ); bool bDoNextSheep = true; if (nextForced == 0) { CVideoFrame *pMainVideoFrame = ReadOneFrame(m_MainVideoInfo); if (pMainVideoFrame != NULL) { CVideoFrame *pSecondVideoFrame = NULL; #define kTransitionFrameLength 60 if (m_SecondVideoInfo != NULL && m_SecondVideoInfo->IsOpen() && m_MainVideoInfo->m_iCurrentFileFrameCount >= (m_MainVideoInfo->m_totalFrameCount - kTransitionFrameLength)) pSecondVideoFrame = ReadOneFrame(m_SecondVideoInfo); if (pSecondVideoFrame != NULL) { pMainVideoFrame->SetMetaData_SecondFrame(pSecondVideoFrame); if (m_SecondVideoInfo->m_iCurrentFileFrameCount < kTransitionFrameLength) pMainVideoFrame->SetMetaData_TransitionProgress((fp4)m_SecondVideoInfo->m_iCurrentFileFrameCount * 100.f / ((fp4)kTransitionFrameLength - 1.f)); else pMainVideoFrame->SetMetaData_TransitionProgress(100.f); } else pMainVideoFrame->SetMetaData_TransitionProgress(0.f); m_FrameQueue.push( pMainVideoFrame ); bDoNextSheep = false; //printf( "yielding..." ); //m_pDecoderThread->yield(); } } if (bDoNextSheep) { g_Log->Info( "calling Next()" ); NextSheepForPlaying( nextForced ); if ( nextForced != 0 ) ClearQueue(); } } } catch(thread_interrupted const&) { } printf( "decoder thread ending..." ); g_Log->Info( "Ending decoder thread..." ); }