[trunk] fixed indentation in opj_compress.c, renamed 2 internal

functions, added some comments
This commit is contained in:
Antonin Descampe 2014-01-16 14:21:14 +00:00
parent 7b14cf8558
commit c59124dfe2
1 changed files with 1692 additions and 1674 deletions

View File

@ -90,13 +90,13 @@ static void encode_help_display(void) {
fprintf(stdout,"HELP for opj_compress\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
/* UniPG>> */
/* UniPG>> */
fprintf(stdout,"List of parameters for the JPEG 2000 "
#ifdef USE_JPWL
#ifdef USE_JPWL
"+ JPWL "
#endif /* USE_JPWL */
#endif /* USE_JPWL */
"encoder:\n");
/* <<UniPG */
/* <<UniPG */
fprintf(stdout,"\n");
fprintf(stdout,"REMARKS:\n");
fprintf(stdout,"---------\n");
@ -122,11 +122,11 @@ static void encode_help_display(void) {
fprintf(stdout," * No offset of the origin of the image\n");
fprintf(stdout," * No offset of the origin of the tiles\n");
fprintf(stdout," * Reversible DWT 5-3\n");
/* UniPG>> */
/* UniPG>> */
#ifdef USE_JPWL
fprintf(stdout," * No JPWL protection\n");
#endif /* USE_JPWL */
/* <<UniPG */
/* <<UniPG */
fprintf(stdout,"\n");
fprintf(stdout,"Parameters:\n");
fprintf(stdout,"------------\n");
@ -220,7 +220,7 @@ static void encode_help_display(void) {
fprintf(stdout,"-jpip : write jpip codestream index box in JP2 output file\n");
fprintf(stdout," NOTICE: currently supports only RPCL order\n");
fprintf(stdout,"\n");
/* UniPG>> */
/* UniPG>> */
#ifdef USE_JPWL
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
fprintf(stdout," The parameters can be written and repeated in any order:\n");
@ -286,7 +286,7 @@ static void encode_help_display(void) {
fprintf(stdout," - when you use UEP, always pair the 'p' option with 'h'\n");
fprintf(stdout," \n");
#endif /* USE_JPWL */
/* <<UniPG */
/* <<UniPG */
fprintf(stdout,"IMPORTANT:\n");
fprintf(stdout,"-----------\n");
fprintf(stdout,"\n");
@ -464,66 +464,83 @@ static int initialise_4K_poc(opj_poc_t *POC, int numres){
return 2;
}
static void cinema_parameters(opj_cparameters_t *parameters){
static void set_cinema_parameters(opj_cparameters_t *parameters){
/* No tiling */
parameters->tile_size_on = OPJ_FALSE;
parameters->cp_tdx=1;
parameters->cp_tdy=1;
/*Tile part*/
/* One tile part for each component */
parameters->tp_flag = 'C';
parameters->tp_on = 1;
/*Tile and Image shall be at (0,0)*/
/* Tile and Image shall be at (0,0) */
parameters->cp_tx0 = 0;
parameters->cp_ty0 = 0;
parameters->image_offset_x0 = 0;
parameters->image_offset_y0 = 0;
/*Codeblock size= 32*32*/
/* Codeblock size= 32*32 */
parameters->cblockw_init = 32;
parameters->cblockh_init = 32;
/* Use of precincts */
parameters->csty |= 0x01;
/*The progression order shall be CPRL*/
/* The progression order shall be CPRL */
parameters->prog_order = OPJ_CPRL;
/* No ROI */
parameters->roi_compno = -1;
parameters->subsampling_dx = 1; parameters->subsampling_dy = 1;
/* No subsampling */
parameters->subsampling_dx = 1;
parameters->subsampling_dy = 1;
/* 9-7 transform */
parameters->irreversible = 1;
}
static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
static void setup_cinema_encoder(opj_cparameters_t *parameters,opj_image_t *image, img_fol_t *img_fol){
int i;
float temp_rate;
/* Size and resolution levels */
switch (parameters->cp_cinema){
case OPJ_CINEMA2K_24:
case OPJ_CINEMA2K_48:
if(parameters->numresolution > 6){
fprintf(stdout,"JPEG 2000 Profile-3 (2k dc profile) requires:\n"
"Number of decomposition levels <= 5\n"
"-> Number of decomposition levels forced to 5");
parameters->numresolution = 6;
}
if (!((image->comps[0].w == 2048) | (image->comps[0].h == 1080))){
fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 "
"(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",
fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\n"
"JPEG 2000 Profile-3 (2k dc profile) requires:\n"
"at least one of coordinates match 2048 x 1080\n",
image->comps[0].w,image->comps[0].h);
parameters->cp_rsiz = OPJ_STD_RSIZ;
}
break;
case OPJ_CINEMA4K_24:
if(parameters->numresolution < 1){
fprintf(stdout,"JPEG 2000 Profile-4 (4k dc profile) requires:\n"
"Number of decomposition levels >= 1 && <= 6\n"
"-> Number of decomposition levels forced to 1");
parameters->numresolution = 1;
}else if(parameters->numresolution > 7){
fprintf(stdout,"JPEG 2000 Profile-4 (4k dc profile) requires:\n"
"Number of decomposition levels >= 1 && <= 6\n"
"-> Number of decomposition levels forced to 6");
parameters->numresolution = 7;
}
if (!((image->comps[0].w == 4096) | (image->comps[0].h == 2160))){
fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4"
"(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n",
fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\n"
"JPEG 2000 Profile-4 (4k dc profile) requires:\n"
"at least one of coordinates match 4096 x 2160\n",
image->comps[0].w,image->comps[0].h);
parameters->cp_rsiz = OPJ_STD_RSIZ;
}
@ -533,6 +550,7 @@ static void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *imag
break;
}
/* Limited bit-rate */
switch (parameters->cp_cinema){
case OPJ_CINEMA2K_24:
case OPJ_CINEMA4K_24:
@ -600,9 +618,9 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* 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:u:J"
#ifdef USE_JPWL
#ifdef USE_JPWL
"W:"
#endif /* USE_JPWL */
#endif /* USE_JPWL */
"h";
totlen=sizeof(long_option);
@ -1130,7 +1148,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
/* ------------------------------------------------------ */
/* UniPG>> */
/* UniPG>> */
#ifdef USE_JPWL
/* ------------------------------------------------------ */
@ -1448,8 +1466,8 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param
}
break;
#endif /* USE_JPWL */
/* <<UniPG */
/* ------------------------------------------------------ */
/* <<UniPG */
/* ------------------------------------------------------ */
case 'J': /* jpip on */
{
@ -1623,7 +1641,7 @@ int main(int argc, char **argv) {
for(i=0; i< parameters.tcp_numlayers; i++){
img_fol.rates[i] = parameters.tcp_rates[i];
}
cinema_parameters(&parameters);
set_cinema_parameters(&parameters);
}
/* Create comment for codestream */
@ -1631,7 +1649,7 @@ int main(int argc, char **argv) {
const char comment[] = "Created by OpenJPEG version ";
const size_t clen = strlen(comment);
const char *version = opj_version();
/* UniPG>> */
/* UniPG>> */
#ifdef USE_JPWL
parameters.cp_comment = (char*)malloc(clen+strlen(version)+11);
sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version);
@ -1639,7 +1657,7 @@ int main(int argc, char **argv) {
parameters.cp_comment = (char*)malloc(clen+strlen(version)+1);
sprintf(parameters.cp_comment,"%s%s", comment, version);
#endif
/* <<UniPG */
/* <<UniPG */
}
/* Read directory if necessary */
@ -1772,7 +1790,7 @@ int main(int argc, char **argv) {
#endif /* OPJ_HAVE_LIBPNG */
}
/* Can happen if input file is TIFF or PNG
/* Can happen if input file is TIFF or PNG
* and OPJ_HAVE_LIBTIF or OPJ_HAVE_LIBPNG is undefined
*/
if( !image) {
@ -1784,7 +1802,7 @@ int main(int argc, char **argv) {
parameters.tcp_mct = image->numcomps == 3 ? 1 : 0;
if(parameters.cp_cinema){
cinema_setup_encoder(&parameters,image,&img_fol);
setup_cinema_encoder(&parameters,image,&img_fol);
}
/* encode the destination image */