opj_set_decoded_components(): add a provision for a apply_color_transforms parameter... 1022/head
authorEven Rouault <even.rouault@spatialys.com>
Tue, 19 Sep 2017 15:48:07 +0000 (17:48 +0200)
committerEven Rouault <even.rouault@spatialys.com>
Tue, 19 Sep 2017 15:48:07 +0000 (17:48 +0200)
src/bin/jp2/opj_decompress.c
src/lib/openjp2/openjpeg.c
src/lib/openjp2/openjpeg.h

index 6c28277ab1824c33b5723764c0ed2c34545f3f44..a963b86a57724e33e84567c38687dbe3b18e2ded 100644 (file)
@@ -1488,7 +1488,8 @@ int main(int argc, char **argv)
         if (parameters.numcomps) {
             if (! opj_set_decoded_components(l_codec,
                                              parameters.numcomps,
-                                             parameters.comps_indices)) {
+                                             parameters.comps_indices,
+                                             OPJ_FALSE)) {
                 fprintf(stderr,
                         "ERROR -> opj_decompress: failed to set the component indices!\n");
                 opj_destroy_codec(l_codec);
index 5ba205e15cddd4a8be8834af6a0b7d74ce54a23b..7b12303423b7ad79cf50b6f259a682dcdab25bb4 100644 (file)
@@ -441,12 +441,21 @@ OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
 
 OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components(opj_codec_t *p_codec,
         OPJ_UINT32 numcomps,
-        const OPJ_UINT32* comps_indices)
+        const OPJ_UINT32* comps_indices,
+        OPJ_BOOL apply_color_transforms)
 {
     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_set_decoded_components function is not a decompressor handler.\n");
+            return OPJ_FALSE;
+        }
+
+        if (apply_color_transforms) {
+            opj_event_msg(&(l_codec->m_event_mgr), EVT_ERROR,
+                          "apply_color_transforms = OPJ_TRUE is not supported.\n");
             return OPJ_FALSE;
         }
 
index 2888e4d1af9ce914fad3f54522c870bcefe3cbc5..f36286eb106e98fab34a69eb1840599f9f01c768 100644 (file)
@@ -1341,9 +1341,12 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
  *
  * This function should be called after opj_read_header().
  *
- * Normally all the components are decoded. This call enables to restrict
- * the set of decoded components to the specified indices.
- * Note that neither the MCT transform nor JP2 channel transformatios will be applied.
+ * This function enables to restrict the set of decoded components to the
+ * specified indices.
+ * Note that the current implementation (apply_color_transforms == OPJ_FALSE)
+ * is such that neither the multi-component transform at codestream level,
+ * nor JP2 channel transformations will be applied.
+ * Consequently the indices are relative to the codestream.
  *
  * Note: opj_decode_tile_data() should not be used together with opj_set_decoded_components().
  *
@@ -1352,12 +1355,17 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_read_header(opj_stream_t *p_stream,
  * @param   comps_indices   Array of numcomps values representing the indices
  *                          of the components to decode (relative to the
  *                          codestream, starting at 0)
+ * @param   apply_color_transforms Whether multi-component transform at codestream level
+ *                                 or JP2 channel transformations should be applied.
+ *                                 Currently this parameter should be set to OPJ_FALSE.
+ *                                 Setting it to OPJ_TRUE will result in an error.
  *
  * @return OPJ_TRUE         in case of success.
  */
 OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components(opj_codec_t *p_codec,
         OPJ_UINT32 numcomps,
-        const OPJ_UINT32* comps_indices);
+        const OPJ_UINT32* comps_indices,
+        OPJ_BOOL apply_color_transforms);
 
 /**
  * Sets the given area to be decoded. This function should be called right after opj_read_header and before any tile header reading.