summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/jp2/convert.h3
-rw-r--r--src/bin/jp2/convertpng.c2
-rw-r--r--src/bin/jp2/converttif.c9
-rw-r--r--src/bin/jp2/opj_compress.c88
-rw-r--r--src/bin/jp2/opj_decompress.c63
-rw-r--r--src/bin/jp2/opj_dump.c43
-rw-r--r--src/bin/jp2/windirent.h10
-rw-r--r--src/bin/jpip/CMakeLists.txt6
-rw-r--r--src/bin/jpip/README2
-rw-r--r--src/bin/jpip/opj_jpip_addxml.c2
-rw-r--r--src/bin/wx/OPJViewer/source/OPJViewer.cpp1875
-rw-r--r--src/lib/openjp2/bench_dwt.c2
-rw-r--r--src/lib/openjp2/cio.h2
-rw-r--r--src/lib/openjp2/dwt.c5
-rw-r--r--src/lib/openjp2/ht_dec.c20
-rw-r--r--src/lib/openjp2/j2k.c89
-rw-r--r--src/lib/openjp2/j2k.h7
-rw-r--r--src/lib/openjp2/jp2.c23
-rw-r--r--src/lib/openjp2/jp2.h9
-rw-r--r--src/lib/openjp2/mct.c2
-rw-r--r--src/lib/openjp2/openjpeg.c27
-rw-r--r--src/lib/openjp2/openjpeg.h29
-rw-r--r--src/lib/openjp2/opj_codec.h3
-rw-r--r--src/lib/openjp2/opj_intmath.h2
-rw-r--r--src/lib/openjp2/pi.c14
-rw-r--r--src/lib/openjp2/sparse_array.c4
-rw-r--r--src/lib/openjp2/t1.h2
-rw-r--r--src/lib/openjp2/t1_ht_generate_luts.c4
-rw-r--r--src/lib/openjp2/t2.c67
-rw-r--r--src/lib/openjpip/auxtrans_manager.c4
-rw-r--r--src/lib/openjpip/imgsock_manager.h6
-rw-r--r--src/lib/openjpip/index_manager.c2
-rw-r--r--src/lib/openjpip/jpip_parser.c2
-rw-r--r--src/lib/openjpip/metadata_manager.h2
-rw-r--r--src/lib/openjpip/mhixbox_manager.h2
35 files changed, 1365 insertions, 1067 deletions
diff --git a/src/bin/jp2/convert.h b/src/bin/jp2/convert.h
index 61439d49..b9b009ce 100644
--- a/src/bin/jp2/convert.h
+++ b/src/bin/jp2/convert.h
@@ -95,7 +95,8 @@ opj_image_t* bmptoimage(const char *filename, opj_cparameters_t *parameters);
int imagetobmp(opj_image_t *image, const char *outfile);
/* TIFF conversion*/
-opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters);
+opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters,
+ const unsigned int target_bitdepth);
int imagetotif(opj_image_t *image, const char *outfile);
/**
Load a single image component encoded in PGX file format
diff --git a/src/bin/jp2/convertpng.c b/src/bin/jp2/convertpng.c
index b8378d35..385d8856 100644
--- a/src/bin/jp2/convertpng.c
+++ b/src/bin/jp2/convertpng.c
@@ -120,7 +120,7 @@ static opj_image_t * pngtoimage_internal(opj_cparameters_t * params,
if (png_get_valid(png, info, PNG_INFO_tRNS)) {
png_set_expand(png);
}
- /* We might wan't to expand background */
+ /* We might want to expand background */
/*
if(png_get_valid(png, info, PNG_INFO_bKGD)) {
png_color_16p bgnd;
diff --git a/src/bin/jp2/converttif.c b/src/bin/jp2/converttif.c
index 61b295bd..c2e7d1cb 100644
--- a/src/bin/jp2/converttif.c
+++ b/src/bin/jp2/converttif.c
@@ -1247,7 +1247,8 @@ static void tif_16uto32s(const OPJ_UINT16* pSrc, OPJ_INT32* pDst,
* libtiff/tif_getimage.c : 1,2,4,8,16 bitspersample accepted
* CINEMA : 12 bit precision
*/
-opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
+opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters,
+ const unsigned int target_bitdepth)
{
int subsampling_dx = parameters->subsampling_dx;
int subsampling_dy = parameters->subsampling_dy;
@@ -1283,8 +1284,6 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &tiSpp);
TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &tiPhoto);
TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &tiPC);
- w = (int)tiWidth;
- h = (int)tiHeight;
if (tiSpp == 0 || tiSpp > 4) { /* should be 1 ... 4 */
fprintf(stderr, "tiftoimage: Bad value for samples per pixel == %d.\n"
@@ -1506,6 +1505,10 @@ opj_image_t* tiftoimage(const char *filename, opj_cparameters_t *parameters)
scale_component(&(image->comps[j]), 12);
}
+ } else if ((target_bitdepth > 0) && (target_bitdepth != tiBps)) {
+ for (j = 0; j < numcomps; ++j) {
+ scale_component(&(image->comps[j]), target_bitdepth);
+ }
}
return image;
diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c
index e488abcd..fc9b7c12 100644
--- a/src/bin/jp2/opj_compress.c
+++ b/src/bin/jp2/opj_compress.c
@@ -44,6 +44,7 @@
#include <stdlib.h>
#include <math.h>
#include <assert.h>
+#include <limits.h>
#ifdef _WIN32
#include "windirent.h"
@@ -186,6 +187,11 @@ static void encode_help_display(void)
fprintf(stdout,
" It corresponds to the number of DWT decompositions +1. \n");
fprintf(stdout, " Default: 6.\n");
+ fprintf(stdout, "-TargetBitDepth <target bit depth>\n");
+ fprintf(stdout, " Target bit depth.\n");
+ fprintf(stdout, " Number of bits per component to use from input image\n");
+ fprintf(stdout, " if all bits are unwanted.\n");
+ fprintf(stdout, " (Currently only implemented for TIF.)\n");
fprintf(stdout, "-b <cblk width>,<cblk height>\n");
fprintf(stdout,
" Code-block size. The dimension must respect the constraint \n");
@@ -298,13 +304,16 @@ static void encode_help_display(void)
fprintf(stdout, " Y >= 0 and Y <= 9.\n");
fprintf(stdout,
" framerate > 0 may be specified to enhance checks and set maximum bit rate when Y > 0.\n");
+ fprintf(stdout, "-GuardBits value\n");
+ fprintf(stdout,
+ " Number of guard bits in [0,7] range. Usually 1 or 2 (default value).\n");
fprintf(stdout, "-jpip\n");
fprintf(stdout, " Write jpip codestream index box in JP2 output file.\n");
fprintf(stdout, " Currently supports only RPCL order.\n");
fprintf(stdout, "-C <comment>\n");
fprintf(stdout, " Add <comment> in the comment marker segment.\n");
if (opj_has_thread_support()) {
- fprintf(stdout, " -threads <num_threads|ALL_CPUS>\n"
+ fprintf(stdout, "-threads <num_threads|ALL_CPUS>\n"
" Number of threads to use for encoding or ALL_CPUS for all available cores.\n");
}
/* UniPG>> */
@@ -480,6 +489,11 @@ static unsigned int get_num_images(char *imgdirpath)
if (strcmp(".", content->d_name) == 0 || strcmp("..", content->d_name) == 0) {
continue;
}
+ if (num_images == UINT_MAX) {
+ fprintf(stderr, "Too many files in folder %s\n", imgdirpath);
+ num_images = 0;
+ break;
+ }
num_images++;
}
closedir(dir);
@@ -542,7 +556,8 @@ static char * get_file_name(char *name)
return fname;
}
-static char get_next_file(int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
+static char get_next_file(unsigned int imageno, dircnt_t *dirptr,
+ img_fol_t *img_fol,
opj_cparameters_t *parameters)
{
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],
@@ -550,7 +565,7 @@ static char get_next_file(int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
char *temp_p, temp1[OPJ_PATH_LEN] = "";
strcpy(image_filename, dirptr->filename[imageno]);
- fprintf(stderr, "File Number %d \"%s\"\n", imageno, image_filename);
+ fprintf(stderr, "File Number %u \"%s\"\n", imageno, image_filename);
parameters->decod_format = get_file_format(image_filename);
if (parameters->decod_format == -1) {
return 1;
@@ -600,7 +615,9 @@ static int parse_cmdline_encoder(int argc, char **argv,
int* pOutFramerate,
OPJ_BOOL* pOutPLT,
OPJ_BOOL* pOutTLM,
- int* pOutNumThreads)
+ int* pOutGuardBits,
+ int* pOutNumThreads,
+ unsigned int* pTarget_bitdepth)
{
OPJ_UINT32 i, j;
int totlen, c;
@@ -620,10 +637,12 @@ static int parse_cmdline_encoder(int argc, char **argv,
{"PLT", NO_ARG, NULL, 'A'},
{"threads", REQ_ARG, NULL, 'B'},
{"TLM", NO_ARG, NULL, 'D'},
+ {"TargetBitDepth", REQ_ARG, NULL, 'X'},
+ {"GuardBits", REQ_ARG, NULL, 'G'}
};
/* 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:JY:"
+ const char optlist[] = "i:o:r:q:n:b:c:t:p:s:SEM:x:R:d:T:If:P:C:F:u:JY:X:G:"
#ifdef USE_JPWL
"W:"
#endif /* USE_JPWL */
@@ -909,6 +928,24 @@ static int parse_cmdline_encoder(int argc, char **argv,
break;
/* ----------------------------------------------------- */
+ case 'X': { /* target bitdepth */
+ char *s = opj_optarg;
+ sscanf(s, "%u", pTarget_bitdepth);
+ if (*pTarget_bitdepth == 0) {
+ fprintf(stderr, "Target bitdepth must be at least 1 bit.\n");
+ return 1;
+ }
+ }
+ break;
+
+ /* ----------------------------------------------------- */
+ case 'G': { /* guard bits */
+ char *s = opj_optarg;
+ sscanf(s, "%d", pOutGuardBits);
+ }
+ break;
+
+ /* ----------------------------------------------------- */
case 'n': { /* resolution */
sscanf(opj_optarg, "%d", &parameters->numresolution);
@@ -1907,6 +1944,10 @@ int main(int argc, char **argv)
OPJ_BOOL PLT = OPJ_FALSE;
OPJ_BOOL TLM = OPJ_FALSE;
int num_threads = 0;
+ int guard_bits = -1;
+
+ /** desired bitdepth from input file */
+ unsigned int target_bitdepth = 0;
/* set encoding parameters to default values */
opj_set_default_encoder_parameters(&parameters);
@@ -1928,7 +1969,7 @@ int main(int argc, char **argv)
255; /* This will be set later according to the input image or the provided option */
if (parse_cmdline_encoder(argc, argv, &parameters, &img_fol, &raw_cp,
indexfilename, sizeof(indexfilename), &framerate, &PLT, &TLM,
- &num_threads) == 1) {
+ &guard_bits, &num_threads, &target_bitdepth) == 1) {
ret = 1;
goto fin;
}
@@ -1936,28 +1977,29 @@ int main(int argc, char **argv)
/* Read directory if necessary */
if (img_fol.set_imgdir == 1) {
num_images = get_num_images(img_fol.imgdirpath);
+ if (num_images == 0) {
+ fprintf(stdout, "Folder is empty\n");
+ ret = 0;
+ goto fin;
+ }
dirptr = (dircnt_t*)malloc(sizeof(dircnt_t));
if (dirptr) {
- dirptr->filename_buf = (char*)malloc(num_images * OPJ_PATH_LEN * sizeof(
+ dirptr->filename_buf = (char*)calloc(num_images, OPJ_PATH_LEN * sizeof(
char)); /* Stores at max 10 image file names*/
- dirptr->filename = (char**) malloc(num_images * sizeof(char*));
+ dirptr->filename = (char**) calloc(num_images, sizeof(char*));
if (!dirptr->filename_buf) {
ret = 0;
goto fin;
}
for (i = 0; i < num_images; i++) {
- dirptr->filename[i] = dirptr->filename_buf + i * OPJ_PATH_LEN;
+ dirptr->filename[i] = dirptr->filename_buf + (size_t)i * OPJ_PATH_LEN;
}
}
if (load_images(dirptr, img_fol.imgdirpath) == 1) {
ret = 0;
goto fin;
}
- if (num_images == 0) {
- fprintf(stdout, "Folder is empty\n");
- ret = 0;
- goto fin;
- }
+
} else {
num_images = 1;
}
@@ -1967,7 +2009,7 @@ int main(int argc, char **argv)
fprintf(stderr, "\n");
if (img_fol.set_imgdir == 1) {
- if (get_next_file((int)imageno, dirptr, &img_fol, &parameters)) {
+ if (get_next_file(imageno, dirptr, &img_fol, &parameters)) {
fprintf(stderr, "skipping file...\n");
continue;
}
@@ -2021,7 +2063,7 @@ int main(int argc, char **argv)
#ifdef OPJ_HAVE_LIBTIFF
case TIF_DFMT:
- image = tiftoimage(parameters.infile, &parameters);
+ image = tiftoimage(parameters.infile, &parameters, target_bitdepth);
if (!image) {
fprintf(stderr, "Unable to load tif(f) file\n");
ret = 1;
@@ -2172,17 +2214,21 @@ int main(int argc, char **argv)
goto fin;
}
- if (PLT || TLM) {
- const char* options[3] = { NULL, NULL, NULL };
+ {
+ const char* options[4] = { NULL, NULL, NULL, NULL };
int iOpt = 0;
+ char szGuardBits[32];
if (PLT) {
options[iOpt++] = "PLT=YES";
}
if (TLM) {
options[iOpt++] = "TLM=YES";
}
- (void)iOpt;
- if (!opj_encoder_set_extra_options(l_codec, options)) {
+ if (guard_bits >= 0) {
+ sprintf(szGuardBits, "GUARD_BITS=%d", guard_bits);
+ options[iOpt++] = szGuardBits;
+ }
+ if (iOpt > 0 && !opj_encoder_set_extra_options(l_codec, options)) {
fprintf(stderr, "failed to encode image: opj_encoder_set_extra_options\n");
opj_destroy_codec(l_codec);
opj_image_destroy(image);
@@ -2222,7 +2268,7 @@ int main(int argc, char **argv)
}
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",
+ fprintf(stderr, "ERROR -> test_tile_encoder: failed to write the tile %u!\n",
i);
opj_stream_destroy(l_stream);
opj_destroy_codec(l_codec);
diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c
index 2ce2783a..c32cc3dc 100644
--- a/src/bin/jp2/opj_decompress.c
+++ b/src/bin/jp2/opj_decompress.c
@@ -44,6 +44,7 @@
#include <stdlib.h>
#include <math.h>
#include <time.h>
+#include <limits.h>
#ifdef _WIN32
#include "windirent.h"
@@ -152,6 +153,8 @@ typedef struct opj_decompress_params {
int num_threads;
/* Quiet */
int quiet;
+ /* Allow partial decode */
+ int allow_partial;
/** number of components to decode */
OPJ_UINT32 numcomps;
/** indices of components to decode */
@@ -160,10 +163,10 @@ typedef struct opj_decompress_params {
/* -------------------------------------------------------------------------- */
/* Declarations */
-int get_num_images(char *imgdirpath);
+unsigned int get_num_images(char *imgdirpath);
int load_images(dircnt_t *dirptr, char *imgdirpath);
int get_file_format(const char *filename);
-char get_next_file(int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
+char get_next_file(unsigned int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
opj_decompress_parameters *parameters);
static int infile_format(const char *fname);
@@ -226,7 +229,7 @@ static void decode_help_display(void)
" OPTIONAL\n"
" Force the precision (bit depth) of components.\n");
fprintf(stdout,
- " There shall be at least 1 value. Theres no limit on the number of values (comma separated, last values ignored if too much values).\n"
+ " There shall be at least 1 value. There is no limit on the number of values (comma separated, last values ignored if too much values).\n"
" If there are less values than components, the last value is used for remaining components.\n"
" If 'C' is specified (default), values are clipped.\n"
" If 'S' is specified, values are scaled.\n"
@@ -245,6 +248,8 @@ static void decode_help_display(void)
fprintf(stdout, " -threads <num_threads|ALL_CPUS>\n"
" Number of threads to use for decoding or ALL_CPUS for all available cores.\n");
}
+ fprintf(stdout, " -allow-partial\n"
+ " Disable strict mode to allow decoding partial codestreams.\n");
fprintf(stdout, " -quiet\n"
" Disable output from the library and other output.\n");
/* UniPG>> */
@@ -370,11 +375,11 @@ static OPJ_BOOL parse_precision(const char* option,
/* -------------------------------------------------------------------------- */
-int get_num_images(char *imgdirpath)
+unsigned int get_num_images(char *imgdirpath)
{
DIR *dir;
struct dirent* content;
- int num_images = 0;
+ unsigned int num_images = 0;
/*Reading the input images from given input directory*/
@@ -388,7 +393,13 @@ int get_num_images(char *imgdirpath)
if (strcmp(".", content->d_name) == 0 || strcmp("..", content->d_name) == 0) {
continue;
}
+ if (num_images == UINT_MAX) {
+ fprintf(stderr, "Too many files in folder %s\n", imgdirpath);
+ num_images = 0;
+ break;
+ }
num_images++;
+
}
closedir(dir);
return num_images;
@@ -468,7 +479,7 @@ const char* path_separator = "/";
#endif
/* -------------------------------------------------------------------------- */
-char get_next_file(int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
+char get_next_file(unsigned int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
opj_decompress_parameters *parameters)
{
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],
@@ -476,7 +487,7 @@ char get_next_file(int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
char *temp_p, temp1[OPJ_PATH_LEN] = "";
strcpy(image_filename, dirptr->filename[imageno]);
- fprintf(stderr, "File Number %d \"%s\"\n", imageno, image_filename);
+ fprintf(stderr, "File Number %u \"%s\"\n", imageno, image_filename);
if (strlen(img_fol->imgdirpath) + strlen(path_separator) + strlen(
image_filename) + 1 > sizeof(infilename)) {
return 1;
@@ -594,6 +605,7 @@ int parse_cmdline_decoder(int argc, char **argv,
{"split-pnm", NO_ARG, NULL, 1},
{"threads", REQ_ARG, NULL, 'T'},
{"quiet", NO_ARG, NULL, 1},
+ {"allow-partial", NO_ARG, NULL, 1},
};
const char optlist[] = "i:o:r:l:x:d:t:p:c:"
@@ -609,6 +621,7 @@ int parse_cmdline_decoder(int argc, char **argv,
long_option[3].flag = &(parameters->upsample);
long_option[4].flag = &(parameters->split_pnm);
long_option[6].flag = &(parameters->quiet);
+ long_option[7].flag = &(parameters->allow_partial);
totlen = sizeof(long_option);
opj_reset_options_reading();
img_fol->set_out_format = 0;
@@ -802,7 +815,7 @@ int parse_cmdline_decoder(int argc, char **argv,
break;
/* ----------------------------------------------------- */
- case 'c': { /* Componenets */
+ case 'c': { /* Components */
const char* iter = opj_optarg;
while (1) {
parameters->numcomps ++;
@@ -1334,7 +1347,7 @@ int main(int argc, char **argv)
{
opj_decompress_parameters parameters; /* decompression parameters */
- OPJ_INT32 num_images, imageno;
+ unsigned int num_images, imageno;
img_fol_t img_fol;
dircnt_t *dirptr = NULL;
int failed = 0;
@@ -1365,41 +1378,41 @@ int main(int argc, char **argv)
/* Initialize reading of directory */
if (img_fol.set_imgdir == 1) {
- int it_image;
+ unsigned int it_image;
num_images = get_num_images(img_fol.imgdirpath);
-
+ if (num_images == 0) {
+ fprintf(stderr, "Folder is empty\n");
+ failed = 1;
+ goto fin;
+ }
dirptr = (dircnt_t*)calloc(1, sizeof(dircnt_t));
if (!dirptr) {
destroy_parameters(&parameters);
return EXIT_FAILURE;
}
/* Stores at max 10 image file names */
- dirptr->filename_buf = (char*)malloc(sizeof(char) *
- (size_t)num_images * OPJ_PATH_LEN);
+ dirptr->filename_buf = calloc((size_t) num_images, sizeof(char) * OPJ_PATH_LEN);
if (!dirptr->filename_buf) {
failed = 1;
goto fin;
}
- dirptr->filename = (char**) malloc((size_t)num_images * sizeof(char*));
+ dirptr->filename = (char**) calloc((size_t) num_images, sizeof(char*));
if (!dirptr->filename) {
failed = 1;
goto fin;
}
for (it_image = 0; it_image < num_images; it_image++) {
- dirptr->filename[it_image] = dirptr->filename_buf + it_image * OPJ_PATH_LEN;
+ dirptr->filename[it_image] = dirptr->filename_buf + (size_t)it_image *
+ OPJ_PATH_LEN;
}
if (load_images(dirptr, img_fol.imgdirpath) == 1) {
failed = 1;
goto fin;
}
- if (num_images == 0) {
- fprintf(stderr, "Folder is empty\n");
- failed = 1;
- goto fin;
- }
+
} else {
num_images = 1;
}
@@ -1484,6 +1497,16 @@ int main(int argc, char **argv)
goto fin;
}
+ /* Disable strict mode if we want to decode partial codestreams. */
+ if (parameters.allow_partial &&
+ !opj_decoder_set_strict_mode(l_codec, OPJ_FALSE)) {
+ fprintf(stderr, "ERROR -> opj_decompress: failed to disable strict mode\n");
+ opj_stream_destroy(l_stream);
+ opj_destroy_codec(l_codec);
+ failed = 1;
+ goto fin;
+ }
+
if (parameters.num_threads >= 1 &&
!opj_codec_set_threads(l_codec, parameters.num_threads)) {
fprintf(stderr, "ERROR -> opj_decompress: failed to set number of threads\n");
diff --git a/src/bin/jp2/opj_dump.c b/src/bin/jp2/opj_dump.c
index 6111d2ab..1ee7973e 100644
--- a/src/bin/jp2/opj_dump.c
+++ b/src/bin/jp2/opj_dump.c
@@ -36,6 +36,7 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
+#include <limits.h>
#ifdef _WIN32
#include "windirent.h"
@@ -82,10 +83,11 @@ typedef struct img_folder {
/* -------------------------------------------------------------------------- */
/* Declarations */
-static int get_num_images(char *imgdirpath);
+static unsigned int get_num_images(char *imgdirpath);
static int load_images(dircnt_t *dirptr, char *imgdirpath);
static int get_file_format(const char *filename);
-static char get_next_file(int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
+static char get_next_file(unsigned int imageno, dircnt_t *dirptr,
+ img_fol_t *img_fol,
opj_dparameters_t *parameters);
static int infile_format(const char *fname);
@@ -122,11 +124,11 @@ static void decode_help_display(void)
}
/* -------------------------------------------------------------------------- */
-static int get_num_images(char *imgdirpath)
+static unsigned int get_num_images(char *imgdirpath)
{
DIR *dir;
struct dirent* content;
- int num_images = 0;
+ unsigned int num_images = 0;
/*Reading the input images from given input directory*/
@@ -140,6 +142,11 @@ static int get_num_images(char *imgdirpath)
if (strcmp(".", content->d_name) == 0 || strcmp("..", content->d_name) == 0) {
continue;
}
+ if (num_images == UINT_MAX) {
+ fprintf(stderr, "Too many files in folder %s\n", imgdirpath);
+ num_images = 0;
+ break;
+ }
num_images++;
}
closedir(dir);
@@ -214,7 +221,8 @@ static int get_file_format(const char *filename)
}
/* -------------------------------------------------------------------------- */
-static char get_next_file(int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
+static char get_next_file(unsigned int imageno, dircnt_t *dirptr,
+ img_fol_t *img_fol,
opj_dparameters_t *parameters)
{
char image_filename[OPJ_PATH_LEN], infilename[OPJ_PATH_LEN],
@@ -222,7 +230,7 @@ static char get_next_file(int imageno, dircnt_t *dirptr, img_fol_t *img_fol,
char *temp_p, temp1[OPJ_PATH_LEN] = "";
strcpy(image_filename, dirptr->filename[imageno]);
- fprintf(stderr, "File Number %d \"%s\"\n", imageno, image_filename);
+ fprintf(stderr, "File Number %u \"%s\"\n", imageno, image_filename);
parameters->decod_format = get_file_format(image_filename);
if (parameters->decod_format == -1) {
return 1;
@@ -486,7 +494,7 @@ int main(int argc, char *argv[])
opj_codestream_info_v2_t* cstr_info = NULL;
opj_codestream_index_t* cstr_index = NULL;
- OPJ_INT32 num_images, imageno;
+ unsigned int num_images, imageno;
img_fol_t img_fol;
dircnt_t *dirptr = NULL;
@@ -508,37 +516,38 @@ int main(int argc, char *argv[])
/* Initialize reading of directory */
if (img_fol.set_imgdir == 1) {
- int it_image;
+ unsigned int it_image;
num_images = get_num_images(img_fol.imgdirpath);
-
+ if (num_images == 0) {
+ fprintf(stdout, "Folder is empty\n");
+ goto fails;
+ }
dirptr = (dircnt_t*)malloc(sizeof(dircnt_t));
if (!dirptr) {
return EXIT_FAILURE;
}
- dirptr->filename_buf = (char*)malloc((size_t)num_images * OPJ_PATH_LEN * sizeof(
- char)); /* Stores at max 10 image file names*/
+ /* Stores at max 10 image file names*/
+ dirptr->filename_buf = (char*) calloc((size_t) num_images,
+ OPJ_PATH_LEN * sizeof(char));
if (!dirptr->filename_buf) {
free(dirptr);
return EXIT_FAILURE;
}
- dirptr->filename = (char**) malloc((size_t)num_images * sizeof(char*));
+ dirptr->filename = (char**) calloc((size_t) num_images, sizeof(char*));
if (!dirptr->filename) {
goto fails;
}
for (it_image = 0; it_image < num_images; it_image++) {
- dirptr->filename[it_image] = dirptr->filename_buf + it_image * OPJ_PATH_LEN;
+ dirptr->filename[it_image] = dirptr->filename_buf + (size_t)it_image *
+ OPJ_PATH_LEN;
}
if (load_images(dirptr, img_fol.imgdirpath) == 1) {
goto fails;
}
- if (num_images == 0) {
- fprintf(stdout, "Folder is empty\n");
- goto fails;
- }
} else {
num_images = 1;
}
diff --git a/src/bin/jp2/windirent.h b/src/bin/jp2/windirent.h
index 19509822..2f0e4ad2 100644
--- a/src/bin/jp2/windirent.h
+++ b/src/bin/jp2/windirent.h
@@ -69,7 +69,7 @@
* handle inclusion of sys/dir.h in a part that is compiled only in Apollo
* operating system. To fix the problem you need to insert DIR.H into
* SYSINCL.DAT located in MSVC\BIN directory and restart visual C++.
- * Consult manuals for more informaton about the problem.
+ * Consult manuals for more information about the problem.
*
* Since many UNIX systems have dirent.h we assume to have one also.
* However, if your UNIX system does not have dirent.h you can download one
@@ -102,7 +102,7 @@
/*
* See what kind of dirent interface we have unless autoconf has already
- * determinated that.
+ * determined that.
*/
#if !defined(HAVE_DIRENT_H) && !defined(HAVE_DIRECT_H) && !defined(HAVE_SYS_DIR_H) && !defined(HAVE_NDIR_H) && !defined(HAVE_SYS_NDIR_H) && !defined(HAVE_DIR_H)
# if defined(_MSC_VER) /* Microsoft C/C++ */
@@ -172,7 +172,7 @@
#elif defined(MSDOS) || defined(WIN32)
-/* figure out type of underlaying directory interface to be used */
+/* figure out type of underlying directory interface to be used */
# if defined(WIN32)
# define DIRENT_WIN32_INTERFACE
# elif defined(MSDOS)
@@ -254,7 +254,7 @@ typedef struct dirent {
/*** Operating system specific part ***/
# if defined(DIRENT_WIN32_INTERFACE) /*WIN32*/
WIN32_FIND_DATA data;
-# elif defined(DIRENT_MSDOS_INTERFACE) /*MSDOS*/
+# elif defined(DIRENT_MSDOS_INTERFACE) /*MS-DOS*/
# if defined(DIRENT_USE_FFBLK)
struct ffblk data;
# else
@@ -592,7 +592,7 @@ rewinddir(DIR *dirp)
/* re-open previous stream */
if (_initdir(dirp) == 0) {
/* initialization failed but we cannot deal with error. User will notice
- * error later when she tries to retrieve first directory enty. */
+ * error later when she tries to retrieve first directory entry. */
/*EMPTY*/;
}
}
diff --git a/src/bin/jpip/CMakeLists.txt b/src/bin/jpip/CMakeLists.txt
index 9b24fa4a..c16e4271 100644
--- a/src/bin/jpip/CMakeLists.txt
+++ b/src/bin/jpip/CMakeLists.txt
@@ -57,14 +57,14 @@ add_executable(${exe} ${exe}.c)
endforeach()
# Build the two java clients:
-find_package(Java 1.6 COMPONENTS Development) # javac, jar
+find_package(Java 1.8 COMPONENTS Development) # javac, jar
# User can override this:
if(NOT DEFINED JAVA_SOURCE_VERSION)
- set(JAVA_SOURCE_VERSION 1.6)
+ set(JAVA_SOURCE_VERSION 1.8)
endif()
if(NOT DEFINED JAVA_TARGET_VERSION)
- set(JAVA_TARGET_VERSION 1.6)
+ set(JAVA_TARGET_VERSION 1.8)
endif()
# Only build the java viewer if dev is found:
diff --git a/src/bin/jpip/README b/src/bin/jpip/README
index 5bcb01fa..f9baff2c 100644
--- a/src/bin/jpip/README
+++ b/src/bin/jpip/README
@@ -92,7 +92,7 @@ Server:
For shutting down JPIP server:
%GET http://hostname/myFCGI?quitJPIP
Notice, http://hostname/myFCGI is the HTTP server URI (myFCGI refers to opj_server by the server setting)
- Requst message "quitJPIP" can be changed in Makfile, modify -DQUIT_SIGNAL=\"quitJPIP\"
+ Request message "quitJPIP" can be changed in Makefile, modify -DQUIT_SIGNAL=\"quitJPIP\"
Client:
1. Launch image decoding server, and keep it alive as long as image viewers are open
diff --git a/src/bin/jpip/opj_jpip_addxml.c b/src/bin/jpip/opj_jpip_addxml.c
index 22fdd05b..78323de5 100644
--- a/src/bin/jpip/opj_jpip_addxml.c
+++ b/src/bin/jpip/opj_jpip_addxml.c
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
long fsize, boxsize;
if (argc < 3) {
- fprintf(stderr, "USAGE: %s modifing.jp2 adding.xml\n", argv[0]);
+ fprintf(stderr, "USAGE: %s modifying.jp2 adding.xml\n", argv[0]);
return -1;
}
diff --git a/src/bin/wx/OPJViewer/source/OPJViewer.cpp b/src/bin/wx/OPJViewer/source/OPJViewer.cpp
index bb1ea05d..59ab5e1f 100644
--- a/src/bin/wx/OPJViewer/source/OPJViewer.cpp
+++ b/src/bin/wx/OPJViewer/source/OPJViewer.cpp
@@ -1,6 +1,6 @@
/*
- * The copyright in this software is being made available under the 2-clauses
- * BSD License, included below. This software may be subject to other third
+ * The copyright in this software is being made available under the 2-clauses
+ * BSD License, included below. This software may be subject to other third
* party and contributor rights, including patent rights, and no such rights
* are granted under this license.
*
@@ -52,7 +52,7 @@
// Name: dialogs.cpp
// Purpose: Common dialogs demo
// Author: Julian Smart
-// Modified by: ABX (2004) - adjustements for conditional building + new menu
+// Modified by: ABX (2004) - adjustments for conditional building + new menu
// Created: 04/01/98
// RCS-ID: $Id: dialogs.cpp,v 1.163 2006/11/04 10:57:24 VZ Exp $
// Copyright: (c) Julian Smart
@@ -102,7 +102,7 @@
// Name: dialogs.cpp
// Purpose: Common dialogs demo
// Author: Julian Smart
-// Modified by: ABX (2004) - adjustements for conditional building + new menu
+// Modified by: ABX (2004) - adjustments for conditional building + new menu
// Created: 04/01/98
// RCS-ID: $Id: dialogs.cpp,v 1.163 2006/11/04 10:57:24 VZ Exp $
// Copyright: (c) Julian Smart
@@ -137,12 +137,12 @@ int winNumber = 1;
// Initialise this in OnInit, not statically
bool OPJViewerApp::OnInit(void)
{
- int n;
+ int n;
#if wxUSE_UNICODE
wxChar **wxArgv = new wxChar *[argc + 1];
- for (n = 0; n < argc; n++ ) {
+ for (n = 0; n < argc; n++) {
wxMB2WXbuf warg = wxConvertMB2WX((char *) argv[n]);
wxArgv[n] = wxStrdup(warg);
}
@@ -151,19 +151,22 @@ bool OPJViewerApp::OnInit(void)
#else // !wxUSE_UNICODE
- #define wxArgv argv
+#define wxArgv argv
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
#if wxUSE_CMDLINE_PARSER
- static const wxCmdLineEntryDesc cmdLineDesc[] =
- {
- { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("show this help message"),
- wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
+ static const wxCmdLineEntryDesc cmdLineDesc[] = {
+ {
+ wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("show this help message"),
+ wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP
+ },
- { wxCMD_LINE_PARAM, NULL, NULL, _T("input file"),
- wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE },
+ {
+ wxCMD_LINE_PARAM, NULL, NULL, _T("input file"),
+ wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE
+ },
{ wxCMD_LINE_NONE }
};
@@ -188,275 +191,293 @@ bool OPJViewerApp::OnInit(void)
//wxInitAllImageHandlers();
#if wxUSE_LIBJPEG
- wxImage::AddHandler( new wxJPEGHandler );
+ wxImage::AddHandler(new wxJPEGHandler);
#endif
#if wxUSE_LIBOPENJPEG
- wxImage::AddHandler( new wxJPEG2000Handler );
+ wxImage::AddHandler(new wxJPEG2000Handler);
#endif
#if USE_MXF
- wxImage::AddHandler( new wxMXFHandler );
+ wxImage::AddHandler(new wxMXFHandler);
#endif // USE_MXF
#if OPJ_MANYFORMATS
- wxImage::AddHandler( new wxBMPHandler );
- wxImage::AddHandler( new wxPNGHandler );
- wxImage::AddHandler( new wxGIFHandler );
- wxImage::AddHandler( new wxPNMHandler );
- wxImage::AddHandler( new wxTIFFHandler );
+ wxImage::AddHandler(new wxBMPHandler);
+ wxImage::AddHandler(new wxPNGHandler);
+ wxImage::AddHandler(new wxGIFHandler);
+ wxImage::AddHandler(new wxPNMHandler);
+ wxImage::AddHandler(new wxTIFFHandler);
#endif
// we use a XPM image in our HTML page
wxImage::AddHandler(new wxXPMHandler);
- // memory file system
+ // memory file system
wxFileSystem::AddHandler(new wxMemoryFSHandler);
#ifdef OPJ_INICONFIG
- //load decoding engine parameters
- OPJconfig = new wxConfig(OPJ_APPLICATION, OPJ_APPLICATION_VENDOR);
-
- OPJconfig->Read(wxT("decode/enabledeco"), &m_enabledeco, (bool) true);
- OPJconfig->Read(wxT("decode/enableparse"), &m_enableparse, (bool) true);
- OPJconfig->Read(wxT("decode/resizemethod"), &m_resizemethod, (long) 0);
- OPJconfig->Read(wxT("decode/xxxreducefactor"), &m_reducefactor, (long) 0);
- OPJconfig->Read(wxT("decode/xxxqualitylayers"), &m_qualitylayers, (long) 0);
- OPJconfig->Read(wxT("decode/xxxcomponents"), &m_components, (long) 0);
- OPJconfig->Read(wxT("decode/xxxframenum"), &m_framenum, (long) 0);
+ //load decoding engine parameters
+ OPJconfig = new wxConfig(OPJ_APPLICATION, OPJ_APPLICATION_VENDOR);
+
+ OPJconfig->Read(wxT("decode/enabledeco"), &m_enabledeco, (bool) true);
+ OPJconfig->Read(wxT("decode/enableparse"), &m_enableparse, (bool) true);
+ OPJconfig->Read(wxT("decode/resizemethod"), &m_resizemethod, (long) 0);
+ OPJconfig->Read(wxT("decode/xxxreducefactor"), &m_reducefactor, (long) 0);
+ OPJconfig->Read(wxT("decode/xxxqualitylayers"), &m_qualitylayers, (long) 0);
+ OPJconfig->Read(wxT("decode/xxxcomponents"), &m_components, (long) 0);
+ OPJconfig->Read(wxT("decode/xxxframenum"), &m_framenum, (long) 0);
#ifdef USE_JPWL
- OPJconfig->Read(wxT("decode/enablejpwl"), &m_enablejpwl, (bool) true);
- OPJconfig->Read(wxT("decode/expcomps"), &m_expcomps, (long) JPWL_EXPECTED_COMPONENTS);
- OPJconfig->Read(wxT("decode/maxtiles"), &m_maxtiles, (long) JPWL_MAXIMUM_TILES);
+ OPJconfig->Read(wxT("decode/enablejpwl"), &m_enablejpwl, (bool) true);
+ OPJconfig->Read(wxT("decode/expcomps"), &m_expcomps,
+ (long) JPWL_EXPECTED_COMPONENTS);
+ OPJconfig->Read(wxT("decode/maxtiles"), &m_maxtiles, (long) JPWL_MAXIMUM_TILES);
#endif // USE_JPWL
- OPJconfig->Write(wxT("teststring"), wxT("This is a test value"));
- OPJconfig->Write(wxT("testbool"), (bool) true);
- OPJconfig->Write(wxT("testlong"), (long) 245);
-
- OPJconfig->Read(wxT("showtoolbar"), &m_showtoolbar, (bool) true);
- OPJconfig->Read(wxT("showbrowser"), &m_showbrowser, (bool) true);
- OPJconfig->Read(wxT("showpeeker"), &m_showpeeker, (bool) true);
- OPJconfig->Read(wxT("browserwidth"), &m_browserwidth, (long) OPJ_BROWSER_WIDTH);
- OPJconfig->Read(wxT("peekerheight"), &m_peekerheight, (long) OPJ_PEEKER_HEIGHT);
- OPJconfig->Read(wxT("framewidth"), &m_framewidth, (long) OPJ_FRAME_WIDTH);
- OPJconfig->Read(wxT("frameheight"), &m_frameheight, (long) OPJ_FRAME_HEIGHT);
-
- // load encoding engine parameters
- OPJconfig->Read(wxT("encode/subsampling"), &m_subsampling, (wxString) wxT("1,1"));
- OPJconfig->Read(wxT("encode/origin"), &m_origin, (wxString) wxT("0,0"));
- OPJconfig->Read(wxT("encode/rates"), &m_rates, (wxString) wxT("20,10,5"));
- OPJconfig->Read(wxT("encode/quality"), &m_quality, (wxString) wxT("30,35,40"));
- OPJconfig->Read(wxT("encode/enablequality"), &m_enablequality, (bool) false);
- OPJconfig->Read(wxT("encode/multicomp"), &m_multicomp, (bool) false);
- OPJconfig->Read(wxT("encode/irreversible"), &m_irreversible, (bool) false);
- OPJconfig->Read(wxT("encode/resolutions"), &m_resolutions, (int) 6);
- OPJconfig->Read(wxT("encode/progression"), &m_progression, (int) 0);
- OPJconfig->Read(wxT("encode/cbsize"), &m_cbsize, (wxString) wxT("32,32"));
- OPJconfig->Read(wxT("encode/prsize"), &m_prsize, (wxString) wxT("[128,128],[128,128]"));
- OPJconfig->Read(wxT("encode/tsize"), &m_tsize, (wxString) wxT(""));
- OPJconfig->Read(wxT("encode/torigin"), &m_torigin, (wxString) wxT("0,0"));
- OPJconfig->Read(wxT("encode/enablesop"), &m_enablesop, (bool) false);
- OPJconfig->Read(wxT("encode/enableeph"), &m_enableeph, (bool) false);
- OPJconfig->Read(wxT("encode/enablebypass"), &m_enablebypass, (bool) false);
- OPJconfig->Read(wxT("encode/enablereset"), &m_enablereset, (bool) false);
- OPJconfig->Read(wxT("encode/enablerestart"), &m_enablerestart, (bool) false);
- OPJconfig->Read(wxT("encode/enablevsc"), &m_enablevsc, (bool) false);
- OPJconfig->Read(wxT("encode/enableerterm"), &m_enableerterm, (bool) false);
- OPJconfig->Read(wxT("encode/enablesegmark"), &m_enablesegmark, (bool) false);
- OPJconfig->Read(wxT("encode/enablecomm"), &m_enablecomm, (bool) true);
- OPJconfig->Read(wxT("encode/enablepoc"), &m_enablepoc, (bool) false);
- OPJconfig->Read(wxT("encode/comment"), &m_comment, (wxString) wxT(""));
- OPJconfig->Read(wxT("encode/poc"), &m_poc, (wxString) wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL"));
- OPJconfig->Read(wxT("encode/enableidx"), &m_enableidx, (bool) false);
- OPJconfig->Read(wxT("encode/index"), &m_index, (wxString) wxT("index.txt"));
+ OPJconfig->Write(wxT("teststring"), wxT("This is a test value"));
+ OPJconfig->Write(wxT("testbool"), (bool) true);
+ OPJconfig->Write(wxT("testlong"), (long) 245);
+
+ OPJconfig->Read(wxT("showtoolbar"), &m_showtoolbar, (bool) true);
+ OPJconfig->Read(wxT("showbrowser"), &m_showbrowser, (bool) true);
+ OPJconfig->Read(wxT("showpeeker"), &m_showpeeker, (bool) true);
+ OPJconfig->Read(wxT("browserwidth"), &m_browserwidth, (long) OPJ_BROWSER_WIDTH);
+ OPJconfig->Read(wxT("peekerheight"), &m_peekerheight, (long) OPJ_PEEKER_HEIGHT);
+ OPJconfig->Read(wxT("framewidth"), &m_framewidth, (long) OPJ_FRAME_WIDTH);
+ OPJconfig->Read(wxT("frameheight"), &m_frameheight, (long) OPJ_FRAME_HEIGHT);
+
+ // load encoding engine parameters
+ OPJconfig->Read(wxT("encode/subsampling"), &m_subsampling,
+ (wxString) wxT("1,1"));
+ OPJconfig->Read(wxT("encode/origin"), &m_origin, (wxString) wxT("0,0"));
+ OPJconfig->Read(wxT("encode/rates"), &m_rates, (wxString) wxT("20,10,5"));
+ OPJconfig->Read(wxT("encode/quality"), &m_quality, (wxString) wxT("30,35,40"));
+ OPJconfig->Read(wxT("encode/enablequality"), &m_enablequality, (bool) false);
+ OPJconfig->Read(wxT("encode/multicomp"), &m_multicomp, (bool) false);
+ OPJconfig->Read(wxT("encode/irreversible"), &m_irreversible, (bool) false);
+ OPJconfig->Read(wxT("encode/resolutions"), &m_resolutions, (int) 6);
+ OPJconfig->Read(wxT("encode/progression"), &m_progression, (int) 0);
+ OPJconfig->Read(wxT("encode/cbsize"), &m_cbsize, (wxString) wxT("32,32"));
+ OPJconfig->Read(wxT("encode/prsize"), &m_prsize,
+ (wxString) wxT("[128,128],[128,128]"));
+ OPJconfig->Read(wxT("encode/tsize"), &m_tsize, (wxString) wxT(""));
+ OPJconfig->Read(wxT("encode/torigin"), &m_torigin, (wxString) wxT("0,0"));
+ OPJconfig->Read(wxT("encode/enablesop"), &m_enablesop, (bool) false);
+ OPJconfig->Read(wxT("encode/enableeph"), &m_enableeph, (bool) false);
+ OPJconfig->Read(wxT("encode/enablebypass"), &m_enablebypass, (bool) false);
+ OPJconfig->Read(wxT("encode/enablereset"), &m_enablereset, (bool) false);
+ OPJconfig->Read(wxT("encode/enablerestart"), &m_enablerestart, (bool) false);
+ OPJconfig->Read(wxT("encode/enablevsc"), &m_enablevsc, (bool) false);
+ OPJconfig->Read(wxT("encode/enableerterm"), &m_enableerterm, (bool) false);
+ OPJconfig->Read(wxT("encode/enablesegmark"), &m_enablesegmark, (bool) false);
+ OPJconfig->Read(wxT("encode/enablecomm"), &m_enablecomm, (bool) true);
+ OPJconfig->Read(wxT("encode/enablepoc"), &m_enablepoc, (bool) false);
+ OPJconfig->Read(wxT("encode/comment"), &m_comment, (wxString) wxT(""));
+ OPJconfig->Read(wxT("encode/poc"), &m_poc,
+ (wxString) wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL"));
+ OPJconfig->Read(wxT("encode/enableidx"), &m_enableidx, (bool) false);
+ OPJconfig->Read(wxT("encode/index"), &m_index, (wxString) wxT("index.txt"));
#ifdef USE_JPWL
- OPJconfig->Read(wxT("encode/enablejpwl"), &m_enablejpwle, (bool) true);
- for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
- OPJconfig->Read(wxT("encode/jpwl/hprotsel") + wxString::Format(wxT("%02d"), n), &m_hprotsel[n], 0);
- OPJconfig->Read(wxT("encode/jpwl/htileval") + wxString::Format(wxT("%02d"), n), &m_htileval[n], 0);
- OPJconfig->Read(wxT("encode/jpwl/pprotsel") + wxString::Format(wxT("%02d"), n), &m_pprotsel[n], 0);
- OPJconfig->Read(wxT("encode/jpwl/ptileval") + wxString::Format(wxT("%02d"), n), &m_ptileval[n], 0);
- OPJconfig->Read(wxT("encode/jpwl/ppackval") + wxString::Format(wxT("%02d"), n), &m_ppackval[n], 0);
- OPJconfig->Read(wxT("encode/jpwl/sensisel") + wxString::Format(wxT("%02d"), n), &m_sensisel[n], 0);
- OPJconfig->Read(wxT("encode/jpwl/stileval") + wxString::Format(wxT("%02d"), n), &m_stileval[n], 0);
- }
+ OPJconfig->Read(wxT("encode/enablejpwl"), &m_enablejpwle, (bool) true);
+ for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
+ OPJconfig->Read(wxT("encode/jpwl/hprotsel") + wxString::Format(wxT("%02d"), n),
+ &m_hprotsel[n], 0);
+ OPJconfig->Read(wxT("encode/jpwl/htileval") + wxString::Format(wxT("%02d"), n),
+ &m_htileval[n], 0);
+ OPJconfig->Read(wxT("encode/jpwl/pprotsel") + wxString::Format(wxT("%02d"), n),
+ &m_pprotsel[n], 0);
+ OPJconfig->Read(wxT("encode/jpwl/ptileval") + wxString::Format(wxT("%02d"), n),
+ &m_ptileval[n], 0);
+ OPJconfig->Read(wxT("encode/jpwl/ppackval") + wxString::Format(wxT("%02d"), n),
+ &m_ppackval[n], 0);
+ OPJconfig->Read(wxT("encode/jpwl/sensisel") + wxString::Format(wxT("%02d"), n),
+ &m_sensisel[n], 0);
+ OPJconfig->Read(wxT("encode/jpwl/stileval") + wxString::Format(wxT("%02d"), n),
+ &m_stileval[n], 0);
+ }
#endif // USE_JPWL
#else
- // set decoding engine parameters
- m_enabledeco = true;
- m_enableparse = true;
- m_resizemethod = 0;
- m_reducefactor = 0;
- m_qualitylayers = 0;
- m_components = 0;
- m_framenum = 0;
+ // set decoding engine parameters
+ m_enabledeco = true;
+ m_enableparse = true;
+ m_resizemethod = 0;
+ m_reducefactor = 0;
+ m_qualitylayers = 0;
+ m_components = 0;
+ m_framenum = 0;
#ifdef USE_JPWL
- m_enablejpwl = true;
- m_expcomps = JPWL_EXPECTED_COMPONENTS;
- m_maxtiles = JPWL_MAXIMUM_TILES;
+ m_enablejpwl = true;
+ m_expcomps = JPWL_EXPECTED_COMPONENTS;
+ m_maxtiles = JPWL_MAXIMUM_TILES;
#endif // USE_JPWL
- m_showtoolbar = true;
- m_showbrowser = true;
- m_showpeeker = true;
- m_browserwidth = OPJ_BROWSER_WIDTH;
- m_peekerheight = OPJ_PEEKER_HEIGHT;
- m_framewidth = OPJ_FRAME_WIDTH;
- m_frameheight = OPJ_FRAME_HEIGHT;
-
- // set encoding engine parameters
- m_subsampling = wxT("1,1");
- m_origin = wxT("0,0");
- m_rates = wxT("20,10,5");
- m_quality = wxT("30,35,40");
- m_enablequality = false;
- m_multicomp = false;
- m_irreversible = false;
- m_resolutions = 6;
- m_progression = 0;
- m_cbsize= wxT("32,32");
- m_prsize= wxT("[128,128],[128,128]");
- m_tsize = wxT("");
- m_torigin = wxT("0,0");
- m_enablesop = false;
- m_enableeph = false;
- m_enablebypass = false;
- m_enablereset = false;
- m_enablerestart = false;
- m_enablevsc = false;
- m_enableerterm = false;
- m_enablesegmark = false;
- m_enableidx = false;
- m_index = wxT("index.txt");
- m_enablecomm = true;
- m_comment = wxT("");
- m_enablepoc = false;
- m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
+ m_showtoolbar = true;
+ m_showbrowser = true;
+ m_showpeeker = true;
+ m_browserwidth = OPJ_BROWSER_WIDTH;
+ m_peekerheight = OPJ_PEEKER_HEIGHT;
+ m_framewidth = OPJ_FRAME_WIDTH;
+ m_frameheight = OPJ_FRAME_HEIGHT;
+
+ // set encoding engine parameters
+ m_subsampling = wxT("1,1");
+ m_origin = wxT("0,0");
+ m_rates = wxT("20,10,5");
+ m_quality = wxT("30,35,40");
+ m_enablequality = false;
+ m_multicomp = false;
+ m_irreversible = false;
+ m_resolutions = 6;
+ m_progression = 0;
+ m_cbsize = wxT("32,32");
+ m_prsize = wxT("[128,128],[128,128]");
+ m_tsize = wxT("");
+ m_torigin = wxT("0,0");
+ m_enablesop = false;
+ m_enableeph = false;
+ m_enablebypass = false;
+ m_enablereset = false;
+ m_enablerestart = false;
+ m_enablevsc = false;
+ m_enableerterm = false;
+ m_enablesegmark = false;
+ m_enableidx = false;
+ m_index = wxT("index.txt");
+ m_enablecomm = true;
+ m_comment = wxT("");
+ m_enablepoc = false;
+ m_poc = wxT("T1=0,0,1,5,3,CPRL/T1=5,0,1,6,3,CPRL");
#ifdef USE_JPWL
- m_enablejpwle = true;
- for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
- m_hprotsel[n] = 0;
- m_htileval[n] = 0;
- m_pprotsel[n] = 0;
- m_ptileval[n] = 0;
- m_sensisel[n] = 0;
- m_stileval[n] = 0;
- }
+ m_enablejpwle = true;
+ for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
+ m_hprotsel[n] = 0;
+ m_htileval[n] = 0;
+ m_pprotsel[n] = 0;
+ m_ptileval[n] = 0;
+ m_sensisel[n] = 0;
+ m_stileval[n] = 0;
+ }
#endif // USE_JPWL
#endif // OPJ_INICONFIG
- if (m_comment == wxT("")) {
+ if (m_comment == wxT("")) {
#if defined __WXMSW__
- m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
+ m_comment = wxT("Created by OPJViewer Win32 - OpenJPEG version ");
#elif defined __WXGTK__
- m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
+ m_comment = wxT("Created by OPJViewer Lin32 - OpenJPEG version ");
#else
- m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
+ m_comment = wxT("Created by OPJViewer - OpenJPEG version ");
#endif
#ifdef USE_JPWL
- m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
+ m_comment += wxString::Format(wxT("%s with JPWL"), (char *) opj_version());
#else
- m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
+ m_comment += wxString::Format(wxT("%s"), (char *) opj_version());
#endif
- }
+ }
- // Create the main frame window
- OPJFrame *frame = new OPJFrame(NULL, wxID_ANY, OPJ_APPLICATION_TITLEBAR,
- wxDefaultPosition, wxSize(wxGetApp().m_framewidth, wxGetApp().m_frameheight),
- wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE |
- wxHSCROLL | wxVSCROLL);
+ // Create the main frame window
+ OPJFrame *frame = new OPJFrame(NULL, wxID_ANY, OPJ_APPLICATION_TITLEBAR,
+ wxDefaultPosition, wxSize(wxGetApp().m_framewidth, wxGetApp().m_frameheight),
+ wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE |
+ wxHSCROLL | wxVSCROLL);
- // Give it an icon (this is ignored in MDI mode: uses resources)
+ // Give it an icon (this is ignored in MDI mode: uses resources)
#ifdef __WXMSW__
- frame->SetIcon(wxIcon(wxT("OPJViewer16")));
+ frame->SetIcon(wxIcon(wxT("OPJViewer16")));
#endif
- frame->Show(true);
+ frame->Show(true);
- SetTopWindow(frame);
+ SetTopWindow(frame);
- // if there are files on the command line, open them
- if (!(m_filelist.IsEmpty())) {
- //wxLogMessage(wxT("Habemus files!!!"));
- wxArrayString paths, filenames;
- for (unsigned int f = 0; f < wxGetApp().m_filelist.GetCount(); f++) {
- paths.Add(wxFileName(wxGetApp().m_filelist[f]).GetFullPath());
- filenames.Add(wxFileName(wxGetApp().m_filelist[f]).GetFullName());
- }
- //wxLogMessage(paths[0]);
- frame->OpenFiles(paths, filenames);
- }
+ // if there are files on the command line, open them
+ if (!(m_filelist.IsEmpty())) {
+ //wxLogMessage(wxT("Habemus files!!!"));
+ wxArrayString paths, filenames;
+ for (unsigned int f = 0; f < wxGetApp().m_filelist.GetCount(); f++) {
+ paths.Add(wxFileName(wxGetApp().m_filelist[f]).GetFullPath());
+ filenames.Add(wxFileName(wxGetApp().m_filelist[f]).GetFullName());
+ }
+ //wxLogMessage(paths[0]);
+ frame->OpenFiles(paths, filenames);
+ }
- return true;
+ return true;
}
int OPJViewerApp::OnExit()
{
- int n;
+ int n;
#ifdef OPJ_INICONFIG
- OPJconfig->Write(wxT("decode/enabledeco"), m_enabledeco);
- OPJconfig->Write(wxT("decode/enableparse"), m_enableparse);
- OPJconfig->Write(wxT("decode/resizemethod"), m_resizemethod);
- OPJconfig->Write(wxT("decode/reducefactor"), m_reducefactor);
- OPJconfig->Write(wxT("decode/qualitylayers"), m_qualitylayers);
- OPJconfig->Write(wxT("decode/components"), m_components);
- OPJconfig->Write(wxT("decode/framenum"), m_framenum);
+ OPJconfig->Write(wxT("decode/enabledeco"), m_enabledeco);
+ OPJconfig->Write(wxT("decode/enableparse"), m_enableparse);
+ OPJconfig->Write(wxT("decode/resizemethod"), m_resizemethod);
+ OPJconfig->Write(wxT("decode/reducefactor"), m_reducefactor);
+ OPJconfig->Write(wxT("decode/qualitylayers"), m_qualitylayers);
+ OPJconfig->Write(wxT("decode/components"), m_components);
+ OPJconfig->Write(wxT("decode/framenum"), m_framenum);
#ifdef USE_JPWL
- OPJconfig->Write(wxT("decode/enablejpwl"), m_enablejpwl);
- OPJconfig->Write(wxT("decode/expcomps"), m_expcomps);
- OPJconfig->Write(wxT("decode/maxtiles"), m_maxtiles);
+ OPJconfig->Write(wxT("decode/enablejpwl"), m_enablejpwl);
+ OPJconfig->Write(wxT("decode/expcomps"), m_expcomps);
+ OPJconfig->Write(wxT("decode/maxtiles"), m_maxtiles);
#endif // USE_JPWL
- OPJconfig->Write(wxT("showtoolbar"), m_showtoolbar);
- OPJconfig->Write(wxT("showbrowser"), m_showbrowser);
- OPJconfig->Write(wxT("showpeeker"), m_showpeeker);
- OPJconfig->Write(wxT("browserwidth"), m_browserwidth);
- OPJconfig->Write(wxT("peekerheight"), m_peekerheight);
- OPJconfig->Write(wxT("framewidth"), m_framewidth);
- OPJconfig->Write(wxT("frameheight"), m_frameheight);
-
- OPJconfig->Write(wxT("encode/subsampling"), m_subsampling);
- OPJconfig->Write(wxT("encode/origin"), m_origin);
- OPJconfig->Write(wxT("encode/rates"), m_rates);
- OPJconfig->Write(wxT("encode/quality"), m_quality);
- OPJconfig->Write(wxT("encode/enablequality"), m_enablequality);
- OPJconfig->Write(wxT("encode/multicomp"), m_multicomp);
- OPJconfig->Write(wxT("encode/irreversible"), m_irreversible);
- OPJconfig->Write(wxT("encode/resolutions"), m_resolutions);
- OPJconfig->Write(wxT("encode/progression"), m_progression);
- OPJconfig->Write(wxT("encode/cbsize"), m_cbsize);
- OPJconfig->Write(wxT("encode/prsize"), m_prsize);
- OPJconfig->Write(wxT("encode/tiles"), m_tsize);
- OPJconfig->Write(wxT("encode/torigin"), m_torigin);
- OPJconfig->Write(wxT("encode/enablesop"), m_enablesop);
- OPJconfig->Write(wxT("encode/enableeph"), m_enableeph);
- OPJconfig->Write(wxT("encode/enablebypass"), m_enablebypass);
- OPJconfig->Write(wxT("encode/enablereset"), m_enablereset);
- OPJconfig->Write(wxT("encode/enablerestart"), m_enablerestart);
- OPJconfig->Write(wxT("encode/enablevsc"), m_enablevsc);
- OPJconfig->Write(wxT("encode/enableerterm"), m_enableerterm);
- OPJconfig->Write(wxT("encode/enablesegmark"), m_enablesegmark);
- OPJconfig->Write(wxT("encode/enableidx"), m_enableidx);
- OPJconfig->Write(wxT("encode/index"), m_index);
- OPJconfig->Write(wxT("encode/enablecomm"), m_enablecomm);
- OPJconfig->Write(wxT("encode/comment"), m_comment);
- OPJconfig->Write(wxT("encode/enablepoc"), m_enablepoc);
- OPJconfig->Write(wxT("encode/poc"), m_poc);
+ OPJconfig->Write(wxT("showtoolbar"), m_showtoolbar);
+ OPJconfig->Write(wxT("showbrowser"), m_showbrowser);
+ OPJconfig->Write(wxT("showpeeker"), m_showpeeker);
+ OPJconfig->Write(wxT("browserwidth"), m_browserwidth);
+ OPJconfig->Write(wxT("peekerheight"), m_peekerheight);
+ OPJconfig->Write(wxT("framewidth"), m_framewidth);
+ OPJconfig->Write(wxT("frameheight"), m_frameheight);
+
+ OPJconfig->Write(wxT("encode/subsampling"), m_subsampling);
+ OPJconfig->Write(wxT("encode/origin"), m_origin);
+ OPJconfig->Write(wxT("encode/rates"), m_rates);
+ OPJconfig->Write(wxT("encode/quality"), m_quality);
+ OPJconfig->Write(wxT("encode/enablequality"), m_enablequality);
+ OPJconfig->Write(wxT("encode/multicomp"), m_multicomp);
+ OPJconfig->Write(wxT("encode/irreversible"), m_irreversible);
+ OPJconfig->Write(wxT("encode/resolutions"), m_resolutions);
+ OPJconfig->Write(wxT("encode/progression"), m_progression);
+ OPJconfig->Write(wxT("encode/cbsize"), m_cbsize);
+ OPJconfig->Write(wxT("encode/prsize"), m_prsize);
+ OPJconfig->Write(wxT("encode/tiles"), m_tsize);
+ OPJconfig->Write(wxT("encode/torigin"), m_torigin);
+ OPJconfig->Write(wxT("encode/enablesop"), m_enablesop);
+ OPJconfig->Write(wxT("encode/enableeph"), m_enableeph);
+ OPJconfig->Write(wxT("encode/enablebypass"), m_enablebypass);
+ OPJconfig->Write(wxT("encode/enablereset"), m_enablereset);
+ OPJconfig->Write(wxT("encode/enablerestart"), m_enablerestart);
+ OPJconfig->Write(wxT("encode/enablevsc"), m_enablevsc);
+ OPJconfig->Write(wxT("encode/enableerterm"), m_enableerterm);
+ OPJconfig->Write(wxT("encode/enablesegmark"), m_enablesegmark);
+ OPJconfig->Write(wxT("encode/enableidx"), m_enableidx);
+ OPJconfig->Write(wxT("encode/index"), m_index);
+ OPJconfig->Write(wxT("encode/enablecomm"), m_enablecomm);
+ OPJconfig->Write(wxT("encode/comment"), m_comment);
+ OPJconfig->Write(wxT("encode/enablepoc"), m_enablepoc);
+ OPJconfig->Write(wxT("encode/poc"), m_poc);
#ifdef USE_JPWL
- OPJconfig->Write(wxT("encode/enablejpwl"), m_enablejpwle);
- for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
- OPJconfig->Write(wxT("encode/jpwl/hprotsel") + wxString::Format(wxT("%02d"), n), m_hprotsel[n]);
- OPJconfig->Write(wxT("encode/jpwl/htileval") + wxString::Format(wxT("%02d"), n), m_htileval[n]);
- OPJconfig->Write(wxT("encode/jpwl/pprotsel") + wxString::Format(wxT("%02d"), n), m_pprotsel[n]);
- OPJconfig->Write(wxT("encode/jpwl/ptileval") + wxString::Format(wxT("%02d"), n), m_ptileval[n]);
- OPJconfig->Write(wxT("encode/jpwl/ppackval") + wxString::Format(wxT("%02d"), n), m_ppackval[n]);
- OPJconfig->Write(wxT("encode/jpwl/sensisel") + wxString::Format(wxT("%02d"), n), m_sensisel[n]);
- OPJconfig->Write(wxT("encode/jpwl/stileval") + wxString::Format(wxT("%02d"), n), m_stileval[n]);
- }
+ OPJconfig->Write(wxT("encode/enablejpwl"), m_enablejpwle);
+ for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
+ OPJconfig->Write(wxT("encode/jpwl/hprotsel") + wxString::Format(wxT("%02d"), n),
+ m_hprotsel[n]);
+ OPJconfig->Write(wxT("encode/jpwl/htileval") + wxString::Format(wxT("%02d"), n),
+ m_htileval[n]);
+ OPJconfig->Write(wxT("encode/jpwl/pprotsel") + wxString::Format(wxT("%02d"), n),
+ m_pprotsel[n]);
+ OPJconfig->Write(wxT("encode/jpwl/ptileval") + wxString::Format(wxT("%02d"), n),
+ m_ptileval[n]);
+ OPJconfig->Write(wxT("encode/jpwl/ppackval") + wxString::Format(wxT("%02d"), n),
+ m_ppackval[n]);
+ OPJconfig->Write(wxT("encode/jpwl/sensisel") + wxString::Format(wxT("%02d"), n),
+ m_sensisel[n]);
+ OPJconfig->Write(wxT("encode/jpwl/stileval") + wxString::Format(wxT("%02d"), n),
+ m_stileval[n]);
+ }
#endif // USE_JPWL
#endif // OPJ_INICONFIG
- return 1;
+ return 1;
}
void OPJViewerApp::ShowCmdLine(const wxCmdLineParser& parser)
@@ -466,7 +487,7 @@ void OPJViewerApp::ShowCmdLine(const wxCmdLineParser& parser)
size_t count = parser.GetParamCount();
for (size_t param = 0; param < count; param++) {
s << parser.GetParam(param) << ';';
- m_filelist.Add(parser.GetParam(param));
+ m_filelist.Add(parser.GetParam(param));
}
//wxLogMessage(s);
@@ -503,384 +524,404 @@ BEGIN_EVENT_TABLE(OPJFrame, wxMDIParentFrame)
EVT_MENU(OPJFRAME_FILETOGGLET, OPJFrame::OnToggleToolbar)
EVT_MENU(OPJFRAME_SETSENCO, OPJFrame::OnSetsEnco)
EVT_MENU(OPJFRAME_SETSDECO, OPJFrame::OnSetsDeco)
- EVT_SASH_DRAGGED_RANGE(OPJFRAME_BROWSEWIN, OPJFRAME_LOGWIN, OPJFrame::OnSashDrag)
+ EVT_SASH_DRAGGED_RANGE(OPJFRAME_BROWSEWIN, OPJFRAME_LOGWIN,
+ OPJFrame::OnSashDrag)
EVT_NOTEBOOK_PAGE_CHANGED(LEFT_NOTEBOOK_ID, OPJFrame::OnNotebook)
EVT_MENU(OPJFRAME_THREADLOGMSG, OPJFrame::OnThreadLogmsg)
END_EVENT_TABLE()
// this is the frame constructor
OPJFrame::OPJFrame(wxWindow *parent, const wxWindowID id, const wxString& title,
- const wxPoint& pos, const wxSize& size, const long style)
- : wxMDIParentFrame(parent, id, title, pos, size, style)
+ const wxPoint& pos, const wxSize& size, const long style)
+ : wxMDIParentFrame(parent, id, title, pos, size, style)
{
- // file menu and its items
- wxMenu *file_menu = new wxMenu;
+ // file menu and its items
+ wxMenu *file_menu = new wxMenu;
- file_menu->Append(OPJFRAME_FILEOPEN, wxT("&Open\tCtrl+O"));
- file_menu->SetHelpString(OPJFRAME_FILEOPEN, wxT("Open one or more files"));
+ file_menu->Append(OPJFRAME_FILEOPEN, wxT("&Open\tCtrl+O"));
+ file_menu->SetHelpString(OPJFRAME_FILEOPEN, wxT("Open one or more files"));
- file_menu->Append(OPJFRAME_MEMORYOPEN, wxT("&Memory\tCtrl+M"));
- file_menu->SetHelpString(OPJFRAME_MEMORYOPEN, wxT("Open a memory buffer"));
+ file_menu->Append(OPJFRAME_MEMORYOPEN, wxT("&Memory\tCtrl+M"));
+ file_menu->SetHelpString(OPJFRAME_MEMORYOPEN, wxT("Open a memory buffer"));
- file_menu->Append(OPJFRAME_FILECLOSE, wxT("&Close\tCtrl+C"));
- file_menu->SetHelpString(OPJFRAME_FILECLOSE, wxT("Close current image"));
+ file_menu->Append(OPJFRAME_FILECLOSE, wxT("&Close\tCtrl+C"));
+ file_menu->SetHelpString(OPJFRAME_FILECLOSE, wxT("Close current image"));
- file_menu->AppendSeparator();
+ file_menu->AppendSeparator();
- file_menu->Append(OPJFRAME_FILESAVEAS, wxT("&Save as\tCtrl+S"));
- file_menu->SetHelpString(OPJFRAME_FILESAVEAS, wxT("Save the current image"));
- //file_menu->Enable(OPJFRAME_FILESAVEAS, false);
+ file_menu->Append(OPJFRAME_FILESAVEAS, wxT("&Save as\tCtrl+S"));
+ file_menu->SetHelpString(OPJFRAME_FILESAVEAS, wxT("Save the current image"));
+ //file_menu->Enable(OPJFRAME_FILESAVEAS, false);
- file_menu->AppendSeparator();
+ file_menu->AppendSeparator();
- file_menu->Append(OPJFRAME_FILETOGGLEB, wxT("Toggle &browser\tCtrl+B"));
- file_menu->SetHelpString(OPJFRAME_FILETOGGLEB, wxT("Toggle the left browsing pane"));
+ file_menu->Append(OPJFRAME_FILETOGGLEB, wxT("Toggle &browser\tCtrl+B"));
+ file_menu->SetHelpString(OPJFRAME_FILETOGGLEB,
+ wxT("Toggle the left browsing pane"));
- file_menu->Append(OPJFRAME_FILETOGGLEP, wxT("Toggle &peeker\tCtrl+P"));
- file_menu->SetHelpString(OPJFRAME_FILETOGGLEP, wxT("Toggle the bottom peeking pane"));
+ file_menu->Append(OPJFRAME_FILETOGGLEP, wxT("Toggle &peeker\tCtrl+P"));
+ file_menu->SetHelpString(OPJFRAME_FILETOGGLEP,
+ wxT("Toggle the bottom peeking pane"));
- file_menu->Append(OPJFRAME_FILETOGGLET, wxT("Toggle &toolbar\tCtrl+T"));
- file_menu->SetHelpString(OPJFRAME_FILETOGGLET, wxT("Toggle the toolbar"));
+ file_menu->Append(OPJFRAME_FILETOGGLET, wxT("Toggle &toolbar\tCtrl+T"));
+ file_menu->SetHelpString(OPJFRAME_FILETOGGLET, wxT("Toggle the toolbar"));
- file_menu->AppendSeparator();
+ file_menu->AppendSeparator();
- file_menu->Append(OPJFRAME_FILEEXIT, wxT("&Exit\tCtrl+Q"));
- file_menu->SetHelpString(OPJFRAME_FILEEXIT, wxT("Quit this program"));
+ file_menu->Append(OPJFRAME_FILEEXIT, wxT("&Exit\tCtrl+Q"));
+ file_menu->SetHelpString(OPJFRAME_FILEEXIT, wxT("Quit this program"));
- // view menu and its items
- wxMenu *view_menu = new wxMenu;
+ // view menu and its items
+ wxMenu *view_menu = new wxMenu;
- view_menu->Append(OPJFRAME_VIEWZOOM, wxT("&Zoom\tCtrl+Z"));
- view_menu->SetHelpString(OPJFRAME_VIEWZOOM, wxT("Rescale the image"));
+ view_menu->Append(OPJFRAME_VIEWZOOM, wxT("&Zoom\tCtrl+Z"));
+ view_menu->SetHelpString(OPJFRAME_VIEWZOOM, wxT("Rescale the image"));
- view_menu->Append(OPJFRAME_VIEWFIT, wxT("Zoom to &fit\tCtrl+F"));
- view_menu->SetHelpString(OPJFRAME_VIEWFIT, wxT("Fit the image in canvas"));
+ view_menu->Append(OPJFRAME_VIEWFIT, wxT("Zoom to &fit\tCtrl+F"));
+ view_menu->SetHelpString(OPJFRAME_VIEWFIT, wxT("Fit the image in canvas"));
- view_menu->Append(OPJFRAME_VIEWRELOAD, wxT("&Reload image\tCtrl+R"));
- view_menu->SetHelpString(OPJFRAME_VIEWRELOAD, wxT("Reload the current image"));
+ view_menu->Append(OPJFRAME_VIEWRELOAD, wxT("&Reload image\tCtrl+R"));
+ view_menu->SetHelpString(OPJFRAME_VIEWRELOAD, wxT("Reload the current image"));
- view_menu->AppendSeparator();
+ view_menu->AppendSeparator();
- view_menu->Append(OPJFRAME_VIEWPREVFRAME, wxT("&Prev frame\tLeft"));
- view_menu->SetHelpString(OPJFRAME_VIEWPREVFRAME, wxT("View previous frame"));
+ view_menu->Append(OPJFRAME_VIEWPREVFRAME, wxT("&Prev frame\tLeft"));
+ view_menu->SetHelpString(OPJFRAME_VIEWPREVFRAME, wxT("View previous frame"));
- view_menu->Append(OPJFRAME_VIEWHOMEFRAME, wxT("&Start frame\tHome"));
- view_menu->SetHelpString(OPJFRAME_VIEWHOMEFRAME, wxT("View starting frame"));
+ view_menu->Append(OPJFRAME_VIEWHOMEFRAME, wxT("&Start frame\tHome"));
+ view_menu->SetHelpString(OPJFRAME_VIEWHOMEFRAME, wxT("View starting frame"));
- view_menu->Append(OPJFRAME_VIEWNEXTFRAME, wxT("&Next frame\tRight"));
- view_menu->SetHelpString(OPJFRAME_VIEWNEXTFRAME, wxT("View next frame"));
+ view_menu->Append(OPJFRAME_VIEWNEXTFRAME, wxT("&Next frame\tRight"));
+ view_menu->SetHelpString(OPJFRAME_VIEWNEXTFRAME, wxT("View next frame"));
- view_menu->AppendSeparator();
+ view_menu->AppendSeparator();
- view_menu->Append(OPJFRAME_VIEWLESSLAYERS, wxT("&Less layers\t-"));
- view_menu->SetHelpString(OPJFRAME_VIEWLESSLAYERS, wxT("Remove a layer"));
+ view_menu->Append(OPJFRAME_VIEWLESSLAYERS, wxT("&Less layers\t-"));
+ view_menu->SetHelpString(OPJFRAME_VIEWLESSLAYERS, wxT("Remove a layer"));
- view_menu->Append(OPJFRAME_VIEWALLLAYERS, wxT("&All layers\t0"));
- view_menu->SetHelpString(OPJFRAME_VIEWALLLAYERS, wxT("Show all layers"));
+ view_menu->Append(OPJFRAME_VIEWALLLAYERS, wxT("&All layers\t0"));
+ view_menu->SetHelpString(OPJFRAME_VIEWALLLAYERS, wxT("Show all layers"));
- view_menu->Append(OPJFRAME_VIEWMORELAYERS, wxT("&More layers\t+"));
- view_menu->SetHelpString(OPJFRAME_VIEWMORELAYERS, wxT("Add a layer"));
+ view_menu->Append(OPJFRAME_VIEWMORELAYERS, wxT("&More layers\t+"));
+ view_menu->SetHelpString(OPJFRAME_VIEWMORELAYERS, wxT("Add a layer"));
- view_menu->AppendSeparator();
+ view_menu->AppendSeparator();
+
+ view_menu->Append(OPJFRAME_VIEWLESSRES, wxT("&Less resolution\t<"));
+ view_menu->SetHelpString(OPJFRAME_VIEWLESSRES, wxT("Reduce the resolution"));
+
+ view_menu->Append(OPJFRAME_VIEWFULLRES, wxT("&Full resolution\tf"));
+ view_menu->SetHelpString(OPJFRAME_VIEWFULLRES, wxT("Full resolution"));
+
+ view_menu->Append(OPJFRAME_VIEWMORERES, wxT("&More resolution\t>"));
+ view_menu->SetHelpString(OPJFRAME_VIEWMORERES, wxT("Increase the resolution"));
+
+ view_menu->AppendSeparator();
+
+ view_menu->Append(OPJFRAME_VIEWPREVCOMP, wxT("&Prev component\tDown"));
+ view_menu->SetHelpString(OPJFRAME_VIEWPREVCOMP, wxT("View previous component"));
+
+ view_menu->Append(OPJFRAME_VIEWALLCOMPS, wxT("&All components\ta"));
+ view_menu->SetHelpString(OPJFRAME_VIEWALLCOMPS, wxT("View all components"));
+
+ view_menu->Append(OPJFRAME_VIEWNEXTCOMP, wxT("&Next component\tUp"));
+ view_menu->SetHelpString(OPJFRAME_VIEWNEXTCOMP, wxT("View next component"));
+
+
+ // settings menu and its items
+ wxMenu *sets_menu = new wxMenu;
+
+ sets_menu->Append(OPJFRAME_SETSENCO, wxT("&Encoder\tCtrl+E"));
+ sets_menu->SetHelpString(OPJFRAME_SETSENCO, wxT("Encoder settings"));
+
+ sets_menu->Append(OPJFRAME_SETSDECO, wxT("&Decoder\tCtrl+D"));
+ sets_menu->SetHelpString(OPJFRAME_SETSDECO, wxT("Decoder settings"));
+
+ // help menu and its items
+ wxMenu *help_menu = new wxMenu;
+
+ help_menu->Append(OPJFRAME_HELPABOUT, wxT("&About\tF1"));
+ help_menu->SetHelpString(OPJFRAME_HELPABOUT, wxT("Basic info on the program"));
+
+ // the whole menubar
+ wxMenuBar *menu_bar = new wxMenuBar;
+ menu_bar->Append(file_menu, wxT("&File"));
+ menu_bar->Append(view_menu, wxT("&View"));
+ menu_bar->Append(sets_menu, wxT("&Settings"));
+ menu_bar->Append(help_menu, wxT("&Help"));
+
+ // Associate the menu bar with the frame
+ SetMenuBar(menu_bar);
+
+ // the status bar
+ CreateStatusBar();
+
+ // the toolbar
+ tool_bar = new wxToolBar(this, OPJFRAME_TOOLBAR,
+ wxDefaultPosition, wxDefaultSize,
+ wxTB_HORIZONTAL | wxNO_BORDER);
+ wxBitmap bmpOpen = wxArtProvider::GetBitmap(wxART_FILE_OPEN, wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpSaveAs = wxArtProvider::GetBitmap(wxART_FILE_SAVE_AS, wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpZoom = wxArtProvider::GetBitmap(wxART_FIND, wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpFit = wxArtProvider::GetBitmap(wxART_FIND_AND_REPLACE,
+ wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpReload = wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE,
+ wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpDecosettings = wxArtProvider::GetBitmap(wxART_REPORT_VIEW,
+ wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpEncosettings = wxArtProvider::GetBitmap(wxART_LIST_VIEW,
+ wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpPrevframe = wxArtProvider::GetBitmap(wxART_GO_BACK, wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpHomeframe = wxArtProvider::GetBitmap(wxART_GO_HOME, wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpNextframe = wxArtProvider::GetBitmap(wxART_GO_FORWARD,
+ wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpLesslayers = bmpPrevframe;
+ wxBitmap bmpAlllayers = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT,
+ wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpMorelayers = bmpNextframe;
+ wxBitmap bmpLessres = bmpPrevframe;
+ wxBitmap bmpFullres = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT,
+ wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpMoreres = bmpNextframe;
+ wxBitmap bmpPrevcomp = bmpPrevframe;
+ wxBitmap bmpAllcomps = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT,
+ wxART_TOOLBAR,
+ wxDefaultSize);
+ wxBitmap bmpNextcomp = bmpNextframe;
+
+ tool_bar->AddTool(OPJFRAME_FILEOPEN, bmpOpen, wxT("Open"));
+ tool_bar->AddTool(OPJFRAME_FILESAVEAS, bmpSaveAs, wxT("Save as "));
+ //tool_bar->EnableTool(OPJFRAME_FILESAVEAS, false);
+ tool_bar->AddSeparator();
+ tool_bar->AddTool(OPJFRAME_VIEWZOOM, bmpZoom, wxT("Zoom"));
+ tool_bar->AddTool(OPJFRAME_VIEWFIT, bmpFit, wxT("Zoom to fit"));
+ tool_bar->AddTool(OPJFRAME_VIEWRELOAD, bmpReload, wxT("Reload"));
+ tool_bar->AddSeparator();
+ tool_bar->AddTool(OPJFRAME_SETSDECO, bmpDecosettings, wxT("Decoder settings"));
+ tool_bar->AddTool(OPJFRAME_SETSENCO, bmpEncosettings, wxT("Encoder settings"));
+ tool_bar->AddSeparator();
+ tool_bar->AddTool(OPJFRAME_VIEWPREVFRAME, bmpPrevframe, wxT("Previous frame"));
+ tool_bar->AddTool(OPJFRAME_VIEWHOMEFRAME, bmpHomeframe, wxT("Starting frame"));
+ tool_bar->AddTool(OPJFRAME_VIEWNEXTFRAME, bmpNextframe, wxT("Next frame"));
+ tool_bar->AddSeparator();
+ tool_bar->AddTool(OPJFRAME_VIEWLESSLAYERS, bmpLesslayers,
+ wxT("Remove a layer"));
+ tool_bar->AddTool(OPJFRAME_VIEWALLLAYERS, bmpAlllayers, wxT("Show all layers"));
+ tool_bar->AddTool(OPJFRAME_VIEWMORELAYERS, bmpMorelayers, wxT("Add a layer"));
+ tool_bar->AddSeparator();
+ tool_bar->AddTool(OPJFRAME_VIEWLESSRES, bmpLessres,
+ wxT("Reduce the resolution"));
+ tool_bar->AddTool(OPJFRAME_VIEWFULLRES, bmpFullres, wxT("Full resolution"));
+ tool_bar->AddTool(OPJFRAME_VIEWMORERES, bmpMoreres,
+ wxT("Increase the resolution"));
+ tool_bar->AddSeparator();
+ tool_bar->AddTool(OPJFRAME_VIEWPREVCOMP, bmpPrevcomp,
+ wxT("Previous component"));
+ tool_bar->AddTool(OPJFRAME_VIEWALLCOMPS, bmpAllcomps, wxT("All components"));
+ tool_bar->AddTool(OPJFRAME_VIEWNEXTCOMP, bmpNextcomp, wxT("Next component"));
+ tool_bar->Realize();
+
+ // associate the toolbar with the frame
+ SetToolBar(tool_bar);
+
+ // show the toolbar?
+ if (!wxGetApp().m_showtoolbar) {
+ tool_bar->Show(false);
+ } else {
+ tool_bar->Show(true);
+ }
- view_menu->Append(OPJFRAME_VIEWLESSRES, wxT("&Less resolution\t<"));
- view_menu->SetHelpString(OPJFRAME_VIEWLESSRES, wxT("Reduce the resolution"));
-
- view_menu->Append(OPJFRAME_VIEWFULLRES, wxT("&Full resolution\tf"));
- view_menu->SetHelpString(OPJFRAME_VIEWFULLRES, wxT("Full resolution"));
-
- view_menu->Append(OPJFRAME_VIEWMORERES, wxT("&More resolution\t>"));
- view_menu->SetHelpString(OPJFRAME_VIEWMORERES, wxT("Increase the resolution"));
-
- view_menu->AppendSeparator();
-
- view_menu->Append(OPJFRAME_VIEWPREVCOMP, wxT("&Prev component\tDown"));
- view_menu->SetHelpString(OPJFRAME_VIEWPREVCOMP, wxT("View previous component"));
-
- view_menu->Append(OPJFRAME_VIEWALLCOMPS, wxT("&All components\ta"));
- view_menu->SetHelpString(OPJFRAME_VIEWALLCOMPS, wxT("View all components"));
-
- view_menu->Append(OPJFRAME_VIEWNEXTCOMP, wxT("&Next component\tUp"));
- view_menu->SetHelpString(OPJFRAME_VIEWNEXTCOMP, wxT("View next component"));
-
-
- // settings menu and its items
- wxMenu *sets_menu = new wxMenu;
-
- sets_menu->Append(OPJFRAME_SETSENCO, wxT("&Encoder\tCtrl+E"));
- sets_menu->SetHelpString(OPJFRAME_SETSENCO, wxT("Encoder settings"));
-
- sets_menu->Append(OPJFRAME_SETSDECO, wxT("&Decoder\tCtrl+D"));
- sets_menu->SetHelpString(OPJFRAME_SETSDECO, wxT("Decoder settings"));
-
- // help menu and its items
- wxMenu *help_menu = new wxMenu;
-
- help_menu->Append(OPJFRAME_HELPABOUT, wxT("&About\tF1"));
- help_menu->SetHelpString(OPJFRAME_HELPABOUT, wxT("Basic info on the program"));
-
- // the whole menubar
- wxMenuBar *menu_bar = new wxMenuBar;
- menu_bar->Append(file_menu, wxT("&File"));
- menu_bar->Append(view_menu, wxT("&View"));
- menu_bar->Append(sets_menu, wxT("&Settings"));
- menu_bar->Append(help_menu, wxT("&Help"));
-
- // Associate the menu bar with the frame
- SetMenuBar(menu_bar);
-
- // the status bar
- CreateStatusBar();
-
- // the toolbar
- tool_bar = new wxToolBar(this, OPJFRAME_TOOLBAR,
- wxDefaultPosition, wxDefaultSize,
- wxTB_HORIZONTAL | wxNO_BORDER);
- wxBitmap bmpOpen = wxArtProvider::GetBitmap(wxART_FILE_OPEN, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpSaveAs = wxArtProvider::GetBitmap(wxART_FILE_SAVE_AS, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpZoom = wxArtProvider::GetBitmap(wxART_FIND, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpFit = wxArtProvider::GetBitmap(wxART_FIND_AND_REPLACE, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpReload = wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpDecosettings = wxArtProvider::GetBitmap(wxART_REPORT_VIEW, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpEncosettings = wxArtProvider::GetBitmap(wxART_LIST_VIEW, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpPrevframe = wxArtProvider::GetBitmap(wxART_GO_BACK, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpHomeframe = wxArtProvider::GetBitmap(wxART_GO_HOME, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpNextframe = wxArtProvider::GetBitmap(wxART_GO_FORWARD, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpLesslayers = bmpPrevframe;
- wxBitmap bmpAlllayers = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpMorelayers = bmpNextframe;
- wxBitmap bmpLessres = bmpPrevframe;
- wxBitmap bmpFullres = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpMoreres = bmpNextframe;
- wxBitmap bmpPrevcomp = bmpPrevframe;
- wxBitmap bmpAllcomps = wxArtProvider::GetBitmap(wxART_GO_TO_PARENT, wxART_TOOLBAR,
- wxDefaultSize);
- wxBitmap bmpNextcomp = bmpNextframe;
-
- tool_bar->AddTool(OPJFRAME_FILEOPEN, bmpOpen, wxT("Open"));
- tool_bar->AddTool(OPJFRAME_FILESAVEAS, bmpSaveAs, wxT("Save as "));
- //tool_bar->EnableTool(OPJFRAME_FILESAVEAS, false);
- tool_bar->AddSeparator();
- tool_bar->AddTool(OPJFRAME_VIEWZOOM, bmpZoom, wxT("Zoom"));
- tool_bar->AddTool(OPJFRAME_VIEWFIT, bmpFit, wxT("Zoom to fit"));
- tool_bar->AddTool(OPJFRAME_VIEWRELOAD, bmpReload, wxT("Reload"));
- tool_bar->AddSeparator();
- tool_bar->AddTool(OPJFRAME_SETSDECO, bmpDecosettings, wxT("Decoder settings"));
- tool_bar->AddTool(OPJFRAME_SETSENCO, bmpEncosettings, wxT("Encoder settings"));
- tool_bar->AddSeparator();
- tool_bar->AddTool(OPJFRAME_VIEWPREVFRAME, bmpPrevframe, wxT("Previous frame"));
- tool_bar->AddTool(OPJFRAME_VIEWHOMEFRAME, bmpHomeframe, wxT("Starting frame"));
- tool_bar->AddTool(OPJFRAME_VIEWNEXTFRAME, bmpNextframe, wxT("Next frame"));
- tool_bar->AddSeparator();
- tool_bar->AddTool(OPJFRAME_VIEWLESSLAYERS, bmpLesslayers, wxT("Remove a layer"));
- tool_bar->AddTool(OPJFRAME_VIEWALLLAYERS, bmpAlllayers, wxT("Show all layers"));
- tool_bar->AddTool(OPJFRAME_VIEWMORELAYERS, bmpMorelayers, wxT("Add a layer"));
- tool_bar->AddSeparator();
- tool_bar->AddTool(OPJFRAME_VIEWLESSRES, bmpLessres, wxT("Reduce the resolution"));
- tool_bar->AddTool(OPJFRAME_VIEWFULLRES, bmpFullres, wxT("Full resolution"));
- tool_bar->AddTool(OPJFRAME_VIEWMORERES, bmpMoreres, wxT("Increase the resolution"));
- tool_bar->AddSeparator();
- tool_bar->AddTool(OPJFRAME_VIEWPREVCOMP, bmpPrevcomp, wxT("Previous component"));
- tool_bar->AddTool(OPJFRAME_VIEWALLCOMPS, bmpAllcomps, wxT("All components"));
- tool_bar->AddTool(OPJFRAME_VIEWNEXTCOMP, bmpNextcomp, wxT("Next component"));
- tool_bar->Realize();
-
- // associate the toolbar with the frame
- SetToolBar(tool_bar);
-
- // show the toolbar?
- if (!wxGetApp().m_showtoolbar)
- tool_bar->Show(false);
- else
- tool_bar->Show(true);
-
- // the logging window
- loggingWindow = new wxSashLayoutWindow(this, OPJFRAME_LOGWIN,
- wxDefaultPosition, wxSize(400, wxGetApp().m_peekerheight),
- wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN
- );
- loggingWindow->SetDefaultSize(wxSize(1000, wxGetApp().m_peekerheight));
- loggingWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
- loggingWindow->SetAlignment(wxLAYOUT_BOTTOM);
- //loggingWindow->SetBackgroundColour(wxColour(0, 0, 255));
- loggingWindow->SetSashVisible(wxSASH_TOP, true);
-
- // show the logging?
- if (!wxGetApp().m_showpeeker)
- loggingWindow->Show(false);
- else
- loggingWindow->Show(true);
-
- // create the bottom notebook
- m_bookCtrlbottom = new wxNotebook(loggingWindow, BOTTOM_NOTEBOOK_ID,
- wxDefaultPosition, wxDefaultSize,
- wxBK_LEFT);
-
- // create the text control of the logger
- m_textCtrl = new wxTextCtrl(m_bookCtrlbottom, wxID_ANY, wxT(""),
- wxDefaultPosition, wxDefaultSize,
- wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY
- );
- m_textCtrl->SetValue(_T("Logging window\n"));
-
- // add it to the notebook
- m_bookCtrlbottom->AddPage(m_textCtrl, wxT("Log"));
-
- // create the text control of the browser
- m_textCtrlbrowse = new wxTextCtrl(m_bookCtrlbottom, wxID_ANY, wxT(""),
- wxDefaultPosition, wxDefaultSize,
- wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY | wxTE_RICH
- );
- wxFont *browsefont = new wxFont(wxNORMAL_FONT->GetPointSize(),
- wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
- m_textCtrlbrowse->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, *browsefont));
- m_textCtrlbrowse->AppendText(wxT("Browsing window\n"));
-
- // add it the notebook
- m_bookCtrlbottom->AddPage(m_textCtrlbrowse, wxT("Peek"), false);
-
- // the browser window
- markerTreeWindow = new wxSashLayoutWindow(this, OPJFRAME_BROWSEWIN,
- wxDefaultPosition, wxSize(wxGetApp().m_browserwidth, 30),
- wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN
- );
- markerTreeWindow->SetDefaultSize(wxSize(wxGetApp().m_browserwidth, 1000));
- markerTreeWindow->SetOrientation(wxLAYOUT_VERTICAL);
- markerTreeWindow->SetAlignment(wxLAYOUT_LEFT);
- //markerTreeWindow->SetBackgroundColour(wxColour(0, 255, 0));
- markerTreeWindow->SetSashVisible(wxSASH_RIGHT, true);
- markerTreeWindow->SetExtraBorderSize(0);
-
- // create the browser notebook
- m_bookCtrl = new wxNotebook(markerTreeWindow, LEFT_NOTEBOOK_ID,
- wxDefaultPosition, wxDefaultSize,
- wxBK_TOP);
-
- // show the browser?
- if (!wxGetApp().m_showbrowser)
- markerTreeWindow->Show(false);
- else
- markerTreeWindow->Show(true);
+ // the logging window
+ loggingWindow = new wxSashLayoutWindow(this, OPJFRAME_LOGWIN,
+ wxDefaultPosition, wxSize(400, wxGetApp().m_peekerheight),
+ wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN
+ );
+ loggingWindow->SetDefaultSize(wxSize(1000, wxGetApp().m_peekerheight));
+ loggingWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
+ loggingWindow->SetAlignment(wxLAYOUT_BOTTOM);
+ //loggingWindow->SetBackgroundColour(wxColour(0, 0, 255));
+ loggingWindow->SetSashVisible(wxSASH_TOP, true);
+
+ // show the logging?
+ if (!wxGetApp().m_showpeeker) {
+ loggingWindow->Show(false);
+ } else {
+ loggingWindow->Show(true);
+ }
+
+ // create the bottom notebook
+ m_bookCtrlbottom = new wxNotebook(loggingWindow, BOTTOM_NOTEBOOK_ID,
+ wxDefaultPosition, wxDefaultSize,
+ wxBK_LEFT);
+
+ // create the text control of the logger
+ m_textCtrl = new wxTextCtrl(m_bookCtrlbottom, wxID_ANY, wxT(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY
+ );
+ m_textCtrl->SetValue(_T("Logging window\n"));
+
+ // add it to the notebook
+ m_bookCtrlbottom->AddPage(m_textCtrl, wxT("Log"));
+
+ // create the text control of the browser
+ m_textCtrlbrowse = new wxTextCtrl(m_bookCtrlbottom, wxID_ANY, wxT(""),
+ wxDefaultPosition, wxDefaultSize,
+ wxTE_MULTILINE | wxSUNKEN_BORDER | wxTE_READONLY | wxTE_RICH
+ );
+ wxFont *browsefont = new wxFont(wxNORMAL_FONT->GetPointSize(),
+ wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
+ m_textCtrlbrowse->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour,
+ *browsefont));
+ m_textCtrlbrowse->AppendText(wxT("Browsing window\n"));
+
+ // add it the notebook
+ m_bookCtrlbottom->AddPage(m_textCtrlbrowse, wxT("Peek"), false);
+
+ // the browser window
+ markerTreeWindow = new wxSashLayoutWindow(this, OPJFRAME_BROWSEWIN,
+ wxDefaultPosition, wxSize(wxGetApp().m_browserwidth, 30),
+ wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN
+ );
+ markerTreeWindow->SetDefaultSize(wxSize(wxGetApp().m_browserwidth, 1000));
+ markerTreeWindow->SetOrientation(wxLAYOUT_VERTICAL);
+ markerTreeWindow->SetAlignment(wxLAYOUT_LEFT);
+ //markerTreeWindow->SetBackgroundColour(wxColour(0, 255, 0));
+ markerTreeWindow->SetSashVisible(wxSASH_RIGHT, true);
+ markerTreeWindow->SetExtraBorderSize(0);
+
+ // create the browser notebook
+ m_bookCtrl = new wxNotebook(markerTreeWindow, LEFT_NOTEBOOK_ID,
+ wxDefaultPosition, wxDefaultSize,
+ wxBK_TOP);
+
+ // show the browser?
+ if (!wxGetApp().m_showbrowser) {
+ markerTreeWindow->Show(false);
+ } else {
+ markerTreeWindow->Show(true);
+ }
#ifdef __WXMOTIF__
- // For some reason, we get a memcpy crash in wxLogStream::DoLogStream
- // on gcc/wxMotif, if we use wxLogTextCtl. Maybe it's just gcc?
- delete wxLog::SetActiveTarget(new wxLogStderr);
+ // For some reason, we get a memcpy crash in wxLogStream::DoLogStream
+ // on gcc/wxMotif, if we use wxLogTextCtl. Maybe it's just gcc?
+ delete wxLog::SetActiveTarget(new wxLogStderr);
#else
- // set our text control as the log target
- wxLogTextCtrl *logWindow = new wxLogTextCtrl(m_textCtrl);
- delete wxLog::SetActiveTarget(logWindow);
+ // set our text control as the log target
+ wxLogTextCtrl *logWindow = new wxLogTextCtrl(m_textCtrl);
+ delete wxLog::SetActiveTarget(logWindow);
#endif
- // associate drop targets with the controls
- SetDropTarget(new OPJDnDFile(this));
+ // associate drop targets with the controls
+ SetDropTarget(new OPJDnDFile(this));
}
// this is the frame destructor
OPJFrame::~OPJFrame(void)
{
- // save size settings
- GetSize(&(wxGetApp().m_framewidth), &(wxGetApp().m_frameheight));
+ // save size settings
+ GetSize(&(wxGetApp().m_framewidth), &(wxGetApp().m_frameheight));
- // delete all possible things
- delete m_bookCtrl;
- m_bookCtrl = NULL;
+ // delete all possible things
+ delete m_bookCtrl;
+ m_bookCtrl = NULL;
- delete markerTreeWindow;
- markerTreeWindow = NULL;
+ delete markerTreeWindow;
+ markerTreeWindow = NULL;
- delete m_textCtrl;
- m_textCtrl = NULL;
+ delete m_textCtrl;
+ m_textCtrl = NULL;
- delete m_bookCtrlbottom;
- m_bookCtrlbottom = NULL;
+ delete m_bookCtrlbottom;
+ m_bookCtrlbottom = NULL;
- delete loggingWindow;
- loggingWindow = NULL;
+ delete loggingWindow;
+ loggingWindow = NULL;
}
void OPJFrame::OnNotebook(wxNotebookEvent& event)
{
- int sel = event.GetSelection();
- long childnum;
+ int sel = event.GetSelection();
+ long childnum;
- m_bookCtrl->GetPageText(sel).ToLong(&childnum);
+ m_bookCtrl->GetPageText(sel).ToLong(&childnum);
- if (m_childhash[childnum])
- m_childhash[childnum]->Activate();
+ if (m_childhash[childnum]) {
+ m_childhash[childnum]->Activate();
+ }
- //wxLogMessage(wxT("Selection changed (now %d --> %d)"), childnum, m_childhash[childnum]->m_winnumber);
+ //wxLogMessage(wxT("Selection changed (now %d --> %d)"), childnum, m_childhash[childnum]->m_winnumber);
}
void OPJFrame::Resize(int number)
{
- wxSize size = GetClientSize();
+ wxSize size = GetClientSize();
}
void OPJFrame::OnSetsEnco(wxCommandEvent& event)
{
- int n;
+ int n;
OPJEncoderDialog dialog(this, event.GetId());
if (dialog.ShowModal() == wxID_OK) {
- // load settings
- wxGetApp().m_subsampling = dialog.m_subsamplingCtrl->GetValue();
- wxGetApp().m_origin = dialog.m_originCtrl->GetValue();
- wxGetApp().m_rates = dialog.m_rateCtrl->GetValue();
- wxGetApp().m_quality = dialog.m_qualityCtrl->GetValue();
- wxGetApp().m_enablequality = dialog.m_qualityRadio->GetValue();
- wxGetApp().m_multicomp = dialog.m_mctCheck->GetValue();
- wxGetApp().m_irreversible = dialog.m_irrevCheck->GetValue();
- wxGetApp().m_resolutions = dialog.m_resolutionsCtrl->GetValue();
- wxGetApp().m_cbsize = dialog.m_cbsizeCtrl->GetValue();
- wxGetApp().m_prsize = dialog.m_prsizeCtrl->GetValue();
- wxGetApp().m_tsize = dialog.m_tsizeCtrl->GetValue();
- wxGetApp().m_torigin = dialog.m_toriginCtrl->GetValue();
- wxGetApp().m_progression = dialog.progressionBox->GetSelection();
- wxGetApp().m_enablesop = dialog.m_sopCheck->GetValue();
- wxGetApp().m_enableeph = dialog.m_ephCheck->GetValue();
- wxGetApp().m_enablebypass = dialog.m_enablebypassCheck->GetValue();
- wxGetApp().m_enablereset = dialog.m_enableresetCheck->GetValue();
- wxGetApp().m_enablerestart = dialog.m_enablerestartCheck->GetValue();
- wxGetApp().m_enablevsc = dialog.m_enablevscCheck->GetValue();
- wxGetApp().m_enableerterm = dialog.m_enableertermCheck->GetValue();
- wxGetApp().m_enablesegmark = dialog.m_enablesegmarkCheck->GetValue();
- wxGetApp().m_enableidx = dialog.m_enableidxCheck->GetValue();
- wxGetApp().m_index = dialog.m_indexCtrl->GetValue();
- wxGetApp().m_enablecomm = dialog.m_enablecommCheck->GetValue();
- wxGetApp().m_comment = dialog.m_commentCtrl->GetValue();
- wxGetApp().m_enablepoc = dialog.m_enablepocCheck->GetValue();
- wxGetApp().m_poc = dialog.m_pocCtrl->GetValue();
+ // load settings
+ wxGetApp().m_subsampling = dialog.m_subsamplingCtrl->GetValue();
+ wxGetApp().m_origin = dialog.m_originCtrl->GetValue();
+ wxGetApp().m_rates = dialog.m_rateCtrl->GetValue();
+ wxGetApp().m_quality = dialog.m_qualityCtrl->GetValue();
+ wxGetApp().m_enablequality = dialog.m_qualityRadio->GetValue();
+ wxGetApp().m_multicomp = dialog.m_mctCheck->GetValue();
+ wxGetApp().m_irreversible = dialog.m_irrevCheck->GetValue();
+ wxGetApp().m_resolutions = dialog.m_resolutionsCtrl->GetValue();
+ wxGetApp().m_cbsize = dialog.m_cbsizeCtrl->GetValue();
+ wxGetApp().m_prsize = dialog.m_prsizeCtrl->GetValue();
+ wxGetApp().m_tsize = dialog.m_tsizeCtrl->GetValue();
+ wxGetApp().m_torigin = dialog.m_toriginCtrl->GetValue();
+ wxGetApp().m_progression = dialog.progressionBox->GetSelection();
+ wxGetApp().m_enablesop = dialog.m_sopCheck->GetValue();
+ wxGetApp().m_enableeph = dialog.m_ephCheck->GetValue();
+ wxGetApp().m_enablebypass = dialog.m_enablebypassCheck->GetValue();
+ wxGetApp().m_enablereset = dialog.m_enableresetCheck->GetValue();
+ wxGetApp().m_enablerestart = dialog.m_enablerestartCheck->GetValue();
+ wxGetApp().m_enablevsc = dialog.m_enablevscCheck->GetValue();
+ wxGetApp().m_enableerterm = dialog.m_enableertermCheck->GetValue();
+ wxGetApp().m_enablesegmark = dialog.m_enablesegmarkCheck->GetValue();
+ wxGetApp().m_enableidx = dialog.m_enableidxCheck->GetValue();
+ wxGetApp().m_index = dialog.m_indexCtrl->GetValue();
+ wxGetApp().m_enablecomm = dialog.m_enablecommCheck->GetValue();
+ wxGetApp().m_comment = dialog.m_commentCtrl->GetValue();
+ wxGetApp().m_enablepoc = dialog.m_enablepocCheck->GetValue();
+ wxGetApp().m_poc = dialog.m_pocCtrl->GetValue();
#ifdef USE_JPWL
- wxGetApp().m_enablejpwle = dialog.m_enablejpwlCheck->GetValue();
- for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
- wxGetApp().m_hprotsel[n] = dialog.m_hprotChoice[n]->GetSelection();
- wxGetApp().m_htileval[n] = dialog.m_htileCtrl[n]->GetValue();
- wxGetApp().m_pprotsel[n] = dialog.m_pprotChoice[n]->GetSelection();
- wxGetApp().m_ptileval[n] = dialog.m_ptileCtrl[n]->GetValue();
- wxGetApp().m_ppackval[n] = dialog.m_ppackCtrl[n]->GetValue();
- wxGetApp().m_sensisel[n] = dialog.m_sensiChoice[n]->GetSelection();
- wxGetApp().m_stileval[n] = dialog.m_stileCtrl[n]->GetValue();
- }
+ wxGetApp().m_enablejpwle = dialog.m_enablejpwlCheck->GetValue();
+ for (n = 0; n < MYJPWL_MAX_NO_TILESPECS; n++) {
+ wxGetApp().m_hprotsel[n] = dialog.m_hprotChoice[n]->GetSelection();
+ wxGetApp().m_htileval[n] = dialog.m_htileCtrl[n]->GetValue();
+ wxGetApp().m_pprotsel[n] = dialog.m_pprotChoice[n]->GetSelection();
+ wxGetApp().m_ptileval[n] = dialog.m_ptileCtrl[n]->GetValue();
+ wxGetApp().m_ppackval[n] = dialog.m_ppackCtrl[n]->GetValue();
+ wxGetApp().m_sensisel[n] = dialog.m_sensiChoice[n]->GetSelection();
+ wxGetApp().m_stileval[n] = dialog.m_stileCtrl[n]->GetValue();
+ }
#endif // USE_JPWL
- };
+ };
}
void OPJFrame::OnSetsDeco(wxCommandEvent& event)
@@ -889,265 +930,276 @@ void OPJFrame::OnSetsDeco(wxCommandEvent& event)
if (dialog.ShowModal() == wxID_OK) {
- // load settings
- wxGetApp().m_enabledeco = dialog.m_enabledecoCheck->GetValue();
- wxGetApp().m_enableparse = dialog.m_enableparseCheck->GetValue();
- wxGetApp().m_resizemethod = dialog.m_resizeBox->GetSelection() - 1;
- wxGetApp().m_reducefactor = dialog.m_reduceCtrl->GetValue();
- wxGetApp().m_qualitylayers = dialog.m_layerCtrl->GetValue();
- wxGetApp().m_components = dialog.m_numcompsCtrl->GetValue();
- wxGetApp().m_framenum = dialog.m_framenumCtrl->GetValue();
+ // load settings
+ wxGetApp().m_enabledeco = dialog.m_enabledecoCheck->GetValue();
+ wxGetApp().m_enableparse = dialog.m_enableparseCheck->GetValue();
+ wxGetApp().m_resizemethod = dialog.m_resizeBox->GetSelection() - 1;
+ wxGetApp().m_reducefactor = dialog.m_reduceCtrl->GetValue();
+ wxGetApp().m_qualitylayers = dialog.m_layerCtrl->GetValue();
+ wxGetApp().m_components = dialog.m_numcompsCtrl->GetValue();
+ wxGetApp().m_framenum = dialog.m_framenumCtrl->GetValue();
#ifdef USE_JPWL
- wxGetApp().m_enablejpwl = dialog.m_enablejpwlCheck->GetValue();
- wxGetApp().m_expcomps = dialog.m_expcompsCtrl->GetValue();
- wxGetApp().m_maxtiles = dialog.m_maxtilesCtrl->GetValue();
+ wxGetApp().m_enablejpwl = dialog.m_enablejpwlCheck->GetValue();
+ wxGetApp().m_expcomps = dialog.m_expcompsCtrl->GetValue();
+ wxGetApp().m_maxtiles = dialog.m_maxtilesCtrl->GetValue();
#endif // USE_JPWL
- };
+ };
}
void OPJFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
- Close(true);
+ Close(true);
}
void OPJFrame::OnClose(wxCommandEvent& WXUNUSED(event))
{
- // current frame
- OPJChildFrame *currframe = (OPJChildFrame *) GetActiveChild();
+ // current frame
+ OPJChildFrame *currframe = (OPJChildFrame *) GetActiveChild();
- if (!currframe)
- return;
+ if (!currframe) {
+ return;
+ }
- wxCloseEvent e;
- currframe->OnClose(e);
+ wxCloseEvent e;
+ currframe->OnClose(e);
}
void OPJFrame::OnFit(wxCommandEvent& event)
{
- OPJChildFrame *currchild;
- wxString eventstring = event.GetString();
-
- //wxLogMessage(wxT("OnFit:%d:%s"), event.GetInt(), eventstring);
-
- // current child
- if (event.GetInt() >= 1) {
- currchild = m_childhash[event.GetInt()];
- } else {
- currchild = (OPJChildFrame *) GetActiveChild();
- }
-
- // problems
- if (!currchild)
- return;
-
- // current canvas
- OPJCanvas *currcanvas = currchild->m_canvas;
-
- // find a fit-to-width zoom
- /*int zooml, wzooml, hzooml;
- wxSize clientsize = currcanvas->GetClientSize();
- wzooml = (int) ceil(100.0 * (double) (clientsize.GetWidth() - 2 * OPJ_CANVAS_BORDER) / (double) (currcanvas->m_image100.GetWidth()));
- hzooml = (int) ceil(100.0 * (double) (clientsize.GetHeight() - 2 * OPJ_CANVAS_BORDER) / (double) (currcanvas->m_image100.GetHeight()));
- zooml = wxMin(100, wxMin(wzooml, hzooml));*/
-
- // fit to width
- Rescale(-1, currchild);
+ OPJChildFrame *currchild;
+ wxString eventstring = event.GetString();
+
+ //wxLogMessage(wxT("OnFit:%d:%s"), event.GetInt(), eventstring);
+
+ // current child
+ if (event.GetInt() >= 1) {
+ currchild = m_childhash[event.GetInt()];
+ } else {
+ currchild = (OPJChildFrame *) GetActiveChild();
+ }
+
+ // problems
+ if (!currchild) {
+ return;
+ }
+
+ // current canvas
+ OPJCanvas *currcanvas = currchild->m_canvas;
+
+ // find a fit-to-width zoom
+ /*int zooml, wzooml, hzooml;
+ wxSize clientsize = currcanvas->GetClientSize();
+ wzooml = (int) ceil(100.0 * (double) (clientsize.GetWidth() - 2 * OPJ_CANVAS_BORDER) / (double) (currcanvas->m_image100.GetWidth()));
+ hzooml = (int) ceil(100.0 * (double) (clientsize.GetHeight() - 2 * OPJ_CANVAS_BORDER) / (double) (currcanvas->m_image100.GetHeight()));
+ zooml = wxMin(100, wxMin(wzooml, hzooml));*/
+
+ // fit to width
+ Rescale(-1, currchild);
}
void OPJFrame::OnZoom(wxCommandEvent& WXUNUSED(event))
{
- // current frame
- OPJChildFrame *currframe = (OPJChildFrame *) GetActiveChild();
-
- if (!currframe)
- return;
-
- // get the preferred zoom
- long zooml = wxGetNumberFromUser(wxT("Choose a scale between 5% and 300%"),
- wxT("Zoom (%)"),
- wxT("Image scale"),
- currframe->m_canvas->m_zooml, 5, 300, NULL, wxDefaultPosition);
-
- // rescale current frame image if necessary
- if (zooml >= 5) {
- Rescale(zooml, currframe);
- wxLogMessage(wxT("zoom to %d%%"), zooml);
- }
+ // current frame
+ OPJChildFrame *currframe = (OPJChildFrame *) GetActiveChild();
+
+ if (!currframe) {
+ return;
+ }
+
+ // get the preferred zoom
+ long zooml = wxGetNumberFromUser(wxT("Choose a scale between 5% and 300%"),
+ wxT("Zoom (%)"),
+ wxT("Image scale"),
+ currframe->m_canvas->m_zooml, 5, 300, NULL, wxDefaultPosition);
+
+ // rescale current frame image if necessary
+ if (zooml >= 5) {
+ Rescale(zooml, currframe);
+ wxLogMessage(wxT("zoom to %d%%"), zooml);
+ }
}
void OPJFrame::Rescale(int zooml, OPJChildFrame *currframe)
{
- wxImage new_image = currframe->m_canvas->m_image100.ConvertToImage();
-
- // resizing enabled?
- if (wxGetApp().m_resizemethod == -1) {
-
- zooml = 100;
-
- } else {
-
- if (zooml < 0) {
- // find a fit-to-width zoom
- int wzooml, hzooml;
- //wxSize clientsize = currframe->m_canvas->GetClientSize();
- wxSize clientsize = currframe->m_frame->GetActiveChild()->GetClientSize();
- wzooml = (int) floor(100.0 * (double) clientsize.GetWidth() / (double) (2 * OPJ_CANVAS_BORDER + currframe->m_canvas->m_image100.GetWidth()));
- hzooml = (int) floor(100.0 * (double) clientsize.GetHeight() / (double) (2 * OPJ_CANVAS_BORDER + currframe->m_canvas->m_image100.GetHeight()));
- zooml = wxMin(100, wxMin(wzooml, hzooml));
- }
- }
-
- if (zooml != 100)
- new_image.Rescale((int) ((double) zooml * (double) new_image.GetWidth() / 100.0),
- (int) ((double) zooml * (double) new_image.GetHeight() / 100.0),
- wxGetApp().m_resizemethod ? wxIMAGE_QUALITY_HIGH : wxIMAGE_QUALITY_NORMAL);
- currframe->m_canvas->m_image = wxBitmap(new_image);
- currframe->m_canvas->SetScrollbars(20,
- 20,
- (int)(0.5 + (double) new_image.GetWidth() / 20.0),
- (int)(0.5 + (double) new_image.GetHeight() / 20.0)
- );
-
- currframe->m_canvas->Refresh();
-
- wxLogMessage(wxT("Rescale said %d%%"), zooml);
-
- // update zoom
- currframe->m_canvas->m_zooml = zooml;
+ wxImage new_image = currframe->m_canvas->m_image100.ConvertToImage();
+
+ // resizing enabled?
+ if (wxGetApp().m_resizemethod == -1) {
+
+ zooml = 100;
+
+ } else {
+
+ if (zooml < 0) {
+ // find a fit-to-width zoom
+ int wzooml, hzooml;
+ //wxSize clientsize = currframe->m_canvas->GetClientSize();
+ wxSize clientsize = currframe->m_frame->GetActiveChild()->GetClientSize();
+ wzooml = (int) floor(100.0 * (double) clientsize.GetWidth() / (double)(
+ 2 * OPJ_CANVAS_BORDER + currframe->m_canvas->m_image100.GetWidth()));
+ hzooml = (int) floor(100.0 * (double) clientsize.GetHeight() / (double)(
+ 2 * OPJ_CANVAS_BORDER + currframe->m_canvas->m_image100.GetHeight()));
+ zooml = wxMin(100, wxMin(wzooml, hzooml));
+ }
+ }
+
+ if (zooml != 100)
+ new_image.Rescale((int)((double) zooml * (double) new_image.GetWidth() / 100.0),
+ (int)((double) zooml * (double) new_image.GetHeight() / 100.0),
+ wxGetApp().m_resizemethod ? wxIMAGE_QUALITY_HIGH : wxIMAGE_QUALITY_NORMAL);
+ currframe->m_canvas->m_image = wxBitmap(new_image);
+ currframe->m_canvas->SetScrollbars(20,
+ 20,
+ (int)(0.5 + (double) new_image.GetWidth() / 20.0),
+ (int)(0.5 + (double) new_image.GetHeight() / 20.0)
+ );
+
+ currframe->m_canvas->Refresh();
+
+ wxLogMessage(wxT("Rescale said %d%%"), zooml);
+
+ // update zoom
+ currframe->m_canvas->m_zooml = zooml;
}
void OPJFrame::OnReload(wxCommandEvent& event)
{
- OPJChildFrame *currframe = (OPJChildFrame *) GetActiveChild();
+ OPJChildFrame *currframe = (OPJChildFrame *) GetActiveChild();
- if (currframe) {
- OPJDecoThread *dthread = currframe->m_canvas->CreateDecoThread();
+ if (currframe) {
+ OPJDecoThread *dthread = currframe->m_canvas->CreateDecoThread();
- if (dthread->Run() != wxTHREAD_NO_ERROR)
- wxLogMessage(wxT("Can't start deco thread!"));
- else
- wxLogMessage(wxT("New deco thread started."));
+ if (dthread->Run() != wxTHREAD_NO_ERROR) {
+ wxLogMessage(wxT("Can't start deco thread!"));
+ } else {
+ wxLogMessage(wxT("New deco thread started."));
+ }
- currframe->m_canvas->Refresh();
+ currframe->m_canvas->Refresh();
- // update zoom
- //currframe->m_canvas->m_zooml = zooml;
- }
+ // update zoom
+ //currframe->m_canvas->m_zooml = zooml;
+ }
}
void OPJFrame::OnPrevFrame(wxCommandEvent& event)
{
- if (--wxGetApp().m_framenum < 0)
- wxGetApp().m_framenum = 0;
+ if (--wxGetApp().m_framenum < 0) {
+ wxGetApp().m_framenum = 0;
+ }
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnHomeFrame(wxCommandEvent& event)
{
- wxGetApp().m_framenum = 0;
+ wxGetApp().m_framenum = 0;
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnNextFrame(wxCommandEvent& event)
{
- ++wxGetApp().m_framenum;
+ ++wxGetApp().m_framenum;
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnLessLayers(wxCommandEvent& event)
{
- if (--wxGetApp().m_qualitylayers < 1)
- wxGetApp().m_qualitylayers = 1;
+ if (--wxGetApp().m_qualitylayers < 1) {
+ wxGetApp().m_qualitylayers = 1;
+ }
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnAllLayers(wxCommandEvent& event)
{
- wxGetApp().m_qualitylayers = 0;
+ wxGetApp().m_qualitylayers = 0;
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnMoreLayers(wxCommandEvent& event)
{
- ++wxGetApp().m_qualitylayers;
+ ++wxGetApp().m_qualitylayers;
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnLessRes(wxCommandEvent& event)
{
- ++wxGetApp().m_reducefactor;
+ ++wxGetApp().m_reducefactor;
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnFullRes(wxCommandEvent& event)
{
- wxGetApp().m_reducefactor = 0;
+ wxGetApp().m_reducefactor = 0;
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnMoreRes(wxCommandEvent& event)
{
- if (--wxGetApp().m_reducefactor < 0)
- wxGetApp().m_reducefactor = 0;
+ if (--wxGetApp().m_reducefactor < 0) {
+ wxGetApp().m_reducefactor = 0;
+ }
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnPrevComp(wxCommandEvent& event)
{
- if (--wxGetApp().m_components < 1)
- wxGetApp().m_components = 1;
+ if (--wxGetApp().m_components < 1) {
+ wxGetApp().m_components = 1;
+ }
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnAllComps(wxCommandEvent& event)
{
- wxGetApp().m_components = 0;
+ wxGetApp().m_components = 0;
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnNextComp(wxCommandEvent& event)
{
- ++wxGetApp().m_components;
+ ++wxGetApp().m_components;
- wxCommandEvent e;
- OnReload(e);
+ wxCommandEvent e;
+ OnReload(e);
}
void OPJFrame::OnToggleBrowser(wxCommandEvent& WXUNUSED(event))
{
- if (markerTreeWindow->IsShown())
+ if (markerTreeWindow->IsShown()) {
markerTreeWindow->Show(false);
- else
+ } else {
markerTreeWindow->Show(true);
+ }
wxLayoutAlgorithm layout;
layout.LayoutMDIFrame(this);
- wxGetApp().m_showbrowser = markerTreeWindow->IsShown();
+ wxGetApp().m_showbrowser = markerTreeWindow->IsShown();
// Leaves bits of itself behind sometimes
GetClientWindow()->Refresh();
@@ -1155,15 +1207,16 @@ void OPJFrame::OnToggleBrowser(wxCommandEvent& WXUNUSED(event))
void OPJFrame::OnTogglePeeker(wxCommandEvent& WXUNUSED(event))
{
- if (loggingWindow->IsShown())
+ if (loggingWindow->IsShown()) {
loggingWindow->Show(false);
- else
+ } else {
loggingWindow->Show(true);
+ }
wxLayoutAlgorithm layout;
layout.LayoutMDIFrame(this);
- wxGetApp().m_showpeeker = loggingWindow->IsShown();
+ wxGetApp().m_showpeeker = loggingWindow->IsShown();
// Leaves bits of itself behind sometimes
GetClientWindow()->Refresh();
@@ -1171,15 +1224,16 @@ void OPJFrame::OnTogglePeeker(wxCommandEvent& WXUNUSED(event))
void OPJFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event))
{
- if (tool_bar->IsShown())
+ if (tool_bar->IsShown()) {
tool_bar->Show(false);
- else
+ } else {
tool_bar->Show(true);
+ }
wxLayoutAlgorithm layout;
layout.LayoutMDIFrame(this);
- wxGetApp().m_showtoolbar = tool_bar->IsShown();
+ wxGetApp().m_showtoolbar = tool_bar->IsShown();
// Leaves bits of itself behind sometimes
GetClientWindow()->Refresh();
@@ -1187,22 +1241,21 @@ void OPJFrame::OnToggleToolbar(wxCommandEvent& WXUNUSED(event))
void OPJFrame::OnSashDrag(wxSashEvent& event)
{
- int wid, hei;
+ int wid, hei;
- if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
+ if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE) {
return;
+ }
switch (event.GetId()) {
- case OPJFRAME_BROWSEWIN:
- {
- markerTreeWindow->SetDefaultSize(wxSize(event.GetDragRect().width, 1000));
- break;
- }
- case OPJFRAME_LOGWIN:
- {
- loggingWindow->SetDefaultSize(wxSize(1000, event.GetDragRect().height));
- break;
- }
+ case OPJFRAME_BROWSEWIN: {
+ markerTreeWindow->SetDefaultSize(wxSize(event.GetDragRect().width, 1000));
+ break;
+ }
+ case OPJFRAME_LOGWIN: {
+ loggingWindow->SetDefaultSize(wxSize(1000, event.GetDragRect().height));
+ break;
+ }
}
wxLayoutAlgorithm layout;
@@ -1211,12 +1264,12 @@ void OPJFrame::OnSashDrag(wxSashEvent& event)
// Leaves bits of itself behind sometimes
GetClientWindow()->Refresh();
- // update dimensions
- markerTreeWindow->GetSize(&wid, &hei);
- wxGetApp().m_browserwidth = wid;
+ // update dimensions
+ markerTreeWindow->GetSize(&wid, &hei);
+ wxGetApp().m_browserwidth = wid;
- loggingWindow->GetSize(&wid, &hei);
- wxGetApp().m_peekerheight = hei;
+ loggingWindow->GetSize(&wid, &hei);
+ wxGetApp().m_peekerheight = hei;
}
@@ -1227,8 +1280,7 @@ void OPJFrame::OnThreadLogmsg(wxCommandEvent& event)
wxLogMessage(event.GetString());
#else
int n = event.GetInt();
- if ( n == -1 )
- {
+ if (n == -1) {
m_dlgProgress->Destroy();
m_dlgProgress = (wxProgressDialog *)NULL;
@@ -1236,11 +1288,8 @@ void OPJFrame::OnThreadLogmsg(wxCommandEvent& event)
// we may need to wake up the main event loop for the dialog to be
// really closed
wxWakeUpIdle();
- }
- else
- {
- if ( !m_dlgProgress->Update(n) )
- {
+ } else {
+ if (!m_dlgProgress->Update(n)) {
wxCriticalSectionLocker lock(m_critsectWork);
m_cancelled = true;
@@ -1253,34 +1302,39 @@ void OPJFrame::OnThreadLogmsg(wxCommandEvent& event)
// physically save the file
void OPJFrame::SaveFile(wxArrayString paths, wxArrayString filenames)
{
- size_t count = paths.GetCount();
- wxString msg, s;
+ size_t count = paths.GetCount();
+ wxString msg, s;
- if (wxFile::Exists(paths[0].c_str())) {
+ if (wxFile::Exists(paths[0].c_str())) {
- s.Printf(wxT("File %s already exists. Do you want to overwrite it?\n"), filenames[0].c_str());
- wxMessageDialog dialog3(this, s, _T("File exists"), wxYES_NO);
- if (dialog3.ShowModal() == wxID_NO)
- return;
- }
+ s.Printf(wxT("File %s already exists. Do you want to overwrite it?\n"),
+ filenames[0].c_str());
+ wxMessageDialog dialog3(this, s, _T("File exists"), wxYES_NO);
+ if (dialog3.ShowModal() == wxID_NO) {
+ return;
+ }
+ }
- /*s.Printf(_T("File %d: %s (%s)\n"), (int)0, paths[0].c_str(), filenames[0].c_str());
- msg += s;
+ /*s.Printf(_T("File %d: %s (%s)\n"), (int)0, paths[0].c_str(), filenames[0].c_str());
+ msg += s;
- wxMessageDialog dialog2(this, msg, _T("Selected files"));
- dialog2.ShowModal();*/
+ wxMessageDialog dialog2(this, msg, _T("Selected files"));
+ dialog2.ShowModal();*/
- if (!GetActiveChild())
- return;
+ if (!GetActiveChild()) {
+ return;
+ }
- ((OPJChildFrame *) GetActiveChild())->m_canvas->m_savename = paths[0];
+ ((OPJChildFrame *) GetActiveChild())->m_canvas->m_savename = paths[0];
- OPJEncoThread *ethread = ((OPJChildFrame *) GetActiveChild())->m_canvas->CreateEncoThread();
+ OPJEncoThread *ethread = ((OPJChildFrame *)
+ GetActiveChild())->m_canvas->CreateEncoThread();
- if (ethread->Run() != wxTHREAD_NO_ERROR)
+ if (ethread->Run() != wxTHREAD_NO_ERROR) {
wxLogMessage(wxT("Can't start enco thread!"));
- else
- wxLogMessage(wxT("New enco thread started."));
+ } else {
+ wxLogMessage(wxT("New enco thread started."));
+ }
}
@@ -1289,73 +1343,76 @@ void OPJFrame::SaveFile(wxArrayString paths, wxArrayString filenames)
void OPJFrame::OpenFiles(wxArrayString paths, wxArrayString filenames)
{
- size_t count = paths.GetCount();
- for (size_t n = 0; n < count; n++) {
-
- wxString msg, s;
- s.Printf(_T("File %d: %s (%s)\n"), (int)n, paths[n].c_str(), filenames[n].c_str());
-
- msg += s;
-
- /*wxMessageDialog dialog2(this, msg, _T("Selected files"));
- dialog2.ShowModal();*/
-
- // Make another frame, containing a canvas
- OPJChildFrame *subframe = new OPJChildFrame(this,
- paths[n],
- winNumber,
- wxT("Canvas Frame"),
- wxDefaultPosition, wxSize(300, 300),
- wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE
- );
- m_childhash[winNumber] = subframe;
-
- // create own marker tree
- m_treehash[winNumber] = new OPJMarkerTree(m_bookCtrl, subframe, paths[n], wxT("Parsing..."), TreeTest_Ctrl,
- wxDefaultPosition, wxDefaultSize,
- wxTR_DEFAULT_STYLE | wxSUNKEN_BORDER
- );
-
- m_bookCtrl->AddPage(m_treehash[winNumber], wxString::Format(wxT("%u"), winNumber), false);
-
- for (unsigned int p = 0; p < m_bookCtrl->GetPageCount(); p++) {
- if (m_bookCtrl->GetPageText(p) == wxString::Format(wxT("%u"), winNumber)) {
- m_bookCtrl->ChangeSelection(p);
- break;
- }
- }
+ size_t count = paths.GetCount();
+ for (size_t n = 0; n < count; n++) {
+
+ wxString msg, s;
+ s.Printf(_T("File %d: %s (%s)\n"), (int)n, paths[n].c_str(),
+ filenames[n].c_str());
+
+ msg += s;
+
+ /*wxMessageDialog dialog2(this, msg, _T("Selected files"));
+ dialog2.ShowModal();*/
+
+ // Make another frame, containing a canvas
+ OPJChildFrame *subframe = new OPJChildFrame(this,
+ paths[n],
+ winNumber,
+ wxT("Canvas Frame"),
+ wxDefaultPosition, wxSize(300, 300),
+ wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE
+ );
+ m_childhash[winNumber] = subframe;
+
+ // create own marker tree
+ m_treehash[winNumber] = new OPJMarkerTree(m_bookCtrl, subframe, paths[n],
+ wxT("Parsing..."), TreeTest_Ctrl,
+ wxDefaultPosition, wxDefaultSize,
+ wxTR_DEFAULT_STYLE | wxSUNKEN_BORDER
+ );
+
+ m_bookCtrl->AddPage(m_treehash[winNumber], wxString::Format(wxT("%u"),
+ winNumber), false);
+
+ for (unsigned int p = 0; p < m_bookCtrl->GetPageCount(); p++) {
+ if (m_bookCtrl->GetPageText(p) == wxString::Format(wxT("%u"), winNumber)) {
+ m_bookCtrl->ChangeSelection(p);
+ break;
+ }
+ }
- winNumber++;
- }
+ winNumber++;
+ }
}
void OPJFrame::OnFileOpen(wxCommandEvent& WXUNUSED(event))
{
wxString wildcards =
#ifdef __WXMOTIF__
- wxT("JPEG 2000 files (*.jp2,*.j2k,*.j2c,*.mj2)|*.*j*2*");
+ wxT("JPEG 2000 files (*.jp2,*.j2k,*.j2c,*.mj2)|*.*j*2*");
#else
#if wxUSE_LIBOPENJPEG
- wxT("JPEG 2000 files (*.jp2,*.j2k,*.j2c,*.mj2)|*.jp2;*.j2k;*.j2c;*.mj2")
+ wxT("JPEG 2000 files (*.jp2,*.j2k,*.j2c,*.mj2)|*.jp2;*.j2k;*.j2c;*.mj2")
#endif
#if USE_MXF
- wxT("|MXF JPEG 2000 video (*.mxf)|*.mxf")
+ wxT("|MXF JPEG 2000 video (*.mxf)|*.mxf")
#endif // USE_MXF
#if wxUSE_LIBJPEG
- wxT("|JPEG files (*.jpg)|*.jpg")
+ wxT("|JPEG files (*.jpg)|*.jpg")
#endif
#if OPJ_MANYFORMATS
- wxT("|BMP files (*.bmp)|*.bmp")
- wxT("|PNG files (*.png)|*.png")
- wxT("|GIF files (*.gif)|*.gif")
- wxT("|PNM files (*.pnm)|*.pnm")
- wxT("|TIFF files (*.tif,*.tiff)|*.tif*")
+ wxT("|BMP files (*.bmp)|*.bmp")
+ wxT("|PNG files (*.png)|*.png")
+ wxT("|GIF files (*.gif)|*.gif")
+ wxT("|PNM files (*.pnm)|*.pnm")
+ wxT("|TIFF files (*.tif,*.tiff)|*.tif*")
#endif
- wxT("|All files|*");
+ wxT("|All files|*");
#endif
wxFileDialog dialog(this, _T("Open image file(s)"),
wxEmptyString, wxEmptyString, wildcards,
- wxFD_OPEN|wxFD_MULTIPLE);
+ wxFD_OPEN | wxFD_MULTIPLE);
if (dialog.ShowModal() == wxID_OK) {
wxArrayString paths, filenames;
@@ -1363,7 +1420,7 @@ void OPJFrame::OnFileOpen(wxCommandEvent& WXUNUSED(event))
dialog.GetPaths(paths);
dialog.GetFilenames(filenames);
- OpenFiles(paths, filenames);
+ OpenFiles(paths, filenames);
}
}
@@ -1373,13 +1430,13 @@ void OPJFrame::OnFileSaveAs(wxCommandEvent& WXUNUSED(event))
wxString wildcards =
#ifdef wxUSE_LIBOPENJPEG
#ifdef __WXMOTIF__
- wxT("JPEG 2000 codestream (*.j2k)|*.*j*2*");
+ wxT("JPEG 2000 codestream (*.j2k)|*.*j*2*");
#else
- wxT("JPEG 2000 codestream (*.j2k)|*.j2k")
- wxT("|JPEG 2000 file format (*.jp2)|*.jp2");
+ wxT("JPEG 2000 codestream (*.j2k)|*.j2k")
+ wxT("|JPEG 2000 file format (*.jp2)|*.jp2");
#endif
#else
- wxT("Houston we have a problem");
+ wxT("Houston we have a problem");
#endif
wxFileDialog dialog(this, _T("Save image file"),
@@ -1392,7 +1449,7 @@ void OPJFrame::OnFileSaveAs(wxCommandEvent& WXUNUSED(event))
dialog.GetPaths(paths);
dialog.GetFilenames(filenames);
- SaveFile(paths, filenames);
+ SaveFile(paths, filenames);
}
@@ -1400,18 +1457,19 @@ void OPJFrame::OnFileSaveAs(wxCommandEvent& WXUNUSED(event))
void OPJFrame::OnMemoryOpen(wxCommandEvent& WXUNUSED(event))
{
- // do nothing
- return;
-
- wxTextEntryDialog dialog(this, wxT("Memory HEX address range: start_address-stop_address"),
- wxT("Decode a memory buffer"),
- wxT("0x-0x"),
- wxOK | wxCANCEL | wxCENTRE,
- wxDefaultPosition);
+ // do nothing
+ return;
- if (dialog.ShowModal() == wxID_OK) {
+ wxTextEntryDialog dialog(this,
+ wxT("Memory HEX address range: start_address-stop_address"),
+ wxT("Decode a memory buffer"),
+ wxT("0x-0x"),
+ wxOK | wxCANCEL | wxCENTRE,
+ wxDefaultPosition);
- }
+ if (dialog.ShowModal() == wxID_OK) {
+
+ }
}
@@ -1421,27 +1479,29 @@ BEGIN_EVENT_TABLE(OPJCanvas, wxScrolledWindow)
END_EVENT_TABLE()
// Define a constructor for my canvas
-OPJCanvas::OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos, const wxSize& size)
- : wxScrolledWindow(parent, wxID_ANY, pos, size,
- wxSUNKEN_BORDER | wxNO_FULL_REPAINT_ON_RESIZE)
+OPJCanvas::OPJCanvas(wxFileName fname, wxWindow *parent, const wxPoint& pos,
+ const wxSize& size)
+ : wxScrolledWindow(parent, wxID_ANY, pos, size,
+ wxSUNKEN_BORDER | wxNO_FULL_REPAINT_ON_RESIZE)
{
SetBackgroundColour(OPJ_CANVAS_COLOUR);
- m_fname = fname;
- m_childframe = (OPJChildFrame *) parent;
- // 100% zoom
- m_zooml = 100;
+ m_fname = fname;
+ m_childframe = (OPJChildFrame *) parent;
+ // 100% zoom
+ m_zooml = 100;
OPJDecoThread *dthread = CreateDecoThread();
- if (dthread->Run() != wxTHREAD_NO_ERROR)
+ if (dthread->Run() != wxTHREAD_NO_ERROR) {
wxLogMessage(wxT("Can't start deco thread!"));
- else
- wxLogMessage(wxT("New deco thread started."));
+ } else {
+ wxLogMessage(wxT("New deco thread started."));
+ }
- // 100% zoom
- //m_zooml = 100;
+ // 100% zoom
+ //m_zooml = 100;
}
@@ -1449,8 +1509,9 @@ OPJDecoThread *OPJCanvas::CreateDecoThread(void)
{
OPJDecoThread *dthread = new OPJDecoThread(this);
- if (dthread->Create() != wxTHREAD_NO_ERROR)
- wxLogError(wxT("Can't create deco thread!"));
+ if (dthread->Create() != wxTHREAD_NO_ERROR) {
+ wxLogError(wxT("Can't create deco thread!"));
+ }
wxCriticalSectionLocker enter(wxGetApp().m_deco_critsect);
wxGetApp().m_deco_threads.Add(dthread);
@@ -1462,8 +1523,9 @@ OPJEncoThread *OPJCanvas::CreateEncoThread(void)
{
OPJEncoThread *ethread = new OPJEncoThread(this);
- if (ethread->Create() != wxTHREAD_NO_ERROR)
- wxLogError(wxT("Can't create enco thread!"));
+ if (ethread->Create() != wxTHREAD_NO_ERROR) {
+ wxLogError(wxT("Can't create enco thread!"));
+ }
wxCriticalSectionLocker enter(wxGetApp().m_enco_critsect);
wxGetApp().m_enco_threads.Add(ethread);
@@ -1475,27 +1537,31 @@ OPJEncoThread *OPJCanvas::CreateEncoThread(void)
// Define the repainting behaviour
void OPJCanvas::OnDraw(wxDC& dc)
{
- if (m_image.Ok()) {
- dc.DrawBitmap(m_image, OPJ_CANVAS_BORDER, OPJ_CANVAS_BORDER);
-
- if (activeoverlay) {
- dc.SetPen(*wxRED_PEN);
- dc.SetBrush(*wxTRANSPARENT_BRUSH);
- //int tw, th;
- dc.DrawRectangle(OPJ_CANVAS_BORDER, OPJ_CANVAS_BORDER,
- (unsigned long int) (0.5 + (double) m_zooml * (double) m_childframe->m_twidth / 100.0),
- (unsigned long int) (0.5 + (double) m_zooml * (double) m_childframe->m_theight / 100.0));
- }
-
- } else {
- dc.SetFont(*wxSWISS_FONT);
- dc.SetPen(*wxBLACK_PEN);
+ if (m_image.Ok()) {
+ dc.DrawBitmap(m_image, OPJ_CANVAS_BORDER, OPJ_CANVAS_BORDER);
+
+ if (activeoverlay) {
+ dc.SetPen(*wxRED_PEN);
+ dc.SetBrush(*wxTRANSPARENT_BRUSH);
+ //int tw, th;
+ dc.DrawRectangle(OPJ_CANVAS_BORDER, OPJ_CANVAS_BORDER,
+ (unsigned long int)(0.5 + (double) m_zooml * (double) m_childframe->m_twidth /
+ 100.0),
+ (unsigned long int)(0.5 + (double) m_zooml * (double) m_childframe->m_theight /
+ 100.0));
+ }
+
+ } else {
+ dc.SetFont(*wxSWISS_FONT);
+ dc.SetPen(*wxBLACK_PEN);
#ifdef __WXGTK__
- dc.DrawText(_T("Decoding image, please wait... (press \"Zoom to Fit\" to show the image)"), 40, 50);
+ dc.DrawText(
+ _T("Decoding image, please wait... (press \"Zoom to Fit\" to show the image)"),
+ 40, 50);
#else
- dc.DrawText(_T("Decoding image, please wait..."), 40, 50);
+ dc.DrawText(_T("Decoding image, please wait..."), 40, 50);
#endif
- }
+ }
}
// This implements a tiny doodling program! Drag the mouse using
@@ -1503,17 +1569,17 @@ void OPJCanvas::OnDraw(wxDC& dc)
void OPJCanvas::OnEvent(wxMouseEvent& event)
{
#if USE_PENCIL_ON_CANVAS
- wxClientDC dc(this);
- PrepareDC(dc);
+ wxClientDC dc(this);
+ PrepareDC(dc);
- wxPoint pt(event.GetLogicalPosition(dc));
+ wxPoint pt(event.GetLogicalPosition(dc));
- if ((xpos > -1) && (ypos > -1) && event.Dragging()) {
- dc.SetPen(*wxRED_PEN);
- dc.DrawLine(xpos, ypos, pt.x, pt.y);
- }
- xpos = pt.x;
- ypos = pt.y;
+ if ((xpos > -1) && (ypos > -1) && event.Dragging()) {
+ dc.SetPen(*wxRED_PEN);
+ dc.DrawLine(xpos, ypos, pt.x, pt.y);
+ }
+ xpos = pt.x;
+ ypos = pt.y;
#endif
}
@@ -1530,8 +1596,7 @@ void OPJCanvas::OnThreadSignal(wxCommandEvent& event)
wxLogMessage(event.GetString());
#else
int n = event.GetInt();
- if ( n == -1 )
- {
+ if (n == -1) {
m_dlgProgress->Destroy();
m_dlgProgress = (wxProgressDialog *)NULL;
@@ -1539,11 +1604,8 @@ void OPJCanvas::OnThreadSignal(wxCommandEvent& event)
// we may need to wake up the main event loop for the dialog to be
// really closed
wxWakeUpIdle();
- }
- else
- {
- if ( !m_dlgProgress->Update(n) )
- {
+ } else {
+ if (!m_dlgProgress->Update(n)) {
wxCriticalSectionLocker lock(m_critsectWork);
m_cancelled = true;
@@ -1558,101 +1620,106 @@ void OPJCanvas::OnThreadSignal(wxCommandEvent& event)
// duplicate event handlers here.
BEGIN_EVENT_TABLE(OPJChildFrame, wxMDIChildFrame)
- /*EVT_MENU(SASHTEST_CHILD_QUIT, OPJChildFrame::OnQuit)*/
- EVT_CLOSE(OPJChildFrame::OnClose)
- EVT_SET_FOCUS(OPJChildFrame::OnGotFocus)
- EVT_KILL_FOCUS(OPJChildFrame::OnLostFocus)
+ /*EVT_MENU(SASHTEST_CHILD_QUIT, OPJChildFrame::OnQuit)*/
+ EVT_CLOSE(OPJChildFrame::OnClose)
+ EVT_SET_FOCUS(OPJChildFrame::OnGotFocus)
+ EVT_KILL_FOCUS(OPJChildFrame::OnLostFocus)
END_EVENT_TABLE()
-OPJChildFrame::OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber, const wxString& title, const wxPoint& pos, const wxSize& size,
-const long style):
- wxMDIChildFrame(parent, wxID_ANY, title, pos, size, style)
+OPJChildFrame::OPJChildFrame(OPJFrame *parent, wxFileName fname, int winnumber,
+ const wxString& title, const wxPoint& pos, const wxSize& size,
+ const long style):
+ wxMDIChildFrame(parent, wxID_ANY, title, pos, size, style)
{
- m_frame = (OPJFrame *) parent;
- m_canvas = NULL;
- //my_children.Append(this);
- m_fname = fname;
- m_winnumber = winnumber;
- SetTitle(wxString::Format(_T("%d: "), m_winnumber) + m_fname.GetFullName());
-
- // Give it an icon (this is ignored in MDI mode: uses resources)
+ m_frame = (OPJFrame *) parent;
+ m_canvas = NULL;
+ //my_children.Append(this);
+ m_fname = fname;
+ m_winnumber = winnumber;
+ SetTitle(wxString::Format(_T("%d: "), m_winnumber) + m_fname.GetFullName());
+
+ // Give it an icon (this is ignored in MDI mode: uses resources)
#ifdef __WXMSW__
- SetIcon(wxIcon(wxT("OPJChild16")));
+ SetIcon(wxIcon(wxT("OPJChild16")));
#endif
- // Give it a status line
- /*CreateStatusBar();*/
+ // Give it a status line
+ /*CreateStatusBar();*/
- int width, height;
- GetClientSize(&width, &height);
+ int width, height;
+ GetClientSize(&width, &height);
- OPJCanvas *canvas = new OPJCanvas(fname, this, wxPoint(0, 0), wxSize(width, height));
+ OPJCanvas *canvas = new OPJCanvas(fname, this, wxPoint(0, 0), wxSize(width,
+ height));
#if USE_PENCIL_ON_CANVAS
- canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
+ canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
#endif
- m_canvas = canvas;
+ m_canvas = canvas;
- // Give it scrollbars
- canvas->SetScrollbars(20, 20, 5, 5);
+ // Give it scrollbars
+ canvas->SetScrollbars(20, 20, 5, 5);
- Show(true);
- Maximize(true);
+ Show(true);
+ Maximize(true);
- /*wxLogError(wxString::Format(wxT("Created tree %d (0x%x)"), m_winnumber, m_frame->m_treehash[m_winnumber]));*/
+ /*wxLogError(wxString::Format(wxT("Created tree %d (0x%x)"), m_winnumber, m_frame->m_treehash[m_winnumber]));*/
}
OPJChildFrame::~OPJChildFrame(void)
{
- //my_children.DeleteObject(this);
+ //my_children.DeleteObject(this);
}
void OPJChildFrame::OnClose(wxCloseEvent& event)
{
- for (unsigned int p = 0; p < m_frame->m_bookCtrl->GetPageCount(); p++) {
- if (m_frame->m_bookCtrl->GetPageText(p) == wxString::Format(wxT("%u"), m_winnumber)) {
- m_frame->m_bookCtrl->DeletePage(p);
- break;
- }
- }
- Destroy();
-
- wxLogMessage(wxT("Closed: %d"), m_winnumber);
+ for (unsigned int p = 0; p < m_frame->m_bookCtrl->GetPageCount(); p++) {
+ if (m_frame->m_bookCtrl->GetPageText(p) == wxString::Format(wxT("%u"),
+ m_winnumber)) {
+ m_frame->m_bookCtrl->DeletePage(p);
+ break;
+ }
+ }
+ Destroy();
+
+ wxLogMessage(wxT("Closed: %d"), m_winnumber);
}
void OPJChildFrame::OnActivate(wxActivateEvent& event)
{
- /*if (event.GetActive() && m_canvas)
- m_canvas->SetFocus();*/
+ /*if (event.GetActive() && m_canvas)
+ m_canvas->SetFocus();*/
}
void OPJChildFrame::OnGotFocus(wxFocusEvent& event)
{
- // we need to check if the notebook is being destroyed or not
- if (!m_frame->m_bookCtrl)
- return;
+ // we need to check if the notebook is being destroyed or not
+ if (!m_frame->m_bookCtrl) {
+ return;
+ }
- for (unsigned int p = 0; p < m_frame->m_bookCtrl->GetPageCount(); p++) {
+ for (unsigned int p = 0; p < m_frame->m_bookCtrl->GetPageCount(); p++) {
- if (m_frame->m_bookCtrl->GetPageText(p) == wxString::Format(wxT("%u"), m_winnumber)) {
- m_frame->m_bookCtrl->ChangeSelection(p);
- break;
- }
+ if (m_frame->m_bookCtrl->GetPageText(p) == wxString::Format(wxT("%u"),
+ m_winnumber)) {
+ m_frame->m_bookCtrl->ChangeSelection(p);
+ break;
+ }
- }
+ }
- //wxLogMessage(wxT("Got focus: %d (%x)"), m_winnumber, event.GetWindow());
+ //wxLogMessage(wxT("Got focus: %d (%x)"), m_winnumber, event.GetWindow());
}
void OPJChildFrame::OnLostFocus(wxFocusEvent& event)
{
- //wxLogMessage(wxT("Lost focus: %d (%x)"), m_winnumber, event.GetWindow());
+ //wxLogMessage(wxT("Lost focus: %d (%x)"), m_winnumber, event.GetWindow());
}
////////////////////////////////
-// drag and drop
+// drag and drop
////////////////////////////////
bool OPJDnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames)
@@ -1664,7 +1731,7 @@ bool OPJDnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames)
str << filenames[n] << wxT("\n");
}
wxLogMessage(str);*/
- m_pOwner->OpenFiles(filenames, filenames);
+ m_pOwner->OpenFiles(filenames, filenames);
return true;
}
diff --git a/src/lib/openjp2/bench_dwt.c b/src/lib/openjp2/bench_dwt.c
index 1124cd61..4f2ea9fb 100644
--- a/src/lib/openjp2/bench_dwt.c
+++ b/src/lib/openjp2/bench_dwt.c
@@ -207,7 +207,7 @@ int main(int argc, char** argv)
}
if (irreversible && check) {
- /* Due to irreversible inverse DWT not being symetric of forward */
+ /* Due to irreversible inverse DWT not being symmetric of forward */
/* See BUG_WEIRD_TWO_INVK in dwt.c */
printf("-I and -check aren't compatible\n");
exit(1);
diff --git a/src/lib/openjp2/cio.h b/src/lib/openjp2/cio.h
index 6996a9a0..7caee30a 100644
--- a/src/lib/openjp2/cio.h
+++ b/src/lib/openjp2/cio.h
@@ -118,7 +118,7 @@ typedef struct opj_stream_private {
opj_stream_seek_fn m_seek_fn;
/**
- * Actual data stored into the stream if readed from. Data is read by chunk of fixed size.
+ * Actual data stored into the stream if read from. Data is read by chunk of fixed size.
* you should never access this data directly.
*/
OPJ_BYTE * m_stored_data;
diff --git a/src/lib/openjp2/dwt.c b/src/lib/openjp2/dwt.c
index 824a9fc4..abc500ec 100644
--- a/src/lib/openjp2/dwt.c
+++ b/src/lib/openjp2/dwt.c
@@ -513,7 +513,7 @@ static void opj_idwt53_h(const opj_dwt_t *dwt,
#if (defined(__SSE2__) || defined(__AVX2__)) && !defined(STANDARD_SLOW_VERSION)
-/* Conveniency macros to improve the readabilty of the formulas */
+/* Conveniency macros to improve the readability of the formulas */
#if __AVX2__
#define VREG __m256i
#define LOAD_CST(x) _mm256_set1_epi32(x)
@@ -801,7 +801,8 @@ static void opj_idwt3_v_cas0(OPJ_INT32* tmp,
opj_int_add_no_overflow(opj_int_add_no_overflow(d1c, d1n), 2) >> 2);
tmp[i ] = s0c;
- tmp[i + 1] = d1c + ((s0c + s0n) >> 1);
+ tmp[i + 1] = opj_int_add_no_overflow(d1c, opj_int_add_no_overflow(s0c,
+ s0n) >> 1);
}
tmp[i] = s0n;
diff --git a/src/lib/openjp2/ht_dec.c b/src/lib/openjp2/ht_dec.c
index 5160ee73..1eb4d525 100644
--- a/src/lib/openjp2/ht_dec.c
+++ b/src/lib/openjp2/ht_dec.c
@@ -136,7 +136,7 @@ static INLINE OPJ_UINT32 read_le_uint32(const void* dataIn)
* Each run represents the number of zero events before a one event.
*/
typedef struct dec_mel {
- // data decoding machinary
+ // data decoding machinery
OPJ_UINT8* data; //!<the address of data (or bitstream)
OPJ_UINT64 tmp; //!<temporary buffer for read data
int bits; //!<number of bits stored in tmp
@@ -600,7 +600,7 @@ void rev_read_mrp(rev_struct_t *mrp)
* an architecture that read size must be compatible with the
* alignment of the read address
*
- * There is another simiar subroutine rev_init. This subroutine does
+ * There is another similar subroutine rev_init. This subroutine does
* NOT skip the first 12 bits, and starts with unstuff set to true.
*
* @param [in] mrp is a pointer to rev_struct structure
@@ -1566,7 +1566,7 @@ OPJ_BOOL opj_t1_ht_decode_cblk(opj_t1_t *t1,
}
//first quad, starting at first sample in quad and moving on
- if (qinf[0] & 0x10) { //is it signifcant? (sigma_n)
+ if (qinf[0] & 0x10) { //is it significant? (sigma_n)
OPJ_UINT32 val;
ms_val = frwd_fetch(&magsgn); //get 32 bits of magsgn data
@@ -1816,14 +1816,14 @@ OPJ_BOOL opj_t1_ht_decode_cblk(opj_t1_t *t1,
if ((qinf[0] & 0xF0) & ((qinf[0] & 0xF0) - 1)) { // is \gamma_q 1?
OPJ_UINT32 E = (ls0 & 0x7Fu);
E = E > (lsp[1] & 0x7Fu) ? E : (lsp[1] & 0x7Fu); //max(E, E^NE, E^NF)
- //since U_q alread has u_q + 1, we subtract 2 instead of 1
+ //since U_q already has u_q + 1, we subtract 2 instead of 1
U_q[0] += E > 2 ? E - 2 : 0;
}
if ((qinf[1] & 0xF0) & ((qinf[1] & 0xF0) - 1)) { //is \gamma_q 1?
OPJ_UINT32 E = (lsp[1] & 0x7Fu);
E = E > (lsp[2] & 0x7Fu) ? E : (lsp[2] & 0x7Fu); //max(E, E^NE, E^NF)
- //since U_q alread has u_q + 1, we subtract 2 instead of 1
+ //since U_q already has u_q + 1, we subtract 2 instead of 1
U_q[1] += E > 2 ? E - 2 : 0;
}
@@ -2153,13 +2153,13 @@ OPJ_BOOL opj_t1_ht_decode_cblk(opj_t1_t *t1,
nxt_sig = y & 0x4 ? sigma1 : sigma2; //future samples
nxt_mbr = y & 0x4 ? mbr1 : mbr2; //future samples
val = 3u << (p - 2); // sample values for newly discovered
- // signficant samples including the bin center
+ // significant samples including the bin center
for (i = 0; i < width;
i += 8, cur_sig++, cur_mbr++, nxt_sig++, nxt_mbr++) {
OPJ_UINT32 ux, tx;
OPJ_UINT32 mbr = *cur_mbr;
OPJ_UINT32 new_sig = 0;
- if (mbr) { //are there any samples that migt be signficant
+ if (mbr) { //are there any samples that might be significant
OPJ_INT32 n;
for (n = 0; n < 8; n += 4) {
OPJ_UINT32 col_mask;
@@ -2187,7 +2187,7 @@ OPJ_BOOL opj_t1_ht_decode_cblk(opj_t1_t *t1,
continue;
}
- //scan mbr to find a new signficant sample
+ //scan mbr to find a new significant sample
sample_mask = 0x11111111u & col_mask; // LSB
if (mbr & sample_mask) {
assert(dp[0] == 0); // the sample must have been 0
@@ -2196,7 +2196,7 @@ OPJ_BOOL opj_t1_ht_decode_cblk(opj_t1_t *t1,
OPJ_UINT32 t;
new_sig |= sample_mask; // new significant samples
t = 0x32u << (j * 4);// propagation to neighbors
- mbr |= t & inv_sig; //remove already signifcant samples
+ mbr |= t & inv_sig; //remove already significant samples
}
cwd >>= 1;
++cnt; //consume bit and increment number of
@@ -2254,7 +2254,7 @@ OPJ_BOOL opj_t1_ht_decode_cblk(opj_t1_t *t1,
for (j = n; j < end; ++j, ++dp, col_mask <<= 4) {
OPJ_UINT32 sample_mask;
- if ((col_mask & new_sig) == 0) { //if non is signficant
+ if ((col_mask & new_sig) == 0) { //if non is significant
continue;
}
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c
index 3bfe8020..bcce3165 100644
--- a/src/lib/openjp2/j2k.c
+++ b/src/lib/openjp2/j2k.c
@@ -50,7 +50,7 @@
/*@{*/
/**
- * Sets up the procedures to do on reading header. Developpers wanting to extend the library can add their own reading procedures.
+ * Sets up the procedures to do on reading header. Developers wanting to extend the library can add their own reading procedures.
*/
static OPJ_BOOL opj_j2k_setup_header_reading(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager);
@@ -89,22 +89,22 @@ static OPJ_BOOL opj_j2k_decoding_validation(opj_j2k_t * p_j2k,
opj_event_mgr_t * p_manager);
/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
+ * Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
+ * are valid. Developers wanting to extend the library can add their own validation procedures.
*/
static OPJ_BOOL opj_j2k_setup_encoding_validation(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager);
/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
+ * Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
+ * are valid. Developers wanting to extend the library can add their own validation procedures.
*/
static OPJ_BOOL opj_j2k_setup_decoding_validation(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager);
/**
- * Sets up the validation ,i.e. adds the procedures to lauch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
+ * Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
+ * are valid. Developers wanting to extend the library can add their own validation procedures.
*/
static OPJ_BOOL opj_j2k_setup_end_compress(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager);
@@ -147,7 +147,7 @@ static OPJ_BOOL opj_j2k_create_tcd(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager);
/**
- * Excutes the given procedures on the given codec.
+ * Executes the given procedures on the given codec.
*
* @param p_procedure_list the list of procedures to execute
* @param p_j2k the jpeg2000 codec to execute the procedures on.
@@ -1430,7 +1430,7 @@ static const opj_dec_memory_marker_handler_t j2k_memory_marker_handler_tab [] =
{J2K_MS_MCC, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mcc},
{J2K_MS_MCO, J2K_STATE_MH | J2K_STATE_TPH, opj_j2k_read_mco},
#ifdef USE_JPWL
-#ifdef TODO_MS /* remove these functions which are not commpatible with the v2 API */
+#ifdef TODO_MS /* remove these functions which are not compatible with the v2 API */
{J2K_MS_EPC, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epc},
{J2K_MS_EPB, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epb},
{J2K_MS_ESD, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_esd},
@@ -1677,7 +1677,7 @@ static OPJ_BOOL opj_j2k_check_poc_val(const opj_poc_t *p_pocs,
assert(p_nb_pocs > 0);
- packet_array = (OPJ_UINT32*) opj_calloc(step_l * p_num_layers,
+ packet_array = (OPJ_UINT32*) opj_calloc((size_t)step_l * p_num_layers,
sizeof(OPJ_UINT32));
if (packet_array == 00) {
opj_event_msg(p_manager, EVT_ERROR,
@@ -1790,7 +1790,7 @@ static OPJ_UINT32 opj_j2k_get_num_tp(opj_cp_t *cp, OPJ_UINT32 pino,
tpnum *= l_current_poc->layE;
break;
}
- /* whould we split here ? */
+ /* would we split here ? */
if (cp->m_specific_param.m_enc.m_tp_flag == prog[i]) {
cp->m_specific_param.m_enc.m_tp_pos = i;
break;
@@ -4964,9 +4964,14 @@ static OPJ_BOOL opj_j2k_read_sod(opj_j2k_t *p_j2k,
/* Check enough bytes left in stream before allocation */
if ((OPJ_OFF_T)p_j2k->m_specific_param.m_decoder.m_sot_length >
opj_stream_get_number_byte_left(p_stream)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "Tile part length size inconsistent with stream length\n");
- return OPJ_FALSE;
+ if (p_j2k->m_cp.strict) {
+ opj_event_msg(p_manager, EVT_ERROR,
+ "Tile part length size inconsistent with stream length\n");
+ return OPJ_FALSE;
+ } else {
+ opj_event_msg(p_manager, EVT_WARNING,
+ "Tile part length size inconsistent with stream length\n");
+ }
}
if (p_j2k->m_specific_param.m_decoder.m_sot_length >
UINT_MAX - OPJ_COMMON_CBLK_DATA_EXTRA) {
@@ -6695,6 +6700,13 @@ void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters)
}
}
+void opj_j2k_decoder_set_strict_mode(opj_j2k_t *j2k, OPJ_BOOL strict)
+{
+ if (j2k) {
+ j2k->m_cp.strict = strict;
+ }
+}
+
OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads)
{
/* Currently we pass the thread-pool to the tcd, so we cannot re-set it */
@@ -7654,6 +7666,8 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
return OPJ_FALSE;
}
+ p_j2k->m_specific_param.m_encoder.m_nb_comps = image->numcomps;
+
/* keep a link to cp so that we can destroy it later in j2k_destroy_compress */
cp = &(p_j2k->m_cp);
@@ -7953,6 +7967,13 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
(OPJ_INT32)cp->tdx);
cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp->ty0),
(OPJ_INT32)cp->tdy);
+ /* Check that the number of tiles is valid */
+ if (cp->tw > 65535 / cp->th) {
+ opj_event_msg(p_manager, EVT_ERROR,
+ "Invalid number of tiles : %u x %u (maximum fixed by jpeg2000 norm is 65535 tiles)\n",
+ cp->tw, cp->th);
+ return OPJ_FALSE;
+ }
} else {
cp->tdx = image->x1 - cp->tx0;
cp->tdy = image->y1 - cp->ty0;
@@ -8019,7 +8040,7 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
}
#endif /* USE_JPWL */
- /* initialize the mutiple tiles */
+ /* initialize the multiple tiles */
/* ---------------------------- */
cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t));
if (!cp->tcps) {
@@ -8829,7 +8850,7 @@ static OPJ_BOOL opj_j2k_read_header_procedure(opj_j2k_t *p_j2k,
if (l_marker_handler->id == J2K_MS_UNK) {
if (! opj_j2k_read_unk(p_j2k, p_stream, &l_current_marker, p_manager)) {
opj_event_msg(p_manager, EVT_ERROR,
- "Unknow marker have been detected and generated error.\n");
+ "Unknown marker has been detected and generated error.\n");
return OPJ_FALSE;
}
@@ -9834,7 +9855,7 @@ OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t * p_j2k,
/* When using the opj_read_tile_header / opj_decode_tile_data API */
/* such as in test_tile_decoder, m_output_image is NULL, so fall back */
/* to the full image dimension. This is a bit surprising that */
- /* opj_set_decode_area() is only used to determinte intersecting tiles, */
+ /* opj_set_decode_area() is only used to determine intersecting tiles, */
/* but full tile decoding is done */
l_image_for_bounds = p_j2k->m_output_image ? p_j2k->m_output_image :
p_j2k->m_private_image;
@@ -9880,10 +9901,10 @@ OPJ_BOOL opj_j2k_decode_tile(opj_j2k_t * p_j2k,
if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_EOC) {
if (opj_stream_read_data(p_stream, l_data, 2, p_manager) != 2) {
- opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
- return OPJ_FALSE;
+ opj_event_msg(p_manager, p_j2k->m_cp.strict ? EVT_ERROR : EVT_WARNING,
+ "Stream too short\n");
+ return p_j2k->m_cp.strict ? OPJ_FALSE : OPJ_TRUE;
}
-
opj_read_bytes(l_data, &l_current_marker, 2);
if (l_current_marker == J2K_MS_EOC) {
@@ -10400,6 +10421,9 @@ opj_j2k_t* opj_j2k_create_decompress(void)
/* per component is allowed */
l_j2k->m_cp.allow_different_bit_depth_sign = 1;
+ /* Default to using strict mode. */
+ l_j2k->m_cp.strict = OPJ_TRUE;
+
#ifdef OPJ_DISABLE_TPSOT_FIX
l_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction_checked = 1;
#endif
@@ -11725,7 +11749,7 @@ static OPJ_BOOL opj_j2k_decode_tiles(opj_j2k_t *p_j2k,
}
/**
- * Sets up the procedures to do on decoding data. Developpers wanting to extend the library can add their own reading procedures.
+ * Sets up the procedures to do on decoding data. Developers wanting to extend the library can add their own reading procedures.
*/
static OPJ_BOOL opj_j2k_setup_decoding(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager)
@@ -11857,7 +11881,7 @@ static OPJ_BOOL opj_j2k_decode_one_tile(opj_j2k_t *p_j2k,
}
/**
- * Sets up the procedures to do on decoding one tile. Developpers wanting to extend the library can add their own reading procedures.
+ * Sets up the procedures to do on decoding one tile. Developers wanting to extend the library can add their own reading procedures.
*/
static OPJ_BOOL opj_j2k_setup_decoding_tile(opj_j2k_t *p_j2k,
opj_event_mgr_t * p_manager)
@@ -12083,7 +12107,7 @@ OPJ_BOOL opj_j2k_get_tile(opj_j2k_t *p_j2k,
opj_image_destroy(p_j2k->m_output_image);
}
- /* Create the ouput image from the information previously computed*/
+ /* Create the output image from the information previously computed*/
p_j2k->m_output_image = opj_image_create0();
if (!(p_j2k->m_output_image)) {
return OPJ_FALSE;
@@ -12173,6 +12197,25 @@ OPJ_BOOL opj_j2k_encoder_set_extra_options(
"Invalid value for option: %s.\n", *p_option_iter);
return OPJ_FALSE;
}
+ } else if (strncmp(*p_option_iter, "GUARD_BITS=", strlen("GUARD_BITS=")) == 0) {
+ OPJ_UINT32 tileno;
+ opj_cp_t *cp = cp = &(p_j2k->m_cp);
+
+ int numgbits = atoi(*p_option_iter + strlen("GUARD_BITS="));
+ if (numgbits < 0 || numgbits > 7) {
+ opj_event_msg(p_manager, EVT_ERROR,
+ "Invalid value for option: %s. Should be in [0,7]\n", *p_option_iter);
+ return OPJ_FALSE;
+ }
+
+ for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
+ OPJ_UINT32 i;
+ opj_tcp_t *tcp = &cp->tcps[tileno];
+ for (i = 0; i < p_j2k->m_specific_param.m_encoder.m_nb_comps; i++) {
+ opj_tccp_t *tccp = &tcp->tccps[i];
+ tccp->numgbits = (OPJ_UINT32)numgbits;
+ }
+ }
} else {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid option: %s.\n", *p_option_iter);
diff --git a/src/lib/openjp2/j2k.h b/src/lib/openjp2/j2k.h
index 2b08e840..04fba645 100644
--- a/src/lib/openjp2/j2k.h
+++ b/src/lib/openjp2/j2k.h
@@ -402,6 +402,8 @@ typedef struct opj_cp {
}
m_specific_param;
+ /** OPJ_TRUE if entire bit stream must be decoded, OPJ_FALSE if partial bitstream decoding allowed */
+ OPJ_BOOL strict;
/* UniPG>> */
#ifdef USE_JPWL
@@ -550,6 +552,9 @@ typedef struct opj_j2k_enc {
/* reserved bytes in m_encoded_tile_size for PLT markers */
OPJ_UINT32 m_reserved_bytes_for_PLT;
+ /** Number of components */
+ OPJ_UINT32 m_nb_comps;
+
} opj_j2k_enc_t;
@@ -622,6 +627,8 @@ Decoding parameters are returned in j2k->cp.
*/
void opj_j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters);
+void opj_j2k_decoder_set_strict_mode(opj_j2k_t *j2k, OPJ_BOOL strict);
+
OPJ_BOOL opj_j2k_set_threads(opj_j2k_t *j2k, OPJ_UINT32 num_threads);
/**
diff --git a/src/lib/openjp2/jp2.c b/src/lib/openjp2/jp2.c
index 7c065ba7..17572195 100644
--- a/src/lib/openjp2/jp2.c
+++ b/src/lib/openjp2/jp2.c
@@ -331,14 +331,14 @@ static OPJ_BOOL opj_jp2_read_colr(opj_jp2_t *jp2,
/**
* Sets up the procedures to do on writing header after the codestream.
- * Developpers wanting to extend the library can add their own writing procedures.
+ * Developers wanting to extend the library can add their own writing procedures.
*/
static OPJ_BOOL opj_jp2_setup_end_header_writing(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
/**
* Sets up the procedures to do on reading header after the codestream.
- * Developpers wanting to extend the library can add their own writing procedures.
+ * Developers wanting to extend the library can add their own writing procedures.
*/
static OPJ_BOOL opj_jp2_setup_end_header_reading(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
@@ -388,13 +388,13 @@ static OPJ_BOOL opj_jp2_read_boxhdr(opj_jp2_box_t *box,
/**
* Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
+ * are valid. Developers wanting to extend the library can add their own validation procedures.
*/
static OPJ_BOOL opj_jp2_setup_encoding_validation(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
/**
- * Sets up the procedures to do on writing header. Developpers wanting to extend the library can add their own writing procedures.
+ * Sets up the procedures to do on writing header. Developers wanting to extend the library can add their own writing procedures.
*/
static OPJ_BOOL opj_jp2_setup_header_writing(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
@@ -457,14 +457,14 @@ static OPJ_BOOL opj_jp2_read_boxhdr_char(opj_jp2_box_t *box,
/**
* Sets up the validation ,i.e. adds the procedures to launch to make sure the codec parameters
- * are valid. Developpers wanting to extend the library can add their own validation procedures.
+ * are valid. Developers wanting to extend the library can add their own validation procedures.
*/
static OPJ_BOOL opj_jp2_setup_decoding_validation(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
/**
* Sets up the procedures to do on reading header.
- * Developpers wanting to extend the library can add their own writing procedures.
+ * Developers wanting to extend the library can add their own writing procedures.
*/
static OPJ_BOOL opj_jp2_setup_header_reading(opj_jp2_t *jp2,
opj_event_mgr_t * p_manager);
@@ -1136,9 +1136,9 @@ static OPJ_BOOL opj_jp2_apply_pclr(opj_image_t *image,
}
max = image->numcomps;
- for (i = 0; i < max; ++i) {
- if (old_comps[i].data) {
- opj_image_data_free(old_comps[i].data);
+ for (j = 0; j < max; ++j) {
+ if (old_comps[j].data) {
+ opj_image_data_free(old_comps[j].data);
}
}
@@ -1901,6 +1901,11 @@ void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters)
OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG;
}
+void opj_jp2_decoder_set_strict_mode(opj_jp2_t *jp2, OPJ_BOOL strict)
+{
+ opj_j2k_decoder_set_strict_mode(jp2->j2k, strict);
+}
+
OPJ_BOOL opj_jp2_set_threads(opj_jp2_t *jp2, OPJ_UINT32 num_threads)
{
return opj_j2k_set_threads(jp2->j2k, num_threads);
diff --git a/src/lib/openjp2/jp2.h b/src/lib/openjp2/jp2.h
index 9e7fa566..173f2511 100644
--- a/src/lib/openjp2/jp2.h
+++ b/src/lib/openjp2/jp2.h
@@ -235,6 +235,15 @@ Decoding parameters are returned in jp2->j2k->cp.
*/
void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters);
+/**
+Set the strict mode parameter. When strict mode is enabled, the entire
+bitstream must be decoded or an error is returned. When it is disabled,
+the decoder will decode partial bitstreams.
+@param jp2 JP2 decompressor handle
+@param strict OPJ_TRUE for strict mode
+*/
+void opj_jp2_decoder_set_strict_mode(opj_jp2_t *jp2, OPJ_BOOL strict);
+
/** Allocates worker threads for the compressor/decompressor.
*
* @param jp2 JP2 decompressor handle
diff --git a/src/lib/openjp2/mct.c b/src/lib/openjp2/mct.c
index 88c8f409..78058128 100644
--- a/src/lib/openjp2/mct.c
+++ b/src/lib/openjp2/mct.c
@@ -457,7 +457,7 @@ void opj_calculate_norms(OPJ_FLOAT64 * pNorms,
for (j = 0; j < pNbComps; ++j) {
lCurrentValue = lMatrix[lIndex];
lIndex += pNbComps;
- lNorms[i] += lCurrentValue * lCurrentValue;
+ lNorms[i] += (OPJ_FLOAT64) lCurrentValue * lCurrentValue;
}
lNorms[i] = sqrt(lNorms[i]);
}
diff --git a/src/lib/openjp2/openjpeg.c b/src/lib/openjp2/openjpeg.c
index 0c5f2d5f..29d3ee52 100644
--- a/src/lib/openjp2/openjpeg.c
+++ b/src/lib/openjp2/openjpeg.c
@@ -219,6 +219,10 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
l_codec->m_codec_data.m_decompression.opj_setup_decoder =
(void (*)(void *, opj_dparameters_t *)) opj_j2k_setup_decoder;
+ l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode =
+ (void (*)(void *, OPJ_BOOL)) opj_j2k_decoder_set_strict_mode;
+
+
l_codec->m_codec_data.m_decompression.opj_read_tile_header =
(OPJ_BOOL(*)(void *,
OPJ_UINT32*,
@@ -326,6 +330,9 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
l_codec->m_codec_data.m_decompression.opj_setup_decoder =
(void (*)(void *, opj_dparameters_t *)) opj_jp2_setup_decoder;
+ l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode =
+ (void (*)(void *, OPJ_BOOL)) opj_jp2_decoder_set_strict_mode;
+
l_codec->m_codec_data.m_decompression.opj_set_decode_area =
(OPJ_BOOL(*)(void *,
opj_image_t*,
@@ -426,6 +433,26 @@ OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
return OPJ_FALSE;
}
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec,
+ OPJ_BOOL strict)
+{
+ if (p_codec) {
+ opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec;
+
+ if (! l_codec->is_decompressor) {
+ opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
+ "Codec provided to the opj_decoder_set_strict_mode function is not a decompressor handler.\n");
+ return OPJ_FALSE;
+ }
+
+ l_codec->m_codec_data.m_decompression.opj_decoder_set_strict_mode(
+ l_codec->m_codec,
+ strict);
+ return OPJ_TRUE;
+ }
+ return OPJ_FALSE;
+}
+
OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
opj_codec_t *p_codec,
opj_image_t **p_image)
diff --git a/src/lib/openjp2/openjpeg.h b/src/lib/openjp2/openjpeg.h
index 68e4e7e1..ebce53db 100644
--- a/src/lib/openjp2/openjpeg.h
+++ b/src/lib/openjp2/openjpeg.h
@@ -455,9 +455,9 @@ typedef struct opj_cparameters {
char infile[OPJ_PATH_LEN];
/** output file name */
char outfile[OPJ_PATH_LEN];
- /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
+ /** DEPRECATED. Index generation is now handled with the opj_encode_with_info() function. Set to NULL */
int index_on;
- /** DEPRECATED. Index generation is now handeld with the opj_encode_with_info() function. Set to NULL */
+ /** DEPRECATED. Index generation is now handled with the opj_encode_with_info() function. Set to NULL */
char index[OPJ_PATH_LEN];
/** subimage encoding: origin image offset in x direction */
int image_offset_x0;
@@ -1346,6 +1346,20 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec,
opj_dparameters_t *parameters);
/**
+ * Set strict decoding parameter for this decoder. If strict decoding is enabled, partial bit
+ * streams will fail to decode. If strict decoding is disabled, the decoder will decode partial
+ * bitstreams as much as possible without erroring
+ *
+ * @param p_codec decompressor handler
+ * @param strict OPJ_TRUE to enable strict decoding, OPJ_FALSE to disable
+ *
+ * @return true if the decoder is correctly set
+ */
+
+OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decoder_set_strict_mode(opj_codec_t *p_codec,
+ OPJ_BOOL strict);
+
+/**
* Allocates worker threads for the compressor/decompressor.
*
* By default, only the main thread is used. If this function is not used,
@@ -1453,7 +1467,7 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_decode(opj_codec_t *p_decompressor,
* Get the decoded tile from the codec
*
* @param p_codec the jpeg2000 codec.
- * @param p_stream input streamm
+ * @param p_stream input stream
* @param p_image output image
* @param tile_index index of the tile which will be decode
*
@@ -1599,9 +1613,12 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_setup_encoder(opj_codec_t *p_codec,
* <li>PLT=YES/NO. Defaults to NO. If set to YES, PLT marker segments,
* indicating the length of each packet in the tile-part header, will be
* written. Since 2.4.0</li>
- * <li>TLM=YES/NO. Defaults to NO (except for Cinema and IMF profiles).
- * If set to YES, TLM marker segments, indicating the length of each
- * tile-part part will be written. Since 2.4.0</li>
+ * <li>TLM=YES/NO. Defaults to NO (except for Cinema and IMF profiles).
+ * If set to YES, TLM marker segments, indicating the length of each
+ * tile-part part will be written. Since 2.4.0</li>
+ * <li>GUARD_BITS=value. Number of guard bits in [0,7] range. Default value is 2.
+ * 1 may be used sometimes (like in SMPTE DCP Bv2.1 Application Profile for 2K images).
+ * Since 2.5.0</li>
* </ul>
*
* @param p_codec Compressor handle
diff --git a/src/lib/openjp2/opj_codec.h b/src/lib/openjp2/opj_codec.h
index 8a8af911..7cff6708 100644
--- a/src/lib/openjp2/opj_codec.h
+++ b/src/lib/openjp2/opj_codec.h
@@ -90,6 +90,9 @@ typedef struct opj_codec_private {
/** Setup decoder function handler */
void (*opj_setup_decoder)(void * p_codec, opj_dparameters_t * p_param);
+ /** Strict mode function handler */
+ void (*opj_decoder_set_strict_mode)(void * p_codec, OPJ_BOOL strict);
+
/** Set decode area function handler */
OPJ_BOOL(*opj_set_decode_area)(void * p_codec,
opj_image_t * p_image,
diff --git a/src/lib/openjp2/opj_intmath.h b/src/lib/openjp2/opj_intmath.h
index f8cc6139..1b0c9d03 100644
--- a/src/lib/openjp2/opj_intmath.h
+++ b/src/lib/openjp2/opj_intmath.h
@@ -277,7 +277,7 @@ static INLINE OPJ_INT32 opj_int_fix_mul_t1(OPJ_INT32 a, OPJ_INT32 b)
}
/**
-Addtion two signed integers with a wrap-around behaviour.
+Addition two signed integers with a wrap-around behaviour.
Assumes complement-to-two signed integers.
@param a
@param b
diff --git a/src/lib/openjp2/pi.c b/src/lib/openjp2/pi.c
index ccc5b75c..38f1ba5a 100644
--- a/src/lib/openjp2/pi.c
+++ b/src/lib/openjp2/pi.c
@@ -943,7 +943,7 @@ static void opj_get_all_encoding_parameters(const opj_image_t *p_image,
*p_dy_min = 0x7fffffff;
for (compno = 0; compno < p_image->numcomps; ++compno) {
- /* aritmetic variables to calculate*/
+ /* arithmetic variables to calculate*/
OPJ_UINT32 l_level_no;
OPJ_UINT32 l_rx0, l_ry0, l_rx1, l_ry1;
OPJ_UINT32 l_px0, l_py0, l_px1, py1;
@@ -1225,7 +1225,7 @@ static void opj_pi_update_decode_poc(opj_pi_iterator_t * p_pi,
/* loop*/
OPJ_UINT32 pino;
- /* encoding prameters to set*/
+ /* encoding parameters to set*/
OPJ_UINT32 l_bound;
opj_pi_iterator_t * l_current_pi = 00;
@@ -1272,7 +1272,7 @@ static void opj_pi_update_decode_not_poc(opj_pi_iterator_t * p_pi,
/* loop*/
OPJ_UINT32 pino;
- /* encoding prameters to set*/
+ /* encoding parameters to set*/
OPJ_UINT32 l_bound;
opj_pi_iterator_t * l_current_pi = 00;
@@ -1401,11 +1401,11 @@ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image,
OPJ_UINT32 pino;
OPJ_UINT32 compno, resno;
- /* to store w, h, dx and dy fro all components and resolutions */
+ /* to store w, h, dx and dy for all components and resolutions */
OPJ_UINT32 * l_tmp_data;
OPJ_UINT32 ** l_tmp_ptr;
- /* encoding prameters to set */
+ /* encoding parameters to set */
OPJ_UINT32 l_max_res;
OPJ_UINT32 l_max_prec;
OPJ_UINT32 l_tx0, l_tx1, l_ty0, l_ty1;
@@ -1624,11 +1624,11 @@ opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image,
OPJ_UINT32 pino;
OPJ_UINT32 compno, resno;
- /* to store w, h, dx and dy fro all components and resolutions*/
+ /* to store w, h, dx and dy for all components and resolutions*/
OPJ_UINT32 * l_tmp_data;
OPJ_UINT32 ** l_tmp_ptr;
- /* encoding prameters to set*/
+ /* encoding parameters to set*/
OPJ_UINT32 l_max_res;
OPJ_UINT32 l_max_prec;
OPJ_UINT32 l_tx0, l_tx1, l_ty0, l_ty1;
diff --git a/src/lib/openjp2/sparse_array.c b/src/lib/openjp2/sparse_array.c
index 73192924..50d1a904 100644
--- a/src/lib/openjp2/sparse_array.c
+++ b/src/lib/openjp2/sparse_array.c
@@ -69,7 +69,7 @@ opj_sparse_array_int32_t* opj_sparse_array_int32_create(OPJ_UINT32 width,
return NULL;
}
sa->data_blocks = (OPJ_INT32**) opj_calloc(sizeof(OPJ_INT32*),
- sa->block_count_hor * sa->block_count_ver);
+ (size_t) sa->block_count_hor * sa->block_count_ver);
if (sa->data_blocks == NULL) {
opj_free(sa);
return NULL;
@@ -235,7 +235,7 @@ static OPJ_BOOL opj_sparse_array_int32_read_or_write(
} else {
if (src_block == NULL) {
src_block = (OPJ_INT32*) opj_calloc(1,
- sa->block_width * sa->block_height * sizeof(OPJ_INT32));
+ (size_t) sa->block_width * sa->block_height * sizeof(OPJ_INT32));
if (src_block == NULL) {
return OPJ_FALSE;
}
diff --git a/src/lib/openjp2/t1.h b/src/lib/openjp2/t1.h
index 81ad0d00..ce43658b 100644
--- a/src/lib/openjp2/t1.h
+++ b/src/lib/openjp2/t1.h
@@ -200,7 +200,7 @@ typedef struct opj_t1 {
OPJ_UINT32 flagssize;
OPJ_BOOL encoder;
- /* Thre 3 variables below are only used by the decoder */
+ /* The 3 variables below are only used by the decoder */
/* set to TRUE in multithreaded context */
OPJ_BOOL mustuse_cblkdatabuffer;
/* Temporary buffer to concatenate all chunks of a codebock */
diff --git a/src/lib/openjp2/t1_ht_generate_luts.c b/src/lib/openjp2/t1_ht_generate_luts.c
index 3fd14eb9..6876e3fd 100644
--- a/src/lib/openjp2/t1_ht_generate_luts.c
+++ b/src/lib/openjp2/t1_ht_generate_luts.c
@@ -887,7 +887,7 @@ static vlc_src_table_t tbl1[] = {
* \li \c cwd_len : 3bits -> the codeword length of the VLC codeword;
* the VLC cwd is in the LSB of bitstream \n
* \li \c u_off : 1bit -> u_offset, which is 1 if u value is not 0 \n
- * \li \c rho : 4bits -> signficant samples within a quad \n
+ * \li \c rho : 4bits -> significant samples within a quad \n
* \li \c e_1 : 4bits -> EMB e_1 \n
* \li \c e_k : 4bits -> EMB e_k \n
* \n
@@ -924,7 +924,7 @@ OPJ_BOOL vlc_init_tables()
}
// this is to convert table entries into values for decoder look up
- // There can be at most 1024 possibilites, not all of them are valid.
+ // There can be at most 1024 possibilities, not all of them are valid.
//
for (int i = 0; i < 1024; ++i) {
int cwd = i & 0x7F; // from i extract codeword
diff --git a/src/lib/openjp2/t2.c b/src/lib/openjp2/t2.c
index 48f8949b..ebda0052 100644
--- a/src/lib/openjp2/t2.c
+++ b/src/lib/openjp2/t2.c
@@ -502,7 +502,6 @@ OPJ_BOOL opj_t2_decode_packets(opj_tcd_t* tcd,
l_current_pi->precno, l_current_pi->layno, skip_packet ? "skipped" : "kept");
*/
}
-
if (!skip_packet) {
l_nb_bytes_read = 0;
@@ -1124,7 +1123,7 @@ static OPJ_BOOL opj_t2_read_packet_header(opj_t2_t* p_t2,
/*
When the marker PPT/PPM is used the packet header are store in PPT/PPM marker
- This part deal with this caracteristic
+ This part deal with this characteristic
step 1: Read packet header in the saved structure
step 2: Return to codestream for decoding
*/
@@ -1378,6 +1377,7 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
opj_tcd_cblk_dec_t* l_cblk = 00;
opj_tcd_resolution_t* l_res =
&p_tile->comps[p_pi->compno].resolutions[p_pi->resno];
+ OPJ_BOOL partial_buffer = OPJ_FALSE;
OPJ_ARG_NOT_USED(p_t2);
OPJ_ARG_NOT_USED(pack_info);
@@ -1397,6 +1397,12 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
for (cblkno = 0; cblkno < l_nb_code_blocks; ++cblkno) {
opj_tcd_seg_t *l_seg = 00;
+ // if we have a partial data stream, set numchunks to zero
+ // since we have no data to actually decode.
+ if (partial_buffer) {
+ l_cblk->numchunks = 0;
+ }
+
if (!l_cblk->numnewpasses) {
/* nothing to do */
++l_cblk;
@@ -1419,12 +1425,32 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
/* Check possible overflow (on l_current_data only, assumes input args already checked) then size */
if ((((OPJ_SIZE_T)l_current_data + (OPJ_SIZE_T)l_seg->newlen) <
(OPJ_SIZE_T)l_current_data) ||
- (l_current_data + l_seg->newlen > p_src_data + p_max_length)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
- l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
- p_pi->compno);
- return OPJ_FALSE;
+ (l_current_data + l_seg->newlen > p_src_data + p_max_length) ||
+ (partial_buffer)) {
+ if (p_t2->cp->strict) {
+ opj_event_msg(p_manager, EVT_ERROR,
+ "read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
+ l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
+ p_pi->compno);
+ return OPJ_FALSE;
+ } else {
+ opj_event_msg(p_manager, EVT_WARNING,
+ "read: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
+ l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
+ p_pi->compno);
+ // skip this codeblock since it is a partial read
+ partial_buffer = OPJ_TRUE;
+ l_cblk->numchunks = 0;
+
+ l_seg->numpasses += l_seg->numnewpasses;
+ l_cblk->numnewpasses -= l_seg->numnewpasses;
+ if (l_cblk->numnewpasses > 0) {
+ ++l_seg;
+ ++l_cblk->numsegs;
+ break;
+ }
+ continue;
+ }
}
#ifdef USE_JPWL
@@ -1486,8 +1512,12 @@ static OPJ_BOOL opj_t2_read_packet_data(opj_t2_t* p_t2,
++l_band;
}
- *(p_data_read) = (OPJ_UINT32)(l_current_data - p_src_data);
-
+ // return the number of bytes read
+ if (partial_buffer) {
+ *(p_data_read) = p_max_length;
+ } else {
+ *(p_data_read) = (OPJ_UINT32)(l_current_data - p_src_data);
+ }
return OPJ_TRUE;
}
@@ -1549,11 +1579,18 @@ static OPJ_BOOL opj_t2_skip_packet_data(opj_t2_t* p_t2,
/* Check possible overflow then size */
if (((*p_data_read + l_seg->newlen) < (*p_data_read)) ||
((*p_data_read + l_seg->newlen) > p_max_length)) {
- opj_event_msg(p_manager, EVT_ERROR,
- "skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
- l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
- p_pi->compno);
- return OPJ_FALSE;
+ if (p_t2->cp->strict) {
+ opj_event_msg(p_manager, EVT_ERROR,
+ "skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
+ l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
+ p_pi->compno);
+ return OPJ_FALSE;
+ } else {
+ opj_event_msg(p_manager, EVT_WARNING,
+ "skip: segment too long (%d) with max (%d) for codeblock %d (p=%d, b=%d, r=%d, c=%d)\n",
+ l_seg->newlen, p_max_length, cblkno, p_pi->precno, bandno, p_pi->resno,
+ p_pi->compno);
+ }
}
#ifdef USE_JPWL
diff --git a/src/lib/openjpip/auxtrans_manager.c b/src/lib/openjpip/auxtrans_manager.c
index 8f364b6d..1471974d 100644
--- a/src/lib/openjpip/auxtrans_manager.c
+++ b/src/lib/openjpip/auxtrans_manager.c
@@ -87,7 +87,7 @@ typedef struct aux_response_param {
unsigned char *data; /*!< sending data */
OPJ_SIZE_T datalen; /*!< length of data */
OPJ_SIZE_T maxlenPerFrame; /*!< maximum data length to send per frame */
- SOCKET listensock; /*!< listeing socket */
+ SOCKET listensock; /*!< listening socket */
#ifdef _WIN32
HANDLE hTh; /*!< thread handle */
#endif
@@ -131,7 +131,7 @@ void send_responsedata_on_aux(OPJ_BOOL istcp, auxtrans_param_t auxtrans,
auxresponse->hTh = (HANDLE)_beginthreadex(NULL, 0, &aux_streaming, auxresponse,
0, &threadId);
if (auxresponse->hTh == 0) {
- fprintf(FCGI_stderr, "ERRO: pthread_create() %s",
+ fprintf(FCGI_stderr, "ERROR: pthread_create() %s",
strerror((int)auxresponse->hTh));
}
#else
diff --git a/src/lib/openjpip/imgsock_manager.h b/src/lib/openjpip/imgsock_manager.h
index 3f5b18f5..1343120a 100644
--- a/src/lib/openjpip/imgsock_manager.h
+++ b/src/lib/openjpip/imgsock_manager.h
@@ -77,7 +77,7 @@ void send_PNMstream(SOCKET connected_socket, Byte_t *pnmstream,
*
* @param [in] connected_socket file descriptor of the connected socket
* @param [in] xmlstream xml data stream
- * @param [in] length legnth of the xml data stream
+ * @param [in] length length of the xml data stream
*/
void send_XMLstream(SOCKET connected_socket, Byte_t *xmlstream,
OPJ_SIZE_T length);
@@ -87,7 +87,7 @@ void send_XMLstream(SOCKET connected_socket, Byte_t *xmlstream,
*
* @param [in] connected_socket file descriptor of the connected socket
* @param [in] tid tid string
- * @param [in] tidlen legnth of the tid string
+ * @param [in] tidlen length of the tid string
*/
void send_TIDstream(SOCKET connected_socket, const char *tid,
OPJ_SIZE_T tidlen);
@@ -97,7 +97,7 @@ void send_TIDstream(SOCKET connected_socket, const char *tid,
*
* @param [in] connected_socket file descriptor of the connected socket
* @param [in] cid cid string
- * @param [in] cidlen legnth of the cid string
+ * @param [in] cidlen length of the cid string
*/
void send_CIDstream(SOCKET connected_socket, const char *cid,
OPJ_SIZE_T cidlen);
diff --git a/src/lib/openjpip/index_manager.c b/src/lib/openjpip/index_manager.c
index 89753752..64e760d7 100644
--- a/src/lib/openjpip/index_manager.c
+++ b/src/lib/openjpip/index_manager.c
@@ -53,7 +53,7 @@
#endif /*SERVER*/
/**
- * chekc JP2 box indexing
+ * check JP2 box indexing
*
* @param[in] toplev_boxlist top level box list
* @return if correct (true) or wrong (false)
diff --git a/src/lib/openjpip/jpip_parser.c b/src/lib/openjpip/jpip_parser.c
index 6d8f9500..5cea13fe 100644
--- a/src/lib/openjpip/jpip_parser.c
+++ b/src/lib/openjpip/jpip_parser.c
@@ -140,7 +140,7 @@ OPJ_BOOL close_channel(query_param_t query_param,
#ifndef SERVER
fprintf(logstream, "local log: close all\n");
#endif
- /* all channels associatd with the session will be closed */
+ /* all channels associated with the session will be closed */
if (!delete_session(cursession, sessionlist)) {
return OPJ_FALSE;
}
diff --git a/src/lib/openjpip/metadata_manager.h b/src/lib/openjpip/metadata_manager.h
index 6cf00306..1a389736 100644
--- a/src/lib/openjpip/metadata_manager.h
+++ b/src/lib/openjpip/metadata_manager.h
@@ -45,7 +45,7 @@ typedef struct metadata_param {
boxlist_param_t *boxlist; /**< box list*/
placeholderlist_param_t *placeholderlist; /**< placeholder box list*/
boxcontents_param_t
- *boxcontents; /**< box contens in case of no boxlist and placeholderlist*/
+ *boxcontents; /**< box contents in case of no boxlist and placeholderlist*/
struct metadata_param
*next; /**< pointer to the next metadata-bin*/
} metadata_param_t;
diff --git a/src/lib/openjpip/mhixbox_manager.h b/src/lib/openjpip/mhixbox_manager.h
index 8b39e58d..40a0f6f1 100644
--- a/src/lib/openjpip/mhixbox_manager.h
+++ b/src/lib/openjpip/mhixbox_manager.h
@@ -37,7 +37,7 @@
/** Marker index parameters*/
typedef struct markeridx_param {
Byte2_t code; /**< marker code*/
- Byte2_t num_remain; /**< remining number of the same marker index segments listed immediately*/
+ Byte2_t num_remain; /**< remaining number of the same marker index segments listed immediately*/
OPJ_OFF_T offset; /**< offset relative to the start of the*/
/**codestream ( including the length*/
/**parameter but not the marker itself)*/