<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic MPEG2 decoder in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913116#M14561</link>
    <description>I have some questions about MPEG2 decoder.&lt;BR /&gt;I'm trying to decode MPEG2 stream from network.&lt;BR /&gt;I receive stream (video only, already splitted) in 2280 bytes packets. &lt;BR /&gt;And I can't figure out how to do it right.&lt;BR /&gt;I have done some test and results are below.&lt;BR /&gt;&lt;BR /&gt;When I load whole test stream in memory first call to MPEG2VideoDecoder-&amp;gt;GetFrame()&lt;BR /&gt;always return UMC_NOT_ENOUGH_DATA (not sure why whole stream is in memory ?) but next call is ok&lt;BR /&gt;and all other frames are correctly decoded. Everything good here.&lt;BR /&gt;But when I set buffer size to for ex. 25000 bytes, first call to MPEG2VideoDecoder-&amp;gt;GetFrame returns UMC_NOT_ENOUGH_DATA second also UMC_NOT_ENOUGH_DATA and third call returns UMC_OK, BUT frame is not correctly decoded only half of frame is decoded.&lt;BR /&gt;If I set buffer size to 15000 only quarter of frame is decoded and at 2280 there is nothing decoded at all, but GetFrame returns UMC_OK.&lt;BR /&gt;What I'm doing wrong ? Do I have to buffer data and then call GetFrame ?&lt;BR /&gt;How do I know how much data do I have to buffer ?&lt;BR /&gt;Here is code how I'm testing this:&lt;BR /&gt;&lt;BR /&gt;UMC::MediaData dataIn;&lt;BR /&gt;UMC::VideoData dataOut;&lt;BR /&gt;&lt;BR /&gt;read to memBuf&lt;BR /&gt;dataIn.SetBufferPointer(memBuf,BUF_SIZE);&lt;BR /&gt;...&lt;BR /&gt;....&lt;BR /&gt;while (true) {&lt;BR /&gt;umcRes = mpg2d-&amp;gt;GetFrame(&amp;amp;dataIn, &amp;amp;dataOut);&lt;BR /&gt;if (umcRes==UMC::UMC_OK) all ok&lt;BR /&gt;else&lt;BR /&gt;if (umcRes==UMC::UMC_NOT_ENOUGH_DATA) {&lt;BR /&gt; read next data to memBuf&lt;BR /&gt; dataIn.SetBufferPointer(memBuf,BUF_SIZE);&lt;BR /&gt;}...&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Any help would be appreciated.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 28 Aug 2006 18:45:03 GMT</pubDate>
    <dc:creator>Boris_V_1</dc:creator>
    <dc:date>2006-08-28T18:45:03Z</dc:date>
    <item>
      <title>MPEG2 decoder</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913116#M14561</link>
      <description>I have some questions about MPEG2 decoder.&lt;BR /&gt;I'm trying to decode MPEG2 stream from network.&lt;BR /&gt;I receive stream (video only, already splitted) in 2280 bytes packets. &lt;BR /&gt;And I can't figure out how to do it right.&lt;BR /&gt;I have done some test and results are below.&lt;BR /&gt;&lt;BR /&gt;When I load whole test stream in memory first call to MPEG2VideoDecoder-&amp;gt;GetFrame()&lt;BR /&gt;always return UMC_NOT_ENOUGH_DATA (not sure why whole stream is in memory ?) but next call is ok&lt;BR /&gt;and all other frames are correctly decoded. Everything good here.&lt;BR /&gt;But when I set buffer size to for ex. 25000 bytes, first call to MPEG2VideoDecoder-&amp;gt;GetFrame returns UMC_NOT_ENOUGH_DATA second also UMC_NOT_ENOUGH_DATA and third call returns UMC_OK, BUT frame is not correctly decoded only half of frame is decoded.&lt;BR /&gt;If I set buffer size to 15000 only quarter of frame is decoded and at 2280 there is nothing decoded at all, but GetFrame returns UMC_OK.&lt;BR /&gt;What I'm doing wrong ? Do I have to buffer data and then call GetFrame ?&lt;BR /&gt;How do I know how much data do I have to buffer ?&lt;BR /&gt;Here is code how I'm testing this:&lt;BR /&gt;&lt;BR /&gt;UMC::MediaData dataIn;&lt;BR /&gt;UMC::VideoData dataOut;&lt;BR /&gt;&lt;BR /&gt;read to memBuf&lt;BR /&gt;dataIn.SetBufferPointer(memBuf,BUF_SIZE);&lt;BR /&gt;...&lt;BR /&gt;....&lt;BR /&gt;while (true) {&lt;BR /&gt;umcRes = mpg2d-&amp;gt;GetFrame(&amp;amp;dataIn, &amp;amp;dataOut);&lt;BR /&gt;if (umcRes==UMC::UMC_OK) all ok&lt;BR /&gt;else&lt;BR /&gt;if (umcRes==UMC::UMC_NOT_ENOUGH_DATA) {&lt;BR /&gt; read next data to memBuf&lt;BR /&gt; dataIn.SetBufferPointer(memBuf,BUF_SIZE);&lt;BR /&gt;}...&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Any help would be appreciated.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Aug 2006 18:45:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913116#M14561</guid>
      <dc:creator>Boris_V_1</dc:creator>
      <dc:date>2006-08-28T18:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: MPEG2 decoder</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913117#M14562</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Decoder requires at least one complete encoded frame on input. Application should care about it. One frame is always buffered in decoder to perform reordering. That is why you receive NOT_ENOUGH_DATA with the first call. In fact it means that there is no data for output. Just ignore it. It can also happen when field coded sequence is decoded - GetFrame returns NOT_ENOUGH_DATA after first field is decoded.&lt;/P&gt;
&lt;P&gt;About dataIn. You should call dataIn.SetDataSize(data_size) after SetBufferPointer. Decoder gets data to be decoded from MediaData::DataPointer. After frame is decoded the decoder advances DataPointer and DataSize in dataIn by the number of consumed bytes. Remained bytes must not be dropped. If the whole stream is read you don't need to do anything with dataIn between GetFrame calls. If it isn't you need to concatenate the rest with new portion of data and set proper datasize.&lt;BR /&gt;Simplest estimation for input buffer size is the size of uncompressed frame. Or you can use bitrate*1 second - it is enoug in most cases.&lt;/P&gt;
&lt;P&gt;I don't see mpg2-&amp;gt;Init() call in your code? &lt;FONT size="2"&gt;VideoDecoderParams::m_pData &lt;/FONT&gt;&lt;FONT size="3"&gt;field provides sequence headers and optionally first frame. When the first frame provided it is decoded during Init and then the first call of GetFrame doesn't return NOT_ENOUGH_DATA.&lt;BR /&gt;To retrieve last frame, which is buffered inside decoder, call once GetFrame(0, out).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Good Luck and Regards&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2006 20:53:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913117#M14562</guid>
      <dc:creator>Leonid_K_Intel</dc:creator>
      <dc:date>2006-08-28T20:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: MPEG2 decoder</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913118#M14563</link>
      <description>&lt;PRE&gt;Thanks for reply.&lt;BR /&gt;&lt;BR /&gt;Below is my test code.&lt;BR /&gt;If BSIZE is 10000, about quarter of frame is decoded, &lt;BR /&gt;if it's more, than more of frame is decoded.&lt;BR /&gt;If I set BSIZE to for ex. to 1000000 than frames are poperly decoded.&lt;BR /&gt;What I'm doing wrong ?&lt;BR /&gt;&lt;BR /&gt;#define vidW 480&lt;BR /&gt;#define vidH 576&lt;BR /&gt;#define BSIZE 10000&lt;BR /&gt;&lt;BR /&gt;	UMC::VideoDecoderParams VDecParams;&lt;BR /&gt;	UMC::ColorConversionInfo ColorInit;&lt;BR /&gt;	UMC::MediaData dataIn;&lt;BR /&gt;	UMC::VideoData dataOut;&lt;BR /&gt;	UMC::ColorSpaceConverter rColorConverter;&lt;BR /&gt;&lt;BR /&gt;	UMC::Status umcRes = UMC::UMC_OK;&lt;BR /&gt;&lt;BR /&gt;	HANDLE fh=CreateFile("testmp2data.bin",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);	&lt;BR /&gt;&lt;BR /&gt;	BYTE * memBuf=(BYTE*)malloc(5*1024*1024);&lt;BR /&gt;	DWORD br;&lt;BR /&gt;	//Read whole file to memory&lt;BR /&gt;	ReadFile(fh,memBuf,5000000,&amp;amp;br,NULL);&lt;BR /&gt;	CloseHandle(fh);&lt;BR /&gt;&lt;BR /&gt;	//for testing set buffer size to BSIZE&lt;BR /&gt;	dataIn.SetBufferPointer(memBuf,BSIZE);&lt;BR /&gt;	dataIn.SetDataSize(BSIZE);&lt;BR /&gt;&lt;BR /&gt;	mpg2d=new UMC::MPEG2VideoDecoder();&lt;BR /&gt;&lt;BR /&gt;	VDecParams.m_pData  = &amp;amp;dataIn;&lt;BR /&gt;&lt;BR /&gt;	ColorInit.FormatDest        = UMC::YV12;&lt;BR /&gt;	ColorInit.SizeSource.width  = vidW;&lt;BR /&gt;	ColorInit.SizeSource.height = vidH;&lt;BR /&gt;&lt;BR /&gt;	ColorInit.SizeDest.width    = vidW;&lt;BR /&gt;	ColorInit.SizeDest.height   = vidH;&lt;BR /&gt;&lt;BR /&gt;	ColorInit.lFlags = 1;&lt;BR /&gt;	ColorInit.lDeinterlace              = 0;&lt;BR /&gt;	ColorInit.lInterpolation            = 1;&lt;BR /&gt;&lt;BR /&gt;	VDecParams.cformat                  = UMC::YV12;&lt;BR /&gt;	VDecParams.lFlags                   = UMC::FLAG_VDEC_COMPATIBLE | UMC::FLAG_VDEC_NO_PREVIEW | UMC::FLAG_VDEC_REORDER;	&lt;BR /&gt;	VDecParams.lpConverter              = NULL;&lt;BR /&gt;	VDecParams.lpConvertInit            = &amp;amp;ColorInit;&lt;BR /&gt;	VDecParams.uiLimitThreads           = 0;&lt;BR /&gt;&lt;BR /&gt;	umcRes = mpg2d-&amp;gt;Init(&amp;amp;VDecParams);	&lt;BR /&gt;&lt;BR /&gt;	UMC::VideoDecoderParams vParams;&lt;BR /&gt;	umcRes = mpg2d-&amp;gt;GetInfo(&amp;amp;vParams);&lt;BR /&gt;&lt;BR /&gt;	VDecParams.lpConvertInit-&amp;gt;SizeSource.width=vParams.info.clip_info.width;&lt;BR /&gt;	VDecParams.lpConvertInit-&amp;gt;SizeSource.height=vParams.info.clip_info.height;&lt;BR /&gt;	VDecParams.lpConvertInit-&amp;gt;SizeDest.width=vParams.info.clip_info.width;&lt;BR /&gt;	VDecParams.lpConvertInit-&amp;gt;SizeDest.height=vParams.info.clip_info.height;&lt;BR /&gt;&lt;BR /&gt;	dataOut.SetVideoParameters(vidW, vidH, UMC::YV12);&lt;BR /&gt;&lt;BR /&gt;	BYTE * pOut = (BYTE*)malloc(vidW*2*vidH);&lt;BR /&gt;	dataOut.SetDest(pOut);&lt;BR /&gt;	dataOut.SetPitch(vidW*2);&lt;BR /&gt;&lt;BR /&gt;	int cc=0;&lt;BR /&gt;	while (cc&amp;lt;150) {&lt;BR /&gt;        umcRes = mpg2d-&amp;gt;GetFrame(&amp;amp;dataIn, &amp;amp;dataOut);&lt;BR /&gt;        if (umcRes!=UMC::UMC_OK &amp;amp;&amp;amp; umcRes!=UMC::UMC_NOT_ENOUGH_DATA) break;&lt;BR /&gt;&lt;BR /&gt;        const Ipp8u* pSrcYUV[3] = {dataOut.m_lpDest[0], dataOut.m_lpDest[2], dataOut.m_lpDest[1],};&lt;BR /&gt;        int          stepYUV[3] = {dataOut.m_lPitch[0], dataOut.m_lPitch[2], dataOut.m_lPitch[1],};&lt;BR /&gt;        IppiSize     roiSize = {vidW, vidH};&lt;BR /&gt;&lt;BR /&gt;	//convert to YUY2&lt;BR /&gt;        ippiYCrCb420ToYCbCr422_8u_P3C2R(pSrcYUV, stepYUV, pOut, vidW*2, roiSize );&lt;BR /&gt;&lt;BR /&gt;        if (umcRes==0) {&lt;BR /&gt;            HANDLE fh2=CreateFile("YUY2.raw",GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL);&lt;BR /&gt;            WriteFile(fh2,pOut,vidW*2*vidH,&amp;amp;br,NULL);&lt;BR /&gt;            CloseHandle(fh2);&lt;BR /&gt;        }&lt;BR /&gt;        cc++;&lt;BR /&gt;&lt;BR /&gt;	//set to next data in buffer, just for testing&lt;BR /&gt;        vm_byte * tbuf=(vm_byte *)dataIn.GetDataPointer();&lt;BR /&gt;        dataIn.SetBufferPointer(tbuf,BSIZE);&lt;BR /&gt;	}&lt;BR /&gt;&lt;BR /&gt;	free(pOut);&lt;BR /&gt;&lt;BR /&gt;	mpg2d-&amp;gt;Close();&lt;BR /&gt;	delete mpg2d;&lt;BR /&gt;	free(memBuf);	&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Aug 2006 00:34:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913118#M14563</guid>
      <dc:creator>Boris_V_1</dc:creator>
      <dc:date>2006-08-29T00:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: MPEG2 decoder</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913119#M14564</link>
      <description>&lt;P&gt;The wrong thing is that you don't update data in input buffer.&lt;/P&gt;
&lt;P&gt;I suppose DWORD br stands for byte_read. Modifications are like the following.&lt;/P&gt;
&lt;P&gt;#define BUF_SIZE 1000000&lt;BR /&gt;#define MIN_SIZE 100000 // min size to start decode, otherwise read new portion&lt;/P&gt;
&lt;P&gt;...&lt;BR /&gt;ReadFile(fh,memBuf, BUF_SIZE, &amp;amp;br, NULL);&lt;BR /&gt;...&lt;BR /&gt;dataIn.SetDataSize(br);&lt;BR /&gt;...&lt;/P&gt;
&lt;P&gt;umcRes = Init...&lt;BR /&gt;if(umcRes != UMC::UMC_OK) error...&lt;BR /&gt;while(...&lt;/P&gt;
&lt;P&gt;int datasize = dataIn.GetDataSize();&lt;BR /&gt;if(datasize&lt;MIN_SIZE&gt;Ipp8u* dataptr = dataIn.GetDataPointer();&lt;BR /&gt;ippsCopy_8u(dataptr, memBuf, datasize); // copy tail to the head of buffer&lt;BR /&gt;ReadFile(fh,memBuf+datasize, BUF_SIZE-datasize, &amp;amp;br, NULL); // read to remained space&lt;BR /&gt;if(br==0 &amp;amp;&amp;amp; datasize &amp;lt; 16) break; // need more accurate EOF detection&lt;BR /&gt;dataIn.MoveDataPointer(memBuf - dataptr); // back to the start of the buffer&lt;BR /&gt;dataIn.SetDataSize(datasize + br); // remained + new read&lt;BR /&gt;GetFrame();&lt;BR /&gt;...&lt;BR /&gt;} // end of while&lt;/MIN_SIZE&gt;&lt;/P&gt;
&lt;P&gt;One more comment. You use pitch = vidW*2 in dataOut.SetPitch(vidW*2);&lt;BR /&gt;This method sets pitch for Y component, which is vidW. Other pithces are computed from the color format. Please check.&lt;/P&gt;
&lt;P&gt;Also you can try ColorInit.FormatDest = UMC::&lt;DIFFERENT format=""&gt;; This way you will not have to convert ownself.&lt;/DIFFERENT&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2006 02:27:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913119#M14564</guid>
      <dc:creator>Leonid_K_Intel</dc:creator>
      <dc:date>2006-08-30T02:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: MPEG2 decoder</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913120#M14565</link>
      <description>&lt;PRE&gt;Thanks for answer.&lt;BR /&gt;My code is similar, except I read whole buffer at start and&lt;BR /&gt;then just set dataIn pointer to next position in this buffer.&lt;BR /&gt;But the problem is still here. If MIN_SIZE is 100000 then frame is properly decoded,&lt;BR /&gt;but if it's 25000 only half of frame is decoded.&lt;BR /&gt;Not sure if this is bug or not, but decoder should return N&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;O&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;T&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;_&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;E&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;N&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;O&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;U&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;G&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;H&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;_&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;D&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;A&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;T&lt;SPAN style="color: Black; background-color: Yellow;"&gt;&lt;/SPAN&gt;A&lt;BR /&gt;until it has enough data to decode whole frame (it actually work like this, but then frame is not correctly decoded).&lt;BR /&gt;Anyway I'll just use bigger buffer for now.&lt;BR /&gt;Thanks for help.&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Sep 2006 01:42:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/MPEG2-decoder/m-p/913120#M14565</guid>
      <dc:creator>Boris_V_1</dc:creator>
      <dc:date>2006-09-01T01:42:46Z</dc:date>
    </item>
  </channel>
</rss>

