Remove some warnings when building

Update #442
This commit is contained in:
mayeut 2015-07-26 02:41:39 +02:00
parent d87de3a88d
commit c423cc84e7
12 changed files with 62 additions and 70 deletions

View File

@ -179,9 +179,9 @@ struct tga_header
static unsigned short get_ushort(unsigned short val) { static unsigned short get_ushort(unsigned short val) {
#ifdef OPJ_BIG_ENDIAN #ifdef OPJ_BIG_ENDIAN
return( ((val & 0xff) << 8) + (val >> 8) ); return (unsigned short)(((val & 0xffU) << 8) | (val >> 8));
#else #else
return( val ); return val;
#endif #endif
} }
@ -267,10 +267,9 @@ static int tga_readheader(FILE *fp, unsigned int *bits_per_pixel,
#ifdef OPJ_BIG_ENDIAN #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) | return (OPJ_UINT16)(((x & 0x00ffU) << 8) | ((x & 0xff00U) >> 8));
(((u_int16_t)x & 0xff00U) >> 8));
} }
#endif #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, static int tga_writeheader(FILE *fp, int bits_per_pixel, int width, int height,
OPJ_BOOL flip_image) 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 uc0, image_type;
unsigned char pixel_depth, image_desc; unsigned char pixel_depth, image_desc;

View File

@ -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) << 16);
header->biColorSpaceType |= (OPJ_UINT32)(getc(IN) << 24); 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);
header->biRedGamma |= (OPJ_UINT32)(getc(IN) << 8); header->biRedGamma |= (OPJ_UINT32)(getc(IN) << 8);

View File

@ -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) static void convert_1u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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++; OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)( val >> 7); pDst[i+0] = (OPJ_INT32)( val >> 7);
pDst[i+1] = (OPJ_INT32)((val >> 6) & 0x1U); 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) static void convert_2u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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++; OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)( val >> 6); pDst[i+0] = (OPJ_INT32)( val >> 6);
pDst[i+1] = (OPJ_INT32)((val >> 4) & 0x3U); 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) static void convert_4u32s_C1R(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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++; OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)(val >> 4); pDst[i+0] = (OPJ_INT32)(val >> 4);
pDst[i+1] = (OPJ_INT32)(val & 0xFU); pDst[i+1] = (OPJ_INT32)(val & 0xFU);

View File

@ -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) static void tif_32sto1u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1]; OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2]; 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) static void tif_32sto2u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1]; OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2]; 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) static void tif_32sto4u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1]; 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) static void tif_32sto6u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1]; OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2]; 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) static void tif_32sto10u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1]; OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2]; 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) static void tif_32sto12u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1]; 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) static void tif_32sto14u(const OPJ_INT32* pSrc, OPJ_BYTE* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 src0 = (OPJ_UINT32)pSrc[i+0];
OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1]; OPJ_UINT32 src1 = (OPJ_UINT32)pSrc[i+1];
OPJ_UINT32 src2 = (OPJ_UINT32)pSrc[i+2]; 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) static void tif_1uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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++; OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)( val >> 7); pDst[i+0] = (OPJ_INT32)( val >> 7);
pDst[i+1] = (OPJ_INT32)((val >> 6) & 0x1U); 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) static void tif_2uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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++; OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)( val >> 6); pDst[i+0] = (OPJ_INT32)( val >> 6);
pDst[i+1] = (OPJ_INT32)((val >> 4) & 0x3U); 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) static void tif_4uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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++; OPJ_UINT32 val = *pSrc++;
pDst[i+0] = (OPJ_INT32)(val >> 4); pDst[i+0] = (OPJ_INT32)(val >> 4);
pDst[i+1] = (OPJ_INT32)(val & 0xFU); 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) static void tif_6uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 val0 = *pSrc++;
OPJ_UINT32 val1 = *pSrc++; OPJ_UINT32 val1 = *pSrc++;
OPJ_UINT32 val2 = *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) static void tif_10uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 val0 = *pSrc++;
OPJ_UINT32 val1 = *pSrc++; OPJ_UINT32 val1 = *pSrc++;
OPJ_UINT32 val2 = *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) static void tif_12uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 val0 = *pSrc++;
OPJ_UINT32 val1 = *pSrc++; OPJ_UINT32 val1 = *pSrc++;
OPJ_UINT32 val2 = *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) static void tif_14uto32s(const OPJ_BYTE* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length)
{ {
OPJ_SIZE_T i; 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 val0 = *pSrc++;
OPJ_UINT32 val1 = *pSrc++; OPJ_UINT32 val1 = *pSrc++;
OPJ_UINT32 val2 = *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 */ /* seems that libtiff decodes this to machine endianness */
static void tif_16uto32s(const OPJ_UINT16* pSrc, OPJ_INT32* pDst, OPJ_SIZE_T length) 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]; pDst[i] = pSrc[i];
} }
} }
#endif
typedef void (* convert_32s_CXPX)(const OPJ_INT32* pSrc, OPJ_INT32* const* pDst, OPJ_SIZE_T length); 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) static void convert_32s_C1P1(const OPJ_INT32* pSrc, OPJ_INT32* const* pDst, OPJ_SIZE_T length)

