fprintf(stdout," Indicate multiple modes by adding their values. \n");
fprintf(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
fprintf(stdout,"\n");
+ fprintf(stdout,"-TP : devide packets of every tile into tile-parts (-TP R) [R, L, C]\n");
+ fprintf(stdout,"\n");
fprintf(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
sprintf(infilename,"%s/%s",img_fol->imgdirpath,image_filename);
strncpy(parameters->infile, infilename, sizeof(infilename));
- //Set output file
+ /*Set output file*/
strcpy(temp_ofname,get_file_name(image_filename));
while((temp_p = strtok(NULL,".")) != NULL){
strcat(temp_ofname,temp1);
{"cinema2K",REQ_ARG, NULL ,'w'},
{"cinema4K",NO_ARG, NULL ,'y'},
{"ImgDir",REQ_ARG, NULL ,'z'},
- {"TP",REQ_ARG, NULL ,'v'},
+ {"TP",REQ_ARG, NULL ,'u'},
{"SOP",NO_ARG, NULL ,'S'},
{"EPH",NO_ARG, NULL ,'E'},
{"OutFor",REQ_ARG, NULL ,'O'},
};
/* parse the command line */
- const char optlist[] = "i:o:r:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:v:"
+ const char optlist[] = "i:o:r:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:u:J"
#ifdef USE_JPWL
"W:"
#endif /* USE_JPWL */
/* ------------------------------------------------------ */
- case 'v': /* Tile part generation*/
+ case 'u': /* Tile part generation*/
{
parameters->tp_flag = opj_optarg[0];
parameters->tp_on = 1;
num_images=get_num_images(img_fol.imgdirpath);
dirptr=(dircnt_t*)malloc(sizeof(dircnt_t));
if(dirptr){
- dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); // Stores at max 10 image file names
+ dirptr->filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
dirptr->filename = (char**) malloc(num_images*sizeof(char*));
if(!dirptr->filename_buf){
return 0;
if (parameters.cod_format == J2K_CFMT) { /* J2K format output */
int codestream_length;
+ size_t res;
opj_cio_t *cio = NULL;
FILE *f = NULL;
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
/* encode the image */
- if (*indexfilename) // If need to extract codestream information
+ if (*indexfilename) /* If need to extract codestream information*/
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
else
bSuccess = opj_encode(cinfo, cio, image, NULL);
fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
return 1;
}
- fwrite(cio->buffer, 1, codestream_length, f);
+ res = fwrite(cio->buffer, 1, codestream_length, f);
+ if( res < codestream_length ) {
+ fprintf(stderr, "failed to write %d (%s)\n", codestream_length, parameters.outfile);
+ return 1;
+ }
fclose(f);
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
opj_destroy_cstr_info(&cstr_info);
} else { /* JP2 format output */
int codestream_length;
+ size_t res;
opj_cio_t *cio = NULL;
FILE *f = NULL;
opj_cinfo_t *cinfo = NULL;
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
/* encode the image */
- if (*indexfilename || parameters.jpip_on) // If need to extract codestream information
+ if (*indexfilename || parameters.jpip_on) /* If need to extract codestream information*/
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
else
bSuccess = opj_encode(cinfo, cio, image, NULL);
fprintf(stderr, "failed to open %s for writing\n", parameters.outfile);
return 1;
}
- fwrite(cio->buffer, 1, codestream_length, f);
+ res = fwrite(cio->buffer, 1, codestream_length, f);
+ if( res < codestream_length ) {
+ fprintf(stderr, "failed to write %d (%s)\n", codestream_length, parameters.outfile);
+ return 1;
+ }
fclose(f);
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
/* close and free the byte stream */