* Copyright (c) 2005, Herve Drolon, FreeImage Team
* Copyright (c) 2006-2007, Parvatha Elangovan
* Copyright (c) 2008, Jerome Fimes, Communications & Systemes <jerome.fimes@c-s.fr>
+ * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France
+ * Copyright (c) 2012, CS Systemes d'Information, France
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
fprintf(stdout,"\n");
fprintf(stdout,"-h : display the help information \n ");
fprintf(stdout,"\n");
- fprintf(stdout,"-cinema2K : Digital Cinema 2K profile compliant codestream for 2K resolution.(-cinema2k 24 or 48) \n");
+ fprintf(stdout,"-cinema2K : Digital Cinema 2K profile compliant codestream for 2K resolution.(-CINEMA2K 24 or 48) \n");
fprintf(stdout," Need to specify the frames per second for a 2K resolution. Only 24 or 48 fps is allowed\n");
fprintf(stdout,"\n");
fprintf(stdout,"-cinema4K : Digital Cinema 4K profile compliant codestream for 4K resolution \n");
static OPJ_PROG_ORDER give_progression(const char progression[4]) {
if(strncmp(progression, "LRCP", 4) == 0) {
- return LRCP;
+ return OPJ_LRCP;
}
if(strncmp(progression, "RLCP", 4) == 0) {
- return RLCP;
+ return OPJ_RLCP;
}
if(strncmp(progression, "RPCL", 4) == 0) {
- return RPCL;
+ return OPJ_RPCL;
}
if(strncmp(progression, "PCRL", 4) == 0) {
- return PCRL;
+ return OPJ_PCRL;
}
if(strncmp(progression, "CPRL", 4) == 0) {
- return CPRL;
+ return OPJ_CPRL;
}
- return PROG_UNKNOWN;
+ return OPJ_PROG_UNKNOWN;
}
static unsigned int get_num_images(char *imgdirpath){
POC[0].layno1 = 1;
POC[0].resno1 = numres-1;
POC[0].compno1 = 3;
- POC[0].prg1 = CPRL;
+ POC[0].prg1 = OPJ_CPRL;
POC[1].tile = 1;
POC[1].resno0 = numres-1;
POC[1].compno0 = 0;
POC[1].layno1 = 1;
POC[1].resno1 = numres;
POC[1].compno1 = 3;
- POC[1].prg1 = CPRL;
+ POC[1].prg1 = OPJ_CPRL;
return 2;
}
parameters->csty |= 0x01;
/*The progression order shall be CPRL*/
- parameters->prog_order = CPRL;
+ parameters->prog_order = OPJ_CPRL;
/* No ROI */
parameters->roi_compno = -1;
float temp_rate;
switch (parameters->cp_cinema){
- case CINEMA2K_24:
- case CINEMA2K_48:
+ case OPJ_CINEMA2K_24:
+ case OPJ_CINEMA2K_48:
if(parameters->numresolution > 6){
parameters->numresolution = 6;
}
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",
image->comps[0].w,image->comps[0].h);
- parameters->cp_rsiz = STD_RSIZ;
+ parameters->cp_rsiz = OPJ_STD_RSIZ;
}
break;
- case CINEMA4K_24:
+ case OPJ_CINEMA4K_24:
if(parameters->numresolution < 1){
parameters->numresolution = 1;
}else if(parameters->numresolution > 7){
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",
image->comps[0].w,image->comps[0].h);
- parameters->cp_rsiz = STD_RSIZ;
+ parameters->cp_rsiz = OPJ_STD_RSIZ;
}
parameters->numpocs = initialise_4K_poc(parameters->POC,parameters->numresolution);
break;
}
switch (parameters->cp_cinema){
- case CINEMA2K_24:
- case CINEMA4K_24:
+ case OPJ_CINEMA2K_24:
+ case OPJ_CINEMA4K_24:
for(i=0 ; i<parameters->tcp_numlayers ; i++){
temp_rate = 0 ;
if (img_fol->rates[i]== 0){
parameters->max_comp_size = COMP_24_CS;
break;
- case CINEMA2K_48:
+ case OPJ_CINEMA2K_48:
for(i=0 ; i<parameters->tcp_numlayers ; i++){
temp_rate = 0 ;
if (img_fol->rates[i]== 0){
};
/* 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:"
+ 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 */
int fps=0;
sscanf(opj_optarg,"%d",&fps);
if(fps == 24){
- parameters->cp_cinema = CINEMA2K_24;
+ parameters->cp_cinema = OPJ_CINEMA2K_24;
}else if(fps == 48 ){
- parameters->cp_cinema = CINEMA2K_48;
+ parameters->cp_cinema = OPJ_CINEMA2K_48;
}else {
fprintf(stderr,"Incorrect value!! must be 24 or 48\n");
return 1;
}
fprintf(stdout,"CINEMA 2K compliant codestream\n");
- parameters->cp_rsiz = CINEMA2K;
+ parameters->cp_rsiz = OPJ_CINEMA2K;
}
break;
case 'y': /* Digital Cinema 4K profile compliance*/
{
- parameters->cp_cinema = CINEMA4K_24;
+ parameters->cp_cinema = OPJ_CINEMA4K_24;
fprintf(stdout,"CINEMA 4K compliant codestream\n");
- parameters->cp_rsiz = CINEMA4K;
+ parameters->cp_rsiz = OPJ_CINEMA4K;
}
break;
/* <<UniPG */
/* ------------------------------------------------------ */
+ case 'J': /* jpip on */
+ {
+ parameters->jpip_on = OPJ_TRUE;
+ }
break;
/* ------------------------------------------------------ */
/* check for possible errors */
if (parameters->cp_cinema){
if(parameters->tcp_numlayers > 1){
- parameters->cp_rsiz = STD_RSIZ;
+ parameters->cp_rsiz = OPJ_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");
}
}
*/
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
- FILE *fout = NULL;
opj_cparameters_t parameters; /* compression parameters */
img_fol_t img_fol;
dircnt_t *dirptr = NULL;
- opj_bool bSuccess;
- opj_bool bUseTiles = OPJ_FALSE; /* OPJ_TRUE */
+ OPJ_BOOL bSuccess;
+ OPJ_BOOL bUseTiles = OPJ_FALSE; /* OPJ_TRUE */
OPJ_UINT32 l_nb_tiles = 4;
/* set encoding parameters to default values */
case J2K_CFMT: /* JPEG-2000 codestream */
{
/* Get a decoder handle */
- l_codec = opj_create_compress(CODEC_J2K);
+ l_codec = opj_create_compress(OPJ_CODEC_J2K);
break;
}
case JP2_CFMT: /* JPEG 2000 compressed image data */
{
/* Get a decoder handle */
- l_codec = opj_create_compress(CODEC_JP2);
+ l_codec = opj_create_compress(OPJ_CODEC_JP2);
break;
}
default:
fprintf(stderr, "skipping file..\n");
- opj_stream_destroy(l_stream);
+ opj_stream_destroy_v3(l_stream);
continue;
}
}
opj_setup_encoder(l_codec, ¶meters, image);
- /* Open the output file*/
- fout = fopen(parameters.outfile, "wb");
- if (! fout) {
- fprintf(stderr, "Not enable to create output file!\n");
- opj_stream_destroy(l_stream);
- return 1;
- }
-
/* open a byte stream for writing and allocate memory for all tiles */
- l_stream = opj_stream_create_default_file_stream(fout,OPJ_FALSE);
+ l_stream = opj_stream_create_default_file_stream_v3(parameters.outfile,OPJ_FALSE);
if (! l_stream){
return 1;
}
for (i=0;i<l_nb_tiles;++i) {
if (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream)) {
fprintf(stderr, "ERROR -> test_tile_encoder: failed to write the tile %d!\n",i);
- opj_stream_destroy(l_stream);
- fclose(fout);
+ opj_stream_destroy_v3(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
return 1;
}
if (!bSuccess) {
- opj_stream_destroy(l_stream);
- fclose(fout);
+ opj_stream_destroy_v3(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
fprintf(stderr, "failed to encode image\n");
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
/* close and free the byte stream */
- opj_stream_destroy(l_stream);
- fclose(fout);
+ opj_stream_destroy_v3(l_stream);
/* free remaining compression structures */
opj_destroy_codec(l_codec);