Add support for partial bitstream decoding (#1407) (fixes #715)
[openjpeg.git] / src / lib / openjp2 / jp2.h
index 7ca5b598a02f2f2220307fe1ccd0144ea38f7e0c..173f25119baf7ff508e3cb79e0095a3e9b2d7a29 100644 (file)
@@ -33,8 +33,8 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
-#ifndef __JP2_H
-#define __JP2_H
+#ifndef OPJ_JP2_H
+#define OPJ_JP2_H
 /**
 @file jp2.h
 @brief The JPEG-2000 file format Reader/Writer (JP2)
@@ -174,7 +174,7 @@ typedef struct opj_jp2 {
     OPJ_UINT32 *cl;
     opj_jp2_comps_t *comps;
     /* FIXME: The following two variables are used to save offset
-      as we write out a JP2 file to disk. This mecanism is not flexible
+      as we write out a JP2 file to disk. This mechanism is not flexible
       as codec writers will need to extand those fields as new part
       of the standard are implemented.
     */
@@ -187,6 +187,8 @@ typedef struct opj_jp2 {
     opj_jp2_color_t color;
 
     OPJ_BOOL ignore_pclr_cmap_cdef;
+    OPJ_BYTE has_jp2h;
+    OPJ_BYTE has_ihdr;
 }
 opj_jp2_t;
 
@@ -233,6 +235,21 @@ 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
+ * @param num_threads Number of threads.
+ * @return OPJ_TRUE in case of success.
+ */
 OPJ_BOOL opj_jp2_set_threads(opj_jp2_t *jp2, OPJ_UINT32 num_threads);
 
 /**
@@ -325,6 +342,21 @@ OPJ_BOOL opj_jp2_read_header(opj_stream_private_t *p_stream,
                              opj_image_t ** p_image,
                              opj_event_mgr_t * p_manager);
 
+/** Sets the indices of the components to decode.
+ *
+ * @param jp2 JP2 decompressor handle
+ * @param numcomps Number of components to decode.
+ * @param comps_indices Array of num_compts indices (numbering starting at 0)
+ *                     corresponding to the components to decode.
+ * @param p_manager Event manager;
+ *
+ * @return OPJ_TRUE in case of success.
+ */
+OPJ_BOOL opj_jp2_set_decoded_components(opj_jp2_t *jp2,
+                                        OPJ_UINT32 numcomps,
+                                        const OPJ_UINT32* comps_indices,
+                                        opj_event_mgr_t * p_manager);
+
 /**
  * Reads a tile header.
  * @param  p_jp2         the jpeg2000 codec.
@@ -436,13 +468,27 @@ OPJ_BOOL opj_jp2_set_decoded_resolution_factor(opj_jp2_t *p_jp2,
         OPJ_UINT32 res_factor,
         opj_event_mgr_t * p_manager);
 
+/**
+ * Specify extra options for the encoder.
+ *
+ * @param  p_jp2        the jpeg2000 codec.
+ * @param  p_options    options
+ * @param  p_manager    the user event manager
+ *
+ * @see opj_encoder_set_extra_options() for more details.
+ */
+OPJ_BOOL opj_jp2_encoder_set_extra_options(
+    opj_jp2_t *p_jp2,
+    const char* const* p_options,
+    opj_event_mgr_t * p_manager);
+
 
 /* TODO MSD: clean these 3 functions */
 /**
  * Dump some elements from the JP2 decompression structure .
  *
  *@param p_jp2        the jp2 codec.
- *@param flag        flag to describe what elments are dump.
+ *@param flag        flag to describe what elements are dump.
  *@param out_stream      output stream where dump the elements.
  *
 */
@@ -471,5 +517,5 @@ opj_codestream_index_t* jp2_get_cstr_index(opj_jp2_t* p_jp2);
 
 /*@}*/
 
-#endif /* __JP2_H */
+#endif /* OPJ_JP2_H */