MPEG4 encoding/decodeing issues

MPEG4 encoding/decodeing issues


I have two questions:

1. I have tryied H264 and MPEG4 encoders to encode 16 live images at the same time. Right now I have best performance on MPEG4, but still for only 5 video streams I'm getting only 8-10 frames per stream on bitrate = 2000000 (for 16 streams even lower). Ether I'm doing something wrong or I'm changing wrong parameters, but it seams that bitrate is the only parameter that has influance on image quality and I need it quite high. Is there a way to set MPEG4 or H264 to encode 16 live streams with at least 12 frames? I'm using P4 2.8Ghz with 512MB RAM.

2. I have tried to decode MPEG4 stream, but I can't get any response from decoder. I have already written all compressed data to AVI file and I can play it back in any kind of player without any problems, but I need to put compressed data into specific file structure that is not AVI or any other media format. I have already tested my solution with raw data or H264, so I know that I'm reading file stream correctly. The problem is that when I feed single data chunk into MPEG4 decoder it is returning me -899 error code. This is a part of code that I'm using to initialize decoder:


m_dataOut = new UMC::VideoData;

m_dataIn = new UMC::MediaData;

UMC::VideoStreamInfo video_info;

video_info.color_format = UMC::YV12;

video_info.stream_type = UMC::MPEG4_VIDEO;

video_info.stream_subtype = UMC::UNDEF_VIDEO_SUBTYPE;

video_info.clip_info.width = XDIM;

video_info.clip_info.height = YDIM;

UMC::ColorConversionInfo ColorInit;

ColorInit.SizeSource.width = XDIM;

ColorInit.SizeSource.height = YDIM;

ColorInit.FormatDest = UMC::YV12;

ColorInit.SizeDest.width = XDIM;

ColorInit.SizeDest.height = YDIM;

ColorInit.lFlags = 1;

ColorInit.lDeinterlace = 0;

ColorInit.lInterpolation = UMC::FLAG_CCNV_CONVERT;

UMC::ColorSpaceConverter ColorDecoder; = video_info;

m_mpeg4_Param.cformat = UMC::YV12;

m_mpeg4_Param.lFlags = 0;

m_mpeg4_Param.lpConverter = &ColorDecoder;

m_mpeg4_Param.lpConvertInit = &ColorInit;

m_mpeg4_Param.uiLimitThreads = 1;

UMC::Status status = m_mpeg4_dec.Init( &m_mpeg4_Param );

// decoding routin

int mRetval;

BYTE *pY = _buffer;

BYTE *pU = _buffer + ( XDIM * YDIM );

BYTE *pV = pU + ( XDIM * YDIM ) / 4;

m_dataOut->SetDest( pY, pU, pV );

m_dataOut->SetPitch( XDIM, XDIM/4, XDIM/4 );

m_dataIn->SetBufferPointer(, _dataFile.dataSize );

m_dataIn->SetDataSize( _dataFile.dataSize );

mRetval = m_mpeg4_dec.GetFrame( m_dataIn, m_dataOut );

return _buffer;

When I retrive mRetval value it's -899. What am I doing wrong? Do I have problems because I'm not using streams from avisplitter or yuvreader?

12 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I have manage to solve my problem with decoding. It apperas that all I had to do was to add FLAG_VDEC_COMPATIBLE. Now decoding seams to work fine. However I still have a big speed issue. Any ideas what can I do to speed up encoding?


few questions also :)

what is the version of IPP do you use?

what is the size (width x height)of your video?

which parameters do you use for initialization of encoder?

About your second question - you need to extract raw MPEG-4 data from AVI and send them to decoder.


I have v5.1.

These are my settings for encoder, where image size is 720x576:

m_mpeg4_Param.Width = XDIM;

m_mpeg4_Param.Height = YDIM;

m_mpeg4_Param.NumOfFrames = 1000000;

m_mpeg4_Param.TimeIncrement = 1;

m_mpeg4_Param.TimeResolution = 30;

m_mpeg4_Param.RateControl = 1;

m_mpeg4_Param.BitRate =2000000;//25000;

m_mpeg4_Param.quant_type = 0;

m_mpeg4_Param.quantIVOP = 4;

m_mpeg4_Param.quantPVOP = 4;

m_mpeg4_Param.quantBVOP = 6;

m_mpeg4_Param.short_video_header = 0;

m_mpeg4_Param.IVOPdist = 300;

m_mpeg4_Param.BVOPdist = 0;

m_mpeg4_Param.PVOPsearchWidth = 15;

m_mpeg4_Param.PVOPsearchHeight = 15;

m_mpeg4_Param.BVOPsearchWidthForw = 15;

m_mpeg4_Param.BVOPsearchHeightForw = 15;

m_mpeg4_Param.BVOPsearchWidthBack = 15;

m_mpeg4_Param.BVOPsearchHeightBack = 15;

m_mpeg4_Param.MEalgorithm = 1;

m_mpeg4_Param.MEaccuracy = 2;

m_mpeg4_Param.ME4mv = 0;

m_mpeg4_Param.obmc_disable = 1;

m_mpeg4_Param.RoundingControl = 1;

m_mpeg4_Param.calcPSNR = 0;

m_mpeg4_Param.SceneChangeThreshold = 50;

m_mpeg4_Param.insertGOV = 0;

