summaryrefslogtreecommitdiff
path: root/src/bin
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 /src/bin
parentd87de3a88da9a405a06e8d1e3b3d5d8b3e935ba2 (diff)
parentc423cc84e7be79051a7f9631fa26aa7d072361f2 (diff)
Merge pull request #548 from mayeut/master
Remove some warnings when building
Diffstat (limited to 'src/bin')
-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
6 files changed, 44 insertions, 53 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;