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

IPP H264 decoder problems

jameslys
Beginner
287 Views

I am new to Intel IPP H64 decoder. I use the simpledecoder.cpp to decode my encoded h264 stream. It can be decoded correctly. As I see from the code, it reads all the data contained inside a file and pass to the decoder to decode. I have 30 encoded h264 files with each of them contains an encoded frame of a video clip. I try to modify the code so that I can read from 30 files and stores all the contents in 30 buffers. Then pass the buffers to the decoder to decode. But it fail to give me the correct answer. Below is my code. Can help me to point out my mistake and give some suggestion? Thank you.

#include "stdafx.h"
#include
#include
#include "ipp.h"
#include "umc_defs.h"
#include "umc_video_decoder.h"
#include "umc_video_data.h"
#include "umc_h264_dec.h"
#include "umc_structures.h"
#include

#define MAXFRAME 100000
#define MAXVIDEOSIZE 100000
#define MAXYUVSIZE 352*288*3/2

void DecodeStream( Ipp8u *cVideoData[],int VideoDataSize[],
Ipp8u *cYUVData[], int& imgWidth, int & imgHeight, int & frameNumber )
{
UMC::Status status; UMC::MediaData DataIn; UMC::VideoData DataOut;
UMC::VideoDecoderParams Params;
UMC::H264VideoDecoder H264Decoder;
int frameSize=0;
int i = 1;
DataIn.SetBufferPointer(cVideoData[0],VideoDataSize[0]);
DataIn.SetDataSize(VideoDataSize[0]);

Params.m_pData = &DataIn; Params.lFlags=0; Params.numThreads=1;
if(status = H264Decoder.Init(&Params)!=UMC::UMC_OK)
return;

H264Decoder.GetInfo(&Params);
imgWidth=Params.info.clip_info.width; imgHeight=Params.info.clip_info.height;

frameSize = imgWidth*imgHeight*3/2;
DataOut.Init(imgWidth,imgHeight,UMC::YUV420,8);
DataOut.SetBufferPointer(cYUVData[0],frameSize);

int exit_flag=0; frameNumber=0;

do{ status = H264Decoder.GetFrame(&DataIn, &DataOut);
if (status == UMC::UMC_OK){
//cYUVData += (imgWidth*imgHeight*3/2);
DataIn.SetBufferPointer(cVideoData,VideoDataSize);
DataIn.SetDataSize(VideoDataSize);
DataOut.SetBufferPointer(cYUVData,frameSize);
i++;
frameNumber++;
}
if((status !=UMC::UMC_OK)||(frameNumber >=MAXFRAME))
exit_flag = 1;

}while (exit_flag!=1);

do{ status = H264Decoder.GetFrame(NULL, &DataOut);
if (status == UMC::UMC_OK) {
//cYUVData += frameSize;
DataOut.SetBufferPointer(cYUVData,frameSize);
i++;
frameNumber++;
}
}while(status == UMC::UMC_OK);
return;
}
int main()
{
Ipp8u *inbuf[30];
Ipp8u *outbuf[30];
int size[30];
int i, width, height, f_num;
FILE *in[30];
FILE *out;
char buf[100];
memset(buf, 0, 100);
fopen_s(&out, "C:\\\\test_ipp.yuv", "wb");
if(out == NULL)
{
fprintf_s(stderr, "open outfile error.\\n");
return -1;
}
for(i=0;i<30;++i)
{
inbuf = new Ipp8u[MAXVIDEOSIZE];
outbuf = new Ipp8u[MAXYUVSIZE];
}
for(i=0;i<30;i++)
{
sprintf(buf, "C:/test/test%d.264", i);
fopen_s(&in, buf, "rb");
if(in == NULL)
{
fprintf_s(stderr, "Open %s failed.\\n", buf);
for(i=0;i<30;++i)
{
delete[] inbuf;
delete[] outbuf;
}
return -1;
}
}
fprintf_s(stdout, "Hello World.\\n");
for(i=0;i<30;i++)
{
size = fread(inbuf, 1, MAXVIDEOSIZE, in);
fclose(in);
}
DecodeStream(inbuf, size, outbuf, width, height, f_num);
for(i=0;i<30;i++)
{
fwrite(outbuf, 1, 352*288*3/2, out);
}
fprintf_s(stdout, "Frame number = %d.\\n", f_num);
for(i=0;i<30;++i)
{
delete[] inbuf;
delete[] outbuf;
}
fclose(out);
return 0;
}

0 Kudos
1 Reply
Chao_Y_Intel
Moderator
287 Views

Hello,

It is fine to read the different frame data from multiple files. I would suggest you put the data into one buffer, and then feed into the decoder.

In this test code, it does not check if the decoder has consumed the data in one buffer, and then move to another buffer. Also, the decoder needs to meet the following frame data, and decode if it has end of decoding the current frame. Put the data in one buffer can avoid this problem.

Thanks,

Chao

0 Kudos
Reply