m_mpeg4_Param.repeatHeaders = 0;

m_mpeg4_Param.resync = 0;

m_mpeg4_Param.VideoPacketLenght = 8192;

m_mpeg4_Param.data_partitioned = 0;

m_mpeg4_Param.reversible_vlc = 0;

m_mpeg4_Param.interlaced = 0;

m_mpeg4_Param.top_field_first = 1;

m_mpeg4_Param.alternate_vertical_scan_flag = 1;

m_mpeg4_Param.interlacedME = 0;

m_mpeg4_Param.sprite_enable = 0;

m_mpeg4_Param.no_of_sprite_warping_points = 0;

m_mpeg4_Param.sprite_warping_accuracy = 0;

m_mpeg4_Param.sprite_brightness_change = 0;

m_mpeg4_Param.sprite_left_coordinate = 0;

m_mpeg4_Param.sprite_top_coordinate = 0;

m_mpeg4_Param.sprite_width = 0;

m_mpeg4_Param.sprite_height = 0;

m_mpeg4_Param.warping_mv_code_du = NULL;

m_mpeg4_Param.warping_mv_code_dv = NULL;

m_mpeg4_Param.brightness_change_factor = NULL;

m_mpeg4_Param.load_intra_quant_mat = 0;

m_mpeg4_Param.load_intra_quant_mat_len = 0;

m_mpeg4_Param.load_nonintra_quant_mat = 0;

m_mpeg4_Param.load_nonintra_quant_mat_len = 0;

m_mpeg4_Param.bsBuffer = (Ipp8u*)1;

m_mpeg4_Param.bsBuffSize = 1; // encoder will not allocate buffer

m_mpeg4_Param.padType = 0; // set 1 for QuickTime and 2 for DivX v. >= 5

Regarding second question I know that I need to have raw data. AVI file that I have created was just to see if compression is done correctly. All the raw data received from encoder is placed in custom file structure and there is no need to extract it from AVI. The only thing missing that has solved my problem was flag FLAG_VDEC_COMPATIBLE, but thanks for the tip.

You can try to do the next things

1. Decrease PVOPsearchWidth and PVOPsearchHeight (set to 7 or less)

2. Set MEaccuracy to 1 (no half-pixel ME). But the quality will be worse.

Instead of 2 you can try the next - Set MEaccuracy to2 (half-pixel ME) and change one line in mp4_enc_misc.cpp file in method ippVideoEncoderMPEG4::Init(mp4_Param *par). Find line mMEfastHP = 0; and change it to mMEfastHP = 1; In this case the fast half-pel ME will be performed with small degradation of quality but with speedup.

The better variant is to use ipp 5.2 beta. It is available now. New MPEG-4 encoder is faster than in 5.1 and also it allowsencoding very fast with zero MV (PVOPsearchWidth and PVOPsearchHeight = 0)


I will try those settings with IPP 5.1. Unfrotunately I have downloaded and tried IPP 5.2, but it is:

1. Not compiling h264_enc - some redefinition errors.
2. When mpeg4 encoder Init(...) is called with encode param PADTYPE = 0, 1 or 2 I get immidiet crush "access violation reading location..." and break point in dbgdel.cpp line 52 according to stack view on delete operator. I have used encoder settings listed here(post 30233318). Any ideas what is going on?

1. please see replace one file

2. Do you have crush with any padTyp? At Init() call? Please try to clean and rebuild your application

It is crushing with any padType. It doesn't metter if I will but 0, 1 or 2 and it crushes and Init(). Now I have modified mpeg4_enc_mis.cpp a little in order to see what is going on. The only thing that I have added is vm_debug_trace and it is showing me that Init() is crushing at delete [] MBinfo ( only number "1" is shown in debug outputwithout "end 1" ). I have already tried cleaning and rebuilding my api, but it doesn't help.

void ippVideoEncoderMPEG4::Close()
if (mIsInit) {
// free
if (MBinfo)
vm_debug_trace( 1, VM_STRING("1") );
delete [] MBinfo;
vm_debug_trace( 1, VM_STRING("end 1") );
if (mbsAlloc && cBS.mBuffer)
vm_debug_trace( 1, VM_STRING("2") );
if (mBuffer_1)
vm_debug_trace( 1, VM_STRING("3") );
if (mBuffer_2)
vm_debug_trace( 1, VM_STRING("4") );

please check your application includes right mpeg4_encincludeumc_mpeg4_video_encoder.h file from ipp 5.2 beta.

did you try to build an run video_enc_con application? Does it work properly?

I have removed IPP 5.1 just in case and left only IPP 5.2. I'm sure that I'm using correct inlcude files.

I can't build video_enc_con application because I have problem with compiling h264_enc. I was pointed by you to replace header file from some other thread, but it didn't help. I'm still not able to compile h264. This time I don't have redefinition error, but "identifier not found". I have attached both log files. Any other ideas what can I do?


Download h264_enc.zip2.51 KB

please restore original 5.2 beta and try to remove redefined functions from umc_h264_to_ipp.h and umc_h264_to_ipp.cpp files.

If it will not help you can remove H.264 encoder from video_enc_con solution and comment lines in umc_defs.h file


Or can you step under debugger in your application and to watch the mIsInit variable. In which moment does it become "true"?

Leave a Comment

Please sign in to add a comment. Not a member? Join today