/** Enable Cod Format for output*/
char set_out_format;
+ int flag;
}img_fol_t;
/* -------------------------------------------------------------------------- */
/* Declarations */
-int get_num_images(char *imgdirpath);
-int load_images(dircnt_t *dirptr, char *imgdirpath);
-int get_file_format(const char *filename);
-char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters);
+static int get_num_images(char *imgdirpath);
+static int load_images(dircnt_t *dirptr, char *imgdirpath);
+static int get_file_format(const char *filename);
+static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters);
static int infile_format(const char *fname);
-int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol);
-int parse_DA_values( char* inArg, unsigned int *DA_x0, unsigned int *DA_y0, unsigned int *DA_x1, unsigned int *DA_y1);
+static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol);
/* -------------------------------------------------------------------------- */
static void decode_help_display(void) {
}
/* -------------------------------------------------------------------------- */
-int get_num_images(char *imgdirpath){
+static int get_num_images(char *imgdirpath){
DIR *dir;
struct dirent* content;
int num_images = 0;
}
/* -------------------------------------------------------------------------- */
-int load_images(dircnt_t *dirptr, char *imgdirpath){
+static int load_images(dircnt_t *dirptr, char *imgdirpath){
DIR *dir;
struct dirent* content;
int i = 0;
}
/* -------------------------------------------------------------------------- */
-int get_file_format(const char *filename) {
+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 get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
+static char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_dparameters_t *parameters){
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],outfilename[OPJ_PATH_LEN],temp_ofname[OPJ_PATH_LEN];
char *temp_p, temp1[OPJ_PATH_LEN]="";
const char *s, *magic_s;
int ext_format, magic_format;
unsigned char buf[12];
- unsigned int l_nb_read;
+ size_t l_nb_read;
reader = fopen(fname, "rb");
* Parse the command line
*/
/* -------------------------------------------------------------------------- */
-int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
+static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
int totlen, c;
opj_option_t long_option[]={
{"ImgDir",REQ_ARG, NULL ,'y'},
};
- const char optlist[] = "i:o:hv";
+ const char optlist[] = "i:o:f:hv";
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
break;
/* ----------------------------------------------------- */
+ case 'f': /* flag */
+ img_fol->flag = atoi(opj_optarg);
+ break;
+ /* ----------------------------------------------------- */
case 'h': /* display an help description */
decode_help_display();
/* -------------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
- FILE *fsrc = NULL, *fout = NULL;
+ FILE *fout = NULL;
opj_dparameters_t parameters; /* Decompression parameters */
opj_image_t* image = NULL; /* Image structure */
/* Initialize img_fol */
memset(&img_fol,0,sizeof(img_fol_t));
+ img_fol.flag = OPJ_IMG_INFO | OPJ_J2K_MH_INFO | OPJ_J2K_MH_IND;
/* Parse input and get user encoding parameters */
if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
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 = (char**) malloc(num_images*sizeof(char*));
+ dirptr->filename_buf = (char*)malloc((size_t)num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/
+ dirptr->filename = (char**) malloc((size_t)num_images*sizeof(char*));
if(!dirptr->filename_buf){
return EXIT_FAILURE;
/* Read the input file and put it in memory */
/* ---------------------------------------- */
- fsrc = fopen(parameters.infile, "rb");
- if (!fsrc) {
- fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
- return EXIT_FAILURE;
- }
- l_stream = opj_stream_create_default_file_stream(fsrc,1);
+ l_stream = opj_stream_create_default_file_stream_v3(parameters.infile,1);
if (!l_stream){
- fclose(fsrc);
- fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
+ fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n",parameters.infile);
return EXIT_FAILURE;
}
}
default:
fprintf(stderr, "skipping file..\n");
- opj_stream_destroy(l_stream);
+ opj_stream_destroy_v3(l_stream);
continue;
}
/* Setup the decoder decoding parameters using user parameters */
if ( !opj_setup_decoder(l_codec, ¶meters) ){
fprintf(stderr, "ERROR -> opj_dump: failed to setup the decoder\n");
- opj_stream_destroy(l_stream);
- fclose(fsrc);
+ opj_stream_destroy_v3(l_stream);
opj_destroy_codec(l_codec);
fclose(fout);
return EXIT_FAILURE;
/* Read the main header of the codestream and if necessary the JP2 boxes*/
if(! opj_read_header(l_stream, l_codec, &image)){
fprintf(stderr, "ERROR -> opj_dump: failed to read the header\n");
- opj_stream_destroy(l_stream);
- fclose(fsrc);
+ opj_stream_destroy_v3(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
fclose(fout);
return EXIT_FAILURE;
}
- opj_dump_codec(l_codec, OPJ_IMG_INFO | OPJ_J2K_MH_INFO | OPJ_J2K_MH_IND, fout );
+ opj_dump_codec(l_codec, img_fol.flag, fout );
cstr_info = opj_get_cstr_info(l_codec);
cstr_index = opj_get_cstr_index(l_codec);
/* close the byte stream */
- opj_stream_destroy(l_stream);
- fclose(fsrc);
+ opj_stream_destroy_v3(l_stream);
/* free remaining structures */
if (l_codec) {