- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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()
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page