Merge pull request #5534 from Beep6581/cr3_cleanup

CR3 decoder cleanup and fixes
This commit is contained in:
Floessie
2019-12-07 11:57:36 +01:00
committed by GitHub
3 changed files with 2999 additions and 2876 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -184,12 +184,12 @@ public:
int32_t mdatHdrSize; int32_t mdatHdrSize;
// Not from header, but from datastream // Not from header, but from datastream
uint32_t MediaSize; uint32_t MediaSize;
INT64 MediaOffset; int64_t MediaOffset;
uint32_t MediaType; /* 1 -> /C/RAW, 2-> JPEG */ uint32_t MediaType; /* 1 -> /C/RAW, 2-> JPEG */
}; };
static constexpr size_t CRXTRACKS_MAXCOUNT = 16; static constexpr size_t CRXTRACKS_MAXCOUNT = 16;
crx_data_header_t crx_header[CRXTRACKS_MAXCOUNT]; crx_data_header_t crx_header[CRXTRACKS_MAXCOUNT];
int crx_track_selected; unsigned int crx_track_selected;
short CR3_CTMDtag; short CR3_CTMDtag;
}; };
protected: protected:
@@ -563,16 +563,16 @@ void nikon_14bit_load_raw(); // ported from LibRaw
// Canon CR3 support ported from LibRaw // Canon CR3 support ported from LibRaw
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void parse_canon_cr3(); void parse_canon_cr3();
void selectCRXTrack(short maxTrack); void selectCRXTrack(unsigned short maxTrack);
int parseCR3(unsigned long long oAtomList, int parseCR3(unsigned long long oAtomList,
unsigned long long szAtomList, short &nesting, unsigned long long szAtomList, short &nesting,
char *AtomNameStack, short &nTrack, short &TrackType); char *AtomNameStack, unsigned short &nTrack, short &TrackType);
int crxDecodePlane(void *p, uint32_t planeNumber); bool crxDecodePlane(void *p, uint32_t planeNumber);
void crxLoadDecodeLoop(void *img, int nPlanes); void crxLoadDecodeLoop(void *img, int nPlanes);
void crxConvertPlaneLineDf(void *p, int imageRow); void crxConvertPlaneLineDf(void *p, int imageRow);
void crxLoadFinalizeLoopE3(void *p, int planeHeight); void crxLoadFinalizeLoopE3(void *p, int planeHeight);
void crxLoadRaw(); void crxLoadRaw();
int crxParseImageHeader(uchar *cmp1TagData, int nTrack); bool crxParseImageHeader(uchar *cmp1TagData, unsigned int nTrack);
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
}; };

View File

@@ -56,28 +56,26 @@ IMFILE* fopen (const char* fname);
IMFILE* gfopen (const char* fname); IMFILE* gfopen (const char* fname);
IMFILE* fopen (unsigned* buf, int size); IMFILE* fopen (unsigned* buf, int size);
void fclose (IMFILE* f); void fclose (IMFILE* f);
inline int ftell (IMFILE* f) inline long ftell (IMFILE* f)
{ {
return f->pos; return f->pos;
} }
inline int feof (IMFILE* f) inline int feof (IMFILE* f)
{ {
return f->eof; return f->eof;
} }
inline void fseek (IMFILE* f, int p, int how) inline void fseek (IMFILE* f, long p, int how)
{ {
int fpos = f->pos; ssize_t fpos = f->pos;
if (how == SEEK_SET) { if (how == SEEK_SET) {
f->pos = p; f->pos = p;
} else if (how == SEEK_CUR) { } else if (how == SEEK_CUR) {
f->pos += p; f->pos += p;
} else if (how == SEEK_END) { } else if (how == SEEK_END) {
if(p <= 0 && -p <= f->size) { if (p <= 0 && -p <= f->size) {
f->pos = f->size + p; f->pos = f->size + p;
} }
return; return;