Community
cancel
Showing results for 
Search instead for 
Did you mean: 
fukugawa
Beginner
44 Views

H.263 decoder crash in release mode

If I use H.263 Decoder of IPP 5.2 for Windows, the application will crash.
If the application is crashed, it crashed in "H263VideoDecoder::GetFrame()" function.
Exception 0x0000005 is generated by function "ippiv8-5.2.dll!0115df34()".
It is strange, and if the application is built in Debug mode, it does't crash.
If the application is built in Release mode, it crash.


Program overview:
This program is a program that tests encode and decode of H.263.
The source file using H.263 to encode and decode the BMP file.

1)Read RGB data from BMP file.
2)RGB data is converted into YUV420 format.
3)YUV420 data is encoded into H.263 bitstream.
4)H.263 bitstream is decoded into YUV420 format.
5)YUV420 data is converted into RGB data.
6)RGB data save to BMP file.

This processing is repeated ten times.
During the 10 times loop, the application will crash in the second loop or the third loop.
If the application is built in the Debug mode, the application runs well and the BMP file will be saved sucessfully.

Environment:
IPP : IPP 5.2 for Windows IA-32
IDE : Visual Studio 2005 Pro
OS : Windows XP Home

Application SourceCode:

#include "stdafx.h"
#include
#include
#include
#include "ipp.h"
#include "umc_video_data.h"
#include "umc_h263_video_encoder.h"
#include "umc_h263_video_decoder.h"

using namespace UMC;

IppiSize imgSize = {176,144};
unsigned char bitstreamBuff[10000];
unsigned char codecBuff[176 * 144 * 3 * 2];
unsigned char rgbBuff[176 * 144 * 3];

