2 * The copyright in this software is being made available under the 2-clauses
3 * BSD License, included below. This software may be subject to other third
4 * party and contributor rights, including patent rights, and no such rights
5 * are granted under this license.
7 * Copyright (c) 2005, Herve Drolon, FreeImage Team
8 * Copyright (c) 2006, M�nica D�ez Garc�a, Image Processing Laboratory, University of Valladolid, Spain
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
37 #include "opj_includes.h"
39 #define JP3D_VERSION "1.3.0"
40 /* ---------------------------------------------------------------------- */
44 DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
45 switch (ul_reason_for_call) {
46 case DLL_PROCESS_ATTACH :
48 case DLL_PROCESS_DETACH :
50 case DLL_THREAD_ATTACH :
51 case DLL_THREAD_DETACH :
57 #endif /* OPJ_STATIC */
60 /* ---------------------------------------------------------------------- */
62 const char* OPJ_CALLCONV opj_version() {
65 opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format) {
66 opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t));
67 if(!dinfo) return NULL;
68 dinfo->is_decompressor = true;
72 /* get a J3D decoder handle */
73 dinfo->j3d_handle = (void*)j3d_create_decompress((opj_common_ptr)dinfo);
74 if(!dinfo->j3d_handle) {
84 dinfo->codec_format = format;
89 void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo) {
91 /* destroy the codec */
92 if(dinfo->codec_format != CODEC_UNKNOWN) {
93 j3d_destroy_decompress((opj_j3d_t*)dinfo->j3d_handle);
95 /* destroy the decompressor */
100 void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters) {
102 memset(parameters, 0, sizeof(opj_dparameters_t));
103 /* default decoding parameters */
104 parameters->cp_layer = 0;
105 parameters->cp_reduce[0] = 0;
106 parameters->cp_reduce[1] = 0;
107 parameters->cp_reduce[2] = 0;
108 parameters->bigendian = 0;
110 parameters->decod_format = -1;
111 parameters->cod_format = -1;
115 void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters) {
116 if(dinfo && parameters) {
117 if (dinfo->codec_format != CODEC_UNKNOWN) {
118 j3d_setup_decoder((opj_j3d_t*)dinfo->j3d_handle, parameters);
123 opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio) {
125 if (dinfo->codec_format != CODEC_UNKNOWN) {
126 return j3d_decode((opj_j3d_t*)dinfo->j3d_handle, cio);
133 opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format) {
134 opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));
135 if(!cinfo) return NULL;
136 cinfo->is_decompressor = false;
140 /* get a J3D coder handle */
141 cinfo->j3d_handle = (void*)j3d_create_compress((opj_common_ptr)cinfo);
142 if(!cinfo->j3d_handle) {
152 cinfo->codec_format = format;
157 void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo) {
159 /* destroy the codec */
160 if (cinfo->codec_format != CODEC_UNKNOWN) {
161 j3d_destroy_compress((opj_j3d_t*)cinfo->j3d_handle);
163 /* destroy the decompressor */
168 void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters) {
170 memset(parameters, 0, sizeof(opj_cparameters_t));
171 /* default coding parameters */
172 parameters->numresolution[0] = 3;
173 parameters->numresolution[1] = 3;
174 parameters->numresolution[2] = 1;
175 parameters->cblock_init[0] = 64;
176 parameters->cblock_init[1] = 64;
177 parameters->cblock_init[2] = 64;
178 parameters->prog_order = LRCP;
179 parameters->roi_compno = -1; /* no ROI */
180 parameters->atk_wt[0] = 1; /* 5-3 WT */
181 parameters->atk_wt[1] = 1; /* 5-3 WT */
182 parameters->atk_wt[2] = 1; /* 5-3 WT */
183 parameters->irreversible = 0;
184 parameters->subsampling_dx = 1;
185 parameters->subsampling_dy = 1;
186 parameters->subsampling_dz = 1;
188 parameters->decod_format = -1;
189 parameters->cod_format = -1;
190 parameters->encoding_format = ENCOD_2EB;
191 parameters->transform_format = TRF_2D_DWT;
195 void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume) {
196 if(cinfo && parameters && volume) {
197 if (cinfo->codec_format != CODEC_UNKNOWN) {
198 j3d_setup_encoder((opj_j3d_t*)cinfo->j3d_handle, parameters, volume);
203 bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index) {
204 if(cinfo && cio && volume) {
205 if (cinfo->codec_format != CODEC_UNKNOWN) {
206 return j3d_encode((opj_j3d_t*)cinfo->j3d_handle, cio, volume, index);