Merge branch 'master' into travis-matrix
This commit is contained in:
commit
5b6ff103bd
|
@ -66,7 +66,7 @@ void opj_reset_options_reading(void) {
|
|||
int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||
# define __progname nargv[0]
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli = NULL; /* option letter list index */
|
||||
const char *oli = NULL; /* option letter list index */
|
||||
|
||||
if (opj_optreset || !*place) { /* update scanning pointer */
|
||||
opj_optreset = 0;
|
||||
|
@ -125,7 +125,7 @@ int opj_getopt(int nargc, char *const *nargv, const char *ostr) {
|
|||
int opj_getopt_long(int argc, char * const argv[], const char *optstring,
|
||||
const opj_option_t *longopts, int totlen) {
|
||||
static int lastidx,lastofs;
|
||||
char *tmp;
|
||||
const char *tmp;
|
||||
int i,len;
|
||||
char param = 1;
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ opj_image_t *pngtoimage(const char *read_idf, opj_cparameters_t * params)
|
|||
image->x1 = (OPJ_UINT32)(image->x0 + (width - 1) * (OPJ_UINT32)params->subsampling_dx + 1 + image->x0);
|
||||
image->y1 = (OPJ_UINT32)(image->y0 + (height - 1) * (OPJ_UINT32)params->subsampling_dy + 1 + image->y0);
|
||||
|
||||
row32s = malloc((size_t)width * nr_comp * sizeof(OPJ_INT32));
|
||||
row32s = (OPJ_INT32 *)malloc((size_t)width * nr_comp * sizeof(OPJ_INT32));
|
||||
if(row32s == NULL) goto fin;
|
||||
|
||||
/* Set alpha channel */
|
||||
|
|
|
@ -290,7 +290,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
|||
TIFFClose(tif);
|
||||
return 1;
|
||||
}
|
||||
buffer32s = malloc((OPJ_SIZE_T)width * numcomps * sizeof(OPJ_INT32));
|
||||
buffer32s = (OPJ_INT32 *)malloc((OPJ_SIZE_T)width * numcomps * sizeof(OPJ_INT32));
|
||||
if (buffer32s == NULL) {
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
|
@ -299,7 +299,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
|||
|
||||
for (i = 0; i < image->comps[0].h; ++i) {
|
||||
cvtPxToCx(planes, buffer32s, (OPJ_SIZE_T)width, adjust);
|
||||
cvt32sToTif(buffer32s, buf, (OPJ_SIZE_T)width * numcomps);
|
||||
cvt32sToTif(buffer32s, (OPJ_BYTE *)buf, (OPJ_SIZE_T)width * numcomps);
|
||||
(void)TIFFWriteEncodedStrip(tif, i, (void*)buf, strip_size);
|
||||
planes[0] += width;
|
||||
planes[1] += width;
|
||||
|
@ -590,7 +590,7 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
|
|||
return NULL;
|
||||
}
|
||||
rowStride = ((OPJ_SIZE_T)w * tiSpp * tiBps + 7U) / 8U;
|
||||
buffer32s = malloc((OPJ_SIZE_T)w * tiSpp * sizeof(OPJ_INT32));
|
||||
buffer32s = (OPJ_INT32 *)malloc((OPJ_SIZE_T)w * tiSpp * sizeof(OPJ_INT32));
|
||||
if (buffer32s == NULL) {
|
||||
_TIFFfree(buf);
|
||||
TIFFClose(tif);
|
||||
|
|
|
@ -291,7 +291,7 @@ static OPJ_BOOL parse_precision(const char* option, opj_decompress_parameters* p
|
|||
|
||||
if (parameters->precision == NULL) {
|
||||
/* first one */
|
||||
parameters->precision = malloc(sizeof(opj_precision));
|
||||
parameters->precision = (opj_precision *)malloc(sizeof(opj_precision));
|
||||
if (parameters->precision == NULL) {
|
||||
fprintf(stderr,"Could not allocate memory for precision option\n");
|
||||
l_result = OPJ_FALSE;
|
||||
|
@ -307,7 +307,7 @@ static OPJ_BOOL parse_precision(const char* option, opj_decompress_parameters* p
|
|||
break;
|
||||
}
|
||||
|
||||
l_new = realloc(parameters->precision, l_new_size * sizeof(opj_precision));
|
||||
l_new = (opj_precision *)realloc(parameters->precision, l_new_size * sizeof(opj_precision));
|
||||
if (l_new == NULL) {
|
||||
fprintf(stderr,"Could not allocate memory for precision option\n");
|
||||
l_result = OPJ_FALSE;
|
||||
|
@ -400,7 +400,7 @@ int get_file_format(const char *filename) {
|
|||
unsigned int i;
|
||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "rawl", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, RAWL_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||
char * ext = strrchr(filename, '.');
|
||||
const char * ext = strrchr(filename, '.');
|
||||
if (ext == NULL)
|
||||
return -1;
|
||||
ext++;
|
||||
|
|
|
@ -171,7 +171,7 @@ static int get_file_format(const char *filename) {
|
|||
unsigned int i;
|
||||
static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp","tif", "raw", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
|
||||
static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
|
||||
char * ext = strrchr(filename, '.');
|
||||
const char *ext = strrchr(filename, '.');
|
||||
if (ext == NULL)
|
||||
return -1;
|
||||
ext++;
|
||||
|
|
|
@ -166,12 +166,12 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create(OPJ_SIZE_T p_buffer_size,OPJ_BOOL l
|
|||
l_stream->m_current_data = l_stream->m_stored_data;
|
||||
|
||||
if (l_is_input) {
|
||||
l_stream->m_status |= opj_stream_e_input;
|
||||
l_stream->m_status |= OPJ_STREAM_STATUS_INPUT;
|
||||
l_stream->m_opj_skip = opj_stream_read_skip;
|
||||
l_stream->m_opj_seek = opj_stream_read_seek;
|
||||
}
|
||||
else {
|
||||
l_stream->m_status |= opj_stream_e_output;
|
||||
l_stream->m_status |= OPJ_STREAM_STATUS_OUTPUT;
|
||||
l_stream->m_opj_skip = opj_stream_write_skip;
|
||||
l_stream->m_opj_seek = opj_stream_write_seek;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ void OPJ_CALLCONV opj_stream_set_read_function(opj_stream_t* p_stream, opj_strea
|
|||
{
|
||||
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
|
||||
|
||||
if ((!l_stream) || (! (l_stream->m_status & opj_stream_e_input))) {
|
||||
if ((!l_stream) || (! (l_stream->m_status & OPJ_STREAM_STATUS_INPUT))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ void OPJ_CALLCONV opj_stream_set_write_function(opj_stream_t* p_stream, opj_stre
|
|||
{
|
||||
opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
|
||||
|
||||
if ((!l_stream )|| (! (l_stream->m_status & opj_stream_e_output))) {
|
||||
if ((!l_stream )|| (! (l_stream->m_status & OPJ_STREAM_STATUS_OUTPUT))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
|
|||
}
|
||||
|
||||
/* we are now in the case when the remaining data if not sufficient */
|
||||
if (p_stream->m_status & opj_stream_e_end) {
|
||||
if (p_stream->m_status & OPJ_STREAM_STATUS_END) {
|
||||
l_read_nb_bytes += p_stream->m_bytes_in_buffer;
|
||||
memcpy(p_buffer,p_stream->m_current_data,p_stream->m_bytes_in_buffer);
|
||||
p_stream->m_current_data += p_stream->m_bytes_in_buffer;
|
||||
|
@ -313,7 +313,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
|
|||
opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
|
||||
|
||||
p_stream->m_bytes_in_buffer = 0;
|
||||
p_stream->m_status |= opj_stream_e_end;
|
||||
p_stream->m_status |= OPJ_STREAM_STATUS_END;
|
||||
/* end of stream */
|
||||
return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T)-1;
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ OPJ_SIZE_T opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
|
|||
opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
|
||||
|
||||
p_stream->m_bytes_in_buffer = 0;
|
||||
p_stream->m_status |= opj_stream_e_end;
|
||||
p_stream->m_status |= OPJ_STREAM_STATUS_END;
|
||||
/* end of stream */
|
||||
return l_read_nb_bytes ? l_read_nb_bytes : (OPJ_SIZE_T)-1;
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ OPJ_SIZE_T opj_stream_write_data (opj_stream_private_t * p_stream,
|
|||
OPJ_SIZE_T l_remaining_bytes = 0;
|
||||
OPJ_SIZE_T l_write_nb_bytes = 0;
|
||||
|
||||
if (p_stream->m_status & opj_stream_e_error) {
|
||||
if (p_stream->m_status & OPJ_STREAM_STATUS_ERROR) {
|
||||
return (OPJ_SIZE_T)-1;
|
||||
}
|
||||
|
||||
|
@ -432,7 +432,7 @@ OPJ_BOOL opj_stream_flush (opj_stream_private_t * p_stream, opj_event_mgr_t * p_
|
|||
p_stream->m_user_data);
|
||||
|
||||
if (l_current_write_nb_bytes == (OPJ_SIZE_T)-1) {
|
||||
p_stream->m_status |= opj_stream_e_error;
|
||||
p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
|
||||
opj_event_msg(p_event_mgr, EVT_INFO, "Error on writing stream!\n");
|
||||
|
||||
return OPJ_FALSE;
|
||||
|
@ -465,7 +465,7 @@ OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz
|
|||
}
|
||||
|
||||
/* we are now in the case when the remaining data if not sufficient */
|
||||
if (p_stream->m_status & opj_stream_e_end) {
|
||||
if (p_stream->m_status & OPJ_STREAM_STATUS_END) {
|
||||
l_skip_nb_bytes += (OPJ_OFF_T)p_stream->m_bytes_in_buffer;
|
||||
p_stream->m_current_data += p_stream->m_bytes_in_buffer;
|
||||
p_stream->m_bytes_in_buffer = 0;
|
||||
|
@ -487,7 +487,7 @@ OPJ_OFF_T opj_stream_read_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz
|
|||
if (l_current_skip_nb_bytes == (OPJ_OFF_T) -1) {
|
||||
opj_event_msg(p_event_mgr, EVT_INFO, "Stream reached its end !\n");
|
||||
|
||||
p_stream->m_status |= opj_stream_e_end;
|
||||
p_stream->m_status |= OPJ_STREAM_STATUS_END;
|
||||
p_stream->m_byte_offset += l_skip_nb_bytes;
|
||||
/* end if stream */
|
||||
return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T) -1;
|
||||
|
@ -507,14 +507,14 @@ OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_si
|
|||
OPJ_OFF_T l_current_skip_nb_bytes = 0;
|
||||
OPJ_OFF_T l_skip_nb_bytes = 0;
|
||||
|
||||
if (p_stream->m_status & opj_stream_e_error) {
|
||||
if (p_stream->m_status & OPJ_STREAM_STATUS_ERROR) {
|
||||
return (OPJ_OFF_T) -1;
|
||||
}
|
||||
|
||||
/* we should flush data */
|
||||
l_is_written = opj_stream_flush (p_stream, p_event_mgr);
|
||||
if (! l_is_written) {
|
||||
p_stream->m_status |= opj_stream_e_error;
|
||||
p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
|
||||
p_stream->m_bytes_in_buffer = 0;
|
||||
return (OPJ_OFF_T) -1;
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ OPJ_OFF_T opj_stream_write_skip (opj_stream_private_t * p_stream, OPJ_OFF_T p_si
|
|||
if (l_current_skip_nb_bytes == (OPJ_OFF_T)-1) {
|
||||
opj_event_msg(p_event_mgr, EVT_INFO, "Stream error!\n");
|
||||
|
||||
p_stream->m_status |= opj_stream_e_error;
|
||||
p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
|
||||
p_stream->m_byte_offset += l_skip_nb_bytes;
|
||||
/* end if stream */
|
||||
return l_skip_nb_bytes ? l_skip_nb_bytes : (OPJ_OFF_T)-1;
|
||||
|
@ -568,12 +568,12 @@ OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size
|
|||
p_stream->m_bytes_in_buffer = 0;
|
||||
|
||||
if( !(p_stream->m_seek_fn(p_size,p_stream->m_user_data)) ) {
|
||||
p_stream->m_status |= opj_stream_e_end;
|
||||
p_stream->m_status |= OPJ_STREAM_STATUS_END;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
else {
|
||||
/* reset stream status */
|
||||
p_stream->m_status &= (~opj_stream_e_end);
|
||||
p_stream->m_status &= (~OPJ_STREAM_STATUS_END);
|
||||
p_stream->m_byte_offset = p_size;
|
||||
|
||||
}
|
||||
|
@ -584,7 +584,7 @@ OPJ_BOOL opj_stream_read_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size
|
|||
OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_size, opj_event_mgr_t * p_event_mgr)
|
||||
{
|
||||
if (! opj_stream_flush(p_stream,p_event_mgr)) {
|
||||
p_stream->m_status |= opj_stream_e_error;
|
||||
p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
|
||||
|
@ -592,7 +592,7 @@ OPJ_BOOL opj_stream_write_seek (opj_stream_private_t * p_stream, OPJ_OFF_T p_siz
|
|||
p_stream->m_bytes_in_buffer = 0;
|
||||
|
||||
if (! p_stream->m_seek_fn(p_size,p_stream->m_user_data)) {
|
||||
p_stream->m_status |= opj_stream_e_error;
|
||||
p_stream->m_status |= OPJ_STREAM_STATUS_ERROR;
|
||||
return OPJ_FALSE;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -70,16 +70,10 @@ The functions in CIO.C have for goal to realize a byte input / output process.
|
|||
#endif
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
opj_signed_sentinel = -1, /* do not use in code */
|
||||
opj_stream_e_output = 0x1,
|
||||
opj_stream_e_input = 0x2,
|
||||
opj_stream_e_end = 0x4,
|
||||
opj_stream_e_error = 0x8
|
||||
}
|
||||
opj_stream_flag ;
|
||||
#define OPJ_STREAM_STATUS_OUTPUT 0x1U
|
||||
#define OPJ_STREAM_STATUS_INPUT 0x2U
|
||||
#define OPJ_STREAM_STATUS_END 0x4U
|
||||
#define OPJ_STREAM_STATUS_ERROR 0x8U
|
||||
|
||||
/**
|
||||
Byte input-output stream.
|
||||
|
@ -162,8 +156,9 @@ typedef struct opj_stream_private
|
|||
|
||||
/**
|
||||
* Flags to tell the status of the stream.
|
||||
* Used with OPJ_STREAM_STATUS_* defines.
|
||||
*/
|
||||
opj_stream_flag m_status;
|
||||
OPJ_UINT32 m_status;
|
||||
|
||||
}
|
||||
opj_stream_private_t;
|
||||
|
|
Loading…
Reference in New Issue