2 * Copyright (c) 2005, Herv� 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 #define JP3D_VERSION "1.3.0"
\r
34 /* ---------------------------------------------------------------------- */
\r
38 DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
\r
39 switch (ul_reason_for_call) {
\r
40 case DLL_PROCESS_ATTACH :
\r
42 case DLL_PROCESS_DETACH :
\r
44 case DLL_THREAD_ATTACH :
\r
45 case DLL_THREAD_DETACH :
\r
51 #endif /* OPJ_STATIC */
\r
54 /* ---------------------------------------------------------------------- */
\r
56 const char* OPJ_CALLCONV opj_version() {
\r
57 return JP3D_VERSION;
\r
59 opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
\r
60 opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t));
\r
61 if(!dinfo) return NULL;
\r
62 dinfo->is_decompressor = true;
\r
66 /* get a J3D decoder handle */
\r
67 dinfo->j3d_handle = (void*)j3d_create_decompress((opj_common_ptr)dinfo);
\r
68 if(!dinfo->j3d_handle) {
\r
78 dinfo->codec_format = format;
\r
83 void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {
\r
85 /* destroy the codec */
\r
86 if(dinfo->codec_format != CODEC_UNKNOWN) {
\r
87 j3d_destroy_decompress((opj_j3d_t*)dinfo->j3d_handle);
\r
89 /* destroy the decompressor */
\r
94 void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
\r
96 memset(parameters, 0, sizeof(opj_dparameters_t));
\r
97 /* default decoding parameters */
\r
98 parameters->cp_layer = 0;
\r
99 parameters->cp_reduce[0] = 0;
\r
100 parameters->cp_reduce[1] = 0;
\r
101 parameters->cp_reduce[2] = 0;
\r
102 parameters->bigendian = 0;
\r
104 parameters->decod_format = -1;
\r
105 parameters->cod_format = -1;
\r
109 void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
\r
110 if(dinfo && parameters) {
\r
111 if (dinfo->codec_format != CODEC_UNKNOWN) {
\r
112 j3d_setup_decoder((opj_j3d_t*)dinfo->j3d_handle, parameters);
\r
117 opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
\r
119 if (dinfo->codec_format != CODEC_UNKNOWN) {
\r
120 return j3d_decode((opj_j3d_t*)dinfo->j3d_handle, cio);
\r
127 opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
\r
128 opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));
\r
129 if(!cinfo) return NULL;
\r
130 cinfo->is_decompressor = false;
\r
134 /* get a J3D coder handle */
\r
135 cinfo->j3d_handle = (void*)j3d_create_compress((opj_common_ptr)cinfo);
\r
136 if(!cinfo->j3d_handle) {
\r
146 cinfo->codec_format = format;
\r
151 void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
\r
153 /* destroy the codec */
\r
154 if (cinfo->codec_format != CODEC_UNKNOWN) {
\r
155 j3d_destroy_compress((opj_j3d_t*)cinfo->j3d_handle);
\r
157 /* destroy the decompressor */
\r
162 void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
\r
164 memset(parameters, 0, sizeof(opj_cparameters_t));
\r
165 /* default coding parameters */
\r
166 parameters->numresolution[0] = 3;
\r
167 parameters->numresolution[1] = 3;
\r
168 parameters->numresolution[2] = 1;
\r
169 parameters->cblock_init[0] = 64;
\r
170 parameters->cblock_init[1] = 64;
\r
171 parameters->cblock_init[2] = 64;
\r
172 parameters->prog_order = LRCP;
\r
173 parameters->roi_compno = -1; /* no ROI */
\r
174 parameters->atk_wt[0] = 1; /* 5-3 WT */
\r
175 parameters->atk_wt[1] = 1; /* 5-3 WT */
\r
176 parameters->atk_wt[2] = 1; /* 5-3 WT */
\r
177 parameters->irreversible = 0;
\r
178 parameters->subsampling_dx = 1;
\r
179 parameters->subsampling_dy = 1;
\r
180 parameters->subsampling_dz = 1;
\r
182 parameters->decod_format = -1;
\r
183 parameters->cod_format = -1;
\r
184 parameters->encoding_format = ENCOD_2EB;
\r
185 parameters->transform_format = TRF_2D_DWT;
\r
189 void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume) {
\r
190 if(cinfo && parameters && volume) {
\r
191 if (cinfo->codec_format != CODEC_UNKNOWN) {
\r
192 j3d_setup_encoder((opj_j3d_t*)cinfo->j3d_handle, parameters, volume);
\r
197 bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index) {
\r
198 if(cinfo && cio && volume) {
\r
199 if (cinfo->codec_format != CODEC_UNKNOWN) {
\r
200 return j3d_encode((opj_j3d_t*)cinfo->j3d_handle, cio, volume, index);
\r