2 * Copyright (c) 2005, Herve Drolon, FreeImage Team
\r
3 * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
\r
4 * All rights reserved.
\r
6 * Redistribution and use in source and binary forms, with or without
\r
7 * modification, are permitted provided that the following conditions
\r
9 * 1. Redistributions of source code must retain the above copyright
\r
10 * notice, this list of conditions and the following disclaimer.
\r
11 * 2. Redistributions in binary form must reproduce the above copyright
\r
12 * notice, this list of conditions and the following disclaimer in the
\r
13 * documentation and/or other materials provided with the distribution.
\r
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
\r
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
\r
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
\r
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
\r
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
\r
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
\r
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
\r
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
25 * POSSIBILITY OF SUCH DAMAGE.
\r
29 #include <windows.h>
\r
32 #include "opj_includes.h"
\r
33 #include "openjp3d.h"
\r
34 #define JP3D_VERSION "1.3.0"
\r
35 /* ---------------------------------------------------------------------- */
\r
39 DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
\r
40 switch (ul_reason_for_call) {
\r
41 case DLL_PROCESS_ATTACH :
\r
43 case DLL_PROCESS_DETACH :
\r
45 case DLL_THREAD_ATTACH :
\r
46 case DLL_THREAD_DETACH :
\r
52 #endif /* OPJ_STATIC */
\r
55 /* ---------------------------------------------------------------------- */
\r
57 const char* OPJ_CALLCONV opj_version() {
\r
58 return JP3D_VERSION;
\r
60 opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
\r
61 opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t));
\r
62 if(!dinfo) return NULL;
\r
63 dinfo->is_decompressor = true;
\r
67 /* get a J3D decoder handle */
\r
68 dinfo->j3d_handle = (void*)j3d_create_decompress((opj_common_ptr)dinfo);
\r
69 if(!dinfo->j3d_handle) {
\r
79 dinfo->codec_format = format;
\r
84 void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {
\r
86 /* destroy the codec */
\r
87 if(dinfo->codec_format != CODEC_UNKNOWN) {
\r
88 j3d_destroy_decompress((opj_j3d_t*)dinfo->j3d_handle);
\r
90 /* destroy the decompressor */
\r
95 void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
\r
97 memset(parameters, 0, sizeof(opj_dparameters_t));
\r
98 /* default decoding parameters */
\r
99 parameters->cp_layer = 0;
\r
100 parameters->cp_reduce[0] = 0;
\r
101 parameters->cp_reduce[1] = 0;
\r
102 parameters->cp_reduce[2] = 0;
\r
103 parameters->bigendian = 0;
\r
105 parameters->decod_format = -1;
\r
106 parameters->cod_format = -1;
\r
110 void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
\r
111 if(dinfo && parameters) {
\r
112 if (dinfo->codec_format != CODEC_UNKNOWN) {
\r
113 j3d_setup_decoder((opj_j3d_t*)dinfo->j3d_handle, parameters);
\r
118 opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
\r
120 if (dinfo->codec_format != CODEC_UNKNOWN) {
\r
121 return j3d_decode((opj_j3d_t*)dinfo->j3d_handle, cio);
\r
128 opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
\r
129 opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));
\r
130 if(!cinfo) return NULL;
\r
131 cinfo->is_decompressor = false;
\r
135 /* get a J3D coder handle */
\r
136 cinfo->j3d_handle = (void*)j3d_create_compress((opj_common_ptr)cinfo);
\r
137 if(!cinfo->j3d_handle) {
\r
147 cinfo->codec_format = format;
\r
152 void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
\r
154 /* destroy the codec */
\r
155 if (cinfo->codec_format != CODEC_UNKNOWN) {
\r
156 j3d_destroy_compress((opj_j3d_t*)cinfo->j3d_handle);
\r
158 /* destroy the decompressor */
\r
163 void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
\r
165 memset(parameters, 0, sizeof(opj_cparameters_t));
\r
166 /* default coding parameters */
\r
167 parameters->numresolution[0] = 3;
\r
168 parameters->numresolution[1] = 3;
\r
169 parameters->numresolution[2] = 1;
\r
170 parameters->cblock_init[0] = 64;
\r
171 parameters->cblock_init[1] = 64;
\r
172 parameters->cblock_init[2] = 64;
\r
173 parameters->prog_order = LRCP;
\r
174 parameters->roi_compno = -1; /* no ROI */
\r
175 parameters->atk_wt[0] = 1; /* 5-3 WT */
\r
176 parameters->atk_wt[1] = 1; /* 5-3 WT */
\r
177 parameters->atk_wt[2] = 1; /* 5-3 WT */
\r
178 parameters->irreversible = 0;
\r
179 parameters->subsampling_dx = 1;
\r
180 parameters->subsampling_dy = 1;
\r
181 parameters->subsampling_dz = 1;
\r
183 parameters->decod_format = -1;
\r
184 parameters->cod_format = -1;
\r
185 parameters->encoding_format = ENCOD_2EB;
\r
186 parameters->transform_format = TRF_2D_DWT;
\r
190 void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume) {
\r
191 if(cinfo && parameters && volume) {
\r
192 if (cinfo->codec_format != CODEC_UNKNOWN) {
\r
193 j3d_setup_encoder((opj_j3d_t*)cinfo->j3d_handle, parameters, volume);
\r
198 bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index) {
\r
199 if(cinfo && cio && volume) {
\r
200 if (cinfo->codec_format != CODEC_UNKNOWN) {
\r
201 return j3d_encode((opj_j3d_t*)cinfo->j3d_handle, cio, volume, index);
\r