int func() {

H263VideoEncoder *pEncoder = NULL;
VideoEncoderParams *pEncoderParams = NULL;
VideoData* inEnc = NULL;
MediaData* outEnc = NULL;

H263VideoDecoder *pDecoder = NULL;
VideoDecoderParams *pDecoderParams = NULL;
MediaData* inDec = NULL;
VideoData* outDec = NULL;

Status umcSt;
IppStatus ippSt;
FILE *outputFp;
FILE *inputFp;
BITMAPFILEHEADER bmpFileHdr;
BITMAPINFOHEADER bmpInfoHdr;
int bitstreamSize;
Ipp8u* dst[3];

// Read Bitmap File
inputFp = fopen("input.bmp","rb");
if(inputFp == NULL) {
return -1;
}
fread(&bmpFileHdr,sizeof(BITMAPFILEHEADER),1,inputFp);
fread(&bmpInfoHdr,sizeof(BITMAPINFOHEADER),1,inputFp);
fseek(inputFp,bmpFileHdr.bfOffBits,SEEK_SET);
fread(rgbBuff,sizeof(rgbBuff),1,inputFp);
fclose(inputFp);

// H.263 Encode --------------------------------------------------------
pEncoder = new H263VideoEncoder();
pEncoderParams = new H263EncoderParams();
umcSt = pEncoderParams->ReadParamFile((const vm_char*)"h263.par");
if(umcSt != UMC_OK) {
return -1;
}

pEncoderParams->info.clip_info.width = imgSize.width;
pEncoderParams->info.clip_info.height = imgSize.height;
pEncoderParams->info.color_format = YUV420;

umcSt = pEncoder->Init(pEncoderParams);
if(umcSt != UMC_OK) {
return -1;
}
umcSt = pEncoder->GetInfo(pEncoderParams);
if(umcSt != UMC_OK) {
return -1;
}

dst[0] = (Ipp8u*)malloc(imgSize.width * imgSize.height);
dst[1] = (Ipp8u*)malloc(imgSize.width * imgSize.height);
dst[2] = (Ipp8u*)malloc(imgSize.width * imgSize.height);

inEnc = new VideoData();
outEnc = new MediaData();

inEnc->SetColorFormat(YUV420);
inEnc->Init(imgSize.width,imgSize.height,YUV420,8);
inEnc->Alloc();

outEnc->SetBufferPointer(codecBuff,sizeof(codecBuff));

// RGB -> YUV420
ippSt = ippiRGBToYUV420_8u_C3P3(rgbBuff,dst,imgSize);
if(ippSt != ippStsNoErr) {
return -1;
}

// YUV -> VideoData
memcpy(inEnc->GetPlanePointer(0),dst[0],imgSize.width * imgSize.height);
memcpy(inEnc->GetPlanePointer(1),dst[1],imgSize.width * imgSize.height / 4);
memcpy(inEnc->GetPlanePointer(2),dst[2],imgSize.width * imgSize.height / 4);

// Encode!!!
umcSt = pEncoder->GetFrame(inEnc,outEnc);
if(umcSt != UMC_OK) {
return -1;
}

// Get H.263 bitstream
memcpy(bitstreamBuff,outEnc->GetDataPointer(),outEnc->GetDataSize());
bitstreamSize = outEnc->GetDataSize();

inEnc->Close();
outEnc->Close();
delete inEnc;
delete outEnc;

free(dst[0]);
free(dst[1]);
free(dst[2]);

delete(pEncoderParams);
pEncoder->Close();
delete(pEncoder);

// H.263 Encode --------------------------------------------------------
pDecoder = new H263VideoDecoder();
pDecoderParams = new VideoDecoderParams();

pDecoderParams->info.clip_info.width = imgSize.width;
pDecoderParams->info.clip_info.height = imgSize.height;
pDecoderParams->info.color_format = YUV420;

umcSt = pDecoder->Init(pDecoderParams);
if(umcSt != UMC_OK) {
return -1;
}

umcSt = pDecoder->GetInfo(pDecoderParams);
if(umcSt != UMC_OK) {
return -1;
}

// Set H.263 bitstream
inDec = new MediaData();
umcSt = inDec->Alloc(bitstreamSize * 8);
memcpy(inDec->GetDataPointer(),bitstreamBuff,bitstreamSize);
umcSt = inDec->SetDataSize(bitstreamSize);

outDec = new VideoData();
umcSt = outDec->Init(imgSize.width,imgSize.height,YUV420,8);
umcSt = outDec->Alloc();
umcSt = outDec->SetColorFormat(YUV420);
umcSt = outDec->SetBufferPointer(codecBuff,sizeof(codecBuff));

// Decode!!!
umcSt = pDecoder->GetFrame(inDec,outDec);// <-- crash point!!!
if(umcSt != UMC_OK) {
return -1;
}

// YUV420 -> RGB
dst[0] = (Ipp8u*)outDec->GetPlanePointer(0);
dst[1] = (Ipp8u*)outDec->GetPlanePointer(1);
dst[2] = (Ipp8u*)outDec->GetPlanePointer(2);

ippSt = ippiYUV420ToRGB_8u_P3C3(dst,rgbBuff,imgSize);
if(ippSt != ippStsNoErr) {
return -1;
}

// Save to Bitmap File
outputFp = fopen("output.bmp","wb");
if(outputFp != NULL) {
BITMAPFILEHEADER bmpFileHdr;
BITMAPINFOHEADER bmpInfoHdr;
&n bsp;memset(&bmpFileHdr,0,sizeof(BITMAPFILEHEADER));
memset(&bmpInfoHdr,0,sizeof(BITMAPINFOHEADER));
bmpFileHdr.bfType = 'B' + ('M'<<8); // 'BM'
bmpFileHdr.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
bmpFileHdr.bfSize = bmpFileHdr.bfOffBits + imgSize.width * imgSize.height * 3;
bmpInfoHdr.biSize = sizeof(BITMAPINFOHEADER);
bmpInfoHdr.biHeight = imgSize.height;
bmpInfoHdr.biWidth = imgSize.width;
bmpInfoHdr.biPlanes = 1;
bmpInfoHdr.biBitCount = 24;
bmpInfoHdr.biCompression = BI_RGB;
bmpInfoHdr.biSizeImage = imgSize.width * imgSize.height * 3;
fwrite(&bmpFileHdr,sizeof(BITMAPFILEHEADER),1,outputFp);
fwrite(&bmpInfoHdr,sizeof(BITMAPINFOHEADER),1,outputFp);
fwrite(rgbBuff,sizeof(rgbBuff),1,outputFp);
fclose(outputFp);
}

outDec->Close();
inDec->Close();
delete outDec;
delete inDec;

delete(pDecoderParams);
pDecoder->Close();
//delete(pDecoder);

return 0;
}

void main() {

for(int i=0;i<10;i++)
func();
}

Thanks.

0 Kudos
4 Replies
Vladimir_Dudnik
Employee
44 Views

Hello,

I would recommend you to move to IPP 5.3 library and samples. By the way, UMC documentation was extended with simple sample of decoder's use in IPP 5.3 release

Regards,
Vladimir

fukugawa
Beginner
44 Views

Thank you for your reply. I will try IPP 5.3 library and samples. I hope you understand my poor English. Thanks, Fukugawa
Vladimir_Dudnik
Employee
44 Views

Hi Fukugawa,

What the question! I'm hoping you also understand my not 'the best of the west' language :)

I'm sure engineeners can always talk to each other regardless language barriers.

Regards,
Vladimir

fukugawa
Beginner
44 Views

When I use IPP 5.3 library, the application did not crash. Thank you for your help. Fukugawa