View File

@ -624,7 +624,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
wrong = OPJ_TRUE; wrong = OPJ_TRUE;
} }
if (!wrong) { if (!wrong) {
int i; int compno;
int lastdx = 1; int lastdx = 1;
int lastdy = 1; int lastdy = 1;
raw_cp->rawWidth = width; 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->rawBitDepth = bitdepth;
raw_cp->rawSigned = raw_signed; raw_cp->rawSigned = raw_signed;
raw_cp->rawComps = (raw_comp_cparameters_t*) malloc(((OPJ_UINT32)(ncomp))*sizeof(raw_comp_cparameters_t)); 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) { if (substr2 == NULL) {
raw_cp->rawComps[i].dx = lastdx; raw_cp->rawComps[compno].dx = lastdx;
raw_cp->rawComps[i].dy = lastdy; raw_cp->rawComps[compno].dy = lastdy;
} else { } else {
int dx,dy; int dx,dy;
sep = strchr(substr2,':'); 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) { if (sscanf(substr2, "%dx%d", &dx, &dy) == 2) {
lastdx = dx; lastdx = dx;
lastdy = dy; lastdy = dy;
raw_cp->rawComps[i].dx = dx; raw_cp->rawComps[compno].dx = dx;
raw_cp->rawComps[i].dy = dy; raw_cp->rawComps[compno].dy = dy;
substr2 = NULL; substr2 = NULL;
} else { } else {
wrong = OPJ_TRUE; wrong = OPJ_TRUE;
} }
} else { } else {
if (sscanf(substr2, "%dx%d:%s", &dx, &dy, substr2) == 3) { if (sscanf(substr2, "%dx%d:%s", &dx, &dy, substr2) == 3) {
raw_cp->rawComps[i].dx = dx; raw_cp->rawComps[compno].dx = dx;
raw_cp->rawComps[i].dy = dy; raw_cp->rawComps[compno].dy = dy;
} else { } else {
wrong = OPJ_TRUE; wrong = OPJ_TRUE;
} }

View File

@ -507,11 +507,11 @@ int parse_cmdline_decoder(int argc, char **argv, opj_decompress_parameters *para
/* parse the command line */ /* parse the command line */
int totlen, c; int totlen, c;
opj_option_t long_option[]={ opj_option_t long_option[]={
{"ImgDir", REQ_ARG, NULL ,'y'}, {"ImgDir", REQ_ARG, NULL,'y'},
{"OutFor", REQ_ARG, NULL ,'O'}, {"OutFor", REQ_ARG, NULL,'O'},
{"force-rgb", NO_ARG, &(parameters->force_rgb), 1}, {"force-rgb", NO_ARG, NULL, 1},
{"upsample", NO_ARG, &(parameters->upsample), 1}, {"upsample", NO_ARG, NULL, 1},
{"split-pnm", NO_ARG, &(parameters->split_pnm), 1} {"split-pnm", NO_ARG, NULL, 1}
}; };
const char optlist[] = "i:o:r:l:x:d:t:p:" 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 */ #endif /* USE_JPWL */
/* <<UniPG */ /* <<UniPG */
"h" ; "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); totlen=sizeof(long_option);
opj_reset_options_reading(); opj_reset_options_reading();
img_fol->set_out_format = 0; img_fol->set_out_format = 0;

View File

@ -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; p_stream->m_current_data = p_stream->m_stored_data;
} }
while(1){ for (;;) {
/* we should read less than a chunk -> read a chunk */ /* we should read less than a chunk -> read a chunk */
if (p_size < p_stream->m_buffer_size) { if (p_size < p_stream->m_buffer_size) {
/* we should do an actual read on the media */ /* 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; return (OPJ_SIZE_T)-1;
} }
while(1) { for (;;) {
l_remaining_bytes = p_stream->m_buffer_size - p_stream->m_bytes_in_buffer; l_remaining_bytes = p_stream->m_buffer_size - p_stream->m_bytes_in_buffer;
/* we have more memory than required */ /* we have more memory than required */

View File

@ -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"); 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*/ /* 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) { 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"); 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_UINT32 l_nb_tiles;
opj_tcp_t * l_current_tile = 00; opj_tcp_t * l_current_tile = 00;
OPJ_UINT32 i;
if (p_cp == 00) if (p_cp == 00)
{ {
@ -7617,10 +7616,11 @@ static void opj_j2k_cp_destroy (opj_cp_t *p_cp)
} }
if (p_cp->tcps != 00) if (p_cp->tcps != 00)
{ {
OPJ_UINT32 i;
l_current_tile = p_cp->tcps; l_current_tile = p_cp->tcps;
l_nb_tiles = p_cp->th * p_cp->tw; 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); opj_j2k_tcp_destroy(l_current_tile);
++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; OPJ_UINT32 l_marker_size;
const opj_dec_memory_marker_handler_t * l_marker_handler = 00; const opj_dec_memory_marker_handler_t * l_marker_handler = 00;
opj_tcp_t * l_tcp = NULL; opj_tcp_t * l_tcp = NULL;
OPJ_UINT32 l_nb_tiles;
/* preconditions */ /* preconditions */
assert(p_stream != 00); assert(p_stream != 00);
@ -7975,8 +7974,8 @@ OPJ_BOOL opj_j2k_read_tile_header( opj_j2k_t * p_j2k,
/* FIXME DOC ???*/ /* FIXME DOC ???*/
if ( ! p_j2k->m_specific_param.m_decoder.m_can_decode) { 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_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) ) { while( (p_j2k->m_current_tile_number < l_nb_tiles) && (l_tcp->m_data == 00) ) {
++p_j2k->m_current_tile_number; ++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; l_max_data_size = 1000;
while (OPJ_TRUE) { for (;;) {
if (! opj_j2k_read_tile_header( p_j2k, if (! opj_j2k_read_tile_header( p_j2k,
&l_current_tile_no, &l_current_tile_no,
&l_data_size, &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; p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
} }
while (OPJ_TRUE) { for (;;) {
if (! opj_j2k_read_tile_header( p_j2k, if (! opj_j2k_read_tile_header( p_j2k,
&l_current_tile_no, &l_current_tile_no,
&l_data_size, &l_data_size,

View File

@ -123,7 +123,7 @@
/* MSVC before 2013 and Borland C do not have lrintf */ /* MSVC before 2013 and Borland C do not have lrintf */
#if defined(_MSC_VER) #if defined(_MSC_VER)
#include <intrin.h> #include <intrin.h>
static INLINE long lrintf(float f){ static INLINE long opj_lrintf(float f){
#ifdef _M_X64 #ifdef _M_X64
return _mm_cvt_ss2si(_mm_load_ss(&f)); return _mm_cvt_ss2si(_mm_load_ss(&f));
@ -139,10 +139,8 @@ static INLINE long lrintf(float f){
return i; return i;
#endif #endif
} }
#endif #elif defined(__BORLANDC__)
static INLINE long opj_lrintf(float f) {
#if defined(__BORLANDC__)
static INLINE long lrintf(float f) {
#ifdef _M_X64 #ifdef _M_X64
return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
#else #else
@ -156,6 +154,10 @@ static INLINE long lrintf(float f) {
return i; return i;
#endif #endif
} }
#else
static INLINE long opj_lrintf(float f) {
return lrintf(f);
}
#endif #endif

View File

@ -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) { static INLINE OPJ_UINT32 opj_uint_adds(OPJ_UINT32 a, OPJ_UINT32 b) {
OPJ_UINT64 sum = (OPJ_UINT64)a + (OPJ_UINT64)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;
} }
/** /**

View File

@ -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; l_step_l = l_max_res * l_step_r;
/* set values for first packet iterator*/ /* 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; l_current_pi = l_pi;
/* memory allocation for include*/ /* memory allocation for include*/

View File

@ -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 (j=0;j<l_height;++j) {
for (i = 0; i < l_width; ++i) { for (i = 0; i < l_width; ++i) {
OPJ_FLOAT32 l_value = *((OPJ_FLOAT32 *) l_current_ptr); 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_current_ptr += l_stride; l_current_ptr += l_stride;