-/*\r
- * Copyright (c) 2005, Herve Drolon, FreeImage Team\r
- * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- * 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'\r
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\r
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
- * POSSIBILITY OF SUCH DAMAGE.\r
- */\r
-\r
-#ifdef _WIN32\r
-#include <windows.h>\r
-#endif /* _WIN32 */\r
-\r
-#include "opj_includes.h"\r
-#define JP3D_VERSION "1.3.0"\r
-/* ---------------------------------------------------------------------- */\r
-#ifdef _WIN32\r
-#ifndef OPJ_STATIC\r
-BOOL APIENTRY\r
-DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {\r
- switch (ul_reason_for_call) {\r
- case DLL_PROCESS_ATTACH :\r
- break;\r
- case DLL_PROCESS_DETACH :\r
- break;\r
- case DLL_THREAD_ATTACH :\r
- case DLL_THREAD_DETACH :\r
- break;\r
- }\r
-\r
- return TRUE;\r
-}\r
-#endif /* OPJ_STATIC */\r
-#endif /* _WIN32 */\r
-\r
-/* ---------------------------------------------------------------------- */\r
-\r
-const char* OPJ_CALLCONV opj_version() {\r
- return JP3D_VERSION;\r
-}\r
-opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {\r
- opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t));\r
- if(!dinfo) return NULL;\r
- dinfo->is_decompressor = true;\r
- switch(format) {\r
- case CODEC_J3D:\r
- case CODEC_J2K:\r
- /* get a J3D decoder handle */\r
- dinfo->j3d_handle = (void*)j3d_create_decompress((opj_common_ptr)dinfo);\r
- if(!dinfo->j3d_handle) {\r
- opj_free(dinfo);\r
- return NULL;\r
- }\r
- break;\r
- default:\r
- opj_free(dinfo);\r
- return NULL;\r
- }\r
-\r
- dinfo->codec_format = format;\r
-\r
- return dinfo;\r
-}\r
-\r
-void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {\r
- if(dinfo) {\r
- /* destroy the codec */\r
- if(dinfo->codec_format != CODEC_UNKNOWN) {\r
- j3d_destroy_decompress((opj_j3d_t*)dinfo->j3d_handle);\r
- }\r
- /* destroy the decompressor */\r
- opj_free(dinfo);\r
- }\r
-}\r
-\r
-void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {\r
- if(parameters) {\r
- memset(parameters, 0, sizeof(opj_dparameters_t));\r
- /* default decoding parameters */\r
- parameters->cp_layer = 0;\r
- parameters->cp_reduce[0] = 0;\r
- parameters->cp_reduce[1] = 0;\r
- parameters->cp_reduce[2] = 0;\r
- parameters->bigendian = 0;\r
-\r
- parameters->decod_format = -1;\r
- parameters->cod_format = -1;\r
- }\r
-}\r
-\r
-void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {\r
- if(dinfo && parameters) {\r
- if (dinfo->codec_format != CODEC_UNKNOWN) {\r
- j3d_setup_decoder((opj_j3d_t*)dinfo->j3d_handle, parameters);\r
- }\r
- }\r
-}\r
-\r
-opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {\r
- if(dinfo && cio) {\r
- if (dinfo->codec_format != CODEC_UNKNOWN) {\r
- return j3d_decode((opj_j3d_t*)dinfo->j3d_handle, cio);\r
- }\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {\r
- opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));\r
- if(!cinfo) return NULL;\r
- cinfo->is_decompressor = false;\r
- switch(format) {\r
- case CODEC_J3D:\r
- case CODEC_J2K:\r
- /* get a J3D coder handle */\r
- cinfo->j3d_handle = (void*)j3d_create_compress((opj_common_ptr)cinfo);\r
- if(!cinfo->j3d_handle) {\r
- opj_free(cinfo);\r
- return NULL;\r
- }\r
- break;\r
- default:\r
- opj_free(cinfo);\r
- return NULL;\r
- }\r
-\r
- cinfo->codec_format = format;\r
-\r
- return cinfo;\r
-}\r
-\r
-void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {\r
- if(cinfo) {\r
- /* destroy the codec */\r
- if (cinfo->codec_format != CODEC_UNKNOWN) {\r
- j3d_destroy_compress((opj_j3d_t*)cinfo->j3d_handle);\r
- }\r
- /* destroy the decompressor */\r
- opj_free(cinfo);\r
- }\r
-}\r
-\r
-void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {\r
- if(parameters) {\r
- memset(parameters, 0, sizeof(opj_cparameters_t));\r
- /* default coding parameters */\r
- parameters->numresolution[0] = 3;\r
- parameters->numresolution[1] = 3;\r
- parameters->numresolution[2] = 1;\r
- parameters->cblock_init[0] = 64;\r
- parameters->cblock_init[1] = 64;\r
- parameters->cblock_init[2] = 64;\r
- parameters->prog_order = LRCP;\r
- parameters->roi_compno = -1; /* no ROI */\r
- parameters->atk_wt[0] = 1; /* 5-3 WT */\r
- parameters->atk_wt[1] = 1; /* 5-3 WT */\r
- parameters->atk_wt[2] = 1; /* 5-3 WT */\r
- parameters->irreversible = 0;\r
- parameters->subsampling_dx = 1;\r
- parameters->subsampling_dy = 1;\r
- parameters->subsampling_dz = 1;\r
-\r
- parameters->decod_format = -1;\r
- parameters->cod_format = -1;\r
- parameters->encoding_format = ENCOD_2EB;\r
- parameters->transform_format = TRF_2D_DWT;\r
- }\r
-}\r
-\r
-void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume) {\r
- if(cinfo && parameters && volume) {\r
- if (cinfo->codec_format != CODEC_UNKNOWN) {\r
- j3d_setup_encoder((opj_j3d_t*)cinfo->j3d_handle, parameters, volume);\r
- }\r
- }\r
-}\r
-\r
-bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index) {\r
- if(cinfo && cio && volume) {\r
- if (cinfo->codec_format != CODEC_UNKNOWN) {\r
- return j3d_encode((opj_j3d_t*)cinfo->j3d_handle, cio, volume, index);\r
- }\r
- }\r
-\r
- return false;\r
-}\r
-\r
-\r
+/*
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
+ * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef _WIN32
+#include <windows.h>
+#endif /* _WIN32 */
+
+#include "opj_includes.h"
+#include "openjp3d.h"
+#define JP3D_VERSION "1.3.0"
+/* ---------------------------------------------------------------------- */
+#ifdef _WIN32
+#ifndef OPJ_STATIC
+BOOL APIENTRY
+DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
+ switch (ul_reason_for_call) {
+ case DLL_PROCESS_ATTACH :
+ break;
+ case DLL_PROCESS_DETACH :
+ break;
+ case DLL_THREAD_ATTACH :
+ case DLL_THREAD_DETACH :
+ break;
+ }
+
+ return TRUE;
+}
+#endif /* OPJ_STATIC */
+#endif /* _WIN32 */
+
+/* ---------------------------------------------------------------------- */
+
+const char* OPJ_CALLCONV opj_version() {
+ return JP3D_VERSION;
+}
+opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
+ opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t));
+ if(!dinfo) return NULL;
+ dinfo->is_decompressor = true;
+ switch(format) {
+ case CODEC_J3D:
+ case CODEC_J2K:
+ /* get a J3D decoder handle */
+ dinfo->j3d_handle = (void*)j3d_create_decompress((opj_common_ptr)dinfo);
+ if(!dinfo->j3d_handle) {
+ opj_free(dinfo);
+ return NULL;
+ }
+ break;
+ default:
+ opj_free(dinfo);
+ return NULL;
+ }
+
+ dinfo->codec_format = format;
+
+ return dinfo;
+}
+
+void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {
+ if(dinfo) {
+ /* destroy the codec */
+ if(dinfo->codec_format != CODEC_UNKNOWN) {
+ j3d_destroy_decompress((opj_j3d_t*)dinfo->j3d_handle);
+ }
+ /* destroy the decompressor */
+ opj_free(dinfo);
+ }
+}
+
+void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
+ if(parameters) {
+ memset(parameters, 0, sizeof(opj_dparameters_t));
+ /* default decoding parameters */
+ parameters->cp_layer = 0;
+ parameters->cp_reduce[0] = 0;
+ parameters->cp_reduce[1] = 0;
+ parameters->cp_reduce[2] = 0;
+ parameters->bigendian = 0;
+
+ parameters->decod_format = -1;
+ parameters->cod_format = -1;
+ }
+}
+
+void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
+ if(dinfo && parameters) {
+ if (dinfo->codec_format != CODEC_UNKNOWN) {
+ j3d_setup_decoder((opj_j3d_t*)dinfo->j3d_handle, parameters);
+ }
+ }
+}
+
+opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
+ if(dinfo && cio) {
+ if (dinfo->codec_format != CODEC_UNKNOWN) {
+ return j3d_decode((opj_j3d_t*)dinfo->j3d_handle, cio);
+ }
+ }
+
+ return NULL;
+}
+
+opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
+ opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));
+ if(!cinfo) return NULL;
+ cinfo->is_decompressor = false;
+ switch(format) {
+ case CODEC_J3D:
+ case CODEC_J2K:
+ /* get a J3D coder handle */
+ cinfo->j3d_handle = (void*)j3d_create_compress((opj_common_ptr)cinfo);
+ if(!cinfo->j3d_handle) {
+ opj_free(cinfo);
+ return NULL;
+ }
+ break;
+ default:
+ opj_free(cinfo);
+ return NULL;
+ }
+
+ cinfo->codec_format = format;
+
+ return cinfo;
+}
+
+void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
+ if(cinfo) {
+ /* destroy the codec */
+ if (cinfo->codec_format != CODEC_UNKNOWN) {
+ j3d_destroy_compress((opj_j3d_t*)cinfo->j3d_handle);
+ }
+ /* destroy the decompressor */
+ opj_free(cinfo);
+ }
+}
+
+void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
+ if(parameters) {
+ memset(parameters, 0, sizeof(opj_cparameters_t));
+ /* default coding parameters */
+ parameters->numresolution[0] = 3;
+ parameters->numresolution[1] = 3;
+ parameters->numresolution[2] = 1;
+ parameters->cblock_init[0] = 64;
+ parameters->cblock_init[1] = 64;
+ parameters->cblock_init[2] = 64;
+ parameters->prog_order = LRCP;
+ parameters->roi_compno = -1; /* no ROI */
+ parameters->atk_wt[0] = 1; /* 5-3 WT */
+ parameters->atk_wt[1] = 1; /* 5-3 WT */
+ parameters->atk_wt[2] = 1; /* 5-3 WT */
+ parameters->irreversible = 0;
+ parameters->subsampling_dx = 1;
+ parameters->subsampling_dy = 1;
+ parameters->subsampling_dz = 1;
+
+ parameters->decod_format = -1;
+ parameters->cod_format = -1;
+ parameters->encoding_format = ENCOD_2EB;
+ parameters->transform_format = TRF_2D_DWT;
+ }
+}
+
+void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume) {
+ if(cinfo && parameters && volume) {
+ if (cinfo->codec_format != CODEC_UNKNOWN) {
+ j3d_setup_encoder((opj_j3d_t*)cinfo->j3d_handle, parameters, volume);
+ }
+ }
+}
+
+bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index) {
+ if(cinfo && cio && volume) {
+ if (cinfo->codec_format != CODEC_UNKNOWN) {
+ return j3d_encode((opj_j3d_t*)cinfo->j3d_handle, cio, volume, index);
+ }
+ }
+
+ return false;
+}
+
+