Tackle warnings
This commit is contained in:
parent
f42efdb2e0
commit
6039f1e300
@ -1,4 +1,24 @@
|
|||||||
/* -*- C++ -*-
|
/*
|
||||||
|
* This file is part of RawTherapee.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 RawTherapee development team
|
||||||
|
*
|
||||||
|
* RawTherapee is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RawTherapee is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Code adapted from ART
|
||||||
|
/*
|
||||||
*
|
*
|
||||||
* This file is part of ART.
|
* This file is part of ART.
|
||||||
*
|
*
|
||||||
@ -16,16 +36,6 @@
|
|||||||
* along with ART. If not, see <https://www.gnu.org/licenses/>.
|
* along with ART. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "dcraw.h"
|
|
||||||
#ifdef __GNUC__ // silence warning
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Code adapted from libraw
|
// Code adapted from libraw
|
||||||
/* -*- C++ -*-
|
/* -*- C++ -*-
|
||||||
* Copyright 2019 LibRaw LLC (info@libraw.org)
|
* Copyright 2019 LibRaw LLC (info@libraw.org)
|
||||||
@ -41,13 +51,17 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
#include "dcraw.h"
|
||||||
|
|
||||||
void DCraw::parse_canon_cr3()
|
void DCraw::parse_canon_cr3()
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
unsigned long long szAtomList;
|
unsigned long long szAtomList;
|
||||||
short nesting = -1;
|
short nesting = -1;
|
||||||
short nTrack = -1;
|
unsigned short nTrack = 0;
|
||||||
short TrackType;
|
short TrackType;
|
||||||
char AtomNameStack[128];
|
char AtomNameStack[128];
|
||||||
strcpy(make, "Canon");
|
strcpy(make, "Canon");
|
||||||
@ -61,14 +75,14 @@ void DCraw::parse_canon_cr3()
|
|||||||
|
|
||||||
#define LIBRAW_CRXTRACKS_MAXCOUNT RT_canon_CR3_data.CRXTRACKS_MAXCOUNT
|
#define LIBRAW_CRXTRACKS_MAXCOUNT RT_canon_CR3_data.CRXTRACKS_MAXCOUNT
|
||||||
|
|
||||||
void DCraw::selectCRXTrack(short maxTrack)
|
void DCraw::selectCRXTrack(unsigned short maxTrack)
|
||||||
{
|
{
|
||||||
if (maxTrack < 0)
|
if (maxTrack < 0)
|
||||||
return;
|
return;
|
||||||
INT64 bitcounts[LIBRAW_CRXTRACKS_MAXCOUNT], maxbitcount = 0;
|
INT64 bitcounts[LIBRAW_CRXTRACKS_MAXCOUNT], maxbitcount = 0;
|
||||||
uint32_t maxjpegbytes = 0;
|
uint32_t maxjpegbytes = 0;
|
||||||
memset(bitcounts, 0, sizeof(bitcounts));
|
memset(bitcounts, 0, sizeof(bitcounts));
|
||||||
for (int i = 0; i <= maxTrack && i < LIBRAW_CRXTRACKS_MAXCOUNT; i++)
|
for (unsigned int i = 0; i <= maxTrack && i < LIBRAW_CRXTRACKS_MAXCOUNT; i++)
|
||||||
{
|
{
|
||||||
CanonCR3Data::crx_data_header_t *d = &RT_canon_CR3_data.crx_header[i];
|
CanonCR3Data::crx_data_header_t *d = &RT_canon_CR3_data.crx_header[i];
|
||||||
if (d->MediaType == 1) // RAW
|
if (d->MediaType == 1) // RAW
|
||||||
@ -89,18 +103,21 @@ void DCraw::selectCRXTrack(short maxTrack)
|
|||||||
}
|
}
|
||||||
if (maxbitcount < 8)
|
if (maxbitcount < 8)
|
||||||
return;
|
return;
|
||||||
int framei = -1, framecnt = 0;
|
bool has_framei = false;
|
||||||
for (int i = 0; i <= maxTrack && i < LIBRAW_CRXTRACKS_MAXCOUNT; i++)
|
unsigned int framei = 0, framecnt = 0;
|
||||||
|
for (unsigned int i = 0; i <= maxTrack && i < LIBRAW_CRXTRACKS_MAXCOUNT; i++)
|
||||||
{
|
{
|
||||||
if (bitcounts[i] == maxbitcount)
|
if (bitcounts[i] == maxbitcount)
|
||||||
{
|
{
|
||||||
if (framecnt <= shot_select)
|
if (framecnt <= shot_select) {
|
||||||
|
has_framei = true;
|
||||||
framei = i;
|
framei = i;
|
||||||
|
}
|
||||||
framecnt++;
|
framecnt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is_raw = framecnt;
|
is_raw = framecnt;
|
||||||
if (framei >= 0 && framei < LIBRAW_CRXTRACKS_MAXCOUNT)
|
if (has_framei && framei < LIBRAW_CRXTRACKS_MAXCOUNT)
|
||||||
{
|
{
|
||||||
CanonCR3Data::crx_data_header_t *d =
|
CanonCR3Data::crx_data_header_t *d =
|
||||||
&RT_canon_CR3_data.crx_header[framei];
|
&RT_canon_CR3_data.crx_header[framei];
|
||||||
@ -129,7 +146,7 @@ void DCraw::selectCRXTrack(short maxTrack)
|
|||||||
|
|
||||||
int tiff_idx = -1;
|
int tiff_idx = -1;
|
||||||
INT64 tpixels = 0;
|
INT64 tpixels = 0;
|
||||||
for (int i = 0; i < tiff_nifds; i++)
|
for (unsigned int i = 0; i < tiff_nifds; i++)
|
||||||
if (INT64(tiff_ifd[i].height) * INT64(tiff_ifd[i].height) > tpixels)
|
if (INT64(tiff_ifd[i].height) * INT64(tiff_ifd[i].height) > tpixels)
|
||||||
{
|
{
|
||||||
tpixels = INT64(tiff_ifd[i].height) * INT64(tiff_ifd[i].height);
|
tpixels = INT64(tiff_ifd[i].height) * INT64(tiff_ifd[i].height);
|
||||||
@ -147,7 +164,7 @@ void DCraw::selectCRXTrack(short maxTrack)
|
|||||||
(get4() != 0x00000008))
|
(get4() != 0x00000008))
|
||||||
int DCraw::parseCR3(unsigned long long oAtomList,
|
int DCraw::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)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Atom starts with 4 bytes for Atom size and 4 bytes containing Atom name
|
Atom starts with 4 bytes for Atom size and 4 bytes containing Atom name
|
||||||
@ -159,8 +176,8 @@ int DCraw::parseCR3(unsigned long long oAtomList,
|
|||||||
*/
|
*/
|
||||||
const char UIID_Canon[17] =
|
const char UIID_Canon[17] =
|
||||||
"\x85\xc0\xb6\x87\x82\x0f\x11\xe0\x81\x11\xf4\xce\x46\x2b\x6a\x48";
|
"\x85\xc0\xb6\x87\x82\x0f\x11\xe0\x81\x11\xf4\xce\x46\x2b\x6a\x48";
|
||||||
const char UIID_Preview[17] =
|
// const char UIID_Preview[17] =
|
||||||
"\xea\xf4\x2b\x5e\x1c\x98\x4b\x88\xb9\xfb\xb7\xdc\x40\x6e\x4d\x16";
|
// "\xea\xf4\x2b\x5e\x1c\x98\x4b\x88\xb9\xfb\xb7\xdc\x40\x6e\x4d\x16";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
AtomType = 0 - unknown: "unk."
|
AtomType = 0 - unknown: "unk."
|
||||||
@ -168,7 +185,7 @@ int DCraw::parseCR3(unsigned long long oAtomList,
|
|||||||
AtomType = 2 - leaf atom: "leaf"
|
AtomType = 2 - leaf atom: "leaf"
|
||||||
AtomType = 3 - can be container, can be leaf: "both"
|
AtomType = 3 - can be container, can be leaf: "both"
|
||||||
*/
|
*/
|
||||||
const char sAtomeType[4][5] = {"unk.", "cont", "leaf", "both"};
|
// const char sAtomeType[4][5] = {"unk.", "cont", "leaf", "both"};
|
||||||
short AtomType;
|
short AtomType;
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
@ -256,7 +273,8 @@ int DCraw::parseCR3(unsigned long long oAtomList,
|
|||||||
|
|
||||||
const char sHandlerType[5][5] = {"unk.", "soun", "vide", "hint", "meta"};
|
const char sHandlerType[5][5] = {"unk.", "soun", "vide", "hint", "meta"};
|
||||||
|
|
||||||
int c, err = 0;
|
unsigned int c;
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
ushort tL; // Atom length represented in 4 or 8 bytes
|
ushort tL; // Atom length represented in 4 or 8 bytes
|
||||||
char nmAtom[5]; // Atom name
|
char nmAtom[5]; // Atom name
|
||||||
@ -268,14 +286,14 @@ int DCraw::parseCR3(unsigned long long oAtomList,
|
|||||||
char UIID[16];
|
char UIID[16];
|
||||||
uchar CMP1[36];
|
uchar CMP1[36];
|
||||||
char HandlerType[5], MediaFormatID[5];
|
char HandlerType[5], MediaFormatID[5];
|
||||||
unsigned ImageWidth, ImageHeight;
|
// unsigned ImageWidth, ImageHeight;
|
||||||
long relpos_inDir, relpos_inBox;
|
long relpos_inDir, relpos_inBox;
|
||||||
unsigned szItem, Tag, lTag;
|
unsigned szItem, Tag, lTag;
|
||||||
ushort tItem;
|
ushort tItem;
|
||||||
|
|
||||||
nmAtom[0] = MediaFormatID[0] = nmAtom[4] = MediaFormatID[4] = '\0';
|
nmAtom[0] = MediaFormatID[0] = nmAtom[4] = MediaFormatID[4] = '\0';
|
||||||
strcpy(HandlerType, sHandlerType[0]);
|
strcpy(HandlerType, sHandlerType[0]);
|
||||||
ImageWidth = ImageHeight = 0U;
|
// ImageWidth = ImageHeight = 0U;
|
||||||
oAtom = oAtomList;
|
oAtom = oAtomList;
|
||||||
nesting++;
|
nesting++;
|
||||||
if (nesting > 31)
|
if (nesting > 31)
|
||||||
@ -450,8 +468,8 @@ int DCraw::parseCR3(unsigned long long oAtomList,
|
|||||||
}
|
}
|
||||||
#define current_track RT_canon_CR3_data.crx_header[nTrack]
|
#define current_track RT_canon_CR3_data.crx_header[nTrack]
|
||||||
|
|
||||||
ImageWidth = get2();
|
// ImageWidth = get2();
|
||||||
ImageHeight = get2();
|
// ImageHeight = get2();
|
||||||
}
|
}
|
||||||
else if (!strcmp(AtomNameStack, "moovtrakmdiaminfstblstsdCRAW"))
|
else if (!strcmp(AtomNameStack, "moovtrakmdiaminfstblstsdCRAW"))
|
||||||
{
|
{
|
||||||
@ -813,7 +831,7 @@ static inline void crxFillBuffer(CrxBitstream *bitStrm)
|
|||||||
|
|
||||||
libraw_inline int crxBitstreamGetZeros(CrxBitstream *bitStrm)
|
libraw_inline int crxBitstreamGetZeros(CrxBitstream *bitStrm)
|
||||||
{
|
{
|
||||||
uint32_t bitData = bitStrm->bitData;
|
// uint32_t bitData = bitStrm->bitData;
|
||||||
uint32_t nonZeroBit = 0;
|
uint32_t nonZeroBit = 0;
|
||||||
uint64_t nextData = 0;
|
uint64_t nextData = 0;
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
@ -2049,7 +2067,7 @@ int crxIdwt53FilterTransform(CrxPlaneComp *comp, uint32_t level)
|
|||||||
lineBufH1[i] = lineBufL1[i] + ((delta + lineBufH0[i]) >> 1);
|
lineBufH1[i] = lineBufL1[i] + ((delta + lineBufH0[i]) >> 1);
|
||||||
lineBufH2[i] = delta;
|
lineBufH2[i] = delta;
|
||||||
}
|
}
|
||||||
if (wavelet->curLine >= wavelet->height - 3 && wavelet->height & 1)
|
if (wavelet->curLine >= wavelet->height - 3 && (wavelet->height & 1))
|
||||||
{
|
{
|
||||||
wavelet->curH += 3;
|
wavelet->curH += 3;
|
||||||
wavelet->curLine += 3;
|
wavelet->curLine += 3;
|
||||||
@ -2644,10 +2662,9 @@ int crxReadSubbandHeaders(crx_data_header_t *hdr, CrxImage *img, CrxTile *tile,
|
|||||||
|
|
||||||
if (!img->subbandCount)
|
if (!img->subbandCount)
|
||||||
return 0;
|
return 0;
|
||||||
int32_t curSubband = 0;
|
|
||||||
int32_t subbandOffset = 0;
|
int32_t subbandOffset = 0;
|
||||||
band = comp->subBands;
|
band = comp->subBands;
|
||||||
for (int curSubband = 0; curSubband < img->subbandCount; curSubband++, band++)
|
for (unsigned int curSubband = 0; curSubband < img->subbandCount; curSubband++, band++)
|
||||||
{
|
{
|
||||||
if (*mdatSize < 0xC)
|
if (*mdatSize < 0xC)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2683,7 +2700,7 @@ int crxReadSubbandHeaders(crx_data_header_t *hdr, CrxImage *img, CrxTile *tile,
|
|||||||
int crxReadImageHeaders(crx_data_header_t *hdr, CrxImage *img, uint8_t *mdatPtr,
|
int crxReadImageHeaders(crx_data_header_t *hdr, CrxImage *img, uint8_t *mdatPtr,
|
||||||
uint32_t mdatSize)
|
uint32_t mdatSize)
|
||||||
{
|
{
|
||||||
int nTiles = img->tileRows * img->tileCols;
|
unsigned int nTiles = img->tileRows * img->tileCols;
|
||||||
|
|
||||||
if (!nTiles)
|
if (!nTiles)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2702,7 +2719,7 @@ int crxReadImageHeaders(crx_data_header_t *hdr, CrxImage *img, uint8_t *mdatPtr,
|
|||||||
CrxPlaneComp *comps = (CrxPlaneComp *)(tile + nTiles);
|
CrxPlaneComp *comps = (CrxPlaneComp *)(tile + nTiles);
|
||||||
CrxSubband *bands = (CrxSubband *)(comps + img->nPlanes * nTiles);
|
CrxSubband *bands = (CrxSubband *)(comps + img->nPlanes * nTiles);
|
||||||
|
|
||||||
for (int curTile = 0; curTile < nTiles; curTile++, tile++)
|
for (unsigned int curTile = 0; curTile < nTiles; curTile++, tile++)
|
||||||
{
|
{
|
||||||
tile->tileFlag = 0; // tile neighbouring flags
|
tile->tileFlag = 0; // tile neighbouring flags
|
||||||
tile->tileNumber = curTile;
|
tile->tileNumber = curTile;
|
||||||
@ -2780,7 +2797,7 @@ int crxReadImageHeaders(crx_data_header_t *hdr, CrxImage *img, uint8_t *mdatPtr,
|
|||||||
uint8_t *dataPtr = mdatPtr;
|
uint8_t *dataPtr = mdatPtr;
|
||||||
CrxTile *tile = img->tiles;
|
CrxTile *tile = img->tiles;
|
||||||
|
|
||||||
for (int curTile = 0; curTile < nTiles; curTile++, tile++)
|
for (unsigned int curTile = 0; curTile < nTiles; curTile++, tile++)
|
||||||
{
|
{
|
||||||
if (dataSize < 0xC)
|
if (dataSize < 0xC)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2997,8 +3014,7 @@ void DCraw::crxLoadFinalizeLoopE3(void *p, int planeHeight)
|
|||||||
void DCraw::crxLoadRaw()
|
void DCraw::crxLoadRaw()
|
||||||
{
|
{
|
||||||
CrxImage img;
|
CrxImage img;
|
||||||
if (RT_canon_CR3_data.crx_track_selected < 0 ||
|
if (RT_canon_CR3_data.crx_track_selected >=
|
||||||
RT_canon_CR3_data.crx_track_selected >=
|
|
||||||
LIBRAW_CRXTRACKS_MAXCOUNT)
|
LIBRAW_CRXTRACKS_MAXCOUNT)
|
||||||
derror();
|
derror();
|
||||||
crx_data_header_t hdr =
|
crx_data_header_t hdr =
|
||||||
@ -3052,9 +3068,9 @@ void DCraw::crxLoadRaw()
|
|||||||
crxFreeImageData(&img);
|
crxFreeImageData(&img);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DCraw::crxParseImageHeader(uchar *cmp1TagData, int nTrack)
|
int DCraw::crxParseImageHeader(uchar *cmp1TagData, unsigned int nTrack)
|
||||||
{
|
{
|
||||||
if (nTrack < 0 || nTrack >= LIBRAW_CRXTRACKS_MAXCOUNT)
|
if (nTrack >= LIBRAW_CRXTRACKS_MAXCOUNT)
|
||||||
return -1;
|
return -1;
|
||||||
if (!cmp1TagData)
|
if (!cmp1TagData)
|
||||||
return -1;
|
return -1;
|
||||||
@ -3099,8 +3115,8 @@ int DCraw::crxParseImageHeader(uchar *cmp1TagData, int nTrack)
|
|||||||
if (hdr->nBits != 8)
|
if (hdr->nBits != 8)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (hdr->nPlanes != 4 || hdr->f_width & 1 || hdr->f_height & 1 ||
|
else if (hdr->nPlanes != 4 || (hdr->f_width & 1) || (hdr->f_height & 1) ||
|
||||||
hdr->tileWidth & 1 || hdr->tileHeight & 1 || hdr->cfaLayout > 3u ||
|
(hdr->tileWidth & 1) || (hdr->tileHeight & 1) || hdr->cfaLayout > 3 ||
|
||||||
(hdr->encType && hdr->encType != 1 && hdr->encType != 3) ||
|
(hdr->encType && hdr->encType != 1 && hdr->encType != 3) ||
|
||||||
hdr->nBits == 8)
|
hdr->nBits == 8)
|
||||||
return -1;
|
return -1;
|
||||||
@ -3118,7 +3134,3 @@ int DCraw::crxParseImageHeader(uchar *cmp1TagData, int nTrack)
|
|||||||
#undef _constrain
|
#undef _constrain
|
||||||
#undef libraw_inline
|
#undef libraw_inline
|
||||||
#undef LIBRAW_CRXTRACKS_MAXCOUNT
|
#undef LIBRAW_CRXTRACKS_MAXCOUNT
|
||||||
|
|
||||||
#ifdef __GNUC__ // silence warning
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#endif
|
|
||||||
|
@ -188,7 +188,7 @@ public:
|
|||||||
};
|
};
|
||||||
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:
|
||||||
@ -562,16 +562,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);
|
int 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);
|
int crxParseImageHeader(uchar *cmp1TagData, unsigned int nTrack);
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user