[trunk] move to the new API for function opj_stream_create_default_file_stream. Use now opj_stream_create_default_file_stream_v3 (WIP)
This commit is contained in:
parent
4bf4a7668e
commit
af58e8e8f9
|
@ -1588,7 +1588,6 @@ static void info_callback(const char *msg, void *client_data) {
|
||||||
*/
|
*/
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
FILE *fout = NULL;
|
|
||||||
|
|
||||||
opj_cparameters_t parameters; /* compression parameters */
|
opj_cparameters_t parameters; /* compression parameters */
|
||||||
|
|
||||||
|
@ -1824,16 +1823,8 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
opj_setup_encoder(l_codec, ¶meters, image);
|
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_v3(l_stream);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* open a byte stream for writing and allocate memory for all tiles */
|
/* 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){
|
if (! l_stream){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1853,7 +1844,6 @@ int main(int argc, char **argv) {
|
||||||
if (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream)) {
|
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);
|
fprintf(stderr, "ERROR -> test_tile_encoder: failed to write the tile %d!\n",i);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fout);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1874,7 +1864,6 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if (!bSuccess) {
|
if (!bSuccess) {
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fout);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
fprintf(stderr, "failed to encode image\n");
|
fprintf(stderr, "failed to encode image\n");
|
||||||
|
@ -1884,7 +1873,6 @@ int main(int argc, char **argv) {
|
||||||
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
|
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
|
||||||
/* close and free the byte stream */
|
/* close and free the byte stream */
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fout);
|
|
||||||
|
|
||||||
/* free remaining compression structures */
|
/* free remaining compression structures */
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
|
|
|
@ -676,7 +676,6 @@ static void info_callback(const char *msg, void *client_data) {
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
FILE *fsrc = NULL;
|
|
||||||
|
|
||||||
opj_dparameters_t parameters; /* decompression parameters */
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
opj_image_t* image = NULL;
|
opj_image_t* image = NULL;
|
||||||
|
@ -746,16 +745,10 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* read the input file and put it in memory */
|
/* 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){
|
if (!l_stream){
|
||||||
fclose(fsrc);
|
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n", parameters.infile);
|
||||||
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,7 +789,6 @@ int main(int argc, char **argv)
|
||||||
if ( !opj_setup_decoder(l_codec, ¶meters) ){
|
if ( !opj_setup_decoder(l_codec, ¶meters) ){
|
||||||
fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n");
|
fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n");
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fsrc);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -806,7 +798,6 @@ int main(int argc, char **argv)
|
||||||
if(! opj_read_header(l_stream, l_codec, &image)){
|
if(! opj_read_header(l_stream, l_codec, &image)){
|
||||||
fprintf(stderr, "ERROR -> opj_decompress: failed to read the header\n");
|
fprintf(stderr, "ERROR -> opj_decompress: failed to read the header\n");
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fsrc);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -820,7 +811,6 @@ int main(int argc, char **argv)
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
fclose(fsrc);
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -830,7 +820,6 @@ int main(int argc, char **argv)
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
fclose(fsrc);
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -842,7 +831,6 @@ int main(int argc, char **argv)
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
fclose(fsrc);
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
@ -851,7 +839,6 @@ int main(int argc, char **argv)
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
fclose(fsrc);
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
fprintf(stdout, "tile %d is decoded!\n\n", parameters.tile_index);
|
fprintf(stdout, "tile %d is decoded!\n\n", parameters.tile_index);
|
||||||
|
@ -859,7 +846,6 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* Close the byte stream */
|
/* Close the byte stream */
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fsrc);
|
|
||||||
|
|
||||||
if(image->color_space == OPJ_CLRSPC_SYCC){
|
if(image->color_space == OPJ_CLRSPC_SYCC){
|
||||||
color_sycc_to_rgb(image); /* FIXME */
|
color_sycc_to_rgb(image); /* FIXME */
|
||||||
|
|
|
@ -401,7 +401,7 @@ static void info_callback(const char *msg, void *client_data) {
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FILE *fsrc = NULL, *fout = NULL;
|
FILE *fout = NULL;
|
||||||
|
|
||||||
opj_dparameters_t parameters; /* Decompression parameters */
|
opj_dparameters_t parameters; /* Decompression parameters */
|
||||||
opj_image_t* image = NULL; /* Image structure */
|
opj_image_t* image = NULL; /* Image structure */
|
||||||
|
@ -486,16 +486,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* Read the input file and put it in memory */
|
/* 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){
|
if (!l_stream){
|
||||||
fclose(fsrc);
|
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n",parameters.infile);
|
||||||
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,7 +530,6 @@ int main(int argc, char *argv[])
|
||||||
if ( !opj_setup_decoder(l_codec, ¶meters) ){
|
if ( !opj_setup_decoder(l_codec, ¶meters) ){
|
||||||
fprintf(stderr, "ERROR -> opj_dump: failed to setup the decoder\n");
|
fprintf(stderr, "ERROR -> opj_dump: failed to setup the decoder\n");
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fsrc);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
fclose(fout);
|
fclose(fout);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -546,7 +539,6 @@ int main(int argc, char *argv[])
|
||||||
if(! opj_read_header(l_stream, l_codec, &image)){
|
if(! opj_read_header(l_stream, l_codec, &image)){
|
||||||
fprintf(stderr, "ERROR -> opj_dump: failed to read the header\n");
|
fprintf(stderr, "ERROR -> opj_dump: failed to read the header\n");
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fsrc);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
fclose(fout);
|
fclose(fout);
|
||||||
|
@ -561,7 +553,6 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* close the byte stream */
|
/* close the byte stream */
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fsrc);
|
|
||||||
|
|
||||||
/* free remaining structures */
|
/* free remaining structures */
|
||||||
if (l_codec) {
|
if (l_codec) {
|
||||||
|
|
|
@ -150,9 +150,7 @@ static int infile_format(const char *fname)
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
FILE *fsrc = NULL;
|
OPJ_UINT32 index;
|
||||||
|
|
||||||
OPJ_UINT32 index;
|
|
||||||
opj_dparameters_t parameters; /* decompression parameters */
|
opj_dparameters_t parameters; /* decompression parameters */
|
||||||
opj_image_t* image = NULL;
|
opj_image_t* image = NULL;
|
||||||
opj_stream_t *l_stream = NULL; /* Stream */
|
opj_stream_t *l_stream = NULL; /* Stream */
|
||||||
|
@ -175,13 +173,6 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
strncpy(parameters.infile, argv[1], OPJ_PATH_LEN - 1);
|
strncpy(parameters.infile, argv[1], OPJ_PATH_LEN - 1);
|
||||||
|
|
||||||
/* read the input file */
|
|
||||||
/* ------------------- */
|
|
||||||
fsrc = fopen(parameters.infile, "rb");
|
|
||||||
if (!fsrc) {
|
|
||||||
fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* decode the JPEG2000 stream */
|
/* decode the JPEG2000 stream */
|
||||||
/* -------------------------- */
|
/* -------------------------- */
|
||||||
|
@ -218,10 +209,9 @@ int main(int argc, char **argv)
|
||||||
opj_set_warning_handler(l_codec, warning_callback,00);
|
opj_set_warning_handler(l_codec, warning_callback,00);
|
||||||
opj_set_error_handler(l_codec, error_callback,00);
|
opj_set_error_handler(l_codec, error_callback,00);
|
||||||
|
|
||||||
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){
|
if (!l_stream){
|
||||||
fclose(fsrc);
|
fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n", parameters.infile);
|
||||||
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +219,6 @@ int main(int argc, char **argv)
|
||||||
if ( !opj_setup_decoder(l_codec, ¶meters) ){
|
if ( !opj_setup_decoder(l_codec, ¶meters) ){
|
||||||
fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n");
|
fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n");
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fsrc);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +227,6 @@ int main(int argc, char **argv)
|
||||||
if(! opj_read_header(l_stream, l_codec, &image)){
|
if(! opj_read_header(l_stream, l_codec, &image)){
|
||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to read the header\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to read the header\n");
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fsrc);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -262,7 +250,6 @@ int main(int argc, char **argv)
|
||||||
opj_destroy_cstr_info(&cstr_info); \
|
opj_destroy_cstr_info(&cstr_info); \
|
||||||
opj_destroy_codec(l_codec); \
|
opj_destroy_codec(l_codec); \
|
||||||
opj_image_destroy(image); \
|
opj_image_destroy(image); \
|
||||||
fclose(fsrc); \
|
|
||||||
return EXIT_FAILURE; \
|
return EXIT_FAILURE; \
|
||||||
} \
|
} \
|
||||||
for(index = 0; index < image->numcomps; ++index) { \
|
for(index = 0; index < image->numcomps; ++index) { \
|
||||||
|
@ -272,7 +259,6 @@ int main(int argc, char **argv)
|
||||||
opj_destroy_cstr_info(&cstr_info); \
|
opj_destroy_cstr_info(&cstr_info); \
|
||||||
opj_destroy_codec(l_codec); \
|
opj_destroy_codec(l_codec); \
|
||||||
opj_image_destroy(image); \
|
opj_image_destroy(image); \
|
||||||
fclose(fsrc); \
|
|
||||||
return EXIT_FAILURE; \
|
return EXIT_FAILURE; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
@ -297,9 +283,6 @@ int main(int argc, char **argv)
|
||||||
/* Free image data structure */
|
/* Free image data structure */
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
|
|
||||||
/* Close the input file */
|
|
||||||
fclose(fsrc);
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
/*end main*/
|
/*end main*/
|
||||||
|
|
|
@ -179,7 +179,6 @@ int main (int argc, char *argv[])
|
||||||
opj_dparameters_t l_param;
|
opj_dparameters_t l_param;
|
||||||
opj_codec_t * l_codec;
|
opj_codec_t * l_codec;
|
||||||
opj_image_t * l_image;
|
opj_image_t * l_image;
|
||||||
FILE * l_file;
|
|
||||||
opj_stream_t * l_stream;
|
opj_stream_t * l_stream;
|
||||||
OPJ_UINT32 l_data_size;
|
OPJ_UINT32 l_data_size;
|
||||||
OPJ_UINT32 l_max_data_size = 1000;
|
OPJ_UINT32 l_max_data_size = 1000;
|
||||||
|
@ -219,17 +218,8 @@ int main (int argc, char *argv[])
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
l_file = fopen(input_file,"rb");
|
l_stream = opj_stream_create_default_file_stream_v3(input_file,OPJ_TRUE);
|
||||||
if (! l_file)
|
|
||||||
{
|
|
||||||
fprintf(stdout, "ERROR while opening input file\n");
|
|
||||||
free(l_data);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
l_stream = opj_stream_create_default_file_stream(l_file,OPJ_TRUE);
|
|
||||||
if (!l_stream){
|
if (!l_stream){
|
||||||
fclose(l_file);
|
|
||||||
free(l_data);
|
free(l_data);
|
||||||
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
|
fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -268,7 +258,6 @@ int main (int argc, char *argv[])
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR -> Not a valid JPEG2000 file!\n");
|
fprintf(stderr, "ERROR -> Not a valid JPEG2000 file!\n");
|
||||||
fclose(l_file);
|
|
||||||
free(l_data);
|
free(l_data);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -284,7 +273,6 @@ int main (int argc, char *argv[])
|
||||||
if (! opj_setup_decoder(l_codec, &l_param))
|
if (! opj_setup_decoder(l_codec, &l_param))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n");
|
fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n");
|
||||||
fclose(l_file);
|
|
||||||
free(l_data);
|
free(l_data);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
|
@ -295,7 +283,6 @@ int main (int argc, char *argv[])
|
||||||
if (! opj_read_header(l_stream, l_codec, &l_image))
|
if (! opj_read_header(l_stream, l_codec, &l_image))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to read the header\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to read the header\n");
|
||||||
fclose(l_file);
|
|
||||||
free(l_data);
|
free(l_data);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
|
@ -304,7 +291,6 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
if (!opj_set_decode_area(l_codec, l_image, da_x0, da_y0,da_x1, da_y1)){
|
if (!opj_set_decode_area(l_codec, l_image, da_x0, da_y0,da_x1, da_y1)){
|
||||||
fprintf(stderr, "ERROR -> j2k_to_image: failed to set the decoded area\n");
|
fprintf(stderr, "ERROR -> j2k_to_image: failed to set the decoded area\n");
|
||||||
fclose(l_file);
|
|
||||||
free(l_data);
|
free(l_data);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
|
@ -326,7 +312,6 @@ int main (int argc, char *argv[])
|
||||||
&l_nb_comps,
|
&l_nb_comps,
|
||||||
&l_go_on))
|
&l_go_on))
|
||||||
{
|
{
|
||||||
fclose(l_file);
|
|
||||||
free(l_data);
|
free(l_data);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
|
@ -341,7 +326,6 @@ int main (int argc, char *argv[])
|
||||||
OPJ_BYTE *l_new_data = (OPJ_BYTE *) realloc(l_data, l_data_size);
|
OPJ_BYTE *l_new_data = (OPJ_BYTE *) realloc(l_data, l_data_size);
|
||||||
if (! l_new_data)
|
if (! l_new_data)
|
||||||
{
|
{
|
||||||
fclose(l_file);
|
|
||||||
free(l_new_data);
|
free(l_new_data);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
|
@ -354,7 +338,6 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
if (! opj_decode_tile_data(l_codec,l_tile_index,l_data,l_data_size,l_stream))
|
if (! opj_decode_tile_data(l_codec,l_tile_index,l_data,l_data_size,l_stream))
|
||||||
{
|
{
|
||||||
fclose(l_file);
|
|
||||||
free(l_data);
|
free(l_data);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
|
@ -367,7 +350,6 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
if (! opj_end_decompress(l_codec,l_stream))
|
if (! opj_end_decompress(l_codec,l_stream))
|
||||||
{
|
{
|
||||||
fclose(l_file);
|
|
||||||
free(l_data);
|
free(l_data);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
|
@ -376,7 +358,6 @@ int main (int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free memory */
|
/* Free memory */
|
||||||
fclose(l_file);
|
|
||||||
free(l_data);
|
free(l_data);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
|
|
|
@ -80,7 +80,6 @@ int main (int argc, char *argv[])
|
||||||
opj_codec_t * l_codec;
|
opj_codec_t * l_codec;
|
||||||
opj_image_t * l_image;
|
opj_image_t * l_image;
|
||||||
opj_image_cmptparm_t l_params [NUM_COMPS_MAX];
|
opj_image_cmptparm_t l_params [NUM_COMPS_MAX];
|
||||||
FILE * l_file;
|
|
||||||
opj_stream_t * l_stream;
|
opj_stream_t * l_stream;
|
||||||
OPJ_UINT32 l_nb_tiles;
|
OPJ_UINT32 l_nb_tiles;
|
||||||
OPJ_UINT32 l_data_size;
|
OPJ_UINT32 l_data_size;
|
||||||
|
@ -278,20 +277,17 @@ int main (int argc, char *argv[])
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
l_file = fopen(output_file,"wb");
|
l_stream = opj_stream_create_default_file_stream_v3(output_file, OPJ_FALSE);
|
||||||
if (! l_file) {
|
if (! l_stream) {
|
||||||
fprintf(stderr, "ERROR -> test_tile_encoder: failed to create the output file!\n");
|
fprintf(stderr, "ERROR -> test_tile_encoder: failed to create the stream from the output file %s !\n",output_file );
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(l_image);
|
opj_image_destroy(l_image);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
l_stream = opj_stream_create_default_file_stream(l_file, OPJ_FALSE);
|
|
||||||
|
|
||||||
if (! opj_start_compress(l_codec,l_image,l_stream)) {
|
if (! opj_start_compress(l_codec,l_image,l_stream)) {
|
||||||
fprintf(stderr, "ERROR -> test_tile_encoder: failed to start compress!\n");
|
fprintf(stderr, "ERROR -> test_tile_encoder: failed to start compress!\n");
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(l_file);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(l_image);
|
opj_image_destroy(l_image);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -301,7 +297,6 @@ int main (int argc, char *argv[])
|
||||||
if (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream)) {
|
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);
|
fprintf(stderr, "ERROR -> test_tile_encoder: failed to write the tile %d!\n",i);
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(l_file);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(l_image);
|
opj_image_destroy(l_image);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -311,14 +306,12 @@ int main (int argc, char *argv[])
|
||||||
if (! opj_end_compress(l_codec,l_stream)) {
|
if (! opj_end_compress(l_codec,l_stream)) {
|
||||||
fprintf(stderr, "ERROR -> test_tile_encoder: failed to end compress!\n");
|
fprintf(stderr, "ERROR -> test_tile_encoder: failed to end compress!\n");
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(l_file);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(l_image);
|
opj_image_destroy(l_image);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(l_file);
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(l_image);
|
opj_image_destroy(l_image);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,6 @@ int main(int argc, char *argv[])
|
||||||
opj_image_t *image;
|
opj_image_t *image;
|
||||||
opj_codec_t* l_codec = 00;
|
opj_codec_t* l_codec = 00;
|
||||||
OPJ_BOOL bSuccess;
|
OPJ_BOOL bSuccess;
|
||||||
FILE *f;
|
|
||||||
opj_stream_t *l_stream = 00;
|
opj_stream_t *l_stream = 00;
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
@ -111,11 +110,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
opj_setup_encoder(l_codec, ¶meters, image);
|
opj_setup_encoder(l_codec, ¶meters, image);
|
||||||
|
|
||||||
strcpy(parameters.outfile, "testempty1.j2k");
|
l_stream = opj_stream_create_default_file_stream_v3("testempty1.j2k",OPJ_FALSE);
|
||||||
f = fopen(parameters.outfile, "wb");
|
|
||||||
assert( f );
|
|
||||||
|
|
||||||
l_stream = opj_stream_create_default_file_stream(f,OPJ_FALSE);
|
|
||||||
assert(l_stream);
|
assert(l_stream);
|
||||||
bSuccess = opj_start_compress(l_codec,image,l_stream);
|
bSuccess = opj_start_compress(l_codec,image,l_stream);
|
||||||
|
|
||||||
|
@ -126,7 +121,6 @@ int main(int argc, char *argv[])
|
||||||
assert( bSuccess );
|
assert( bSuccess );
|
||||||
|
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
|
|
|
@ -73,7 +73,6 @@ int main(int argc, char *argv[])
|
||||||
opj_image_t *image;
|
opj_image_t *image;
|
||||||
opj_codec_t* l_codec = 00;
|
opj_codec_t* l_codec = 00;
|
||||||
OPJ_BOOL bSuccess;
|
OPJ_BOOL bSuccess;
|
||||||
FILE *f;
|
|
||||||
opj_stream_t *l_stream = 00;
|
opj_stream_t *l_stream = 00;
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
|
@ -113,11 +112,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
opj_setup_encoder(l_codec, ¶meters, image);
|
opj_setup_encoder(l_codec, ¶meters, image);
|
||||||
|
|
||||||
strcpy(parameters.outfile, outputfile);
|
l_stream = opj_stream_create_default_file_stream_v3(parameters.outfile,OPJ_FALSE);
|
||||||
f = fopen(parameters.outfile, "wb");
|
|
||||||
assert( f );
|
|
||||||
|
|
||||||
l_stream = opj_stream_create_default_file_stream(f,OPJ_FALSE);
|
|
||||||
assert(l_stream);
|
assert(l_stream);
|
||||||
bSuccess = opj_start_compress(l_codec,image,l_stream);
|
bSuccess = opj_start_compress(l_codec,image,l_stream);
|
||||||
|
|
||||||
|
@ -128,7 +123,6 @@ int main(int argc, char *argv[])
|
||||||
assert( bSuccess );
|
assert( bSuccess );
|
||||||
|
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
opj_destroy_codec(l_codec);
|
opj_destroy_codec(l_codec);
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
|
@ -136,10 +130,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
/* read back the generated file */
|
/* read back the generated file */
|
||||||
{
|
{
|
||||||
FILE *fsrc = fopen(outputfile, "rb");
|
|
||||||
opj_codec_t* d_codec = 00;
|
opj_codec_t* d_codec = 00;
|
||||||
opj_dparameters_t dparameters;
|
opj_dparameters_t dparameters;
|
||||||
assert( fsrc );
|
|
||||||
|
|
||||||
d_codec = opj_create_decompress(OPJ_CODEC_J2K);
|
d_codec = opj_create_decompress(OPJ_CODEC_J2K);
|
||||||
opj_set_info_handler(d_codec, info_callback,00);
|
opj_set_info_handler(d_codec, info_callback,00);
|
||||||
|
@ -149,7 +141,7 @@ int main(int argc, char *argv[])
|
||||||
bSuccess = opj_setup_decoder(d_codec, &dparameters);
|
bSuccess = opj_setup_decoder(d_codec, &dparameters);
|
||||||
assert( bSuccess );
|
assert( bSuccess );
|
||||||
|
|
||||||
l_stream = opj_stream_create_default_file_stream(fsrc,1);
|
l_stream = opj_stream_create_default_file_stream_v3(outputfile,1);
|
||||||
assert( l_stream );
|
assert( l_stream );
|
||||||
|
|
||||||
bSuccess = opj_read_header(l_stream, d_codec, &image);
|
bSuccess = opj_read_header(l_stream, d_codec, &image);
|
||||||
|
@ -162,7 +154,7 @@ int main(int argc, char *argv[])
|
||||||
assert( bSuccess );
|
assert( bSuccess );
|
||||||
|
|
||||||
opj_stream_destroy_v3(l_stream);
|
opj_stream_destroy_v3(l_stream);
|
||||||
fclose(fsrc);
|
|
||||||
opj_destroy_codec(d_codec);
|
opj_destroy_codec(d_codec);
|
||||||
|
|
||||||
opj_image_destroy(image);
|
opj_image_destroy(image);
|
||||||
|
|
Loading…
Reference in New Issue