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)
46 switch (ul_reason_for_call) {
47 case DLL_PROCESS_ATTACH :
49 case DLL_PROCESS_DETACH :
51 case DLL_THREAD_ATTACH :
52 case DLL_THREAD_DETACH :
58 #endif /* OPJ_STATIC */
61 /* ---------------------------------------------------------------------- */
63 const char* OPJ_CALLCONV opj_version()
67 opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format)
69 opj_dinfo_t *dinfo = (opj_dinfo_t*)opj_malloc(sizeof(opj_dinfo_t));
73 dinfo->is_decompressor = true;
77 /* get a J3D decoder handle */
78 dinfo->j3d_handle = (void*)j3d_create_decompress((opj_common_ptr)dinfo);
79 if (!dinfo->j3d_handle) {
89 dinfo->codec_format = format;
94 void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo)
97 /* destroy the codec */
98 if (dinfo->codec_format != CODEC_UNKNOWN) {
99 j3d_destroy_decompress((opj_j3d_t*)dinfo->j3d_handle);
101 /* destroy the decompressor */
106 void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t
110 memset(parameters, 0, sizeof(opj_dparameters_t));
111 /* default decoding parameters */
112 parameters->cp_layer = 0;
113 parameters->cp_reduce[0] = 0;
114 parameters->cp_reduce[1] = 0;
115 parameters->cp_reduce[2] = 0;
116 parameters->bigendian = 0;
118 parameters->decod_format = -1;
119 parameters->cod_format = -1;
123 void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo,
124 opj_dparameters_t *parameters)
126 if (dinfo && parameters) {
127 if (dinfo->codec_format != CODEC_UNKNOWN) {
128 j3d_setup_decoder((opj_j3d_t*)dinfo->j3d_handle, parameters);
133 opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio)
136 if (dinfo->codec_format != CODEC_UNKNOWN) {
137 return j3d_decode((opj_j3d_t*)dinfo->j3d_handle, cio);
144 opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format)
146 opj_cinfo_t *cinfo = (opj_cinfo_t*)opj_malloc(sizeof(opj_cinfo_t));
150 cinfo->is_decompressor = false;
154 /* get a J3D coder handle */
155 cinfo->j3d_handle = (void*)j3d_create_compress((opj_common_ptr)cinfo);
156 if (!cinfo->j3d_handle) {
166 cinfo->codec_format = format;
171 void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo)
174 /* destroy the codec */
175 if (cinfo->codec_format != CODEC_UNKNOWN) {
176 j3d_destroy_compress((opj_j3d_t*)cinfo->j3d_handle);
178 /* destroy the decompressor */
183 void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t
187 memset(parameters, 0, sizeof(opj_cparameters_t));
188 /* default coding parameters */
189 parameters->numresolution[0] = 3;
190 parameters->numresolution[1] = 3;
191 parameters->numresolution[2] = 1;
192 parameters->cblock_init[0] = 64;
193 parameters->cblock_init[1] = 64;
194 parameters->cblock_init[2] = 64;
195 parameters->prog_order = LRCP;
196 parameters->roi_compno = -1; /* no ROI */
197 parameters->atk_wt[0] = 1; /* 5-3 WT */
198 parameters->atk_wt[1] = 1; /* 5-3 WT */
199 parameters->atk_wt[2] = 1; /* 5-3 WT */
200 parameters->irreversible = 0;
201 parameters->subsampling_dx = 1;
202 parameters->subsampling_dy = 1;
203 parameters->subsampling_dz = 1;
205 parameters->decod_format = -1;
206 parameters->cod_format = -1;
207 parameters->encoding_format = ENCOD_2EB;
208 parameters->transform_format = TRF_2D_DWT;
212 void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo,
213 opj_cparameters_t *parameters, opj_volume_t *volume)
215 if (cinfo && parameters && volume) {
216 if (cinfo->codec_format != CODEC_UNKNOWN) {
217 j3d_setup_encoder((opj_j3d_t*)cinfo->j3d_handle, parameters, volume);
222 bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio,
223 opj_volume_t *volume, char *index)
225 if (cinfo && cio && volume) {
226 if (cinfo->codec_format != CODEC_UNKNOWN) {
227 return j3d_encode((opj_j3d_t*)cinfo->j3d_handle, cio, volume, index);