summaryrefslogtreecommitdiff
path: root/codec
diff options
context:
space:
mode:
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2007-09-17 15:11:20 +0000
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2007-09-17 15:11:20 +0000
commit55c4c14352519b84ad79abcb2f8527e1c25b9e54 (patch)
treeeb3efc84b540eccc43ca1ef19d8ca11ef0370942 /codec
parent569bbb00776f08211f7184ea4ea94571b652adae (diff)
OpenJPEG library interface modified to retain compatibility with version 1.2. Sorry if some of you already adapted their code to the previous interface, but we want to avoid a ABI break....
Diffstat (limited to 'codec')
-rw-r--r--codec/image_to_j2k.c17
-rw-r--r--codec/j2k_to_image.c20
2 files changed, 26 insertions, 11 deletions
diff --git a/codec/image_to_j2k.c b/codec/image_to_j2k.c
index 40ec2af0..d3027a81 100644
--- a/codec/image_to_j2k.c
+++ b/codec/image_to_j2k.c
@@ -1919,7 +1919,10 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
/* encode the image */
- bSuccess = opj_encode(cinfo, cio, image, &cstr_info);
+ 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);
if (!bSuccess) {
opj_cio_close(cio);
fprintf(stderr, "failed to encode image\n");
@@ -1950,8 +1953,8 @@ int main(int argc, char **argv) {
/* free remaining compression structures */
opj_destroy_compress(cinfo);
- opj_destroy_cstr_info(&cstr_info);
-
+ if (*indexfilename)
+ opj_destroy_cstr_info(&cstr_info);
} else { /* JP2 format output */
int codestream_length;
opj_cio_t *cio = NULL;
@@ -1971,7 +1974,10 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
/* encode the image */
- bSuccess = opj_encode(cinfo, cio, image, &cstr_info);
+ 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);
if (!bSuccess) {
opj_cio_close(cio);
fprintf(stderr, "failed to encode image\n");
@@ -2001,7 +2007,8 @@ int main(int argc, char **argv) {
/* free remaining compression structures */
opj_destroy_compress(cinfo);
- opj_destroy_cstr_info(&cstr_info);
+ if (*indexfilename)
+ opj_destroy_cstr_info(&cstr_info);
}
/* free image data */
diff --git a/codec/j2k_to_image.c b/codec/j2k_to_image.c
index 98eae955..f265894e 100644
--- a/codec/j2k_to_image.c
+++ b/codec/j2k_to_image.c
@@ -834,8 +834,6 @@ int main(int argc, char **argv) {
fread(src, 1, file_length, fsrc);
fclose(fsrc);
-
-
/* decode the code-stream */
/* ---------------------- */
@@ -857,7 +855,10 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
- image = opj_decode(dinfo, cio, &cstr_info);
+ if (*indexfilename) // If need to extract codestream information
+ image = opj_decode_with_info(dinfo, cio, &cstr_info);
+ else
+ image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
@@ -896,7 +897,10 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
- image = opj_decode(dinfo, cio, &cstr_info);
+ if (*indexfilename) // If need to extract codestream information
+ image = opj_decode_with_info(dinfo, cio, &cstr_info);
+ else
+ image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
@@ -935,7 +939,10 @@ int main(int argc, char **argv) {
cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length);
/* decode the stream and fill the image structure */
- image = opj_decode(dinfo, cio, &cstr_info);
+ if (*indexfilename) // If need to extract codestream information
+ image = opj_decode_with_info(dinfo, cio, &cstr_info);
+ else
+ image = opj_decode(dinfo, cio);
if(!image) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_decompress(dinfo);
@@ -1029,7 +1036,8 @@ int main(int argc, char **argv) {
opj_destroy_decompress(dinfo);
}
/* free codestream information structure */
- opj_destroy_cstr_info(&cstr_info);
+ if (*indexfilename)
+ opj_destroy_cstr_info(&cstr_info);
/* free image data structure */
opj_image_destroy(image);