Intel® Integrated Performance Primitives
Community support and discussions relating to developing high-performance vision, signal, security, and storage applications.
6621 Discussions

Intel IPP 5.3 JPEG Parse Bug and Fixed Code

johnt
Beginner
112 Views

CBitStreamInput::CheckByte(...) should fill the buffer when it exceeds the buffer length, and then only return an error if there still is not space.

Otherwise, you will get incorrect parse failures on boundary conditions when parsing an APP14 and possibly other blocks.

Cheers.

Here's the full, fixed function we implemented:

JERRCODE CBitStreamInput::CheckByte(

int pos, int* byte)

{

if(m_currPos + pos >= m_DataLen)

{

JERRCODE jerr = FillBuffer();

if(JPEG_OK != jerr)

return jerr;

if(m_currPos + pos >= m_DataLen)

return JPEG_ERR_INTERNAL;

}

*byte = m_pData[m_currPos + pos];

return JPEG_OK;

}

// CBitStreamInput::CheckByte()

0 Kudos
1 Reply
Vladimir_Dudnik
Employee
112 Views

Hi John,

That might work in your case, but I would recommend to the following fix for that issue:

1. seek up to requested position 'pos' with Seek method. If that fail - most probably requested position is outside of file or JPEG memory buffer.

2. Call FillBuffer method, to obtain missed data

3. return byte at postion 0 (which now is desired 'pos')

That will give you opportunity to check bytes on long distances.

Regards,
Vladimir

Reply