<?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 Re: UMC how to extract frames from MPEG2 video in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869703#M8789</link>
    <description>&lt;P&gt;I figured out the srcStep; it comes from m_lPitch member variable of UMC::VideoData. However, using &lt;/P&gt;&lt;FONT size="2"&gt;
&lt;P&gt;ippiYCbCr420ToRGB_8u_P3C3R(pSrcYUV, step, pOut, stepBytes, roiSize);&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;I'm still getting incorrect results: (&lt;A href="http://www.cs.ucf.edu/~aaved/out2.jpg"&gt;http://www.cs.ucf.edu/~aaved/out2.jpg&lt;/A&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;</description>
    <pubDate>Sun, 15 Apr 2007 03:17:07 GMT</pubDate>
    <dc:creator>ajambox-webpages</dc:creator>
    <dc:date>2007-04-15T03:17:07Z</dc:date>
    <item>
      <title>UMC how to extract frames from MPEG2 video</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869700#M8786</link>
      <description>&lt;P&gt;Hello, what I would like to do is extract frames from an MPEG2 video, eventually for use with OpenCV (, etc.) but right now I'm just writing to a PPM file. When I view the PPM file, however, the image is wrong (i.e., &lt;A href="http://www.cs.ucf.edu/~aaved/imgoutput.jpg"&gt;http://www.cs.ucf.edu/~aaved/imgoutput.jpg&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;My questions: How do you extract the image from the VideoData object (i.e., m_lpDest[...]). It seems the data is YUV420, however, the results from ippiYUV420ToRGB_8u_P3C3R are not correct; is this the correct function I should call? What is the 'srcStep' of the data in the VideoData.m_lpDest? (That is, the distance between starts of consecutive lines in the source image.)The image width?&lt;/P&gt;
