]> granicus.if.org Git - openjpeg/commitdiff
Added OPJ_LIMIT_DECODING enabling us to limit the decoding to main header
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Mon, 19 Feb 2007 09:59:29 +0000 (09:59 +0000)
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>
Mon, 19 Feb 2007 09:59:29 +0000 (09:59 +0000)
ChangeLog
libopenjpeg/j2k.c
libopenjpeg/j2k.h
libopenjpeg/openjpeg.c
libopenjpeg/openjpeg.h

index 42e940f069a410f45b9a347f7167dd757b329975..57b582ab7895aade56c061398ed816a993503123 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : 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
 ! [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.
index 6e232f27d2d79b382339a8cdd3defd2876c0f099..db291ff23db08a1e0e8f8c87b2aec22fdc0e0017 100644 (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));
                cp->reduce = parameters->cp_reduce;     
                cp->layer = parameters->cp_layer;
+               cp->limit_decoding = parameters->cp_limit_decoding;
 /* UniPG>> */
 #ifdef USE_JPWL
                cp->correct = parameters->jpwl_correct;
@@ -1594,11 +1595,18 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio) {
                        return 0;
                }
                e = j2k_dec_mstab_lookup(id);
+               // Check if the marker is known
                if (!(j2k->state & e->states)) {
                        opj_image_destroy(image);
                        opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id);
                        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) {
                        (*e->handler)(j2k);
                }
index 00ccacfc896bac611b2e92f5152b47156c7e0022..9738bf850d9938c98fa322f87da799c79aabc9c7 100644 (file)
@@ -197,6 +197,8 @@ typedef struct opj_cp {
        int reduce;
        /** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */
        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 */
        int index_on;
        /** XTOsiz */
index e90fbb68bee49f7cbf3b84352fcfdc783b72b1eb..b522939e0d866a51755b5c200dce1096f05b3147 100644 (file)
@@ -116,6 +116,7 @@ void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *paramete
                /* default decoding parameters */
                parameters->cp_layer = 0;
                parameters->cp_reduce = 0;
+               parameters->cp_limit_decoding = NO_LIMITATION;
 
                parameters->decod_format = -1;
                parameters->cod_format = -1;
index 392901064bfc84fec33b54050ad661d49a53e6d1..8e9da44645508c9e3326fc2ec7ed547c596450e1 100644 (file)
@@ -143,6 +143,14 @@ typedef enum CODEC_FORMAT {
        CODEC_JP2 = 2           /**< JPEG-2000 file format : read/write */
 } 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
@@ -331,6 +339,14 @@ typedef struct opj_dparameters {
        */
        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) */
        /*@{*/
        /** input file name */