summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Darbois <mayeut@users.noreply.github.com>2015-07-26 02:42:41 +0200
committerMatthieu Darbois <mayeut@users.noreply.github.com>2015-07-26 02:42:41 +0200
commitdb9b3400e545f474bd4ab28e06cde2178fd3386b (patch)
tree98d92f8501df77e5510c69eb4db6f1fab20b9855
parentd87de3a88da9a405a06e8d1e3b3d5d8b3e935ba2 (diff)
parentc423cc84e7be79051a7f9631fa26aa7d072361f2 (diff)
Merge pull request #548 from mayeut/master
Remove some warnings when building
-rw-r--r--src/bin/jp2/convert.c11
-rw-r--r--src/bin/jp2/convertbmp.c5
-rw-r--r--src/bin/jp2/convertpng.c6
-rw-r--r--src/bin/jp2/converttif.c45
-rw-r--r--src/bin/jp2/opj_compress.c16
-rw-r--r--src/bin/jp2/opj_decompress.c14
-rw-r--r--src/lib/openjp2/cio.c4
-rw-r--r--src/lib/openjp2/j2k.c13
-rw-r--r--src/lib/openjp2/opj_includes.h12
-rw-r--r--src/lib/openjp2/opj_intmath.h2
-rw-r--r--src/lib/openjp2/pi.c2
-rw-r--r--src/lib/openjp2/tcd.c2
12 files changed, 62 insertions, 70 deletions
diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c
index 6f3e0a22..72e9e916 100644
--- a/src/bin/jp2/convert.c
+++ b/src/bin/jp2/convert.c
@@ -179,9 +179,9 @@ struct tga_header
static unsigned short get_ushort(unsigned short val) {
#ifdef OPJ_BIG_ENDIAN
- return( ((val & 0xff) << 8) + (val >> 8) );
+ return (unsigned short)(((val & 0xffU) << 8) | (val >> 8));
#else
- return( val );
+ return val;
#endif
}
@@ -267,10 +267,9 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
#ifdef OPJ_BIG_ENDIAN
-static INLINE int16_t swap16(int16_t x)
+static INLINE OPJ_UINT16 swap16(OPJ_UINT16 x)
{
- return((((u_int16_t)x & 0x00ffU) << 8) |
- (((u_int16_t)x & 0xff00U) >> 8));
+ return (OPJ_UINT16)(((x & 0x00ffU) << 8) | ((x & 0xff00U) >> 8));
}
#endif
@@ -278,7 +277,7 @@ static INLINE int16_t swap16(int16_t x)
static int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height,
OPJ_BOOL flip_image)
{
- unsigned short image_w, image_h, us0;
+ OPJ_UINT16 image_w, image_h, us0;
unsigned char uc0, image_type;
unsigned char pixel_depth, image_desc;
diff --git a/src/bin/jp2/convertbmp.c b/src/bin/jp2/convertbmp.c
index 78ca0329..9d779b39 100644
--- a/src/bin/jp2/convertbmp.c
+++ b/src/bin/jp2/convertbmp.c
@@ -440,7 +440,10 @@ static OPJ_BOOL bmp_read_info_header(FILE* IN, OPJ_BITMAPINFOHEADER* header)
header->biColorSpaceType |= (OPJ_UINT32)(getc(IN) << 16);
header->biColorSpaceType |= (OPJ_UINT32)(getc(IN) << 24);
- fread(&(header->biColorSpaceEP), 1U, sizeof(header->biColorSpaceEP), IN);
+ if (fread(&(header->biColorSpaceEP), 1U, sizeof(header->biColorSpaceEP), IN) != sizeof(header->biColorSpaceEP)) {
+ fprintf(stderr,"Error, can't read BMP header\n");
+ return OPJ_FALSE;
+ }
header->biRedGamma = (OPJ_UINT32)getc(IN);
header->biRedGamma |= (OPJ_UINT32)(getc(IN) << 8);
diff --git a/src/bin/jp2/convertpng.c b/src/bin/jp2/convertpng.c
index 5fe6dccc..f962f696 100644
--- a/src/bin/jp2/convertpng.c
+++ b/src/bin/jp2/convertpng.c
@@ -102,7 +102,7 @@ typedef void (* convert_XXx32s_C1R)(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_S
static void convert_1u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)8U); i+=8U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)( val >> 7);
pDst[i+1] = (OPJ_INT32)((val >> 6) & 0x1U);
@@ -141,7 +141,7 @@ static void convert_1u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T
static void convert_2u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)4U); i+=4U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)( val >> 6);
pDst[i+1] = (OPJ_INT32)((val >> 4) & 0x3U);
@@ -165,7 +165,7 @@ static void convert_2u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T
static void convert_4u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)2U); i+=2U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)1U); i+=2U) {
OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)(val >> 4);
pDst[i+1] = (OPJ_INT32)(val & 0xFU);
diff --git a/src/bin/jp2/converttif.c b/src/bin/jp2/converttif.c
index e8ff38f3..5000c0fe 100644
--- a/src/bin/jp2/converttif.c
+++ b/src/bin/jp2/converttif.c
@@ -61,7 +61,7 @@ typedef void (* tif_32stoX)(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T le
static void tif_32sto1u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)8U); i+=8U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
@@ -109,7 +109,7 @@ static void tif_32sto1u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length
static void tif_32sto2u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)4U); i+=4U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
@@ -137,7 +137,7 @@ static void tif_32sto2u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length
static void tif_32sto4u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)2U); i+=2U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)1U); i+=2U) {
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
@@ -153,7 +153,7 @@ static void tif_32sto4u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length
static void tif_32sto6u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)4U); i+=4U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
@@ -195,7 +195,7 @@ static void tif_32sto8u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length
static void tif_32sto10u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)4U); i+=4U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
@@ -233,7 +233,7 @@ static void tif_32sto10u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
static void tif_32sto12u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)2U); i+=2U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)1U); i+=2U) {
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
@@ -251,7 +251,7 @@ static void tif_32sto12u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T lengt
static void tif_32sto14u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)4U); i+=4U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
OPJ_UINT32 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2];
@@ -515,7 +515,7 @@ typedef void (* tif_Xto32s)(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T le
static void tif_1uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)8U); i+=8U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)7U); i+=8U) {
OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)( val >> 7);
pDst[i+1] = (OPJ_INT32)((val >> 6) & 0x1U);
@@ -554,7 +554,7 @@ static void tif_1uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length
static void tif_2uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)4U); i+=4U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)( val >> 6);
pDst[i+1] = (OPJ_INT32)((val >> 4) & 0x3U);
@@ -578,7 +578,7 @@ static void tif_2uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length
static void tif_4uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)2U); i+=2U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)1U); i+=2U) {
OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)(val >> 4);
pDst[i+1] = (OPJ_INT32)(val & 0xFU);
@@ -591,7 +591,7 @@ static void tif_4uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length
static void tif_6uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)4U); i+=4U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
OPJ_UINT32 val0 = *pSrc++;
OPJ_UINT32 val1 = *pSrc++;
OPJ_UINT32 val2 = *pSrc++;
@@ -626,7 +626,7 @@ static void tif_8uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length
static void tif_10uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)4U); i+=4U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
OPJ_UINT32 val0 = *pSrc++;
OPJ_UINT32 val1 = *pSrc++;
OPJ_UINT32 val2 = *pSrc++;
@@ -658,7 +658,7 @@ static void tif_10uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
static void tif_12uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)2U); i+=2U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)1U); i+=2U) {
OPJ_UINT32 val0 = *pSrc++;
OPJ_UINT32 val1 = *pSrc++;
OPJ_UINT32 val2 = *pSrc++;
@@ -675,7 +675,7 @@ static void tif_12uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
static void tif_14uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
OPJ_SIZE_T i;
- for (i = 0; i < (length & -(OPJ_SIZE_T)4U); i+=4U) {
+ for (i = 0; i < (length & ~(OPJ_SIZE_T)3U); i+=4U) {
OPJ_UINT32 val0 = *pSrc++;
OPJ_UINT32 val1 = *pSrc++;
OPJ_UINT32 val2 = *pSrc++;
@@ -708,21 +708,7 @@ static void tif_14uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T lengt
}
}
}
-#if 0
-static void tif_16uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
-{
- OPJ_SIZE_T i;
- for (i = 0; i < length; i++) {
- OPJ_UINT32 val0 = *pSrc++;
- OPJ_UINT32 val1 = *pSrc++;
-#ifdef OPJ_BIG_ENDIAN
- pDst[i] = (OPJ_INT32)((val0 << 8) | val1);
-#else
- pDst[i] = (OPJ_INT32)((val1 << 8) | val0);
-#endif
- }
-}
-#else
+
/* seems that libtiff decodes this to machine endianness */
static void tif_16uto32s(const OPJ_UINT16* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{
@@ -731,7 +717,6 @@ static void tif_16uto32s(const OPJ_UINT16* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T len
pDst[i] = pSrc[i];
}
}
-#endif
typedef void (* convert_32s_CXPX)(const OPJ_INT32* pSrc, OPJ_INT32* const* pDst, OPJ_SIZE_T length);
static void convert_32s_C1P1(const OPJ_INT32* pSrc, OPJ_INT32* const* pDst, OPJ_SIZE_T length)
diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c
index 68cc0469..92e2a1e8 100644
--- a/src/bin/jp2/opj_compress.c
+++ b/src/bin/jp2/opj_compress.c
@@ -624,7 +624,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
wrong = OPJ_TRUE;
}
if (!wrong) {
- int i;
+ int compno;
int lastdx = 1;
int lastdy = 1;
raw_cp->rawWidth = width;
@@ -633,10 +633,10 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
raw_cp->rawBitDepth = bitdepth;
raw_cp->rawSigned = raw_signed;
raw_cp->rawComps = (raw_comp_cparameters_t*) malloc(((OPJ_UINT32)(ncomp))*sizeof(raw_comp_cparameters_t));
- for (i = 0; i < ncomp && !wrong; i++) {
+ for (compno = 0; compno < ncomp && !wrong; compno++) {
if (substr2 == NULL) {
- raw_cp->rawComps[i].dx = lastdx;
- raw_cp->rawComps[i].dy = lastdy;
+ raw_cp->rawComps[compno].dx = lastdx;
+ raw_cp->rawComps[compno].dy = lastdy;
} else {
int dx,dy;
sep = strchr(substr2,':');
@@ -644,16 +644,16 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
if (sscanf(substr2, "%dx%d", &dx, &dy) == 2) {
lastdx = dx;
lastdy = dy;
- raw_cp->rawComps[i].dx = dx;
- raw_cp->rawComps[i].dy = dy;
+ raw_cp->rawComps[compno].dx = dx;
+ raw_cp->rawComps[compno].dy = dy;
substr2 = NULL;
} else {
wrong = OPJ_TRUE;
}
} else {
if (sscanf(substr2, "%dx%d:%s", &dx, &dy, substr2) == 3) {
- raw_cp->rawComps[i].dx = dx;
- raw_cp->rawComps[i].dy = dy;
+ raw_cp->rawComps[compno].dx = dx;
+ raw_cp->rawComps[compno].dy = dy;
} else {
wrong = OPJ_TRUE;
}
diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c
index 78f56a6a..6630e2ef 100644
--- a/src/bin/jp2/opj_decompress.c
+++ b/src/bin/jp2/opj_decompress.c
@@ -507,11 +507,11 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* parse the command line */
int totlen, c;
opj_option_t long_option[]={
- {"ImgDir", REQ_ARG, NULL ,'y'},
- {"OutFor", REQ_ARG, NULL ,'O'},
- {"force-rgb", NO_ARG, &(parameters->force_rgb), 1},
- {"upsample", NO_ARG, &(parameters->upsample), 1},
- {"split-pnm", NO_ARG, &(parameters->split_pnm), 1}
+ {"ImgDir", REQ_ARG, NULL,'y'},
+ {"OutFor", REQ_ARG, NULL,'O'},
+ {"force-rgb", NO_ARG, NULL, 1},
+ {"upsample", NO_ARG, NULL, 1},
+ {"split-pnm", NO_ARG, NULL, 1}
};
const char optlist[] = "i:o:r:l:x:d:t:p:"
@@ -522,6 +522,10 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
#endif /* USE_JPWL */
/* <<UniPG */
"h" ;
+
+ long_option[2].flag = &(parameters->force_rgb);
+ long_option[3].flag = &(parameters->upsample);
+ long_option[4].flag = &(parameters->split_pnm);
totlen=sizeof(long_option);
opj_reset_options_reading();
img_fol->set_out_format = 0;
diff --git a/src/lib/openjp2/cio.c b/src/lib/openjp2/cio.c
index c6f778c9..b2f6405f 100644
--- a/src/lib/openjp2/cio.c
+++ b/src/lib/openjp2/cio.c
@@ -302,7 +302,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
p_stream->m_current_data = p_stream->m_stored_data;
}
- while(1){
+ for (;;) {
/* we should read less than a chunk -> read a chunk */
if (p_size < p_stream->m_buffer_size) {
/* we should do an actual read on the media */
@@ -382,7 +382,7 @@ OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream,
return (OPJ_SIZE_T)-1;
}
- while(1) {
+ for (;;) {
l_remaining_bytes = p_stream->m_buffer_size - p_stream->m_bytes_in_buffer;
/* we have more memory than required */
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c
index 5a2e795e..bdc56959 100644
--- a/src/lib/openjp2/j2k.c
+++ b/src/lib/openjp2/j2k.c
@@ -5007,7 +5007,7 @@ static OPJ_BOOL opj_j2k_read_unk ( opj_j2k_t *p_j2k,
opj_event_msg(p_manager, EVT_WARNING, "Unknown marker\n");
- while(1) {
+ for (;;) {
/* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer*/
if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
@@ -7609,7 +7609,6 @@ static void opj_j2k_cp_destroy (opj_cp_t *p_cp)
{
OPJ_UINT32 l_nb_tiles;
opj_tcp_t * l_current_tile = 00;
- OPJ_UINT32 i;
if (p_cp == 00)
{
@@ -7617,10 +7616,11 @@ static void opj_j2k_cp_destroy (opj_cp_t *p_cp)
}
if (p_cp->tcps != 00)
{
+ OPJ_UINT32 i;
l_current_tile = p_cp->tcps;
l_nb_tiles = p_cp->th * p_cp->tw;
- for (i = 0; i < l_nb_tiles; ++i)
+ for (i = 0U; i < l_nb_tiles; ++i)
{
opj_j2k_tcp_destroy(l_current_tile);
++l_current_tile;
@@ -7763,7 +7763,6 @@ OPJ_BOOL opj_j2k_read_tile_header( opj_j2k_t * p_j2k,
OPJ_UINT32 l_marker_size;
const opj_dec_memory_marker_handler_t * l_marker_handler = 00;
opj_tcp_t * l_tcp = NULL;
- OPJ_UINT32 l_nb_tiles;
/* preconditions */
assert(p_stream != 00);
@@ -7975,8 +7974,8 @@ OPJ_BOOL opj_j2k_read_tile_header( opj_j2k_t * p_j2k,
/* FIXME DOC ???*/
if ( ! p_j2k->m_specific_param.m_decoder.m_can_decode) {
+ OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
l_tcp = p_j2k->m_cp.tcps + p_j2k->m_current_tile_number;
- l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
while( (p_j2k->m_current_tile_number < l_nb_tiles) && (l_tcp->m_data == 00) ) {
++p_j2k->m_current_tile_number;
@@ -9538,7 +9537,7 @@ static OPJ_BOOL opj_j2k_decode_tiles ( opj_j2k_t *p_j2k,
}
l_max_data_size = 1000;
- while (OPJ_TRUE) {
+ for (;;) {
if (! opj_j2k_read_tile_header( p_j2k,
&l_current_tile_no,
&l_data_size,
@@ -9661,7 +9660,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k,
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
}
- while (OPJ_TRUE) {
+ for (;;) {
if (! opj_j2k_read_tile_header( p_j2k,
&l_current_tile_no,
&l_data_size,
diff --git a/src/lib/openjp2/opj_includes.h b/src/lib/openjp2/opj_includes.h
index d8faede0..0d8c1ff3 100644
--- a/src/lib/openjp2/opj_includes.h
+++ b/src/lib/openjp2/opj_includes.h
@@ -123,7 +123,7 @@
/* MSVC before 2013 and Borland C do not have lrintf */
#if defined(_MSC_VER)
#include <intrin.h>
-static INLINE long lrintf(float f){
+static INLINE long opj_lrintf(float f){
#ifdef _M_X64
return _mm_cvt_ss2si(_mm_load_ss(&f));
@@ -139,10 +139,8 @@ static INLINE long lrintf(float f){
return i;
#endif
}
-#endif
-
-#if defined(__BORLANDC__)
-static INLINE long lrintf(float f) {
+#elif defined(__BORLANDC__)
+static INLINE long opj_lrintf(float f) {
#ifdef _M_X64
return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
#else
@@ -156,6 +154,10 @@ static INLINE long lrintf(float f) {
return i;
#endif
}
+#else
+static INLINE long opj_lrintf(float f) {
+ return lrintf(f);
+}
#endif
diff --git a/src/lib/openjp2/opj_intmath.h b/src/lib/openjp2/opj_intmath.h
index 8fa89c03..188a09a7 100644
--- a/src/lib/openjp2/opj_intmath.h
+++ b/src/lib/openjp2/opj_intmath.h
@@ -87,7 +87,7 @@ static INLINE OPJ_UINT32 opj_uint_max(OPJ_UINT32 a, OPJ_UINT32 b) {
*/
static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b) {
OPJ_UINT64 sum = (OPJ_UINT64)a + (OPJ_UINT64)b;
- return -(OPJ_UINT32)(sum >> 32) | (OPJ_UINT32)sum;
+ return (OPJ_UINT32)(-(OPJ_INT32)(sum >> 32)) | (OPJ_UINT32)sum;
}
/**
diff --git a/src/lib/openjp2/pi.c b/src/lib/openjp2/pi.c
index e32aaeb0..1697bcbc 100644
--- a/src/lib/openjp2/pi.c
+++ b/src/lib/openjp2/pi.c
@@ -1430,7 +1430,7 @@ opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
l_step_l = l_max_res * l_step_r;
/* set values for first packet iterator*/
- l_pi->tp_on = p_cp->m_specific_param.m_enc.m_tp_on;
+ l_pi->tp_on = (OPJ_BYTE)p_cp->m_specific_param.m_enc.m_tp_on;
l_current_pi = l_pi;
/* memory allocation for include*/
diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c
index 1caa615f..08d97c78 100644
--- a/src/lib/openjp2/tcd.c
+++ b/src/lib/openjp2/tcd.c
@@ -1775,7 +1775,7 @@ static OPJ_BOOL opj_tcd_dc_level_shift_decode ( opj_tcd_t *p_tcd )
for (j=0;j<l_height;++j) {
for (i = 0; i < l_width; ++i) {
OPJ_FLOAT32 l_value = *((OPJ_FLOAT32 *) l_current_ptr);
- *l_current_ptr = opj_int_clamp((OPJ_INT32)lrintf(l_value) + l_tccp->m_dc_level_shift, l_min, l_max); ;
+ *l_current_ptr = opj_int_clamp((OPJ_INT32)opj_lrintf(l_value) + l_tccp->m_dc_level_shift, l_min, l_max); ;
++l_current_ptr;
}
l_current_ptr += l_stride;