&lt;P&gt;Also, what is the best way to advance the data in the VideoData buffer? Can I assume if I advance it the entire buffer length, that the buffer will contain only one frame (i.e., not 1.5 frames worth of data, etc.)&lt;/P&gt;
&lt;P&gt;Any comments would be much appreciated; I'm about out of ideas :) I've tried to keep this short, please let me know if I need to clarify something. &lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;PS, my save_ppm function correctly saves the results of an ippiImageJaehne_8u_C3R function call, so I don't think its the problem.&lt;/P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;My code:&lt;/P&gt;
&lt;P&gt;// #includes, etc.&lt;/P&gt;
&lt;P&gt;static void save_ppm (int width, int height, Ipp8u * buf, int num, int stepSize)&lt;BR /&gt;{&lt;BR /&gt; char filename[100];&lt;BR /&gt; FILE * ppmfile;&lt;/P&gt;
&lt;P&gt; sprintf (filename, "%d.ppm", num);&lt;BR /&gt; ppmfile = fopen (filename, "wb");&lt;BR /&gt; if (!ppmfile) {&lt;BR /&gt;fprintf (stderr, "Could not open file "%s".
", filename);&lt;BR /&gt;exit (1);&lt;BR /&gt; }&lt;BR /&gt; // P6 binary, and P3 ascii&lt;BR /&gt;fprintf (ppmfile, "P6
%d %d
255
", width, height);&lt;/P&gt;
&lt;P&gt;for (int i=0; i&lt;HEIGHT&gt; fwrite (&amp;amp;buf[i*stepSize], 3 * width, 1, ppmfile);&lt;BR /&gt;} // save_ppm &lt;/HEIGHT&gt;&lt;/P&gt;
&lt;P&gt;int _tmain(int argc, _TCHAR* argv[])&lt;BR /&gt;{&lt;/P&gt;
&lt;P&gt;ippStaticInit();&lt;/P&gt;
&lt;P&gt;char* fname;&lt;BR /&gt;vm_char* szFileName;&lt;/P&gt;
&lt;P&gt;fname = "c:\temp\SR436_M2U00037.MPG";&lt;BR /&gt;szFileName = VM_STRING(fname);&lt;/P&gt;
&lt;P&gt;UMC::FIOReader fr;&lt;BR /&gt;UMC::FileReaderParams frp;&lt;BR /&gt;UMC::Status umc_status;&lt;BR /&gt;UMC::MpegSplitterParams splParams;&lt;BR /&gt;UMC::SplitterInfospi;&lt;BR /&gt;UMC::MPEG2Splitter mpgSplitter;&lt;/P&gt;
&lt;P&gt;UMC::ColorSpaceConverter cc;&lt;BR /&gt;UMC::ColorConversionInfo cci;&lt;BR /&gt;&lt;BR /&gt;UMC::MediaDataEx md;&lt;BR /&gt;UMC::MPEG2VideoDecoder vd;&lt;BR /&gt;UMC::VideoDecoderParams vdp;&lt;/P&gt;
&lt;P&gt;vm_string_strcpy(frp.m_file_name, szFileName);&lt;BR /&gt;frp.m_portion_size = 0;&lt;/P&gt;
&lt;P&gt;umc_status = fr.Init(&amp;amp;frp);&lt;/P&gt;
&lt;P&gt;splParams.m_pDataReader = &amp;amp;fr;&lt;BR /&gt;splParams.m_lFlags = UMC::VIDEO_SPLITTER | UMC::FLAG_VSPL_VIDEO_FRAME_REQ;&lt;BR /&gt;&lt;BR /&gt;splParams.m_mediaData = &amp;amp;md;&lt;BR /&gt;&lt;BR /&gt;if ((umc_status = mpgSplitter.Init(splParams)) != UMC::UMC_OK) {&lt;BR /&gt;printf("
Error mpgSplitter.Init(): %d", umc_status);&lt;BR /&gt;exit(1);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;printf("
Init'd splitter");&lt;BR /&gt;&lt;BR /&gt;if (mpgSplitter.GetInfo(&amp;amp;spi) != UMC::UMC_OK) {&lt;BR /&gt;printf("
Error mpgSplitter.GetInfo()");&lt;BR /&gt;exit(1);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;printf
("
called splitter.GetInfo()");&lt;/P&gt;
&lt;P&gt;cci.FormatDest = UMC::YV12;&lt;BR /&gt;cci.SizeSource.width = spi.m_video_info.clip_info.width;&lt;BR /&gt;cci.SizeSource.height = spi.m_video_info.clip_info.height;&lt;BR /&gt;cci.SizeDest.height = spi.m_video_info.clip_info.width;&lt;BR /&gt;cci.SizeDest.width = spi.m_video_info.clip_info.height;&lt;BR /&gt;cci.lFlags = 1;&lt;BR /&gt;cci.lDeinterlace = 0;&lt;BR /&gt;cci.lInterpolation = UMC::FLAG_CCNV_CONVERT;&lt;/P&gt;
&lt;P&gt;vdp.info = spi.m_video_info;&lt;BR /&gt;vdp.cformat = UMC::YV12;&lt;BR /&gt;vdp.lFlags = 0;&lt;BR /&gt;//vdp.lFlags = UMC::FLAG_VDEC_COMPATIBLE | UMC::FLAG_VDEC_NO_PREVIEW | UMC::FLAG_VDEC_REORDER;&lt;BR /&gt;vdp.lpConverter = &amp;amp;cc;// Pointer to color converter&lt;BR /&gt;vdp.lpConvertInit = &amp;amp;cci;// ptr to structure w/ conversion info&lt;BR /&gt;vdp.uiLimitThreads = 1;&lt;BR /&gt;vdp.m_pData = &amp;amp;md;// Init'd MediaData buffer&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;if ((umc_status = vd.Init(&amp;amp;vdp)) != UMC::UMC_OK) {&lt;BR /&gt;printf("
Error Init'ing Video Decoder");&lt;BR /&gt;exit(1);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;printf("
Init'd video decoder");&lt;/P&gt;
&lt;P&gt;printf("
	File: %s", fname);&lt;BR /&gt;printf("
	Type: %s", VideoStreamTypeStr(spi.m_video_info.stream_type));&lt;BR /&gt;printf("
	Dims: %dx%d", spi.m_video_info.clip_info.width, spi.m_video_info.clip_info.height);&lt;BR /&gt;printf("
	Color: %s", ColorFormatStr(spi.m_video_info.color_format));&lt;BR /&gt;printf("
	Duration: %f", spi.m_video_info.duration / 60);&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;UMC::MJPEGVideoDecoder mjpeg_dec;&lt;BR /&gt;UMC::VideoData out;&lt;/P&gt;
&lt;P&gt;out.Init(spi.m_video_info.clip_info.width, spi.m_video_info.clip_info.height, spi.m_video_info.color_format);&lt;BR /&gt;out.SetColorFormat(UMC::YV12);&lt;/P&gt;
&lt;P&gt;unsigned int nframes = 0;&lt;/P&gt;
&lt;P&gt;umc_status = UMC::UMC_OK;&lt;BR /&gt;UMC::MediaData in;&lt;BR /&gt;UMC::FWVideoRender vr; // VideoRender to display decompressed video stream&lt;BR /&gt;UMC::VideoRenderParams video_params;&lt;/P&gt;
&lt;P&gt;video_params.color_format = spi.m_video_info.color_format;&lt;BR /&gt;video_params.info = spi.m_video_info.clip_info;&lt;/P&gt;
&lt;P&gt;if ((umc_status = vr.Init(&amp;amp;video_params)) != UMC::UMC_OK)&lt;BR /&gt;{&lt;BR /&gt;printf("
Error Init'ing video renderer %d", umc_status);&lt;BR /&gt;exit(1);&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;printf(" 
");&lt;BR /&gt;&lt;BR /&gt;IppiSize roiSize = {spi.m_video_info.clip_info.width, spi.m_video_info.clip_info.height};&lt;BR /&gt;int height = spi.m_video_info.clip_info.height;&lt;BR /&gt;int width = spi.m_video_info.clip_info.width;&lt;/P&gt;
&lt;P&gt;int stepBytes = height;&lt;BR /&gt;Ipp8u* pOut = ippiMalloc_8u_C3(width, height, &amp;amp;stepBytes);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;IppStatus stus;&lt;/P&gt;
&lt;P&gt;while (umc_status == UMC::UMC_OK || umc_status == UMC::UMC_NOT_ENOUGH_DATA)&lt;BR /&gt;{&lt;BR /&gt;umc_status = mpgSplitter.GetNextVideoData(&amp;amp;in);&lt;BR /&gt;if (umc_status != UMC::UMC_OK)&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;umc_status = vr.LockInputBuffer(&amp;amp;out);&lt;BR /&gt;if (umc_status != UMC::UMC_OK)&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;umc_status = vd.GetFrame(&amp;amp;in, &amp;amp;out);&lt;BR /&gt;if (umc_status != UMC::UMC_OK)// -998 - UMC_NOT_INITIALIZED -996 - not enough data&lt;BR /&gt;//break;&lt;BR /&gt;con
tinue;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;printf("
	Color: %s", ColorFormatStr(out.m_ColorFormat));&lt;BR /&gt;// prints out "YUV420"&lt;/P&gt;
&lt;P&gt;if (umc_status == UMC::UMC_OK)&lt;BR /&gt;{&lt;/P&gt;
&lt;P&gt;const Ipp8u* pSrcYUV[3] = {out.m_lpDest[0], out.m_lpDest[2], out.m_lpDest[1]};&lt;BR /&gt;&lt;BR /&gt;int step[3] = {width, width, width}; // I'm guessing its `width'&lt;/P&gt;
&lt;P&gt;stus = ippiYUV420ToRGB_8u_P3C3R(pSrcYUV, step, pOut, stepBytes, roiSize);&lt;BR /&gt;&lt;BR /&gt;save_ppm(720, 480, pOut, nframes, stepBytes);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;umc_status = vr.UnLockInputBuffer(&amp;amp;out);&lt;BR /&gt;if (umc_status != UMC::UMC_OK)&lt;BR /&gt;break;&lt;/P&gt;
&lt;P&gt;umc_status = vr.RenderFrame();&lt;BR /&gt;if (umc_status != UMC::UMC_OK)&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;nframes++;&lt;/P&gt;
&lt;P&gt;if (nframes == 10)&lt;BR /&gt;{&lt;BR /&gt;printf("
processed 10 frames...exiting...
");&lt;BR /&gt;exit(102);&lt;BR /&gt;}&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;} // while&lt;BR /&gt;&lt;BR /&gt;ippFree(pOut);&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2007 06:01:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869700#M8786</guid>
      <dc:creator>ajambox-webpages</dc:creator>
      <dc:date>2007-04-13T06:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: UMC how to extract frames from MPEG2 video</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869701#M8787</link>
      <description>What version of IPP and media sample do you use?</description>
      <pubDate>Fri, 13 Apr 2007 17:44:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869701#M8787</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2007-04-13T17:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: UMC how to extract frames from MPEG2 video</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869702#M8788</link>
      <description>&lt;P&gt;Intel Integrated Performance Primitives&lt;BR /&gt;ippcore-5.1.dll, 5.1.1 {5.1.133.240}, build date Dec 19 2006&lt;BR /&gt;ippsw7-5.1.dll, 5.1.1 {5.1.133.277}, build date Dec 19 2006&lt;BR /&gt;ippiw7-5.1.dll, 5.1.1 {5.1.133.275}, build date Dec 19 2006&lt;BR /&gt;ippjw7-5.1.dll, 5.1.1 {5.1.133.250}, build date Jun 17 2006&lt;BR /&gt;ippccw7-5.1.dll, 5.1.1 {5.1.133.181}, build date Jun 17 2006&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;and 5.1 Media sample. Compiler is MS Visual C++ 2005 w/ the service pack.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Apr 2007 14:40:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869702#M8788</guid>
      <dc:creator>ajambox-webpages</dc:creator>
      <dc:date>2007-04-14T14:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: UMC how to extract frames from MPEG2 video</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869703#M8789</link>
      <description>&lt;P&gt;I figured out the srcStep; it comes from m_lPitch member variable of UMC::VideoData. However, using &lt;/P&gt;&lt;FONT size="2"&gt;
&lt;P&gt;ippiYCbCr420ToRGB_8u_P3C3R(pSrcYUV, step, pOut, stepBytes, roiSize);&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;I'm still getting incorrect results: (&lt;A href="http://www.cs.ucf.edu/~aaved/out2.jpg"&gt;http://www.cs.ucf.edu/~aaved/out2.jpg&lt;/A&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;</description>
      <pubDate>Sun, 15 Apr 2007 03:17:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869703#M8789</guid>
      <dc:creator>ajambox-webpages</dc:creator>
      <dc:date>2007-04-15T03:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: UMC how to extract frames from MPEG2 video</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869704#M8790</link>
      <description>&lt;P&gt;Did you try code like this one?&lt;/P&gt;&lt;PRE&gt;&lt;FONT size="2"&gt;&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT color="#ff0000" size="2"&gt;&lt;P&gt;int step[3] = {&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; out.m_lPitch [0], out.m_lPitch [2],&lt;/FONT&gt;&lt;FONT color="#ff0000" size="2"&gt; &lt;/FONT&gt;&lt;FONT size="2"&gt;out.m_lPitch [1]&lt;/FONT&gt;&lt;FONT color="#ff0000" size="2"&gt;}; // I'm guessing its `width'&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt;&lt;P&gt;stus = ippiYUV420ToRGB_8u_P3C3R(pSrcYUV, step, pOut, stepBytes, roiSize);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;  Vladimir&lt;/P&gt;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2007 16:10:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/UMC-how-to-extract-frames-from-MPEG2-video/m-p/869704#M8790</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2007-04-19T16:10:11Z</dc:date>
    </item>
  </channel>
</rss>

