Community
cancel
Showing results for 
Search instead for 
Did you mean: 
johnt
Beginner
34 Views

Intel IPP 5.3 JPEG Parse Bug and Fixed Code

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
34 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