manage case 0 frames inside yuv_num_frames function and correct some warnings with gcc4.5 (credit to Winfried)
This commit is contained in:
parent
c2b0a8101b
commit
e716a316f6
|
@ -1968,7 +1968,6 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
||||||
int width, height, imgsize;
|
int width, height, imgsize;
|
||||||
int bps,index,adjust, sgnd;
|
int bps,index,adjust, sgnd;
|
||||||
int ushift, dshift, has_alpha, force16;
|
int ushift, dshift, has_alpha, force16;
|
||||||
unsigned int last_i=0;
|
|
||||||
TIFF *tif;
|
TIFF *tif;
|
||||||
tdata_t buf;
|
tdata_t buf;
|
||||||
tstrip_t strip;
|
tstrip_t strip;
|
||||||
|
@ -2029,7 +2028,7 @@ int imagetotif(opj_image_t * image, const char *outfile)
|
||||||
for(strip = 0; strip < TIFFNumberOfStrips(tif); strip++)
|
for(strip = 0; strip < TIFFNumberOfStrips(tif); strip++)
|
||||||
{
|
{
|
||||||
unsigned char *dat8;
|
unsigned char *dat8;
|
||||||
tsize_t i, ssize;
|
tsize_t i, ssize, last_i = 0;
|
||||||
int step, restx;
|
int step, restx;
|
||||||
ssize = TIFFStripSize(tif);
|
ssize = TIFFStripSize(tif);
|
||||||
dat8 = (unsigned char*)buf;
|
dat8 = (unsigned char*)buf;
|
||||||
|
|
|
@ -595,7 +595,7 @@ int main(int argc, char **argv) {
|
||||||
file_length = ftell(fsrc);
|
file_length = ftell(fsrc);
|
||||||
fseek(fsrc, 0, SEEK_SET);
|
fseek(fsrc, 0, SEEK_SET);
|
||||||
src = (unsigned char *) malloc(file_length);
|
src = (unsigned char *) malloc(file_length);
|
||||||
if (fread(src, 1, file_length, fsrc) != file_length)
|
if (fread(src, 1, file_length, fsrc) != (size_t)file_length)
|
||||||
{
|
{
|
||||||
free(src);
|
free(src);
|
||||||
fclose(fsrc);
|
fclose(fsrc);
|
||||||
|
|
|
@ -129,7 +129,7 @@ int getopt(int nargc, char *const *nargv, const char *ostr) {
|
||||||
|
|
||||||
|
|
||||||
int getopt_long(int argc, char * const argv[], const char *optstring,
|
int getopt_long(int argc, char * const argv[], const char *optstring,
|
||||||
struct option *longopts, int totlen) {
|
const struct option *longopts, int totlen) {
|
||||||
static int lastidx,lastofs;
|
static int lastidx,lastofs;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int i,len;
|
int i,len;
|
||||||
|
|
|
@ -144,7 +144,7 @@ int main(int argc, char *argv[]){
|
||||||
|
|
||||||
int listening_socket = open_listeningsocket();
|
int listening_socket = open_listeningsocket();
|
||||||
|
|
||||||
int addrlen = sizeof(peer_sin);
|
unsigned int addrlen = sizeof(peer_sin);
|
||||||
|
|
||||||
cachelist_param_t *cachelist = gene_cachelist();
|
cachelist_param_t *cachelist = gene_cachelist();
|
||||||
|
|
||||||
|
|
|
@ -199,29 +199,29 @@ void help_display()
|
||||||
fprintf(stdout,"TotalDisto\n\n");
|
fprintf(stdout,"TotalDisto\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int give_progression(char progression[4])
|
OPJ_PROG_ORDER give_progression(char progression[5])
|
||||||
{
|
{
|
||||||
if (progression[0] == 'L' && progression[1] == 'R'
|
if (progression[0] == 'L' && progression[1] == 'R'
|
||||||
&& progression[2] == 'C' && progression[3] == 'P') {
|
&& progression[2] == 'C' && progression[3] == 'P') {
|
||||||
return 0;
|
return LRCP;
|
||||||
} else {
|
} else {
|
||||||
if (progression[0] == 'R' && progression[1] == 'L'
|
if (progression[0] == 'R' && progression[1] == 'L'
|
||||||
&& progression[2] == 'C' && progression[3] == 'P') {
|
&& progression[2] == 'C' && progression[3] == 'P') {
|
||||||
return 1;
|
return RLCP;
|
||||||
} else {
|
} else {
|
||||||
if (progression[0] == 'R' && progression[1] == 'P'
|
if (progression[0] == 'R' && progression[1] == 'P'
|
||||||
&& progression[2] == 'C' && progression[3] == 'L') {
|
&& progression[2] == 'C' && progression[3] == 'L') {
|
||||||
return 2;
|
return RPCL;
|
||||||
} else {
|
} else {
|
||||||
if (progression[0] == 'P' && progression[1] == 'C'
|
if (progression[0] == 'P' && progression[1] == 'C'
|
||||||
&& progression[2] == 'R' && progression[3] == 'L') {
|
&& progression[2] == 'R' && progression[3] == 'L') {
|
||||||
return 3;
|
return PCRL;
|
||||||
} else {
|
} else {
|
||||||
if (progression[0] == 'C' && progression[1] == 'P'
|
if (progression[0] == 'C' && progression[1] == 'P'
|
||||||
&& progression[2] == 'R' && progression[3] == 'L') {
|
&& progression[2] == 'R' && progression[3] == 'L') {
|
||||||
return 4;
|
return CPRL;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return PROG_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,9 +475,9 @@ int main(int argc, char **argv)
|
||||||
/* ----------------------------------------------------- */
|
/* ----------------------------------------------------- */
|
||||||
case 'p': /* progression order */
|
case 'p': /* progression order */
|
||||||
{
|
{
|
||||||
char progression[4];
|
char progression[5];
|
||||||
|
|
||||||
strncpy(progression, optarg, 4);
|
strncpy(progression, optarg, 5);
|
||||||
j2k_parameters->prog_order = give_progression(progression);
|
j2k_parameters->prog_order = give_progression(progression);
|
||||||
if (j2k_parameters->prog_order == -1) {
|
if (j2k_parameters->prog_order == -1) {
|
||||||
fprintf(stderr, "Unrecognized progression order "
|
fprintf(stderr, "Unrecognized progression order "
|
||||||
|
@ -696,7 +696,7 @@ int main(int argc, char **argv)
|
||||||
movie->tk[0].num_samples =
|
movie->tk[0].num_samples =
|
||||||
yuv_num_frames(&movie->tk[0],mj2_parameters.infile);
|
yuv_num_frames(&movie->tk[0],mj2_parameters.infile);
|
||||||
|
|
||||||
if (movie->tk[0].num_samples == -1) {
|
if (movie->tk[0].num_samples == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,9 +240,7 @@ void mj2_tts_decompact(mj2_tk_t * tk)
|
||||||
*/
|
*/
|
||||||
void mj2_stsc_decompact(mj2_tk_t * tk)
|
void mj2_stsc_decompact(mj2_tk_t * tk)
|
||||||
{
|
{
|
||||||
int j, i;
|
unsigned int i, j, k, sampleno = 0;
|
||||||
unsigned int k;
|
|
||||||
int sampleno=0;
|
|
||||||
|
|
||||||
if (tk->num_samplestochunk == 1) {
|
if (tk->num_samplestochunk == 1) {
|
||||||
tk->num_chunks =
|
tk->num_chunks =
|
||||||
|
@ -283,10 +281,8 @@ void mj2_stsc_decompact(mj2_tk_t * tk)
|
||||||
*/
|
*/
|
||||||
void mj2_stco_decompact(mj2_tk_t * tk)
|
void mj2_stco_decompact(mj2_tk_t * tk)
|
||||||
{
|
{
|
||||||
int j;
|
unsigned int i, j, k = 0;
|
||||||
unsigned int i;
|
unsigned int intra_chunk_offset;
|
||||||
int k = 0;
|
|
||||||
int intra_chunk_offset;
|
|
||||||
|
|
||||||
for (i = 0; i < tk->num_chunks; i++) {
|
for (i = 0; i < tk->num_chunks; i++) {
|
||||||
intra_chunk_offset = 0;
|
intra_chunk_offset = 0;
|
||||||
|
@ -585,7 +581,7 @@ int mj2_read_stsz(mj2_tk_t * tk, opj_cio_t *cio)
|
||||||
*/
|
*/
|
||||||
void mj2_write_stsc(mj2_tk_t * tk, opj_cio_t *cio)
|
void mj2_write_stsc(mj2_tk_t * tk, opj_cio_t *cio)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
mj2_box_t box;
|
mj2_box_t box;
|
||||||
|
|
||||||
box.init_pos = cio_tell(cio);
|
box.init_pos = cio_tell(cio);
|
||||||
|
@ -617,7 +613,7 @@ void mj2_write_stsc(mj2_tk_t * tk, opj_cio_t *cio)
|
||||||
*/
|
*/
|
||||||
int mj2_read_stsc(mj2_tk_t * tk, opj_cio_t *cio)
|
int mj2_read_stsc(mj2_tk_t * tk, opj_cio_t *cio)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
mj2_box_t box;
|
mj2_box_t box;
|
||||||
|
|
||||||
mj2_read_boxhdr(&box, cio); /* Box Size */
|
mj2_read_boxhdr(&box, cio); /* Box Size */
|
||||||
|
|
|
@ -103,7 +103,7 @@ typedef struct mj2_tts {
|
||||||
Chunk
|
Chunk
|
||||||
*/
|
*/
|
||||||
typedef struct mj2_chunk {
|
typedef struct mj2_chunk {
|
||||||
int num_samples;
|
unsigned int num_samples;
|
||||||
int sample_descr_idx;
|
int sample_descr_idx;
|
||||||
int offset;
|
int offset;
|
||||||
} mj2_chunk_t;
|
} mj2_chunk_t;
|
||||||
|
@ -112,8 +112,8 @@ typedef struct mj2_chunk {
|
||||||
Sample to chunk
|
Sample to chunk
|
||||||
*/
|
*/
|
||||||
typedef struct mj2_sampletochunk {
|
typedef struct mj2_sampletochunk {
|
||||||
int first_chunk;
|
unsigned int first_chunk;
|
||||||
int samples_per_chunk;
|
unsigned int samples_per_chunk;
|
||||||
int sample_descr_idx;
|
int sample_descr_idx;
|
||||||
} mj2_sampletochunk_t;
|
} mj2_sampletochunk_t;
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ typedef struct mj2_tk {
|
||||||
mj2_tts_t *tts;
|
mj2_tts_t *tts;
|
||||||
unsigned int num_chunks;
|
unsigned int num_chunks;
|
||||||
mj2_chunk_t *chunk;
|
mj2_chunk_t *chunk;
|
||||||
int num_samplestochunk;
|
unsigned int num_samplestochunk;
|
||||||
mj2_sampletochunk_t *sampletochunk;
|
mj2_sampletochunk_t *sampletochunk;
|
||||||
char *name;
|
char *name;
|
||||||
opj_jp2_t jp2_struct;
|
opj_jp2_t jp2_struct;
|
||||||
|
|
|
@ -37,20 +37,20 @@
|
||||||
/* */
|
/* */
|
||||||
/* ----------------------- */
|
/* ----------------------- */
|
||||||
|
|
||||||
int yuv_num_frames(mj2_tk_t * tk, char *infile)
|
unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile)
|
||||||
{
|
{
|
||||||
int numimages, frame_size, prec_size;
|
unsigned int prec_size;
|
||||||
long end_of_f;
|
long end_of_f, frame_size;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
f = fopen(infile,"rb");
|
f = fopen(infile,"rb");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
fprintf(stderr, "failed to open %s for reading\n",infile);
|
fprintf(stderr, "failed to open %s for reading\n",infile);
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
prec_size = (tk->depth + 7)/8;/* bytes of precision */
|
prec_size = (tk->depth + 7)/8;/* bytes of precision */
|
||||||
|
|
||||||
frame_size = (int) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy))); /* Calculate frame size */
|
frame_size = (long) (tk->w * tk->h * (1.0 + (double) 2 / (double) (tk->CbCr_subsampling_dx * tk->CbCr_subsampling_dy))); /* Calculate frame size */
|
||||||
frame_size *= prec_size;
|
frame_size *= prec_size;
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
fseek(f, 0, SEEK_END);
|
||||||
|
@ -60,13 +60,11 @@ int yuv_num_frames(mj2_tk_t * tk, char *infile)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"YUV does not contains any frame of %d x %d size\n", tk->w,
|
"YUV does not contains any frame of %d x %d size\n", tk->w,
|
||||||
tk->h);
|
tk->h);
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
numimages = end_of_f / frame_size; /* Calculate number of images */
|
return (unsigned int)(end_of_f / frame_size);
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
return numimages;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------
|
// -----------------------
|
||||||
|
|
|
@ -39,7 +39,7 @@ opj_image_t *mj2_image_create(mj2_tk_t * tk, opj_cparameters_t *parameters);
|
||||||
|
|
||||||
char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile);
|
char yuvtoimage(mj2_tk_t * tk, opj_image_t * img, int frame_num, opj_cparameters_t *parameters, char* infile);
|
||||||
|
|
||||||
int yuv_num_frames(mj2_tk_t * tk, char *infile);
|
unsigned int yuv_num_frames(mj2_tk_t * tk, char *infile);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -527,7 +527,7 @@ static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1
|
||||||
|
|
||||||
int w = tilec->x1 - tilec->x0;
|
int w = tilec->x1 - tilec->x0;
|
||||||
|
|
||||||
h.mem = opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
|
h.mem = (int*)opj_aligned_malloc(dwt_decode_max_resolution(tr, numres) * sizeof(int));
|
||||||
v.mem = h.mem;
|
v.mem = h.mem;
|
||||||
|
|
||||||
while( --numres) {
|
while( --numres) {
|
||||||
|
|
|
@ -236,7 +236,7 @@ static void j2k_read_unk(opj_j2k_t *j2k);
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
typedef struct j2k_prog_order{
|
typedef struct j2k_prog_order{
|
||||||
OPJ_PROG_ORDER enum_prog;
|
OPJ_PROG_ORDER enum_prog;
|
||||||
char str_prog[4];
|
char str_prog[5];
|
||||||
}j2k_prog_order_t;
|
}j2k_prog_order_t;
|
||||||
|
|
||||||
j2k_prog_order_t j2k_prog_order_list[] = {
|
j2k_prog_order_t j2k_prog_order_list[] = {
|
||||||
|
|
|
@ -75,9 +75,10 @@ jpwl_epc_ms_t *jpwl_epc_create(opj_j2k_t *j2k, opj_bool esd_on, opj_bool red_on,
|
||||||
@param sensval pointer to an array of sensitivity values (if NULL, they will be automatically filled)
|
@param sensval pointer to an array of sensitivity values (if NULL, they will be automatically filled)
|
||||||
@return returns the freshly created ESD
|
@return returns the freshly created ESD
|
||||||
*/
|
*/
|
||||||
jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comps, unsigned char addrm, unsigned char ad_size,
|
jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comps,
|
||||||
unsigned char senst, int se_size, int tileno,
|
unsigned char addrm, unsigned char ad_size,
|
||||||
unsigned long int svalnum, void *sensval);
|
unsigned char senst, int se_size, int tileno,
|
||||||
|
unsigned long int svalnum, void *sensval);
|
||||||
|
|
||||||
/** this function is used to compare two JPWL markers based on
|
/** this function is used to compare two JPWL markers based on
|
||||||
their relevant wishlist position
|
their relevant wishlist position
|
||||||
|
@ -168,7 +169,7 @@ void j2k_add_marker(opj_codestream_info_t *cstr_info, unsigned short int type, i
|
||||||
/* expand the list? */
|
/* expand the list? */
|
||||||
if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) {
|
if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) {
|
||||||
cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F);
|
cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F);
|
||||||
cstr_info->marker = opj_realloc(cstr_info->marker, cstr_info->maxmarknum);
|
cstr_info->marker = (opj_marker_info_t*)opj_realloc(cstr_info->marker, cstr_info->maxmarknum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the marker */
|
/* add the marker */
|
||||||
|
@ -906,7 +907,7 @@ void j2k_read_epc(opj_j2k_t *j2k) {
|
||||||
unsigned short int Lepc, Pcrc = 0x0000;
|
unsigned short int Lepc, Pcrc = 0x0000;
|
||||||
unsigned char Pepc;
|
unsigned char Pepc;
|
||||||
opj_cio_t *cio = j2k->cio;
|
opj_cio_t *cio = j2k->cio;
|
||||||
char *ans1;
|
const char *ans1;
|
||||||
|
|
||||||
/* Simply read the EPC parameters */
|
/* Simply read the EPC parameters */
|
||||||
Lepcp = cio_tell(cio);
|
Lepcp = cio_tell(cio);
|
||||||
|
|
|
@ -1200,9 +1200,10 @@ int jpwl_esds_add(opj_j2k_t *j2k, jpwl_marker_t *jwmarker, int *jwmarker_num,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, unsigned char ad_size,
|
jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp,
|
||||||
unsigned char senst, unsigned char se_size, int tileno,
|
unsigned char addrm, unsigned char ad_size,
|
||||||
unsigned long int svalnum, void *sensval) {
|
unsigned char senst, int se_size, int tileno,
|
||||||
|
unsigned long int svalnum, void *sensval) {
|
||||||
|
|
||||||
jpwl_esd_ms_t *esd = NULL;
|
jpwl_esd_ms_t *esd = NULL;
|
||||||
|
|
||||||
|
@ -1232,7 +1233,7 @@ jpwl_esd_ms_t *jpwl_esd_create(opj_j2k_t *j2k, int comp, unsigned char addrm, un
|
||||||
/* packet mode */
|
/* packet mode */
|
||||||
case (0):
|
case (0):
|
||||||
ad_size = 0; /* as per the standard */
|
ad_size = 0; /* as per the standard */
|
||||||
esd->sensval_size = se_size;
|
esd->sensval_size = (unsigned int)se_size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* byte range */
|
/* byte range */
|
||||||
|
|
Loading…
Reference in New Issue