pi.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. * Copyright (c) 2001-2003, David Janssens
  10. * Copyright (c) 2002-2003, Yannick Verschueren
  11. * Copyright (c) 2003-2007, Francois-Olivier Devaux
  12. * Copyright (c) 2003-2014, Antonin Descampe
  13. * Copyright (c) 2005, Herve Drolon, FreeImage Team
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted provided that the following conditions
  18. * are met:
  19. * 1. Redistributions of source code must retain the above copyright
  20. * notice, this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright
  22. * notice, this list of conditions and the following disclaimer in the
  23. * documentation and/or other materials provided with the distribution.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  29. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  35. * POSSIBILITY OF SUCH DAMAGE.
  36. */
  37. #ifndef OPJ_PI_H
  38. #define OPJ_PI_H
  39. /**
  40. @file pi.h
  41. @brief Implementation of a packet iterator (PI)
  42. The functions in PI.C have for goal to realize a packet iterator that permits to get the next
  43. packet following the progression order and change of it. The functions in PI.C are used
  44. by some function in T2.C.
  45. */
  46. /** @defgroup PI PI - Implementation of a packet iterator */
  47. /*@{*/
  48. /**
  49. FIXME DOC
  50. */
  51. typedef struct opj_pi_resolution {
  52. OPJ_UINT32 pdx, pdy;
  53. OPJ_UINT32 pw, ph;
  54. } opj_pi_resolution_t;
  55. /**
  56. FIXME DOC
  57. */
  58. typedef struct opj_pi_comp {
  59. OPJ_UINT32 dx, dy;
  60. /** number of resolution levels */
  61. OPJ_UINT32 numresolutions;
  62. opj_pi_resolution_t *resolutions;
  63. } opj_pi_comp_t;
  64. /**
  65. Packet iterator
  66. */
  67. typedef struct opj_pi_iterator {
  68. /** Enabling Tile part generation*/
  69. OPJ_BYTE tp_on;
  70. /** precise if the packet has been already used (useful for progression order change) */
  71. OPJ_INT16 *include;
  72. /** Number of elements in include array */
  73. OPJ_UINT32 include_size;
  74. /** layer step used to localize the packet in the include vector */
  75. OPJ_UINT32 step_l;
  76. /** resolution step used to localize the packet in the include vector */
  77. OPJ_UINT32 step_r;
  78. /** component step used to localize the packet in the include vector */
  79. OPJ_UINT32 step_c;
  80. /** precinct step used to localize the packet in the include vector */
  81. OPJ_UINT32 step_p;
  82. /** component that identify the packet */
  83. OPJ_UINT32 compno;
  84. /** resolution that identify the packet */
  85. OPJ_UINT32 resno;
  86. /** precinct that identify the packet */
  87. OPJ_UINT32 precno;
  88. /** layer that identify the packet */
  89. OPJ_UINT32 layno;
  90. /** 0 if the first packet */
  91. OPJ_BOOL first;
  92. /** progression order change information */
  93. opj_poc_t poc;
  94. /** number of components in the image */
  95. OPJ_UINT32 numcomps;
  96. /** Components*/
  97. opj_pi_comp_t *comps;
  98. /** FIXME DOC*/
  99. OPJ_UINT32 tx0, ty0, tx1, ty1;
  100. /** FIXME DOC*/
  101. OPJ_UINT32 x, y;
  102. /** FIXME DOC*/
  103. OPJ_UINT32 dx, dy;
  104. /** event manager */
  105. opj_event_mgr_t* manager;
  106. } opj_pi_iterator_t;
  107. /** @name Exported functions */
  108. /*@{*/
  109. /* ----------------------------------------------------------------------- */
  110. /**
  111. * Creates a packet iterator for encoding.
  112. *
  113. * @param image the image being encoded.
  114. * @param cp the coding parameters.
  115. * @param tileno index of the tile being encoded.
  116. * @param t2_mode the type of pass for generating the packet iterator
  117. * @param manager Event manager
  118. *
  119. * @return a list of packet iterator that points to the first packet of the tile (not true).
  120. */
  121. opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *image,
  122. opj_cp_t *cp,
  123. OPJ_UINT32 tileno,
  124. J2K_T2_MODE t2_mode,
  125. opj_event_mgr_t* manager);
  126. /**
  127. * Updates the encoding parameters of the codec.
  128. *
  129. * @param p_image the image being encoded.
  130. * @param p_cp the coding parameters.
  131. * @param p_tile_no index of the tile being encoded.
  132. */
  133. void opj_pi_update_encoding_parameters(const opj_image_t *p_image,
  134. opj_cp_t *p_cp,
  135. OPJ_UINT32 p_tile_no);
  136. /**
  137. Modify the packet iterator for enabling tile part generation
  138. @param pi Handle to the packet iterator generated in pi_initialise_encode
  139. @param cp Coding parameters
  140. @param tileno Number that identifies the tile for which to list the packets
  141. @param pino FIXME DOC
  142. @param tpnum Tile part number of the current tile
  143. @param tppos The position of the tile part flag in the progression order
  144. @param t2_mode FIXME DOC
  145. */
  146. void opj_pi_create_encode(opj_pi_iterator_t *pi,
  147. opj_cp_t *cp,
  148. OPJ_UINT32 tileno,
  149. OPJ_UINT32 pino,
  150. OPJ_UINT32 tpnum,
  151. OPJ_INT32 tppos,
  152. J2K_T2_MODE t2_mode);
  153. /**
  154. Create a packet iterator for Decoder
  155. @param image Raw image for which the packets will be listed
  156. @param cp Coding parameters
  157. @param tileno Number that identifies the tile for which to list the packets
  158. @param manager Event manager
  159. @return Returns a packet iterator that points to the first packet of the tile
  160. @see opj_pi_destroy
  161. */
  162. opj_pi_iterator_t *opj_pi_create_decode(opj_image_t * image,
  163. opj_cp_t * cp,
  164. OPJ_UINT32 tileno,
  165. opj_event_mgr_t* manager);
  166. /**
  167. * Destroys a packet iterator array.
  168. *
  169. * @param p_pi the packet iterator array to destroy.
  170. * @param p_nb_elements the number of elements in the array.
  171. */
  172. void opj_pi_destroy(opj_pi_iterator_t *p_pi,
  173. OPJ_UINT32 p_nb_elements);
  174. /**
  175. Modify the packet iterator to point to the next packet
  176. @param pi Packet iterator to modify
  177. @return Returns false if pi pointed to the last packet or else returns true
  178. */
  179. OPJ_BOOL opj_pi_next(opj_pi_iterator_t * pi);
  180. /**
  181. * Return the number of packets in the tile.
  182. * @param image the image being encoded.
  183. * @param cp Coding parameters
  184. * @param tileno Number that identifies the tile.
  185. */
  186. OPJ_UINT32 opj_get_encoding_packet_count(const opj_image_t *p_image,
  187. const opj_cp_t *p_cp,
  188. OPJ_UINT32 p_tile_no);
  189. /* ----------------------------------------------------------------------- */
  190. /*@}*/
  191. /*@}*/
  192. #endif /* OPJ_PI_H */