summaryrefslogtreecommitdiff
path: root/codec
diff options
context:
space:
mode:
authorParvatha Elangovan <p.elangovan@intopix.com>2007-03-29 14:15:14 +0000
committerParvatha Elangovan <p.elangovan@intopix.com>2007-03-29 14:15:14 +0000
commit9ba672366e5dfc2151544b0ef9c51f1a81ae3194 (patch)
tree0614dbc5f550e3c2865d0232b8539e5666bf0cb5 /codec
parenta1fe5809a4760ed2aa64951c596156f48fca393e (diff)
Enable accepting file names with `-´ symbol .Modification getopt.c
Rsiz profile name generation to be STD_RSIZ for profiles which are not DCI compliant.Modification in image_to_j2k.c Renamed convert_progression_order to j2k_convert_progression_order. Modification j2k.c Calculation of number of tile part in each tile in j2k_calculate_tp. Modification j2k.c j2k_setup_encoder to set bit rate limitation for digital cinema compliance with quality option. Modification in j2k.c Equation to check multiple tile precincts. Modification pi.c array size generation of pi->include in pi_initialise_encode().Modification in pi.c Modification in pi_create_encode for tile part generation.Modification in pi.c In tcd_rateallocate a variable stable_threshold which holds the valid threshold value. This is used to avoid error in case of a wrong threshold value in the last iteration. Modification in tcd.c.
Diffstat (limited to 'codec')
-rw-r--r--codec/compat/getopt.c52
-rw-r--r--codec/compat/getopt.h2
-rw-r--r--codec/image_to_j2k.c32
-rw-r--r--codec/j2k_to_image.c10
4 files changed, 51 insertions, 45 deletions
diff --git a/codec/compat/getopt.c b/codec/compat/getopt.c
index 6bb31c86..3ecbde15 100644
--- a/codec/compat/getopt.c
+++ b/codec/compat/getopt.c
@@ -125,7 +125,7 @@ int getopt(int nargc, char *const *nargv, const char *ostr) {
int getopt_long(int argc, char * const argv[], const char *optstring,
-struct option *longopts, int *longindex, int totlen) {
+struct option *longopts, int totlen) {
static int lastidx,lastofs;
char *tmp;
int i,len;
@@ -147,24 +147,28 @@ again:
if(strlen(arg)>1){
for (i=0;i<totlen;i=i+len,o++) {
if (!strcmp(o->name,arg)) { /* match */
- if (longindex) *longindex=o-longopts;
- if (o->has_arg>0) {
- optarg=argv[optind+1];
- if(optarg){
- if (strchr(optarg,'-')){ /* Has read next input parameter: No arg for current parameter */
- if (opterr) {
- fprintf(stderr,"%s: option requires an argument\n",arg);
- return (BADCH);
- }
- }
- }
- if (!optarg && o->has_arg==1) { /* no argument there */
+ if (o->has_arg == 0) {
+ if (!(argv[optind+1][0]=='-')){
+ fprintf(stderr,"%s: option does not require an argument. Ignoring %s\n",arg,argv[optind+1]);
+ ++optind;
+ }
+ }else{
+ optarg=argv[optind+1];
+ if(optarg){
+ if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
if (opterr) {
- fprintf(stderr,"%s: option requires an argument %c\n",arg, optopt);
+ fprintf(stderr,"%s: option requires an argument\n",arg);
return (BADCH);
}
}
- ++optind;
+ }
+ if (!optarg && o->has_arg==1) { /* no argument there */
+ if (opterr) {
+ fprintf(stderr,"%s: option requires an argument \n",arg);
+ return (BADCH);
+ }
+ }
+ ++optind;
}
++optind;
if (o->flag)
@@ -195,7 +199,7 @@ again:
}
optarg=argv[optind+1];
if(optarg){
- if (strchr(optarg,'-')){ /* Has read next input parameter: No arg for current parameter */
+ if (optarg[0] == '-'){ /* Has read next input parameter: No arg for current parameter */
if (opterr) {
fprintf(stderr,"%s: option requires an argument\n",arg);
return (BADCH);
@@ -210,16 +214,16 @@ again:
}
++optind;
}else {/*Argument not expected*/
- ++lastofs;
- return optopt;
+ ++lastofs;
+ return optopt;
}
found:
- ++optind;
- return optopt;
+ ++optind;
+ return optopt;
} else { /* not found */
- fprintf(stderr,"Invalid option %s\n",arg);
- ++optind;
- return (BADCH);
+ fprintf(stderr,"Invalid option %s\n",arg);
+ ++optind;
+ return (BADCH);
}//end of not found
}// end of single character
@@ -227,4 +231,4 @@ found:
fprintf(stderr,"Invalid option %s\n");
++optind;
return (BADCH);;
- }//end function
+}//end function
diff --git a/codec/compat/getopt.h b/codec/compat/getopt.h
index 4492e850..3477e069 100644
--- a/codec/compat/getopt.h
+++ b/codec/compat/getopt.h
@@ -23,7 +23,7 @@ extern char *optarg;
extern int getopt(int nargc, char *const *nargv, const char *ostr);
extern int getopt_long(int argc, char * const argv[], const char *optstring,
- const struct option *longopts, int *longindex,int totlen);
+ const struct option *longopts, int totlen);
#endif /* _GETOPT_H_ */
diff --git a/codec/image_to_j2k.c b/codec/image_to_j2k.c
index 3d423e77..f626833e 100644
--- a/codec/image_to_j2k.c
+++ b/codec/image_to_j2k.c
@@ -450,24 +450,24 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
switch (parameters->cp_cinema){
case CINEMA2K_24:
case CINEMA2K_48:
- parameters->cp_rsiz = CINEMA2K;
if(parameters->numresolution > 6){
parameters->numresolution = 6;
}
if (!((image->comps[0].w == 2048) & (image->comps[0].h == 1080))){
- fprintf(stdout,"Image coordinates is not 2K, %d x %d\n",image->comps[0].w,image->comps[0].h);
+ fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nDCI 2K compliance requires that atleast one of coordinates match 2048 x 1080\n",image->comps[0].w,image->comps[0].h);
+ parameters->cp_rsiz = STD_RSIZ;
}
break;
case CINEMA4K_24:
- parameters->cp_rsiz = CINEMA4K;
if(parameters->numresolution < 1){
parameters->numresolution = 1;
- }else if(parameters->numresolution > 7){
+ }else if((parameters->numresolution < 7) || (parameters->numresolution > 7)){
parameters->numresolution = 7;
}
if (!((image->comps[0].w == 4096) & (image->comps[0].h == 2160))){
- fprintf(stdout,"Image coordinates is not 4K, %d x %d\n",image->comps[0].w,image->comps[0].h);
+ fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nDCI 4K compliance requires that atleast one of coordinates match 4096 x 2160\n",image->comps[0].w,image->comps[0].h);
+ parameters->cp_rsiz = STD_RSIZ;
}
break;
}
@@ -493,22 +493,21 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
case CINEMA2K_48:
for(i=0;i<parameters->tcp_numlayers;i++){
+ temp_rate = 0 ;
if (parameters->tcp_rates[i]== 0){
parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}else{
- parameters->tcp_rates[i]=((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
+ temp_rate =((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(parameters->tcp_rates[i] * 8 * image->comps[0].dx * image->comps[0].dy);
- if (parameters->tcp_rates[i] > CINEMA_48_CS ){
+ if (temp_rate > CINEMA_48_CS ){
parameters->tcp_rates[0]= ((float) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec))/
(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].dy);
}
}
}
break;
-
-}
-
+ }
parameters->cp_disto_alloc = 1;
}
@@ -517,8 +516,8 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,img_fol_t *img_fol) {
int i, j,totlen;
option_t long_option[]={
- {"cinema2k",REQ_ARG, NULL ,'w'},
- {"cinema4k",NO_ARG, NULL ,'y'},
+ {"cinema2K",REQ_ARG, NULL ,'w'},
+ {"cinema4K",NO_ARG, NULL ,'y'},
{"ImgDir",REQ_ARG, NULL ,'z'},
{"TP",REQ_ARG, NULL ,'v'},
{"SOP",NO_ARG, NULL ,'S'},
@@ -538,7 +537,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
img_fol->set_out_format=0;
while (1) {
- int c = getopt_long(argc, argv, optlist,long_option,NULL,totlen);
+ int c = getopt_long(argc, argv, optlist,long_option,totlen);
/* <<UniPG */
if (c == -1)
break;
@@ -943,6 +942,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
return 1;
}
fprintf(stdout,"CINEMA 2K compliant codestream\n");
+ parameters->cp_rsiz = CINEMA2K;
}
break;
@@ -953,6 +953,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
{
parameters->cp_cinema = CINEMA4K_24;
fprintf(stdout,"CINEMA 4K compliant codestream\n");
+ parameters->cp_rsiz = CINEMA4K;
}
break;
@@ -1292,7 +1293,8 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,i
/* check for possible errors */
if (parameters->cp_cinema){
- if(parameters->tcp_numlayers > 0){
+ if(parameters->tcp_numlayers > 1){
+ parameters->cp_rsiz = STD_RSIZ;
fprintf(stdout,"Warning: DC profiles do not allow more than one quality layer. The codestream created will not be compliant with the DC profile\n");
}
}
@@ -1604,7 +1606,7 @@ int main(int argc, char **argv) {
}
fwrite(cio->buffer, 1, codestream_length, f);
fclose(f);
-
+ fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
/* close and free the byte stream */
opj_cio_close(cio);
diff --git a/codec/j2k_to_image.c b/codec/j2k_to_image.c
index ccc22471..bdf6de74 100644
--- a/codec/j2k_to_image.c
+++ b/codec/j2k_to_image.c
@@ -240,7 +240,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
while (1) {
- int c = getopt_long(argc, argv,optlist,long_option,NULL,totlen);
+ int c = getopt_long(argc, argv,optlist,long_option,totlen);
if (c == -1)
break;
switch (c) {
@@ -678,7 +678,7 @@ int main(int argc, char **argv) {
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
- fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
@@ -687,7 +687,7 @@ int main(int argc, char **argv) {
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
- fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
@@ -696,7 +696,7 @@ int main(int argc, char **argv) {
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
- fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
@@ -705,7 +705,7 @@ int main(int argc, char **argv) {
fprintf(stdout,"Outfile %s not generated\n",parameters.outfile);
}
else {
- fprintf(stdout,"Successfully generated Outfile %s\n",parameters.outfile);
+ fprintf(stdout,"Generated Outfile %s\n",parameters.outfile);
}
break;
}