我逐帧读入了yuv格式文件,现在想要对得到的每一帧图片进行处理,我该如何获取每一帧图像指针? 20
下面是我的程序voidgetSeqName(char*inseqpath,char*seqname);//intnImgWidth,nImgHeight;UINTPlay...
下面是我的程序
void getSeqName(char *inseqpath, char *seqname);
//int nImgWidth, nImgHeight;
UINT PlayVideo( LPVOID pParam )
{
int i;//,j;
BOOL bPlay = g_bPlay;
BOOL bEof = FALSE;
CYUVviewerDlg *pWin = (CYUVviewerDlg *)pParam;
UINT picsize = pWin->m_nWidth*pWin->m_nHeight;
int timespan = 1000/atoi(pWin->m_sFrameRate);
if(g_nCurrentFrame < g_nStartFrame) g_nCurrentFrame = g_nStartFrame;
if(g_nCurrentFrame > g_nEndFrame) g_nCurrentFrame = g_nEndFrame;
for(i=0; i<pWin->m_iCount; i++)
{
pWin->m_pFile[i]->Seek(g_nCurrentFrame*picsize*3/2, SEEK_SET);
pWin->m_pWnd[i]->nPicShowOrder = g_nCurrentFrame;
}
HANDLE hPlayTemp1 = OpenMutex(MUTEX_ALL_ACCESS,FALSE,"Play");
while(g_nCurrentFrame >= g_nStartFrame && g_nCurrentFrame <= g_nEndFrame && !bEof)
{
DWORD t2=GetTickCount();
g_nFrameNumber = g_nCurrentFrame;//j;
if ( WAIT_OBJECT_0 == WaitForSingleObject(hPlayTemp1,INFINITE) )
ReleaseMutex( hPlayTemp1 );
for(i=0; i<pWin->m_iCount; i++)
{
pWin->m_pFile[i]->Seek(g_nCurrentFrame*picsize*3/2, SEEK_SET);
if(picsize != pWin->m_pFile[i]->Read(pWin->m_pWnd[i]->Y,picsize))
{
AfxMessageBox("Get to end of file");
bEof = TRUE;
break;
}
if(1)//bColorImage)
{
if(picsize/4 != pWin->m_pFile[i]->Read(pWin->m_pWnd[i]->Cb,picsize/4))
{
AfxMessageBox("Get to end of file");
bEof = TRUE;
break;
}
if(picsize/4 != pWin->m_pFile[i]->Read(pWin->m_pWnd[i]->Cr,picsize/4))
{
AfxMessageBox("Get to end of file");
bEof = TRUE;
break;
}
}
pWin->m_pWnd[i]->InvalidateRect (NULL,FALSE);
pWin->m_pWnd[i]->UpdateWindow ();
pWin->m_pWnd[i]->nPicShowOrder=g_nCurrentFrame;
}
if(g_bReversePlay == FALSE)
g_nCurrentFrame++;
else
g_nCurrentFrame--;
int t1=GetTickCount()-t2;
if(t1 < timespan)
Sleep(timespan - t1); // sleep time in milliseconds
}
pWin->m_pWinThread = NULL;
AfxEndThread(0);
return 1;
}
里面我用int变量 g_currentFrame表示每一帧,最好能够获得一个指针数组,能够指向每一帧 展开
void getSeqName(char *inseqpath, char *seqname);
//int nImgWidth, nImgHeight;
UINT PlayVideo( LPVOID pParam )
{
int i;//,j;
BOOL bPlay = g_bPlay;
BOOL bEof = FALSE;
CYUVviewerDlg *pWin = (CYUVviewerDlg *)pParam;
UINT picsize = pWin->m_nWidth*pWin->m_nHeight;
int timespan = 1000/atoi(pWin->m_sFrameRate);
if(g_nCurrentFrame < g_nStartFrame) g_nCurrentFrame = g_nStartFrame;
if(g_nCurrentFrame > g_nEndFrame) g_nCurrentFrame = g_nEndFrame;
for(i=0; i<pWin->m_iCount; i++)
{
pWin->m_pFile[i]->Seek(g_nCurrentFrame*picsize*3/2, SEEK_SET);
pWin->m_pWnd[i]->nPicShowOrder = g_nCurrentFrame;
}
HANDLE hPlayTemp1 = OpenMutex(MUTEX_ALL_ACCESS,FALSE,"Play");
while(g_nCurrentFrame >= g_nStartFrame && g_nCurrentFrame <= g_nEndFrame && !bEof)
{
DWORD t2=GetTickCount();
g_nFrameNumber = g_nCurrentFrame;//j;
if ( WAIT_OBJECT_0 == WaitForSingleObject(hPlayTemp1,INFINITE) )
ReleaseMutex( hPlayTemp1 );
for(i=0; i<pWin->m_iCount; i++)
{
pWin->m_pFile[i]->Seek(g_nCurrentFrame*picsize*3/2, SEEK_SET);
if(picsize != pWin->m_pFile[i]->Read(pWin->m_pWnd[i]->Y,picsize))
{
AfxMessageBox("Get to end of file");
bEof = TRUE;
break;
}
if(1)//bColorImage)
{
if(picsize/4 != pWin->m_pFile[i]->Read(pWin->m_pWnd[i]->Cb,picsize/4))
{
AfxMessageBox("Get to end of file");
bEof = TRUE;
break;
}
if(picsize/4 != pWin->m_pFile[i]->Read(pWin->m_pWnd[i]->Cr,picsize/4))
{
AfxMessageBox("Get to end of file");
bEof = TRUE;
break;
}
}
pWin->m_pWnd[i]->InvalidateRect (NULL,FALSE);
pWin->m_pWnd[i]->UpdateWindow ();
pWin->m_pWnd[i]->nPicShowOrder=g_nCurrentFrame;
}
if(g_bReversePlay == FALSE)
g_nCurrentFrame++;
else
g_nCurrentFrame--;
int t1=GetTickCount()-t2;
if(t1 < timespan)
Sleep(timespan - t1); // sleep time in milliseconds
}
pWin->m_pWinThread = NULL;
AfxEndThread(0);
return 1;
}
里面我用int变量 g_currentFrame表示每一帧,最好能够获得一个指针数组,能够指向每一帧 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询