opj_codec.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  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.
  6. *
  7. * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium
  8. * Copyright (c) 2002-2014, Professor Benoit Macq
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  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.
  19. *
  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.
  31. */
  32. #ifndef OPJ_CODEC_H
  33. #define OPJ_CODEC_H
  34. /**
  35. @file opj_codec.h
  36. */
  37. /**
  38. * Main codec handler used for compression or decompression.
  39. */
  40. typedef struct opj_codec_private {
  41. /** FIXME DOC */
  42. union {
  43. /**
  44. * Decompression handler.
  45. */
  46. struct opj_decompression {
  47. /** Main header reading function handler */
  48. OPJ_BOOL(*opj_read_header)(struct opj_stream_private * cio,
  49. void * p_codec,
  50. opj_image_t **p_image,
  51. struct opj_event_mgr * p_manager);
  52. /** Decoding function */
  53. OPJ_BOOL(*opj_decode)(void * p_codec,
  54. struct opj_stream_private * p_cio,
  55. opj_image_t * p_image,
  56. struct opj_event_mgr * p_manager);
  57. /** FIXME DOC */
  58. OPJ_BOOL(*opj_read_tile_header)(void * p_codec,
  59. OPJ_UINT32 * p_tile_index,
  60. OPJ_UINT32 * p_data_size,
  61. OPJ_INT32 * p_tile_x0,
  62. OPJ_INT32 * p_tile_y0,
  63. OPJ_INT32 * p_tile_x1,
  64. OPJ_INT32 * p_tile_y1,
  65. OPJ_UINT32 * p_nb_comps,
  66. OPJ_BOOL * p_should_go_on,
  67. struct opj_stream_private * p_cio,
  68. struct opj_event_mgr * p_manager);
  69. /** FIXME DOC */
  70. OPJ_BOOL(*opj_decode_tile_data)(void * p_codec,
  71. OPJ_UINT32 p_tile_index,
  72. OPJ_BYTE * p_data,
  73. OPJ_UINT32 p_data_size,
  74. struct opj_stream_private * p_cio,
  75. struct opj_event_mgr * p_manager);
  76. /** Reading function used after codestream if necessary */
  77. OPJ_BOOL(* opj_end_decompress)(void *p_codec,
  78. struct opj_stream_private * cio,
  79. struct opj_event_mgr * p_manager);
  80. /** Codec destroy function handler */
  81. void (*opj_destroy)(void * p_codec);
  82. /** Setup decoder function handler */
  83. void (*opj_setup_decoder)(void * p_codec, opj_dparameters_t * p_param);
  84. /** Strict mode function handler */
  85. void (*opj_decoder_set_strict_mode)(void * p_codec, OPJ_BOOL strict);
  86. /** Set decode area function handler */
  87. OPJ_BOOL(*opj_set_decode_area)(void * p_codec,
  88. opj_image_t * p_image,
  89. OPJ_INT32 p_start_x,
  90. OPJ_INT32 p_end_x,
  91. OPJ_INT32 p_start_y,
  92. OPJ_INT32 p_end_y,
  93. struct opj_event_mgr * p_manager);
  94. /** Get tile function */
  95. OPJ_BOOL(*opj_get_decoded_tile)(void *p_codec,
  96. opj_stream_private_t * p_cio,
  97. opj_image_t *p_image,
  98. struct opj_event_mgr * p_manager,
  99. OPJ_UINT32 tile_index);
  100. /** Set the decoded resolution factor */
  101. OPJ_BOOL(*opj_set_decoded_resolution_factor)(void * p_codec,
  102. OPJ_UINT32 res_factor,
  103. opj_event_mgr_t * p_manager);
  104. /** Set the decoded components */
  105. OPJ_BOOL(*opj_set_decoded_components)(void * p_codec,
  106. OPJ_UINT32 num_comps,
  107. const OPJ_UINT32* comps_indices,
  108. opj_event_mgr_t * p_manager);
  109. } m_decompression;
  110. /**
  111. * Compression handler. FIXME DOC
  112. */
  113. struct opj_compression {
  114. OPJ_BOOL(* opj_start_compress)(void *p_codec,
  115. struct opj_stream_private * cio,
  116. struct opj_image * p_image,
  117. struct opj_event_mgr * p_manager);
  118. OPJ_BOOL(* opj_encode)(void * p_codec,
  119. struct opj_stream_private *p_cio,
  120. struct opj_event_mgr * p_manager);
  121. OPJ_BOOL(* opj_write_tile)(void * p_codec,
  122. OPJ_UINT32 p_tile_index,
  123. OPJ_BYTE * p_data,
  124. OPJ_UINT32 p_data_size,
  125. struct opj_stream_private * p_cio,
  126. struct opj_event_mgr * p_manager);
  127. OPJ_BOOL(* opj_end_compress)(void * p_codec,
  128. struct opj_stream_private * p_cio,
  129. struct opj_event_mgr * p_manager);
  130. void (* opj_destroy)(void * p_codec);
  131. OPJ_BOOL(* opj_setup_encoder)(void * p_codec,
  132. opj_cparameters_t * p_param,
  133. struct opj_image * p_image,
  134. struct opj_event_mgr * p_manager);
  135. OPJ_BOOL(* opj_encoder_set_extra_options)(void * p_codec,
  136. const char* const* p_options,
  137. struct opj_event_mgr * p_manager);
  138. } m_compression;
  139. } m_codec_data;
  140. /** FIXME DOC*/
  141. void * m_codec;
  142. /** Event handler */
  143. opj_event_mgr_t m_event_mgr;
  144. /** Flag to indicate if the codec is used to decode or encode*/
  145. OPJ_BOOL is_decompressor;
  146. void (*opj_dump_codec)(void * p_codec, OPJ_INT32 info_flag,
  147. FILE* output_stream);
  148. opj_codestream_info_v2_t* (*opj_get_codec_info)(void* p_codec);
  149. opj_codestream_index_t* (*opj_get_codec_index)(void* p_codec);
  150. /** Set number of threads */
  151. OPJ_BOOL(*opj_set_threads)(void * p_codec, OPJ_UINT32 num_threads);
  152. }
  153. opj_codec_private_t;
  154. #endif /* OPJ_CODEC_H */