pi.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
  3. * Copyright (c) 2002-2007, Professor Benoit Macq
  4. * Copyright (c) 2001-2003, David Janssens
  5. * Copyright (c) 2002-2003, Yannick Verschueren
  6. * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
  7. * Copyright (c) 2005, Herve Drolon, FreeImage Team
  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 __PI_H
  32. #define __PI_H
  33. /**
  34. @file pi.h
  35. @brief Implementation of a packet iterator (PI)
  36. The functions in PI.C have for goal to realize a packet iterator that permits to get the next
  37. packet following the progression order and change of it. The functions in PI.C are used
  38. by some function in T2.C.
  39. */
  40. /** @defgroup PI PI - Implementation of a packet iterator */
  41. /*@{*/
  42. /**
  43. FIXME: documentation
  44. */
  45. typedef struct opj_pi_resolution {
  46. int pdx, pdy;
  47. int pw, ph;
  48. } opj_pi_resolution_t;
  49. /**
  50. FIXME: documentation
  51. */
  52. typedef struct opj_pi_comp {
  53. int dx, dy;
  54. /** number of resolution levels */
  55. int numresolutions;
  56. opj_pi_resolution_t *resolutions;
  57. } opj_pi_comp_t;
  58. /**
  59. Packet iterator
  60. */
  61. typedef struct opj_pi_iterator {
  62. /** Enabling Tile part generation*/
  63. char tp_on;
  64. /** precise if the packet has been already used (usefull for progression order change) */
  65. short int *include;
  66. /** layer step used to localize the packet in the include vector */
  67. int step_l;
  68. /** resolution step used to localize the packet in the include vector */
  69. int step_r;
  70. /** component step used to localize the packet in the include vector */
  71. int step_c;
  72. /** precinct step used to localize the packet in the include vector */
  73. int step_p;
  74. /** component that identify the packet */
  75. int compno;
  76. /** resolution that identify the packet */
  77. int resno;
  78. /** precinct that identify the packet */
  79. int precno;
  80. /** layer that identify the packet */
  81. int layno;
  82. /** 0 if the first packet */
  83. int first;
  84. /** progression order change information */
  85. opj_poc_t poc;
  86. /** number of components in the image */
  87. int numcomps;
  88. /** Components*/
  89. opj_pi_comp_t *comps;
  90. int tx0, ty0, tx1, ty1;
  91. int x, y, dx, dy;
  92. } opj_pi_iterator_t;
  93. /** @name Exported functions */
  94. /*@{*/
  95. /* ----------------------------------------------------------------------- */
  96. /**
  97. Create a packet iterator for Encoder
  98. @param image Raw image for which the packets will be listed
  99. @param cp Coding parameters
  100. @param tileno Number that identifies the tile for which to list the packets
  101. @param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
  102. @return Returns a packet iterator that points to the first packet of the tile
  103. @see pi_destroy
  104. */
  105. opj_pi_iterator_t *pi_initialise_encode(opj_image_t *image, opj_cp_t *cp, int tileno,J2K_T2_MODE t2_mode);
  106. /**
  107. Modify the packet iterator for enabling tile part generation
  108. @param pi Handle to the packet iterator generated in pi_initialise_encode
  109. @param cp Coding parameters
  110. @param tileno Number that identifies the tile for which to list the packets
  111. @param pino Iterator index for pi
  112. @param tpnum Tile part number of the current tile
  113. @param tppos The position of the tile part flag in the progression order
  114. @param t2_mode If == 0 In Threshold calculation ,If == 1 Final pass
  115. @param cur_totnum_tp The total number of tile parts in the current tile
  116. @return Returns true if an error is detected
  117. */
  118. opj_bool pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode,int cur_totnum_tp);
  119. /**
  120. Create a packet iterator for Decoder
  121. @param image Raw image for which the packets will be listed
  122. @param cp Coding parameters
  123. @param tileno Number that identifies the tile for which to list the packets
  124. @return Returns a packet iterator that points to the first packet of the tile
  125. @see pi_destroy
  126. */
  127. opj_pi_iterator_t *pi_create_decode(opj_image_t * image, opj_cp_t * cp, int tileno);
  128. /**
  129. Destroy a packet iterator
  130. @param pi Previously created packet iterator
  131. @param cp Coding parameters
  132. @param tileno Number that identifies the tile for which the packets were listed
  133. @see pi_create
  134. */
  135. void pi_destroy(opj_pi_iterator_t *pi, opj_cp_t *cp, int tileno);
  136. /**
  137. Modify the packet iterator to point to the next packet
  138. @param pi Packet iterator to modify
  139. @return Returns false if pi pointed to the last packet or else returns true
  140. */
  141. opj_bool pi_next(opj_pi_iterator_t * pi);
  142. /* ----------------------------------------------------------------------- */
  143. /*@}*/
  144. /*@}*/
  145. #endif /* __PI_H */