Merge pull request #5645 from jia-kai:master
This commit is contained in:
commit
9ab59fb22e
@ -42,6 +42,13 @@
|
|||||||
|
|
||||||
#include "jpeg_exif.hpp"
|
#include "jpeg_exif.hpp"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
class ExifParsingError {
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -66,12 +73,16 @@ ExifReader::~ExifReader()
|
|||||||
*/
|
*/
|
||||||
bool ExifReader::parse()
|
bool ExifReader::parse()
|
||||||
{
|
{
|
||||||
m_exif = getExif();
|
try {
|
||||||
if( !m_exif.empty() )
|
m_exif = getExif();
|
||||||
{
|
if( !m_exif.empty() )
|
||||||
return true;
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (ExifParsingError&) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -147,6 +158,9 @@ std::map<int, ExifEntry_t > ExifReader::getExif()
|
|||||||
|
|
||||||
case APP1: //actual Exif Marker
|
case APP1: //actual Exif Marker
|
||||||
exifSize = getFieldSize(f);
|
exifSize = getFieldSize(f);
|
||||||
|
if (exifSize <= offsetToTiffHeader) {
|
||||||
|
throw ExifParsingError();
|
||||||
|
}
|
||||||
m_data.resize( exifSize - offsetToTiffHeader );
|
m_data.resize( exifSize - offsetToTiffHeader );
|
||||||
fseek(f, static_cast<long>( offsetToTiffHeader ), SEEK_CUR);
|
fseek(f, static_cast<long>( offsetToTiffHeader ), SEEK_CUR);
|
||||||
count = fread( &m_data[0], sizeof( unsigned char ), exifSize - offsetToTiffHeader, f );
|
count = fread( &m_data[0], sizeof( unsigned char ), exifSize - offsetToTiffHeader, f );
|
||||||
@ -401,6 +415,9 @@ std::string ExifReader::getString(const size_t offset) const
|
|||||||
*/
|
*/
|
||||||
uint16_t ExifReader::getU16(const size_t offset) const
|
uint16_t ExifReader::getU16(const size_t offset) const
|
||||||
{
|
{
|
||||||
|
if (offset + 1 >= m_data.size())
|
||||||
|
throw ExifParsingError();
|
||||||
|
|
||||||
if( m_format == INTEL )
|
if( m_format == INTEL )
|
||||||
{
|
{
|
||||||
return m_data[offset] + ( m_data[offset + 1] << 8 );
|
return m_data[offset] + ( m_data[offset + 1] << 8 );
|
||||||
@ -416,6 +433,9 @@ uint16_t ExifReader::getU16(const size_t offset) const
|
|||||||
*/
|
*/
|
||||||
uint32_t ExifReader::getU32(const size_t offset) const
|
uint32_t ExifReader::getU32(const size_t offset) const
|
||||||
{
|
{
|
||||||
|
if (offset + 3 >= m_data.size())
|
||||||
|
throw ExifParsingError();
|
||||||
|
|
||||||
if( m_format == INTEL )
|
if( m_format == INTEL )
|
||||||
{
|
{
|
||||||
return m_data[offset] +
|
return m_data[offset] +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user