<?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 h264 decoder exceptions in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772963#M924</link>
    <description>Hi Max,&lt;BR /&gt;Can you tell me which version of IPP you are using?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Naveen Gv</description>
    <pubDate>Thu, 12 Aug 2010 10:59:44 GMT</pubDate>
    <dc:creator>Naveen_G_Intel</dc:creator>
    <dc:date>2010-08-12T10:59:44Z</dc:date>
    <item>
      <title>h264 decoder exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772961#M922</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I'm using IPP 6.1.5.054. I've took h264 decoder from IPP examples and integrated it into my project.&lt;BR /&gt;H264 encoder works fine and produces correct output (have tested it with h264 reference decoder).&lt;BR /&gt;&lt;BR /&gt;The problem is when I pass that stream to h264 decoder. After 3-4 frames are feeded to it, it starts throwing exceptions and decompressed video gets corrupted.&lt;BR /&gt;&lt;BR /&gt;Here is the part of code where I'm initializing decoder and decoding frames:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[cpp]H264Source::H264Source()
{
	if(!ipp_init_done) {
		ipp_init_done = true;
		ippStaticInit();
	}
	last_buffer = NULL;
	wnd = NULL;
	graph = NULL;
	renderer = NULL;
	source = NULL;
	active = false;
	decoder_initialized = false;
	own_last_buffer = false;
	video_vflip = false;
	
	decoder = new UMC::H264VideoDecoder();
	params = new UMC::H264VideoDecoderParams();
	
	decoder_mutex = CreateMutex(NULL, FALSE, NULL);
	last_buffer_mutex = CreateMutex(NULL, FALSE, NULL);
}

/*virtual*/ bool
H264Source::source_frame_output(char **buf, int *len)
{
	if(!active)
		return true;

	VIDEOINFO *vi = (VIDEOINFO *)media_type.pbFormat;
	BITMAPINFOHEADER *bi = &amp;amp;vi-&amp;gt;bmiHeader;

	char *fbuf = NULL;
	int flen = 0;

	// returns the exact video buffer as created by IPP H.264 Encoder
	if(!buffer_get(&amp;amp;fbuf, &amp;amp;flen))
		return false;

	if(flen == 0)
		return true;

	UMC::MediaData src;
	src.Reset();
	src.SetTime(frame_counter + 1 / (10000000 / vi-&amp;gt;AvgTimePerFrame));
	src.SetBufferPointer((Ipp8u *)fbuf, flen);
	src.SetDataSize(flen);

	if(decoder_initialized == false) {
		WaitForSingleObject(decoder_mutex, INFINITE);
		int st = UMC::UMC_ERR_FAILED;
		UMC::H264VideoDecoderParams par;
		if((fbuf[4] &amp;amp; 0x1f) == 7) {
			params-&amp;gt;numThreads = 1;
			params-&amp;gt;info.stream_type = UMC::H264_VIDEO;
			params-&amp;gt;lFlags = 0;
			params-&amp;gt;m_pData = &amp;amp;src;
			
			st = decoder-&amp;gt;Initparams;
			if(st == UMC::UMC_OK) {
				st = decoder-&amp;gt;GetInfo(&amp;amp;par);
				if(st != UMC::UMC_OK) {
					decoder-&amp;gt;Close();
					log_printf(LOG_INFO, "H264Source::source_frame_output(%08x) init decoder video params failed: %d", decoder, st);
				}
			} else {
				log_printf(LOG_INFO, "H264Source::source_frame_output(%08x) init decoder video failed: %d", decoder, st);
			}
		} else {
			log_printf(LOG_INFO, "H264Source::source_frame_output(%08x) init decoder video: skipping non SPS frame", decoder);
		}
		if(st == UMC::UMC_OK) {
			decoder_initialized = true;
			log_printf(LOG_INFO, "H264Source::source_frame_output(%08x) init decoder video %dx%d", decoder, par.info.clip_info.width, par.info.clip_info.height);
		}
		ReleaseMutex(decoder_mutex);
		
		src.Close();
		buffer_free(fbuf);
		return true;
	}

	UMC::VideoData dst;
	dst.Init(vid_info.bmiHeader.biWidth, vid_info.bmiHeader.biHeight, 1, 8);
	dst.SetColorFormat(UMC::RGB24);
	dst.Reset();
	dst.SetBufferPointer((Ipp8u *)*buf, *len);

	WaitForSingleObject(decoder_mutex, INFINITE);

	int st = decoder-&amp;gt;GetFrame(&amp;amp;src, &amp;amp;dst);

	ReleaseMutex(decoder_mutex);
	
	src.Close();
	buffer_free(fbuf);
	
	if(st != UMC::UMC_OK &amp;amp;&amp;amp; st != UMC::UMC_ERR_NOT_ENOUGH_DATA) {
		*len = 0;
		log_printf(LOG_DEBUG, "H264Source decoder %08x finished with %d", decoder, st);
		return false;
	}
	
	size_t dlen = dst.GetDataSize();
//
// ***** If I uncomment this code decoder usually goes on for about an hour before it starts giving exceptions *****
//
//	if(dlen == 0) {
//		// try to force frame output
//		WaitForSingleObject(decoder_mutex, INFINITE);
//		st = decoder-&amp;gt;GetFrame(NULL, &amp;amp;dst);
//		ReleaseMutex(decoder_mutex);
//		if(st != UMC::UMC_OK &amp;amp;&amp;amp; st != UMC::UMC_ERR_NOT_ENOUGH_DATA) {
//			log_printf(LOG_DEBUG, "H264Source decoder %08x finished with %d", decoder, st);
//			return false;
//		}
//		dlen = dst.GetDataSize();
//	}

	if(dlen &amp;gt;= *len) {
		frame_counter++;
		*len = dlen;
	} else {
		*len = 0;
	}
	dst.Close();

	return true;
}
[/cpp]&lt;/PRE&gt; &lt;BR /&gt;There is piece of code that is commented out which forces frame output from decoder (usually it buffers them before output) and if I uncomment that, decoder goes on for an hour before throwing exceptions.&lt;BR /&gt;&lt;BR /&gt;I've tried to debug exception and have found this:&lt;BR /&gt;The exception is thrown because ippiDecodeExpGolombOne_H264_1u32s() is trying to parse bad golomb value, which is called from some macroblock decoding/parsing method, and have noticed that pointer that is passed to ippiDecodeExpGolombOne_H264_1u32s() is 4 bytes before end of macroblock buffer, and I suppose ippiDecodeExpGolombOne_H264_1u32s() overflows because it's reading non golomb data.&lt;BR /&gt;&lt;BR /&gt;I've thought that stream gets corrupted because it doesn't makes a copy of buffer that is passed in, so I've tried omiting calling Close() on src and free() it's buffer, but except memory leaks it didn't change a thing.&lt;BR /&gt;&lt;BR /&gt;Can you please help me?&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;Max&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Jul 2010 12:56:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772961#M922</guid>
      <dc:creator>maxrd2</dc:creator>
      <dc:date>2010-07-27T12:56:30Z</dc:date>
    </item>
    <item>
      <title>h264 decoder exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772962#M923</link>
      <description>is there anyone who can help me with this please?</description>
      <pubDate>Wed, 04 Aug 2010 12:56:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772962#M923</guid>
      <dc:creator>maxrd2</dc:creator>
      <dc:date>2010-08-04T12:56:05Z</dc:date>
    </item>
    <item>
      <title>h264 decoder exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772963#M924</link>
      <description>Hi Max,&lt;BR /&gt;Can you tell me which version of IPP you are using?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Naveen Gv</description>
      <pubDate>Thu, 12 Aug 2010 10:59:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772963#M924</guid>
      <dc:creator>Naveen_G_Intel</dc:creator>
      <dc:date>2010-08-12T10:59:44Z</dc:date>
    </item>
    <item>
      <title>h264 decoder exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772964#M925</link>
      <description>Hi Naveen,

