Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (c) 2001-2003, David Janssens
  3.  * Copyright (c) 2002-2003, Yannick Verschueren
  4.  * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
  5.  * Copyright (c) 2005, Hervé Drolon, FreeImage Team
  6.  * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
  7.  * Copyright (c) 2006, Mónica Díez García, Image Processing Laboratory, University of Valladolid, Spain
  8.  * All rights reserved.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Redistributions in binary form must reproduce the above copyright
  16.  *    notice, this list of conditions and the following disclaimer in the
  17.  *    documentation and/or other materials provided with the distribution.
  18.  *
  19.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
  20.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  23.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29.  * POSSIBILITY OF SUCH DAMAGE.
  30.  */
  31. #ifndef OPENJPEG_H
  32. #define OPENJPEG_H
  33.  
  34. /*
  35. ==========================================================
  36.    Compiler directives
  37. ==========================================================
  38. */
  39.  
  40. #if defined(OPJ_STATIC) || !(defined(WIN32) || defined(__WIN32__))
  41. #define OPJ_API
  42. #define OPJ_CALLCONV
  43. #else
  44. #define OPJ_CALLCONV __stdcall
  45. /*
  46. The following ifdef block is the standard way of creating macros which make exporting
  47. from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
  48. symbol defined on the command line. this symbol should not be defined on any project
  49. that uses this DLL. This way any other project whose source files include this file see
  50. OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
  51. defined with this macro as being exported.
  52. */
  53. #ifdef OPJ_EXPORTS
  54. #define OPJ_API __declspec(dllexport)
  55. #else
  56. #define OPJ_API __declspec(dllimport)
  57. #endif /* OPJ_EXPORTS */
  58. #endif /* !OPJ_STATIC || !WIN32 */
  59.  
  60. #ifndef __cplusplus
  61. #if defined(HAVE_STDBOOL_H)
  62. /*
  63. The C language implementation does correctly provide the standard header
  64. file "stdbool.h".
  65.  */
  66. #include <stdbool.h>
  67. #else
  68. /*
  69. The C language implementation does not provide the standard header file
  70. "stdbool.h" as required by ISO/IEC 9899:1999.  Try to compensate for this
  71. braindamage below.
  72. */
  73. #if !defined(bool)
  74. #define bool    int
  75. #endif
  76. #if !defined(true)
  77. #define true    1
  78. #endif
  79. #if !defined(false)
  80. #define false   0
  81. #endif
  82. #endif
  83. #endif /* __cplusplus */
  84.  
  85. /*
  86. ==========================================================
  87.    Useful constant definitions
  88. ==========================================================
  89. */
  90. #ifndef MAX_SLICES
  91. #define MAX_SLICES 300  /**< Maximum allowed size for slices */
  92. #endif /* MAX_PATH */
  93.  
  94. #ifndef MAX_PATH
  95. #define MAX_PATH 260    /**< Maximum allowed size for filenames */
  96. #endif /* MAX_PATH */
  97.  
  98. #define J3D_MAXRLVLS 32                                 /**< Number of maximum resolution level authorized */
  99. #define J3D_MAXBANDS (7*J3D_MAXRLVLS + 1)       /**< Number of maximum sub-band linked to number of resolution level */
  100.  
  101. #define TINY 1.0E-20
  102. /*
  103. ==========================================================
  104.    enum definitions
  105. ==========================================================
  106. */
  107.  
  108. #define J2K_CFMT 0
  109. #define J3D_CFMT 1
  110. #define LSE_CFMT 2
  111.  
  112. #define BIN_DFMT 0
  113. #define PGX_DFMT 1
  114. #define IMG_DFMT 2
  115. /* ----------------------------------------------------------------------- */
  116.  
  117. /** Progression order */
  118. typedef enum PROG_ORDER {
  119. /**< place-holder */   
  120.         PROG_UNKNOWN = -1,     
  121. /**< layer-resolution-component-precinct order */      
  122.         LRCP = 0,              
  123. /**< resolution-layer-component-precinct order */      
  124.         RLCP = 1,              
  125. /**< resolution-precinct-component-layer order */      
  126.         RPCL = 2,              
  127. /**< precinct-component-resolution-layer order */      
  128.         PCRL = 3,              
  129. /**< component-precinct-resolution-layer order */      
  130.         CPRL = 4               
  131. } OPJ_PROG_ORDER;
  132.  
  133. /**
  134. Supported volume color spaces
  135. */
  136. typedef enum COLOR_SPACE {
  137. /**< place-holder */   
  138.         CLRSPC_UNKNOWN = -1,   
  139. /**< sRGB */   
  140.         CLRSPC_SRGB = 1,               
  141. /**< grayscale */      
  142.         CLRSPC_GRAY = 2,               
  143. /**< YUV */    
  144.         CLRSPC_SYCC = 3                
  145. } OPJ_COLOR_SPACE;
  146.  
  147. /**
  148. Supported codec
  149. */
  150. typedef enum CODEC_FORMAT {
  151.         /**< place-holder */
  152.         CODEC_UNKNOWN = -1,
  153. /**< JPEG-2000 codestream : read/write */
  154.         CODEC_J2K = 0,         
  155. /**< JPEG-2000 Part 10 file format : read/write */
  156.         CODEC_J3D = 1          
  157. } OPJ_CODEC_FORMAT;
  158.  
  159. /**
  160. Supported entropy coding algorithms
  161. */
  162. typedef enum ENTROPY_CODING {
  163. /**< place-holder */
  164.         ENCOD_UNKNOWN = -1,
  165. /**< 2D EBCOT encoding */
  166.         ENCOD_2EB = 0,         
  167. /**< 3D EBCOT encoding */
  168.         ENCOD_3EB = 1,         
  169. /**< Golomb-Rice coding with 2D context */
  170.         ENCOD_2GR = 2,         
  171. /**< Golomb-Rice coding with 3D context  */
  172.         ENCOD_3GR = 3          
  173. } OPJ_ENTROPY_CODING;
  174.  
  175. /**
  176. Supported transforms
  177. */
  178. typedef enum TRANSFORM {
  179. /**< place-holder */
  180.         TRF_UNKNOWN = -1,      
  181. /**< 2D DWT, no transform in axial dim */
  182.         TRF_2D_DWT = 0,        
  183. /**< 3D DWT */
  184.         TRF_3D_DWT = 1,        
  185. /**< 3D prediction*/
  186.         TRF_3D_RLS = 2,        
  187.         TRF_3D_LSE = 3
  188. } OPJ_TRANSFORM;
  189. /*
  190. ==========================================================
  191.    event manager typedef definitions
  192. ==========================================================
  193. */
  194.  
  195. /**
  196. Callback function prototype for events
  197. @param msg Event message
  198. @param client_data
  199. */
  200. typedef void (*opj_msg_callback) (const char *msg, void *client_data);
  201.  
  202. /**
  203. Message handler object
  204. used for
  205. <ul>
  206. <li>Error messages
  207. <li>Warning messages
  208. <li>Debugging messages
  209. </ul>
  210. */
  211. typedef struct opj_event_mgr {
  212.         /** Error message callback if available, NULL otherwise */
  213.         opj_msg_callback error_handler;
  214.         /** Warning message callback if available, NULL otherwise */
  215.         opj_msg_callback warning_handler;
  216.         /** Debug message callback if available, NULL otherwise */
  217.         opj_msg_callback info_handler;
  218. } opj_event_mgr_t;
  219.  
  220.  
  221. /*
  222. ==========================================================
  223.    codec typedef definitions
  224. ==========================================================
  225. */
  226.  
  227. /**
  228. Progression order changes
  229. */
  230. typedef struct opj_poc {
  231.   int resno0, compno0;
  232.   int layno1, resno1, compno1;
  233.   OPJ_PROG_ORDER prg;
  234.   int tile;
  235.   char progorder[4];
  236. } opj_poc_t;
  237.  
  238.  
  239. /**
  240. Compression parameters
  241. */
  242. typedef struct opj_cparameters {
  243. /** size of tile: tile_size_on = false (not in argument) or = true (in argument) */
  244.         bool tile_size_on;     
  245. /** XTOsiz */
  246.         int cp_tx0;
  247. /** YTOsiz */
  248.         int cp_ty0;    
  249. /** ZTOsiz */
  250.         int cp_tz0;            
  251.  
  252. /** XTsiz */
  253.         int cp_tdx;    
  254. /** YTsiz */
  255.         int cp_tdy;    
  256. /** ZTsiz */
  257.         int cp_tdz;            
  258.                                                        
  259. /** allocation by rate/distortion */
  260.         int cp_disto_alloc;            
  261. /** allocation by fixed layer */               
  262.         int cp_fixed_alloc;            
  263. /** add fixed_quality */       
  264.         int cp_fixed_quality;  
  265. /** fixed layer */
  266.         int *cp_matrice;
  267. /** number of layers */
  268.         int tcp_numlayers;
  269. /** rates for successive layers */
  270.         float tcp_rates[100];
  271. /** psnr's for successive layers */
  272.         float tcp_distoratio[100];     
  273. /** comment for coding */
  274.         char *cp_comment;
  275. /** csty : coding style */
  276.         int csty;                                      
  277. /** DC offset (DCO) */
  278.         int dcoffset;
  279. /** progression order (default LRCP) */
  280.         OPJ_PROG_ORDER prog_order;     
  281. /** progression order changes */
  282.         opj_poc_t POC[J3D_MAXRLVLS-1]; 
  283. /** number of progression order changes (POC), default to 0 */
  284.         int numpocs;                           
  285.  
  286. /** number of resolutions */
  287.         int numresolution[3];          
  288. /** initial code block width, height and depth, default to 64 */
  289.         int cblock_init[3];                    
  290. /** mode switch (1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL) 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)) */
  291.         int mode;                                      
  292.  
  293. /** 1 : use the irreversible DWT 9-7, 0 : use lossless compression (default) */
  294.         int irreversible;                      
  295. /** WT from ATK, default to 0 (false), no of atk used */
  296.         int atk_wt[3];
  297. /** region of interest: affected component in [0..3], -1 means no ROI */
  298.         int roi_compno;                        
  299. /** region of interest: upshift value */
  300.         int roi_shift;                         
  301.  
  302. /* number of precinct size specifications */
  303.         int res_spec;                          
  304. /** initial precinct width */
  305.         int prct_init[3][J3D_MAXRLVLS];
  306.  
  307. /** transform format 0: 0: 2DWT, 1: 2D1P, 2: 3DWT, 3: 3RLS */
  308.         OPJ_TRANSFORM transform_format;
  309. /** output file format 0: 2EB, 1: 3EB, 2: 2GR, 3: 3GR, 4: GRI */
  310.         OPJ_ENTROPY_CODING encoding_format;    
  311.  
  312.         /**@name command line encoder parameters (not used inside the library) */
  313.         /*@{*/
  314.         char infile[MAX_PATH];          /** input file name */
  315.         char outfile[MAX_PATH];         /** output file name */
  316.         char imgfile[MAX_PATH];         /** IMG file name for BIN volumes*/
  317.         int index_on;                           /** creation of an index file, default to 0 (false) */
  318.         char index[MAX_PATH];           /** index file name */
  319.        
  320.         int volume_offset_x0;           /** subvolume encoding: origin volume offset in x, y and z direction */
  321.         int volume_offset_y0;
  322.         int volume_offset_z0;
  323.        
  324.         int subsampling_dx;                     /** subsampling value for dx */
  325.         int subsampling_dy;
  326.         int subsampling_dz;
  327.        
  328.         int decod_format;                       /** input file format 0: BIN, 1: PGX */
  329.         int cod_format;                         /** output file format 0: JP3D */
  330.         /*@}*/
  331. } opj_cparameters_t;
  332.  
  333. /**
  334. Decompression parameters
  335. */
  336. typedef struct opj_dparameters {
  337. /** Set the number of highest resolution levels to be discarded. if != 0, then original dimension divided by 2^(reduce); if == 0 or not used, volume is decoded to the full resolution */
  338.         int cp_reduce[3];              
  339. /** Set the maximum number of quality layers to decode. if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded        */
  340.         int cp_layer;  
  341.         int bigendian;
  342.        
  343.         /**@name command line encoder parameters (not used inside the library) */
  344.         /*@{*/
  345. /** input file name */
  346.         char infile[MAX_PATH]; 
  347. /** output file name */
  348.         char outfile[MAX_PATH];
  349. /** IMG file name for BIN volumes*/
  350.         char imgfile[MAX_PATH];
  351. /** Original file name for PSNR measures*/
  352.         char original[MAX_PATH];
  353. /** input file format 0: J2K, 1: JP3D */
  354.         int decod_format;              
  355. /** input file format 0: BIN, 1: PGM */
  356.         int cod_format;
  357. /** original file format 0: BIN, 1: PGM */
  358.         int orig_format;       
  359.         /*@}*/
  360. } opj_dparameters_t;
  361.  
  362. /** Common fields between JPEG-2000 compression and decompression master structs. */
  363. #define opj_common_fields \
  364.         opj_event_mgr_t *event_mgr;     /**< pointer to the event manager */\
  365.         void * client_data;                     /**< Available for use by application */\
  366.         bool is_decompressor;           /**< So common code can tell which is which */\
  367.         OPJ_CODEC_FORMAT codec_format;          /**< selected codec */\
  368.         OPJ_ENTROPY_CODING encoding_format;     /**< selected entropy coding */\
  369.         OPJ_TRANSFORM transform_format;         /**< selected transform */\
  370.         void *j3d_handle                        /**< pointer to the J3D codec */
  371.        
  372. /* Routines that are to be used by both halves of the library are declared
  373.  * to receive a pointer to this structure.  There are no actual instances of
  374.  * opj_common_struct_t, only of opj_cinfo_t and opj_dinfo_t.
  375.  */
  376. typedef struct opj_common_struct {
  377.   opj_common_fields;            /* Fields common to both master struct types */
  378.   /* Additional fields follow in an actual opj_cinfo_t or
  379.    * opj_dinfo_t.  All three structs must agree on these
  380.    * initial fields!  (This would be a lot cleaner in C++.)
  381.    */
  382. } opj_common_struct_t;
  383.  
  384. typedef opj_common_struct_t * opj_common_ptr;
  385.  
  386. /**
  387. Compression context info
  388. */
  389. typedef struct opj_cinfo {
  390.         /** Fields shared with opj_dinfo_t */
  391.         opj_common_fields;     
  392.         /* other specific fields go here */
  393. } opj_cinfo_t;
  394.  
  395. /**
  396. Decompression context info
  397. */
  398. typedef struct opj_dinfo {
  399.         /** Fields shared with opj_cinfo_t */
  400.         opj_common_fields;     
  401.         /* other specific fields go here */
  402. } opj_dinfo_t;
  403.  
  404. /*
  405. ==========================================================
  406.    I/O stream typedef definitions
  407. ==========================================================
  408. */
  409.  
  410. /*
  411.  * Stream open flags.
  412.  */
  413. /** The stream was opened for reading. */
  414. #define OPJ_STREAM_READ 0x0001
  415. /** The stream was opened for writing. */
  416. #define OPJ_STREAM_WRITE 0x0002
  417.  
  418. /**
  419. Byte input-output stream (CIO)
  420. */
  421. typedef struct opj_cio {
  422. /** codec context */
  423.         opj_common_ptr cinfo;  
  424. /** open mode (read/write) either OPJ_STREAM_READ or OPJ_STREAM_WRITE */
  425.         int openmode;                  
  426. /** pointer to the start of the buffer */
  427.         unsigned char *buffer; 
  428. /** buffer size in bytes */
  429.         int length;                            
  430. /** pointer to the start of the stream */
  431.         unsigned char *start;          
  432. /** pointer to the end of the stream */
  433.         unsigned char *end;                    
  434. /** pointer to the current position */
  435.         unsigned char *bp;                     
  436. } opj_cio_t;
  437.  
  438. /*
  439. ==========================================================
  440.    volume typedef definitions
  441. ==========================================================
  442. */
  443.  
  444. /**
  445. Defines a single volume component
  446. */
  447. typedef struct opj_volume_comp {
  448. /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
  449.         int dx;
  450. /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
  451.         int dy;
  452. /** ZRsiz: vertical separation of a sample of ith component with respect to the reference grid */
  453.         int dz;
  454. /** data width */
  455.         int w; 
  456.         /** data height */
  457.         int h; 
  458.         /** data length : no of slices */
  459.         int l; 
  460.         /** x component offset compared to the whole volume */
  461.         int x0;
  462.         /** y component offset compared to the whole volume */
  463.         int y0;
  464.         /** z component offset compared to the whole volume */
  465.         int z0;
  466.         /** precision */
  467.         int prec;      
  468.         /** volume depth in bits */
  469.         int bpp;       
  470.         /** DC offset (15444-2) */
  471.         int dcoffset;
  472.         /** signed (1) / unsigned (0) */
  473.         int sgnd;              
  474.         /** BE byte order (1) / LE byte order  (0) */
  475.         int bigendian;
  476.         /** number of decoded resolution */
  477.         int resno_decoded[3];  
  478.         /** number of division by 2 of the out volume compared to the original size of volume */
  479.         int factor[3]; 
  480.         /** volume component data */
  481.         int *data;                             
  482. } opj_volume_comp_t;
  483.  
  484. /**
  485. Defines volume data and characteristics
  486. */
  487. typedef struct opj_volume {
  488. /** XOsiz: horizontal offset from the origin of the reference grid to the left side of the volume area */
  489.         int x0;
  490. /** YOsiz: vertical offset from the origin of the reference grid to the top side of the volume area */
  491.         int y0;
  492. /** ZOsiz: vertical offset from the origin of the reference grid to the top side of the volume area */
  493.         int z0;
  494. /** Xsiz: width of the reference grid */
  495.         int x1;
  496. /** Ysiz: height of the reference grid */
  497.         int y1;
  498. /** Zsiz: length of the reference grid */
  499.         int z1;
  500. /** number of components in the volume */
  501.         int numcomps;  
  502. /** number of slices in the volume */
  503.         int numslices; 
  504. /** color space: sRGB, Greyscale or YUV */
  505.         OPJ_COLOR_SPACE color_space;
  506. /** volume components */
  507.         opj_volume_comp_t *comps;      
  508. } opj_volume_t;
  509.  
  510. /**
  511. Component parameters structure used by the opj_volume_create function
  512. */
  513. typedef struct opj_volume_comptparm {
  514.         /** XRsiz: horizontal separation of a sample of ith component with respect to the reference grid */
  515.         int dx;
  516.         /** YRsiz: vertical separation of a sample of ith component with respect to the reference grid */
  517.         int dy;
  518.         /** ZRsiz: axial separation of a sample of ith component with respect to the reference grid */
  519.         int dz;
  520.         /** data width */
  521.         int w; 
  522.         /** data height */
  523.         int h; 
  524.         /** data length */
  525.         int l; 
  526.         /** x component offset compared to the whole volume */
  527.         int x0;
  528.         /** y component offset compared to the whole volume */
  529.         int y0;
  530.         /** z component offset compared to the whole volume */
  531.         int z0;
  532.         /** precision */
  533.         int prec;
  534.         /** volume depth in bits */
  535.         int bpp;       
  536.         /** signed (1) / unsigned (0) */
  537.         int sgnd;
  538.         /** DC offset*/
  539.         int dcoffset;
  540.         /** BE byte order (1) / LE byte order  (0) */
  541.         int bigendian;
  542. } opj_volume_cmptparm_t;
  543.  
  544. #ifdef __cplusplus
  545. extern "C" {
  546. #endif
  547.  
  548.  
  549. /*
  550. ==========================================================
  551.    openjpeg version
  552. ==========================================================
  553. */
  554.  
  555. OPJ_API const char * OPJ_CALLCONV opj_version();
  556.  
  557. /*
  558. ==========================================================
  559.    volume functions definitions
  560. ==========================================================
  561. */
  562.  
  563. /**
  564. Create an volume
  565. @param numcmpts number of components
  566. @param cmptparms components parameters
  567. @param clrspc volume color space
  568. @return returns a new volume structure if successful, returns NULL otherwise
  569. */
  570. OPJ_API opj_volume_t* OPJ_CALLCONV opj_volume_create(int numcmpts, opj_volume_cmptparm_t *cmptparms, OPJ_COLOR_SPACE clrspc);
  571.  
  572. /**
  573. Deallocate any resources associated with an volume
  574. @param volume volume to be destroyed
  575. */
  576. OPJ_API void OPJ_CALLCONV opj_volume_destroy(opj_volume_t *volume);
  577.  
  578. /*
  579. ==========================================================
  580.    stream functions definitions
  581. ==========================================================
  582. */
  583.  
  584. /**
  585. Open and allocate a memory stream for read / write.
  586. On reading, the user must provide a buffer containing encoded data. The buffer will be
  587. wrapped by the returned CIO handle.
  588. On writing, buffer parameters must be set to 0: a buffer will be allocated by the library
  589. to contain encoded data.
  590. @param cinfo Codec context info
  591. @param buffer Reading: buffer address. Writing: NULL
  592. @param length Reading: buffer length. Writing: 0
  593. @return Returns a CIO handle if successful, returns NULL otherwise
  594. */
  595. OPJ_API opj_cio_t* OPJ_CALLCONV opj_cio_open(opj_common_ptr cinfo, unsigned char *buffer, int length);
  596.  
  597. /**
  598. Close and free a CIO handle
  599. @param cio CIO handle to free
  600. */
  601. OPJ_API void OPJ_CALLCONV opj_cio_close(opj_cio_t *cio);
  602.  
  603. /**
  604. Get position in byte stream
  605. @param cio CIO handle
  606. @return Returns the position in bytes
  607. */
  608. OPJ_API int OPJ_CALLCONV cio_tell(opj_cio_t *cio);
  609. /**
  610. Set position in byte stream
  611. @param cio CIO handle
  612. @param pos Position, in number of bytes, from the beginning of the stream
  613. */
  614. OPJ_API void OPJ_CALLCONV cio_seek(opj_cio_t *cio, int pos);
  615.  
  616. /*
  617. ==========================================================
  618.    event manager functions definitions
  619. ==========================================================
  620. */
  621.  
  622. OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context);
  623.  
  624. /*
  625. ==========================================================
  626.    codec functions definitions
  627. ==========================================================
  628. */
  629. /**
  630. Creates a J3D decompression structure
  631. @param format Decoder to select
  632. @return Returns a handle to a decompressor if successful, returns NULL otherwise
  633. */
  634. OPJ_API opj_dinfo_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT format);
  635. /**
  636. Destroy a decompressor handle
  637. @param dinfo decompressor handle to destroy
  638. */
  639. OPJ_API void OPJ_CALLCONV opj_destroy_decompress(opj_dinfo_t *dinfo);
  640. /**
  641. Set decoding parameters to default values
  642. @param parameters Decompression parameters
  643. */
  644. OPJ_API void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *parameters);
  645. /**
  646. Setup the decoder decoding parameters using user parameters.
  647. Decoding parameters are returned in j3d->cp.
  648. @param dinfo decompressor handle
  649. @param parameters decompression parameters
  650. */
  651. OPJ_API void OPJ_CALLCONV opj_setup_decoder(opj_dinfo_t *dinfo, opj_dparameters_t *parameters);
  652. /**
  653. Decode an volume from a JPEG-2000 codestream
  654. @param dinfo decompressor handle
  655. @param cio Input buffer stream
  656. @return Returns a decoded volume if successful, returns NULL otherwise
  657. */
  658. OPJ_API opj_volume_t* OPJ_CALLCONV opj_decode(opj_dinfo_t *dinfo, opj_cio_t *cio);
  659. /**
  660. Creates a J3D/JP2 compression structure
  661. @param format Coder to select
  662. @return Returns a handle to a compressor if successful, returns NULL otherwise
  663. */
  664. OPJ_API opj_cinfo_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT format);
  665. /**
  666. Destroy a compressor handle
  667. @param cinfo compressor handle to destroy
  668. */
  669. OPJ_API void OPJ_CALLCONV opj_destroy_compress(opj_cinfo_t *cinfo);
  670. /**
  671. Set encoding parameters to default values, that means :
  672. <ul>
  673. <li>Lossless
  674. <li>1 tile
  675. <li>Size of precinct : 2^15 x 2^15 (means 1 precinct)
  676. <li>Size of code-block : 64 x 64
  677. <li>Number of resolutions: 6
  678. <li>No SOP marker in the codestream
  679. <li>No EPH marker in the codestream
  680. <li>No sub-sampling in x or y direction
  681. <li>No mode switch activated
  682. <li>Progression order: LRCP
  683. <li>No index file
  684. <li>No ROI upshifted
  685. <li>No offset of the origin of the volume
  686. <li>No offset of the origin of the tiles
  687. <li>Reversible DWT 5-3
  688. </ul>
  689. @param parameters Compression parameters
  690. */
  691. OPJ_API void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *parameters);
  692. /**
  693. Setup the encoder parameters using the current volume and using user parameters.
  694. @param cinfo compressor handle
  695. @param parameters compression parameters
  696. @param volume input filled volume
  697. */
  698. OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_volume_t *volume);
  699. /**
  700. Encode an volume into a JPEG-2000 codestream
  701. @param cinfo compressor handle
  702. @param cio Output buffer stream
  703. @param volume Volume to encode
  704. @param index Name of the index file if required, NULL otherwise
  705. @return Returns true if successful, returns false otherwise
  706. */
  707. OPJ_API bool OPJ_CALLCONV opj_encode(opj_cinfo_t *cinfo, opj_cio_t *cio, opj_volume_t *volume, char *index);
  708.  
  709. #ifdef __cplusplus
  710. }
  711. #endif
  712.  
  713. #endif /* OPENJPEG_H */
  714.