00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef OPENJPEG_H
00033 #define OPENJPEG_H
00034
00035 #define OPENJPEG_VERSION "1.3.0"
00036
00037
00038
00039
00040
00041
00042
00043 #if defined(OPJ_STATIC) || !(defined(WIN32) || defined(__WIN32__))
00044 #define OPJ_API
00045 #define OPJ_CALLCONV
00046 #else
00047 #define OPJ_CALLCONV __stdcall
00048
00049
00050
00051
00052
00053
00054
00055
00056 #ifdef OPJ_EXPORTS
00057 #define OPJ_API __declspec(dllexport)
00058 #else
00059 #define OPJ_API __declspec(dllimport)
00060 #endif
00061 #endif
00062
00063 #ifndef __cplusplus
00064 #if 1
00065
00066
00067
00068
00069 #include <stdbool.h>
00070 #else
00071
00072
00073
00074
00075
00076 #if !defined(bool)
00077 #define bool int
00078 #endif
00079 #if !defined(true)
00080 #define true 1
00081 #endif
00082 #if !defined(false)
00083 #define false 0
00084 #endif
00085 #endif
00086 #endif
00087
00088
00089
00090
00091
00092
00093
00094 #define OPJ_PATH_LEN 4096
00096 #define J2K_MAXRLVLS 33
00097 #define J2K_MAXBANDS (3*J2K_MAXRLVLS-2)
00099
00100 #define JPWL_MAX_NO_TILESPECS 16
00101 #define JPWL_MAX_NO_PACKSPECS 16
00102 #define JPWL_MAX_NO_MARKERS 512
00103 #define JPWL_PRIVATEINDEX_NAME "jpwl_index_privatefilename"
00104 #define JPWL_EXPECTED_COMPONENTS 3
00105 #define JPWL_MAXIMUM_TILES 8192
00106 #define JPWL_MAXIMUM_HAMMING 2
00107 #define JPWL_MAXIMUM_EPB_ROOM 65450
00108
00109
00110
00111
00112
00113
00114
00118 typedef enum RSIZ_CAPABILITIES {
00119 STD_RSIZ = 0,
00120 CINEMA2K = 3,
00121 CINEMA4K = 4
00122 } OPJ_RSIZ_CAPABILITIES;
00123
00127 typedef enum CINEMA_MODE {
00128 OFF = 0,
00129 CINEMA2K_24 = 1,
00130 CINEMA2K_48 = 2,
00131 CINEMA4K_24 = 3
00132 }OPJ_CINEMA_MODE;
00133
00137 typedef enum PROG_ORDER {
00138 PROG_UNKNOWN = -1,
00139 LRCP = 0,
00140 RLCP = 1,
00141 RPCL = 2,
00142 PCRL = 3,
00143 CPRL = 4
00144 } OPJ_PROG_ORDER;
00145
00149 typedef enum COLOR_SPACE {
00150 CLRSPC_UNKNOWN = -1,
00151 CLRSPC_SRGB = 1,
00152 CLRSPC_GRAY = 2,
00153 CLRSPC_SYCC = 3
00154 } OPJ_COLOR_SPACE;
00155
00159 typedef enum CODEC_FORMAT {
00160 CODEC_UNKNOWN = -1,
00161 CODEC_J2K = 0,
00162 CODEC_JPT = 1,
00163 CODEC_JP2 = 2
00164 } OPJ_CODEC_FORMAT;
00165
00169 typedef enum LIMIT_DECODING {
00170 NO_LIMITATION = 0,
00171 LIMIT_TO_MAIN_HEADER = 1,
00172 DECODE_ALL_BUT_PACKETS = 2
00173 } OPJ_LIMIT_DECODING;
00174
00175
00176
00177
00178
00179
00180
00186 typedef void (*opj_msg_callback) (const char *msg, void *client_data);
00187
00197 typedef struct opj_event_mgr {
00199 opj_msg_callback error_handler;
00201 opj_msg_callback warning_handler;
00203 opj_msg_callback info_handler;
00204 } opj_event_mgr_t;
00205
00206
00207
00208
00209
00210
00211
00212
00216 typedef struct opj_poc {
00218 int resno0, compno0;
00220 int layno1, resno1, compno1;
00222 int layno0, precno0, precno1;
00224 OPJ_PROG_ORDER prg1,prg;
00226 char progorder[5];
00228 int tile;
00230 int tx0,tx1,ty0,ty1;
00232 int layS, resS, compS, prcS;
00234 int layE, resE, compE, prcE;
00236 int txS,txE,tyS,tyE,dx,dy;
00238 int lay_t, res_t, comp_t, prc_t,tx0_t,ty0_t;
00239 } opj_poc_t;
00240
00244 typedef struct opj_cparameters {
00246 bool tile_size_on;
00248 int cp_tx0;
00250 int cp_ty0;
00252 int cp_tdx;
00254 int cp_tdy;
00256 int cp_disto_alloc;
00258 int cp_fixed_alloc;
00260 int cp_fixed_quality;
00262 int *cp_matrice;
00264 char *cp_comment;
00266 int csty;
00268 OPJ_PROG_ORDER prog_order;
00270 opj_poc_t POC[32];
00272 int numpocs;
00274 int tcp_numlayers;
00276 float tcp_rates[100];
00278 float tcp_distoratio[100];
00280 int numresolution;
00282 int cblockw_init;
00284 int cblockh_init;
00286 int mode;
00288 int irreversible;
00290 int roi_compno;
00292 int roi_shift;
00293
00294 int res_spec;
00296 int prcw_init[J2K_MAXRLVLS];
00298 int prch_init[J2K_MAXRLVLS];
00299
00303 char infile[OPJ_PATH_LEN];
00305 char outfile[OPJ_PATH_LEN];
00307 int index_on;
00309 char index[OPJ_PATH_LEN];
00311 int image_offset_x0;
00313 int image_offset_y0;
00315 int subsampling_dx;
00317 int subsampling_dy;
00319 int decod_format;
00321 int cod_format;
00324
00328 bool jpwl_epc_on;
00330 int jpwl_hprot_MH;
00332 int jpwl_hprot_TPH_tileno[JPWL_MAX_NO_TILESPECS];
00334 int jpwl_hprot_TPH[JPWL_MAX_NO_TILESPECS];
00336 int jpwl_pprot_tileno[JPWL_MAX_NO_PACKSPECS];
00338 int jpwl_pprot_packno[JPWL_MAX_NO_PACKSPECS];
00340 int jpwl_pprot[JPWL_MAX_NO_PACKSPECS];
00342 int jpwl_sens_size;
00344 int jpwl_sens_addr;
00346 int jpwl_sens_range;
00348 int jpwl_sens_MH;
00350 int jpwl_sens_TPH_tileno[JPWL_MAX_NO_TILESPECS];
00352 int jpwl_sens_TPH[JPWL_MAX_NO_TILESPECS];
00354
00355
00357 OPJ_CINEMA_MODE cp_cinema;
00359 int max_comp_size;
00361 OPJ_RSIZ_CAPABILITIES cp_rsiz;
00363 char tp_on;
00365 char tp_flag;
00367 char tcp_mct;
00368 } opj_cparameters_t;
00369
00373 typedef struct opj_dparameters {
00381 int cp_reduce;
00388 int cp_layer;
00389
00393 char infile[OPJ_PATH_LEN];
00395 char outfile[OPJ_PATH_LEN];
00397 int decod_format;
00399 int cod_format;
00402
00406 bool jpwl_correct;
00408 int jpwl_exp_comps;
00410 int jpwl_max_tiles;
00412
00413
00420 OPJ_LIMIT_DECODING cp_limit_decoding;
00421
00422 } opj_dparameters_t;
00423
00426 #define opj_common_fields \
00427 opj_event_mgr_t *event_mgr; \
00428 void * client_data; \
00429 bool is_decompressor; \
00430 OPJ_CODEC_FORMAT codec_format; \
00431 void *j2k_handle; \
00432 void *jp2_handle; \
00433 void *mj2_handle
00435
00436
00437
00438
00439 typedef struct opj_common_struct {
00440 opj_common_fields;
00441
00442
00443
00444
00445 } opj_common_struct_t;
00446
00447 typedef opj_common_struct_t * opj_common_ptr;
00448
00452 typedef struct opj_cinfo {
00454 opj_common_fields;
00455
00456 } opj_cinfo_t;
00457
00461 typedef struct opj_dinfo {
00463 opj_common_fields;
00464
00465 } opj_dinfo_t;
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00477 #define OPJ_STREAM_READ 0x0001
00478
00479 #define OPJ_STREAM_WRITE 0x0002
00480
00484 typedef struct opj_cio {
00486 opj_common_ptr cinfo;
00487
00489 int openmode;
00491 unsigned char *buffer;
00493 int length;
00494
00496 unsigned char *start;
00498 unsigned char *end;
00500 unsigned char *bp;
00501 } opj_cio_t;
00502
00503
00504
00505
00506
00507
00508
00512 typedef struct opj_image_comp {
00514 int dx;
00516 int dy;
00518 int w;
00520 int h;
00522 int x0;
00524 int y0;
00526 int prec;
00528 int bpp;
00530 int sgnd;
00532 int resno_decoded;
00534 int factor;
00536 int *data;
00537 } opj_image_comp_t;
00538
00542 typedef struct opj_image {
00544 int x0;
00546 int y0;
00548 int x1;
00550 int y1;
00552 int numcomps;
00554 OPJ_COLOR_SPACE color_space;
00556 opj_image_comp_t *comps;
00557 } opj_image_t;
00558
00562 typedef struct opj_image_comptparm {
00564 int dx;
00566 int dy;
00568 int w;
00570 int h;
00572 int x0;
00574 int y0;
00576 int prec;
00578 int bpp;
00580 int sgnd;
00581 } opj_image_cmptparm_t;
00582
00583
00584
00585
00586
00587
00588
00592 typedef struct opj_packet_info {
00594 int start_pos;
00596 int end_ph_pos;
00598 int end_pos;
00600 double disto;
00601 } opj_packet_info_t;
00602
00606 typedef struct opj_tp_info {
00608 int tp_start_pos;
00610 int tp_end_header;
00612 int tp_end_pos;
00614 int tp_start_pack;
00616 int tp_numpacks;
00617 } opj_tp_info_t;
00618
00622 typedef struct opj_tile_info {
00624 double *thresh;
00626 int tileno;
00628 int start_pos;
00630 int end_header;
00632 int end_pos;
00634 int pw[33];
00636 int ph[33];
00638 int pdx[33];
00640 int pdy[33];
00642 opj_packet_info_t *packet;
00644 int numpix;
00646 double distotile;
00648 int num_tps;
00650 opj_tp_info_t *tp;
00651 } opj_tile_info_t;
00652
00653
00657 typedef struct opj_marker_info_t {
00659 unsigned short int type;
00661 int pos;
00663 int len;
00664 } opj_marker_info_t;
00665
00666
00670 typedef struct opj_codestream_info {
00672 double D_max;
00674 int packno;
00676 int index_write;
00678 int image_w;
00680 int image_h;
00682 OPJ_PROG_ORDER prog;
00684 int tile_x;
00686 int tile_y;
00688 int tile_Ox;
00690 int tile_Oy;
00692 int tw;
00694 int th;
00696 int numcomps;
00698 int numlayers;
00700 int *numdecompos;
00701
00703 int marknum;
00705 opj_marker_info_t *marker;
00707 int maxmarknum;
00708
00710 int main_head_start;
00712 int main_head_end;
00714 int codestream_size;
00716 opj_tile_info_t *tile;
00717 } opj_codestream_info_t;
00718
00719 #ifdef __cplusplus
00720 extern "C" {
00721 #endif
00722
00723
00724
00725
00726
00727
00728
00729
00730 OPJ_API const char * OPJ_CALLCONV opj_version(void);
00731
00732
00733
00734
00735
00736
00737
00745 OPJ_API opj_image_t* OPJ_CALLCONV opj_image_create(int numcmpts, opj_image_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
00746
00751 OPJ_API void OPJ_CALLCONV opj_image_destroy(opj_image_t *image);
00752
00753
00754
00755
00756
00757
00758
00770 OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
00771
00776 OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio);
00777
00783 OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio);
00789 OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
00790
00791
00792
00793
00794
00795
00796
00797 OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
00798
00799
00800
00801
00802
00803
00809 OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
00814 OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo);
00819 OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
00826 OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
00833 OPJ_API opj_image_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
00834
00842 OPJ_API opj_image_t* OPJ_CALLCONV opj_decode_with_info(opj_dinfo_t *dinfo, opj_cio_t *cio, opj_codestream_info_t *cstr_info);
00848 OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
00853 OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo);
00875 OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
00882 OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
00891 OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, char *index);
00900 OPJ_API bool OPJ_CALLCONV opj_encode_with_info(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
00905 OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
00906
00907 #ifdef __cplusplus
00908 }
00909 #endif
00910
00911 #endif