/* * The copyright in this software is being made available under the 2-clauses * BSD License, included below. This software may be subject to other third * party and contributor rights, including patent rights, and no such rights * are granted under this license. * * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium * Copyright (c) 2002-2014, Professor Benoit Macq * Copyright (c) 2001-2003, David Janssens * Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2003-2007, Francois-Olivier Devaux * Copyright (c) 2003-2014, Antonin Descampe * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2006-2007, Parvatha Elangovan * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #define OPJ_UINT32_SEMANTICALLY_BUT_INT32 … #include "opj_includes.h" /** @defgroup PI PI - Implementation of a packet iterator */ /*@{*/ /** @name Local static functions */ /*@{*/ /** Get next packet in layer-resolution-component-precinct order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ static OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterator_t * pi); /** Get next packet in resolution-layer-component-precinct order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ static OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterator_t * pi); /** Get next packet in resolution-precinct-component-layer order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ static OPJ_BOOL opj_pi_next_rpcl(opj_pi_iterator_t * pi); /** Get next packet in precinct-component-resolution-layer order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ static OPJ_BOOL opj_pi_next_pcrl(opj_pi_iterator_t * pi); /** Get next packet in component-precinct-resolution-layer order. @param pi packet iterator to modify @return returns false if pi pointed to the last packet or else returns true */ static OPJ_BOOL opj_pi_next_cprl(opj_pi_iterator_t * pi); /** * Updates the coding parameters if the encoding is used with Progression order changes and final (or cinema parameters are used). * * @param p_cp the coding parameters to modify * @param p_tileno the tile index being concerned. * @param p_tx0 X0 parameter for the tile * @param p_tx1 X1 parameter for the tile * @param p_ty0 Y0 parameter for the tile * @param p_ty1 Y1 parameter for the tile * @param p_max_prec the maximum precision for all the bands of the tile * @param p_max_res the maximum number of resolutions for all the poc inside the tile. * @param p_dx_min the minimum dx of all the components of all the resolutions for the tile. * @param p_dy_min the minimum dy of all the components of all the resolutions for the tile. */ static void opj_pi_update_encode_poc_and_final(opj_cp_t *p_cp, OPJ_UINT32 p_tileno, OPJ_UINT32 p_tx0, OPJ_UINT32 p_tx1, OPJ_UINT32 p_ty0, OPJ_UINT32 p_ty1, OPJ_UINT32 p_max_prec, OPJ_UINT32 p_max_res, OPJ_UINT32 p_dx_min, OPJ_UINT32 p_dy_min); /** * Updates the coding parameters if the encoding is not used with Progression order changes and final (and cinema parameters are used). * * @param p_cp the coding parameters to modify * @param p_num_comps the number of components * @param p_tileno the tile index being concerned. * @param p_tx0 X0 parameter for the tile * @param p_tx1 X1 parameter for the tile * @param p_ty0 Y0 parameter for the tile * @param p_ty1 Y1 parameter for the tile * @param p_max_prec the maximum precision for all the bands of the tile * @param p_max_res the maximum number of resolutions for all the poc inside the tile. * @param p_dx_min the minimum dx of all the components of all the resolutions for the tile. * @param p_dy_min the minimum dy of all the components of all the resolutions for the tile. */ static void opj_pi_update_encode_not_poc(opj_cp_t *p_cp, OPJ_UINT32 p_num_comps, OPJ_UINT32 p_tileno, OPJ_UINT32 p_tx0, OPJ_UINT32 p_tx1, OPJ_UINT32 p_ty0, OPJ_UINT32 p_ty1, OPJ_UINT32 p_max_prec, OPJ_UINT32 p_max_res, OPJ_UINT32 p_dx_min, OPJ_UINT32 p_dy_min); /** * Gets the encoding parameters needed to update the coding parameters and all the pocs. * * @param p_image the image being encoded. * @param p_cp the coding parameters. * @param tileno the tile index of the tile being encoded. * @param p_tx0 pointer that will hold the X0 parameter for the tile * @param p_tx1 pointer that will hold the X1 parameter for the tile * @param p_ty0 pointer that will hold the Y0 parameter for the tile * @param p_ty1 pointer that will hold the Y1 parameter for the tile * @param p_max_prec pointer that will hold the maximum precision for all the bands of the tile * @param p_max_res pointer that will hold the maximum number of resolutions for all the poc inside the tile. * @param p_dx_min pointer that will hold the minimum dx of all the components of all the resolutions for the tile. * @param p_dy_min pointer that will hold the minimum dy of all the components of all the resolutions for the tile. */ static void opj_get_encoding_parameters(const opj_image_t *p_image, const opj_cp_t *p_cp, OPJ_UINT32 tileno, OPJ_UINT32 * p_tx0, OPJ_UINT32 * p_tx1, OPJ_UINT32 * p_ty0, OPJ_UINT32 * p_ty1, OPJ_UINT32 * p_dx_min, OPJ_UINT32 * p_dy_min, OPJ_UINT32 * p_max_prec, OPJ_UINT32 * p_max_res); /** * Gets the encoding parameters needed to update the coding parameters and all the pocs. * The precinct widths, heights, dx and dy for each component at each resolution will be stored as well. * the last parameter of the function should be an array of pointers of size nb components, each pointer leading * to an area of size 4 * max_res. The data is stored inside this area with the following pattern : * dx_compi_res0 , dy_compi_res0 , w_compi_res0, h_compi_res0 , dx_compi_res1 , dy_compi_res1 , w_compi_res1, h_compi_res1 , ... * * @param p_image the image being encoded. * @param p_cp the coding parameters. * @param tileno the tile index of the tile being encoded. * @param p_tx0 pointer that will hold the X0 parameter for the tile * @param p_tx1 pointer that will hold the X1 parameter for the tile * @param p_ty0 pointer that will hold the Y0 parameter for the tile * @param p_ty1 pointer that will hold the Y1 parameter for the tile * @param p_max_prec pointer that will hold the maximum precision for all the bands of the tile * @param p_max_res pointer that will hold the maximum number of resolutions for all the poc inside the tile. * @param p_dx_min pointer that will hold the minimum dx of all the components of all the resolutions for the tile. * @param p_dy_min pointer that will hold the minimum dy of all the components of all the resolutions for the tile. * @param p_resolutions pointer to an area corresponding to the one described above. */ static void opj_get_all_encoding_parameters(const opj_image_t *p_image, const opj_cp_t *p_cp, OPJ_UINT32 tileno, OPJ_UINT32 * p_tx0, OPJ_UINT32 * p_tx1, OPJ_UINT32 * p_ty0, OPJ_UINT32 * p_ty1, OPJ_UINT32 * p_dx_min, OPJ_UINT32 * p_dy_min, OPJ_UINT32 * p_max_prec, OPJ_UINT32 * p_max_res, OPJ_UINT32 ** p_resolutions); /** * Allocates memory for a packet iterator. Data and data sizes are set by this operation. * No other data is set. The include section of the packet iterator is not allocated. * * @param p_image the image used to initialize the packet iterator (in fact only the number of components is relevant. * @param p_cp the coding parameters. * @param tileno the index of the tile from which creating the packet iterator. * @param manager Event manager */ static opj_pi_iterator_t * opj_pi_create(const opj_image_t *p_image, const opj_cp_t *p_cp, OPJ_UINT32 tileno, opj_event_mgr_t* manager); /** * FIXME DOC */ static void opj_pi_update_decode_not_poc(opj_pi_iterator_t * p_pi, opj_tcp_t * p_tcp, OPJ_UINT32 p_max_precision, OPJ_UINT32 p_max_res); /** * FIXME DOC */ static void opj_pi_update_decode_poc(opj_pi_iterator_t * p_pi, opj_tcp_t * p_tcp, OPJ_UINT32 p_max_precision, OPJ_UINT32 p_max_res); /** * FIXME DOC */ static OPJ_BOOL opj_pi_check_next_level(OPJ_INT32 pos, opj_cp_t *cp, OPJ_UINT32 tileno, OPJ_UINT32 pino, const OPJ_CHAR *prog); /*@}*/ /*@}*/ /* ========================================================== local functions ========================================================== */ static OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterator_t * pi) { … } static OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterator_t * pi) { … } static OPJ_BOOL opj_pi_next_rpcl(opj_pi_iterator_t * pi) { … } static OPJ_BOOL opj_pi_next_pcrl(opj_pi_iterator_t * pi) { … } static OPJ_BOOL opj_pi_next_cprl(opj_pi_iterator_t * pi) { … } static void opj_get_encoding_parameters(const opj_image_t *p_image, const opj_cp_t *p_cp, OPJ_UINT32 p_tileno, OPJ_UINT32 * p_tx0, OPJ_UINT32 * p_tx1, OPJ_UINT32 * p_ty0, OPJ_UINT32 * p_ty1, OPJ_UINT32 * p_dx_min, OPJ_UINT32 * p_dy_min, OPJ_UINT32 * p_max_prec, OPJ_UINT32 * p_max_res) { … } static void opj_get_all_encoding_parameters(const opj_image_t *p_image, const opj_cp_t *p_cp, OPJ_UINT32 tileno, OPJ_UINT32 * p_tx0, OPJ_UINT32 * p_tx1, OPJ_UINT32 * p_ty0, OPJ_UINT32 * p_ty1, OPJ_UINT32 * p_dx_min, OPJ_UINT32 * p_dy_min, OPJ_UINT32 * p_max_prec, OPJ_UINT32 * p_max_res, OPJ_UINT32 ** p_resolutions) { … } static opj_pi_iterator_t * opj_pi_create(const opj_image_t *image, const opj_cp_t *cp, OPJ_UINT32 tileno, opj_event_mgr_t* manager) { … } static void opj_pi_update_encode_poc_and_final(opj_cp_t *p_cp, OPJ_UINT32 p_tileno, OPJ_UINT32 p_tx0, OPJ_UINT32 p_tx1, OPJ_UINT32 p_ty0, OPJ_UINT32 p_ty1, OPJ_UINT32 p_max_prec, OPJ_UINT32 p_max_res, OPJ_UINT32 p_dx_min, OPJ_UINT32 p_dy_min) { … } static void opj_pi_update_encode_not_poc(opj_cp_t *p_cp, OPJ_UINT32 p_num_comps, OPJ_UINT32 p_tileno, OPJ_UINT32 p_tx0, OPJ_UINT32 p_tx1, OPJ_UINT32 p_ty0, OPJ_UINT32 p_ty1, OPJ_UINT32 p_max_prec, OPJ_UINT32 p_max_res, OPJ_UINT32 p_dx_min, OPJ_UINT32 p_dy_min) { … } static void opj_pi_update_decode_poc(opj_pi_iterator_t * p_pi, opj_tcp_t * p_tcp, OPJ_UINT32 p_max_precision, OPJ_UINT32 p_max_res) { … } static void opj_pi_update_decode_not_poc(opj_pi_iterator_t * p_pi, opj_tcp_t * p_tcp, OPJ_UINT32 p_max_precision, OPJ_UINT32 p_max_res) { … } static OPJ_BOOL opj_pi_check_next_level(OPJ_INT32 pos, opj_cp_t *cp, OPJ_UINT32 tileno, OPJ_UINT32 pino, const OPJ_CHAR *prog) { … } /* ========================================================== Packet iterator interface ========================================================== */ opj_pi_iterator_t *opj_pi_create_decode(opj_image_t *p_image, opj_cp_t *p_cp, OPJ_UINT32 p_tile_no, opj_event_mgr_t* manager) { … } OPJ_UINT32 opj_get_encoding_packet_count(const opj_image_t *p_image, const opj_cp_t *p_cp, OPJ_UINT32 p_tile_no) { … } opj_pi_iterator_t *opj_pi_initialise_encode(const opj_image_t *p_image, opj_cp_t *p_cp, OPJ_UINT32 p_tile_no, J2K_T2_MODE p_t2_mode, opj_event_mgr_t* manager) { … } void opj_pi_create_encode(opj_pi_iterator_t *pi, opj_cp_t *cp, OPJ_UINT32 tileno, OPJ_UINT32 pino, OPJ_UINT32 tpnum, OPJ_INT32 tppos, J2K_T2_MODE t2_mode) { … } void opj_pi_destroy(opj_pi_iterator_t *p_pi, OPJ_UINT32 p_nb_elements) { … } void opj_pi_update_encoding_parameters(const opj_image_t *p_image, opj_cp_t *p_cp, OPJ_UINT32 p_tile_no) { … } OPJ_BOOL opj_pi_next(opj_pi_iterator_t * pi) { … }