Added OPJ_LIMIT_DECODING enabling us to limit the decoding to main header

This commit is contained in:
Francois-Olivier Devaux 2007-02-19 09:59:29 +00:00
parent d084ff59f2
commit eac141b69a
5 changed files with 30 additions and 0 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed ! : changed
+ : added + : added
February 19, 2007
+ [FOD] Added OPJ_LIMIT_DECODING enabling us to limit the decoding to main header (modified openjpeg.c, openjpeg.h, j2k.c and j2k.h)
February 13, 2007 February 13, 2007
! [FOD] David Fries suggestions. In image_to_j2k and j2k_to_image, strncpy() functions: instead of specifying the path size macro, let the compiler read the length out of the array entry. ! [FOD] David Fries suggestions. In image_to_j2k and j2k_to_image, strncpy() functions: instead of specifying the path size macro, let the compiler read the length out of the array entry.
! [FOD] David Fries suggestions. Makefile modified. -fPIC flag used for 64-bit compilation. Move operation (rather than copy) for the dist library creation, and -p flag added. ! [FOD] David Fries suggestions. Makefile modified. -fPIC flag used for 64-bit compilation. Move operation (rather than copy) for the dist library creation, and -p flag added.

View File

@ -1522,6 +1522,7 @@ void j2k_setup_decoder(opj_j2k_t *j2k, opj_dparameters_t *parameters) {
opj_cp_t *cp = (opj_cp_t*)opj_malloc(sizeof(opj_cp_t)); opj_cp_t *cp = (opj_cp_t*)opj_malloc(sizeof(opj_cp_t));
cp->reduce = parameters->cp_reduce; cp->reduce = parameters->cp_reduce;
cp->layer = parameters->cp_layer; cp->layer = parameters->cp_layer;
cp->limit_decoding = parameters->cp_limit_decoding;
/* UniPG>> */ /* UniPG>> */
#ifdef USE_JPWL #ifdef USE_JPWL
cp->correct = parameters->jpwl_correct; cp->correct = parameters->jpwl_correct;
@ -1594,11 +1595,18 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio) {
return 0; return 0;
} }
e = j2k_dec_mstab_lookup(id); e = j2k_dec_mstab_lookup(id);
// Check if the marker is known
if (!(j2k->state & e->states)) { if (!(j2k->state & e->states)) {
opj_image_destroy(image); opj_image_destroy(image);
opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id); opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id);
return 0; return 0;
} }
// Check if the decoding is limited to the main header
if (e->id == J2K_MS_SOT && j2k->cp->limit_decoding == LIMIT_TO_MAIN_HEADER) {
opj_event_msg(cinfo, EVT_INFO, "Main Header decoded.\n");
return image;
}
if (e->handler) { if (e->handler) {
(*e->handler)(j2k); (*e->handler)(j2k);
} }

View File

@ -197,6 +197,8 @@ typedef struct opj_cp {
int reduce; int reduce;
/** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */ /** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
int layer; int layer;
/** if == NO_LIMITATION, decode entire codestream; if == LIMIT_TO_MAIN_HEADER then only decode the main header */
OPJ_LIMIT_DECODING limit_decoding;
/** 0 = no index || 1 = index */ /** 0 = no index || 1 = index */
int index_on; int index_on;
/** XTOsiz */ /** XTOsiz */

View File

@ -116,6 +116,7 @@ void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *paramete
/* default decoding parameters */ /* default decoding parameters */
parameters->cp_layer = 0; parameters->cp_layer = 0;
parameters->cp_reduce = 0; parameters->cp_reduce = 0;
parameters->cp_limit_decoding = NO_LIMITATION;
parameters->decod_format = -1; parameters->decod_format = -1;
parameters->cod_format = -1; parameters->cod_format = -1;

View File

@ -143,6 +143,14 @@ typedef enum CODEC_FORMAT {
CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */ CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */
} OPJ_CODEC_FORMAT; } OPJ_CODEC_FORMAT;
/**
Limit decoding to certain portions of the codestream.
*/
typedef enum LIMIT_DECODING {
NO_LIMITATION = 0, /**< No limitation for the decoding. The entire codestream will de decoded */
LIMIT_TO_MAIN_HEADER = 1 /**< The decoding is limited to the Main Header */
} OPJ_LIMIT_DECODING;
/* /*
========================================================== ==========================================================
event manager typedef definitions event manager typedef definitions
@ -331,6 +339,14 @@ typedef struct opj_dparameters {
*/ */
int cp_layer; int cp_layer;
/**
Specify whether the decoding should be done on the entire codestream, or be limited to the main header
Limiting the decoding to the main header makes it possible to extract the characteristics of the codestream
if == NO_LIMITATION, the entire codestream is decoded;
if == LIMIT_TO_MAIN_HEADER, only the main header is decoded;
*/
OPJ_LIMIT_DECODING cp_limit_decoding;
/**@name command line encoder parameters (not used inside the library) */ /**@name command line encoder parameters (not used inside the library) */
/*@{*/ /*@{*/
/** input file name */ /** input file name */