Skip to content

Commit

Permalink
Merge pull request #548 from mayeut/master
Browse files Browse the repository at this point in the history
Remove some warnings when building
  • Loading branch information
mayeut committed Jul 26, 2015
2 parents d87de3a + c423cc8 commit db9b340
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 70 deletions.
11 changes: 5 additions & 6 deletions src/bin/jp2/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
Expand Down Expand Up @@ -267,18 +267,17 @@ 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

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;

Expand Down
5 changes: 4 additions & 1 deletion src/bin/jp2/convertbmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/bin/jp2/convertpng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
45 changes: 15 additions & 30 deletions src/bin/jp2/converttif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];

Expand All @@ -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];
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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];

Expand All @@ -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];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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++;
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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++;
Expand All @@ -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++;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions src/bin/jp2/opj_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -633,27 +633,27 @@ 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,':');
if (sep == NULL) {
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;
}
Expand Down
14 changes: 9 additions & 5 deletions src/bin/jp2/opj_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/openjp2/cio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
13 changes: 6 additions & 7 deletions src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -7609,18 +7609,18 @@ 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)
{
return;
}
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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit db9b340

Please sign in to comment.