Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6709 Discussions

Getting low framerate while using UMC MJPEG Video Decoder

Harish_Kulkarni
Beginner
238 Views
Hi,
Here is the IPP version I use:
Intel Integrated Performance Primitives 7.0 Update 4 for Windows* OS
Package ID: w_ipp_7.0.4.196 w_ccompxe_2011.4.196


I am trying to decode a MJPEG stream from an IP camera and display it on a window.In the process for decoding MJPEG stream I am using UMC MJPEG Video Decoder class.
I am able to successfully get the frames and show it on a window but even if I mention the framerate as 25 or 30(supported by the camera),I get only 12 less than that frames per second and there is a second delay in streaming.I am bewildered at the issue.If required I will post the code.
Please help.
Thanks in advance
0 Kudos
2 Replies
Chao_Y_Intel
Moderator
238 Views

Hi,

Do you mean to call decoder GetFrame() method to decode the video?

Actually, GetFrame() method does not control the frame rate, and it tried to decode as fast as possible?

Thanks,
Chao

0 Kudos
Harish_Kulkarni
Beginner
238 Views
Hi Chao,

Thanks for the reply,
I am using the GetFrame function for decoding.
This is how my code looks and this function will be called in an infinitive loop.Initializations of WinInetApi and opening the corresponding camera MJPEG URL happens in another initialization function.

DWORD WINAPI StartStreaming1(LPVOID myParam) {
myParam;
UMC::Status status;
PMYDATA pDataArray = (PMYDATA)myParam;
DWORD pInetResetTimerMilliseconds = 1000 * CONN_REFRESH_SECS;

//Reset the main buffer used for decoding to 0 if the buffer is allocated
if(pDataArray->myParams.pChunkBuffer != NULL){
memset(pDataArray->myParams.pChunkBuffer,0,INET_BUF_SIZE);
pDataArray->myParams.u32totalBytes = 0;
}
//Set the DataIn pointers
status = pDataArray->myParams.DataIn.SetBufferPointer(pDataArray->myParams.pChunkBuffer,
INET_BUF_SIZE);
status = pDataArray->myParams.DataIn.SetDataSize(INET_BUF_SIZE);
// Prevent TCP Connection Time out by re-connecting
if(GetTickCount() >= pDataArray->myParams.dwStartTime + pInetResetTimerMilliseconds) {
InternetCloseHandle(pDataArray->myParams.pURLHandle);
pDataArray->myParams.pURLHandle = NULL;
InternetCloseHandle(pDataArray->myParams.hInternetRoot);
pDataArray->myParams.hInternetRoot = NULL;
//Reconnect
pDataArray->myParams.hInternetRoot = InternetOpen("MJPEGDisplay", INTERNET_OPEN_TYPE_PRECONFIG, NULL,NULL, 0);
if(pDataArray->myParams.hInternetRoot == NULL) {
AfxMessageBox("INITIALIZE_INIT_WININET_FAILED");
return INITIALIZE_INIT_WININET_FAILED;
}
//Open the MJPEG resource file specified by the complete HTTP URL
pDataArray->myParams.pURLHandle = InternetOpenUrl(pDataArray->myParams.hInternetRoot,
pDataArray->myParams.sURL,NULL,0,INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION,0);
if(pDataArray->myParams.pURLHandle == NULL){
DWORD dword = GetLastError();
char myString[1024] = "InternetOpenUrl for ";
sprintf_s(myString,"%s %d cam failed with %d",myString,0,dword);
AfxMessageBox(myString);
InternetCloseHandle(pDataArray->myParams.hInternetRoot);
return INITIALIZE_OPEN_MJPEG_URL_FAILED;
}
pDataArray->myParams.dwStartTime = GetTickCount();
}//if(GetTickCount() >= pDataArray->myParams.dwStartTime + pInetResetTimerMilliseconds)
while((InternetReadFile(pDataArray->myParams.pURLHandle,
pDataArray->myParams.pbyStreamData,
pDataArray->myParams.BytesToread,
&pDataArray->myParams.BytesRead) == TRUE) &&
pDataArray->myParams.BytesRead!=0) {
if(pDataArray->myParams.BytesRead < 300) {
if(strstr((const char *)pDataArray->myParams.pbyStreamData,"401 Unauthorized") != NULL) {
AfxMessageBox("401 Unauthorized");
return 1;
}
if(strstr((const char *)pDataArray->myParams.pbyStreamData,"404 Not Found") != NULL) {
AfxMessageBox("404 Not Found");
return 1;
}
if(strstr((const char *)pDataArray->myParams.pbyStreamData,"400 Bad Request") != NULL) {
AfxMessageBox("400 Bad Request");
return 1;
}
}//if(pDataArray->myParams.BytesRead < 300)
if(pDataArray->myParams.u32totalBytes == INET_BUF_SIZE) return AfxMessageBox("Not able to get a frame");
memcpy_s(pDataArray->myParams.pChunkBuffer +
pDataArray->myParams.u32totalBytes,INET_BUF_SIZE,
pDataArray->myParams.pbyStreamData,
pDataArray->myParams.BytesRead);
pDataArray->myParams.u32totalBytes += pDataArray->myParams.BytesRead;
status = pDataArray->myParams.DataOut.SetBufferPointer(pDataArray->u8Buffer,
sizeof(Ipp8u)*QCIF*3);
status = pDataArray->myParams.mjpegDecoder.GetFrame(&(pDataArray->myParams.DataIn),
&(pDataArray->myParams.DataOut));
if (status == UMC::UMC_OK){
iFrmCntr++;

AfxMessageBox("Successful Decoding of a frame");
((CFaceMatchDlg*)g_hWnd)->StaticDisplay1.DisplayImage(pDataArray->u8Buffer,QCIF_WIDTH,QCIF_HEIGHT,24,"");

return 0;
}//if (status == UMC::UMC_OK)
}//Read the complete file
if(pDataArray->myParams.BytesRead == 0){
AfxMessageBox("Read no bytes");
return 1;
}
return 0;
}

0 Kudos
Reply