Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for big-endian CPUs #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions TinyEXIF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ namespace Tools {

namespace TinyEXIF {

uint32_t const _ONE32 = 1;
bool const IS_LITTLE_ENDIAN = (reinterpret_cast<uint8_t const*>(&_ONE32))[0] == 1;

enum JPEG_MARKERS {
JM_START = 0xFF,
JM_SOF0 = 0xC0,
Expand Down Expand Up @@ -945,10 +948,10 @@ int EXIFInfo::parseFromEXIFSegment(const uint8_t* buf, unsigned len) {
return PARSE_CORRUPT_DATA;
bool alignIntel;
if (buf[offs] == 'I' && buf[offs+1] == 'I')
alignIntel = true; // 1: Intel byte alignment
alignIntel = IS_LITTLE_ENDIAN; // 1: Intel byte alignment
else
if (buf[offs] == 'M' && buf[offs+1] == 'M')
alignIntel = false; // 0: Motorola byte alignment
alignIntel = !IS_LITTLE_ENDIAN; // 0: Motorola byte alignment
else
return PARSE_UNKNOWN_BYTEALIGN;
EntryParser parser(buf, len, offs, alignIntel);
Expand Down