Remove some simple warnings about comments
[openjpeg.git] / applications / codec / image_to_j2k.c
index 93d0c6ff6029b64b0879160cc9aa47f21e90de59..dd8425dbf2ffa564cb6a95a7e01fd1fa74fa8495 100644 (file)
@@ -193,6 +193,8 @@ void encode_help_display(void) {
        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");
@@ -425,7 +427,7 @@ char get_next_file(int imageno,dircnt_t *dirptr,img_fol_t *img_fol, opj_cparamet
        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);
@@ -581,7 +583,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
                {"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'},
@@ -591,7 +593,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
        };
 
        /* 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 */
@@ -1005,7 +1007,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
 
                        /* ------------------------------------------------------ */
 
-                       case 'v':                       /* Tile part generation*/
+                       case 'u':                       /* Tile part generation*/
                        {
                                parameters->tp_flag = opj_optarg[0];
                                parameters->tp_on = 1;
@@ -1548,7 +1550,7 @@ int main(int argc, char **argv) {
                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;
@@ -1679,6 +1681,7 @@ int main(int argc, char **argv) {
 
                        if (parameters.cod_format == J2K_CFMT) {        /* J2K format output */
                                int codestream_length;
+        size_t res;
                                opj_cio_t *cio = NULL;
                                FILE *f = NULL;
 
@@ -1696,7 +1699,7 @@ int main(int argc, char **argv) {
                                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);
@@ -1713,7 +1716,11 @@ int main(int argc, char **argv) {
                                        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);
@@ -1734,6 +1741,7 @@ int main(int argc, char **argv) {
                                        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;
@@ -1752,7 +1760,7 @@ int main(int argc, char **argv) {
                                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);
@@ -1769,7 +1777,11 @@ int main(int argc, char **argv) {
                                        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 */