sorry for my slow reply..
Version I'm using is 6.1.5.054
But same is happening with 6.1.2

best regards
 Max</description>
      <pubDate>Mon, 06 Sep 2010 08:26:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772964#M925</guid>
      <dc:creator>maxrd2</dc:creator>
      <dc:date>2010-09-06T08:26:33Z</dc:date>
    </item>
    <item>
      <title>h264 decoder exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772965#M926</link>
      <description>Was there a resolution here?&lt;DIV&gt;I appear to be getting the same problem trying to decode a H264 stream from the Polycom phone.&lt;/DIV&gt;</description>
      <pubDate>Wed, 23 Nov 2011 00:09:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772965#M926</guid>
      <dc:creator>CraigC</dc:creator>
      <dc:date>2011-11-23T00:09:37Z</dc:date>
    </item>
    <item>
      <title>h264 decoder exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772966#M927</link>
      <description>Please, any help would be appricated here...&lt;DIV&gt;I am using IPP version 6.1.137.763, the specific problem is ocurring in umc_h264_bitstream_inlines.h, line 495.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;PRE&gt;[bash]inline
Ipp32s H264Bitstream::GetVLCElement(bool bIsSigned)
{
    Ipp32s sval = 0;

    IppStatus ippRes = ippiDecodeExpGolombOne_H264_1u32s(&amp;amp;m_pbs, &amp;amp;m_bitOffset, &amp;amp;sval, bIsSigned);

    if (ippStsNoErr &amp;gt; ippRes)
        throw h264_exception(UMC_ERR_INVALID_STREAM);

    return sval;

}[/bash]&lt;/PRE&gt; &lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;ippResis -5.&lt;/DIV&gt;&lt;DIV&gt;I can supply wireshark traces of the stream from the phone etc. if need be.&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 24 Nov 2011 18:42:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772966#M927</guid>
      <dc:creator>CraigC</dc:creator>
      <dc:date>2011-11-24T18:42:44Z</dc:date>
    </item>
    <item>
      <title>h264 decoder exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772967#M928</link>
      <description>Is there any reason for the lack of response here, have I asked the question in a confusing or vauge manner?&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 29 Nov 2011 20:44:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772967#M928</guid>
      <dc:creator>CraigC</dc:creator>
      <dc:date>2011-11-29T20:44:46Z</dc:date>
    </item>
    <item>
      <title>h264 decoder exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772968#M929</link>
      <description>We had changed behaviour of this function in IPP7.0.2 to skip very long codes without error. So update should help you with this problem.</description>
      <pubDate>Mon, 05 Dec 2011 07:51:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/h264-decoder-exceptions/m-p/772968#M929</guid>
      <dc:creator>Pavel_V_Intel</dc:creator>
      <dc:date>2011-12-05T07:51:27Z</dc:date>
    </item>
  </channel>
</rss>

