summaryrefslogtreecommitdiff
path: root/src/bin/jp2
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-09-25 13:29:02 +0200
committerGitHub <noreply@github.com>2021-09-25 13:29:02 +0200
commit15615751b840d5b85a46292cf8fe393dab8e1a8b (patch)
treebb0e5837e0df4c04e2e899f9d93b8255e50689a1 /src/bin/jp2
parentec651740191dc765c8a1fc5cc3c5348cd0cd2ccc (diff)
parent0544a0885bbc4c918e8b7f759cba70e0c70a0539 (diff)
Merge pull request #1381 from rouault/htj2k_followup
Added support for high throughput (HTJ2K) decoding.
Diffstat (limited to 'src/bin/jp2')
-rw-r--r--src/bin/jp2/opj_decompress.c24
-rw-r--r--src/bin/jp2/opj_dump.c24
2 files changed, 40 insertions, 8 deletions
diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c
index 18ead672..0ef48767 100644
--- a/src/bin/jp2/opj_decompress.c
+++ b/src/bin/jp2/opj_decompress.c
@@ -427,8 +427,24 @@ int load_images(dircnt_t *dirptr, char *imgdirpath)
int get_file_format(const char *filename)
{
unsigned int i;
- static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp", "tif", "tiff", "raw", "yuv", "rawl", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
- static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, TIF_DFMT, RAW_DFMT, RAW_DFMT, RAWL_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
+ static const char * const extension[] = {
+ "pgx", "pnm", "pgm", "ppm", "bmp",
+ "tif", "tiff",
+ "raw", "yuv", "rawl",
+ "tga", "png",
+ "j2k", "jp2", "jpt", "j2c", "jpc",
+ "jph", /* HTJ2K with JP2 boxes */
+ "jhc" /* HTJ2K codestream */
+ };
+ static const int format[] = {
+ PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT,
+ TIF_DFMT, TIF_DFMT,
+ RAW_DFMT, RAW_DFMT, RAWL_DFMT,
+ TGA_DFMT, PNG_DFMT,
+ J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT,
+ JP2_CFMT, /* HTJ2K with JP2 boxes */
+ J2K_CFMT /* HTJ2K codestream */
+ };
const char * ext = strrchr(filename, '.');
if (ext == NULL) {
return -1;
@@ -538,10 +554,10 @@ static int infile_format(const char *fname)
if (memcmp(buf, JP2_RFC3745_MAGIC, 12) == 0 || memcmp(buf, JP2_MAGIC, 4) == 0) {
magic_format = JP2_CFMT;
- magic_s = ".jp2";
+ magic_s = ".jp2 or .jph";
} else if (memcmp(buf, J2K_CODESTREAM_MAGIC, 4) == 0) {
magic_format = J2K_CFMT;
- magic_s = ".j2k or .jpc or .j2c";
+ magic_s = ".j2k or .jpc or .j2c or .jhc";
} else {
return -1;
}
diff --git a/src/bin/jp2/opj_dump.c b/src/bin/jp2/opj_dump.c
index 79d518ec..56db5edc 100644
--- a/src/bin/jp2/opj_dump.c
+++ b/src/bin/jp2/opj_dump.c
@@ -179,8 +179,24 @@ static int load_images(dircnt_t *dirptr, char *imgdirpath)
static int get_file_format(const char *filename)
{
unsigned int i;
- static const char *extension[] = {"pgx", "pnm", "pgm", "ppm", "bmp", "tif", "tiff", "raw", "yuv", "tga", "png", "j2k", "jp2", "jpt", "j2c", "jpc" };
- static const int format[] = { PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT, TIF_DFMT, TIF_DFMT, RAW_DFMT, RAW_DFMT, TGA_DFMT, PNG_DFMT, J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT };
+ static const char * const extension[] = {
+ "pgx", "pnm", "pgm", "ppm", "bmp",
+ "tif", "tiff",
+ "raw", "yuv", "rawl",
+ "tga", "png",
+ "j2k", "jp2", "jpt", "j2c", "jpc",
+ "jph", /* HTJ2K with JP2 boxes */
+ "jhc" /* HTJ2K codestream */
+ };
+ static const int format[] = {
+ PGX_DFMT, PXM_DFMT, PXM_DFMT, PXM_DFMT, BMP_DFMT,
+ TIF_DFMT, TIF_DFMT,
+ RAW_DFMT, RAW_DFMT, RAWL_DFMT,
+ TGA_DFMT, PNG_DFMT,
+ J2K_CFMT, JP2_CFMT, JPT_CFMT, J2K_CFMT, J2K_CFMT,
+ JP2_CFMT, /* HTJ2K with JP2 boxes */
+ J2K_CFMT /* HTJ2K codestream */
+ };
const char *ext = strrchr(filename, '.');
if (ext == NULL) {
return -1;
@@ -271,10 +287,10 @@ static int infile_format(const char *fname)
if (memcmp(buf, JP2_RFC3745_MAGIC, 12) == 0 || memcmp(buf, JP2_MAGIC, 4) == 0) {
magic_format = JP2_CFMT;
- magic_s = ".jp2";
+ magic_s = ".jp2 or .jph";
} else if (memcmp(buf, J2K_CODESTREAM_MAGIC, 4) == 0) {
magic_format = J2K_CFMT;
- magic_s = ".j2k or .jpc or .j2c";
+ magic_s = ".j2k or .jpc or .j2c or .jhc";
} else {
return -1;
}