${CMAKE_CURRENT_SOURCE_DIR}/t2.c
${CMAKE_CURRENT_SOURCE_DIR}/tcd.c
${CMAKE_CURRENT_SOURCE_DIR}/tgt.c
- ${CMAKE_CURRENT_SOURCE_DIR}/cidx_manager.c
- ${CMAKE_CURRENT_SOURCE_DIR}/phix_manager.c
- ${CMAKE_CURRENT_SOURCE_DIR}/ppix_manager.c
- ${CMAKE_CURRENT_SOURCE_DIR}/thix_manager.c
- ${CMAKE_CURRENT_SOURCE_DIR}/tpix_manager.c
- ${CMAKE_CURRENT_SOURCE_DIR}/function_list.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/function_list.c
)
# Build the library
+++ /dev/null
-/*
- * $Id: cidx_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
- *
- * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2011, Professor Benoit Macq
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2010-2011, Kaori Hagihara
- * 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.
- */
-
-#include "opj_includes.h"
-
-
-/*
- * Write CPTR Codestream finder box
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] clen length of j2k codestream
- * @param[in] cio file output handle
- */
-void write_cptr(int coff, int clen, opj_cio_t *cio);
-
-
-/*
- * Write main header index table (box)
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] cstr_info codestream information
- * @param[in] cio file output handle
- * @return length of mainmhix box
- */
-int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio);
-
-
-/*
- * Check if EPH option is used
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] markers marker information
- * @param[in] marknum number of markers
- * @param[in] cio file output handle
- * @return true if EPH is used
- */
-opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio);
-
-
-int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen)
-{
- int len, i, lenp;
- opj_jp2_box_t *box;
- int num_box = 0;
- opj_bool EPHused;
- (void)image; /* unused ? */
-
- lenp = -1;
- box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t));
-
- for (i=0;i<2;i++){
-
- if(i)
- cio_seek( cio, lenp);
-
- lenp = cio_tell( cio);
-
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_CIDX, 4); /* CIDX */
- write_cptr( offset, cstr_info.codestream_size, cio);
-
- write_manf( i, num_box, box, cio);
-
- num_box = 0;
- box[num_box].length = write_mainmhix( offset, cstr_info, cio);
- box[num_box].type = JPIP_MHIX;
- num_box++;
-
- box[num_box].length = write_tpix( offset, cstr_info, j2klen, cio);
- box[num_box].type = JPIP_TPIX;
- num_box++;
-
- box[num_box].length = write_thix( offset, cstr_info, cio);
- box[num_box].type = JPIP_THIX;
- num_box++;
-
- EPHused = check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio);
-
- box[num_box].length = write_ppix( offset, cstr_info, EPHused, j2klen, cio);
- box[num_box].type = JPIP_PPIX;
- num_box++;
-
- box[num_box].length = write_phix( offset, cstr_info, EPHused, j2klen, cio);
- box[num_box].type = JPIP_PHIX;
- num_box++;
-
- len = cio_tell( cio)-lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
- }
-
- opj_free( box);
-
- return len;
-}
-
-void write_cptr(int coff, int clen, opj_cio_t *cio)
-{
- int len, lenp;
-
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_CPTR, 4); /* T */
- cio_write( cio, 0, 2); /* DR A PRECISER !! */
- cio_write( cio, 0, 2); /* CONT */
- cio_write( cio, coff, 8); /* COFF A PRECISER !! */
- cio_write( cio, clen, 8); /* CLEN */
- len = cio_tell( cio) - lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
-}
-
-void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio)
-{
- int len, lenp, i;
-
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_MANF,4); /* T */
-
- if (second){ /* Write only during the second pass */
- for( i=0; i<v; i++){
- cio_write( cio, box[i].length, 4); /* Box length */
- cio_write( cio, box[i].type, 4); /* Box type */
- }
- }
-
- len = cio_tell( cio) - lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
-}
-
-int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio)
-{
- int i;
- int len, lenp;
-
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_MHIX, 4); /* MHIX */
-
- cio_write( cio, cstr_info.main_head_end-cstr_info.main_head_start+1, 8); /* TLEN */
-
- for(i = 1; i < cstr_info.marknum; i++){ /* Marker restricted to 1 apparition, skip SOC marker */
- cio_write( cio, cstr_info.marker[i].type, 2);
- cio_write( cio, 0, 2);
- cio_write( cio, cstr_info.marker[i].pos-coff, 8);
- cio_write( cio, cstr_info.marker[i].len, 2);
- }
-
- len = cio_tell( cio) - lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
-
- return len;
-}
-
-opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio)
-{
- opj_bool EPHused = OPJ_FALSE;
- int i=0;
- int org_pos;
- unsigned int Scod;
-
- for(i = 0; i < marknum; i++){
- if( markers[i].type == J2K_MS_COD){
- org_pos = cio_tell( cio);
- cio_seek( cio, coff+markers[i].pos+2);
-
- Scod = cio_read( cio, 1);
- if( ((Scod >> 2) & 1))
- EPHused = OPJ_TRUE;
- cio_seek( cio, org_pos);
-
- break;
- }
- }
- return EPHused;
-}
+++ /dev/null
-/*
- * $Id: cidx_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
- *
- * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2011, Professor Benoit Macq
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2010-2011, Kaori Hagihara
- * 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.
- */
-
-/*! \file
- * \brief Modification of jpip.h from 2KAN indexer
- */
-
-
-#ifndef CIDX_MANAGER_H_
-# define CIDX_MANAGER_H_
-
-#include "openjpeg.h"
-
-
-/*
- * Write Codestream index box (superbox)
- *
- * @param[in] offset offset of j2k codestream
- * @param[in] cio file output handle
- * @param[in] image image data
- * @param[in] cstr_info codestream information
- * @param[in] j2klen length of j2k codestream
- * @return length of cidx box
- */
-int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen);
-
-
-#endif /* !CIDX_MANAGER_H_ */
+++ /dev/null
-/*
- * $Id: indexbox_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
- *
- * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2011, Professor Benoit Macq
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2010-2011, Kaori Hagihara
- * 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.
- */
-
-/*! \file
- * \brief Modification of jpip.c from 2KAN indexer
- */
-
-#ifndef INDEXBOX_MANAGER_H_
-# define INDEXBOX_MANAGER_H_
-
-#include "openjpeg.h"
-#include "j2k.h" /* needed to use jp2.h */
-#include "jp2.h"
-
-#define JPIP_CIDX 0x63696478 /* Codestream index */
-#define JPIP_CPTR 0x63707472 /* Codestream Finder Box */
-#define JPIP_MANF 0x6d616e66 /* Manifest Box */
-#define JPIP_FAIX 0x66616978 /* Fragment array Index box */
-#define JPIP_MHIX 0x6d686978 /* Main Header Index Table */
-#define JPIP_TPIX 0x74706978 /* Tile-part Index Table box */
-#define JPIP_THIX 0x74686978 /* Tile header Index Table box */
-#define JPIP_PPIX 0x70706978 /* Precinct Packet Index Table box */
-#define JPIP_PHIX 0x70686978 /* Packet Header index Table */
-#define JPIP_FIDX 0x66696478 /* File Index */
-#define JPIP_FPTR 0x66707472 /* File Finder */
-#define JPIP_PRXY 0x70727879 /* Proxy boxes */
-#define JPIP_IPTR 0x69707472 /* Index finder box */
-#define JPIP_PHLD 0x70686c64 /* Place holder */
-
-
-/*
- * Write tile-part Index table box (superbox)
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] cstr_info codestream information
- * @param[in] j2klen length of j2k codestream
- * @param[in] cio file output handle
- * @return length of tpix box
- */
-int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio);
-
-
-/*
- * Write tile header index table box (superbox)
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] cstr_info codestream information pointer
- * @param[in] cio file output handle
- * @return length of thix box
- */
-int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio);
-
-
-/*
- * Write precinct packet index table box (superbox)
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] cstr_info codestream information
- * @param[in] EPHused true if EPH option used
- * @param[in] j2klen length of j2k codestream
- * @param[in] cio file output handle
- * @return length of ppix box
- */
-int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
-
-
-/*
- * Write packet header index table box (superbox)
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] cstr_info codestream information
- * @param[in] EPHused true if EPH option used
- * @param[in] j2klen length of j2k codestream
- * @param[in] cio file output handle
- * @return length of ppix box
- */
-int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
-
-/*
- * Wriet manifest box (box)
- *
- * @param[in] second number to be visited
- * @param[in] v number of boxes
- * @param[in] box box to be manifested
- * @param[in] cio file output handle
- */
-void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio);
-
-
-#endif /* !INDEXBOX_MANAGER_H_ */
#include "mct.h"
#include "opj_intmath.h"
+#ifdef USE_JPIP
#include "cidx_manager.h"
#include "indexbox_manager.h"
+#endif
/* JPWL>> */
#ifdef USE_JPWL
+++ /dev/null
-/*
- * $Id: phix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
- *
- * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2011, Professor Benoit Macq
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2010-2011, Kaori Hagihara
- * 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.
- */
-
-/*! \file
- * \brief Modification of jpip.c from 2KAN indexer
- */
-
-#include "opj_includes.h"
-
-
-/*
- * Write faix box of phix
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] compno component number
- * @param[in] cstr_info codestream information
- * @param[in] EPHused true if if EPH option used
- * @param[in] j2klen length of j2k codestream
- * @param[in] cio file output handle
- * @return length of faix box
- */
-int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
-
-int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
-{
- int len, lenp=0, compno, i;
- opj_jp2_box_t *box;
-
- box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t));
-
- for( i=0;i<2;i++){
- if (i) cio_seek( cio, lenp);
-
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_PHIX, 4); /* PHIX */
-
- write_manf( i, cstr_info.numcomps, box, cio);
-
- for( compno=0; compno<cstr_info.numcomps; compno++){
- box[compno].length = write_phixfaix( coff, compno, cstr_info, EPHused, j2klen, cio);
- box[compno].type = JPIP_FAIX;
- }
-
- len = cio_tell( cio)-lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
- }
-
- opj_free(box);
-
- return len;
-}
-
-int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
-{
- int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8 */
- opj_tile_info_t *tile_Idx;
- opj_packet_info_t packet;
- int resno, precno, layno, num_packet;
- int numOfres, numOfprec, numOflayers;
- packet.end_ph_pos = packet.start_pos = -1;
- (void)EPHused; /* unused ? */
-
- if( j2klen > pow( 2, 32)){
- size_of_coding = 8;
- version = 1;
- }
- else{
- size_of_coding = 4;
- version = 0;
- }
-
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_FAIX, 4); /* FAIX */
- cio_write( cio, version,1); /* Version 0 = 4 bytes */
-
- nmax = 0;
- for( i=0; i<=cstr_info.numdecompos[compno]; i++)
- nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers;
-
- cio_write( cio, nmax, size_of_coding); /* NMAX */
- cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
-
- for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
- tile_Idx = &cstr_info.tile[ tileno];
-
- num_packet = 0;
- numOfres = cstr_info.numdecompos[compno] + 1;
-
- for( resno=0; resno<numOfres ; resno++){
- numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
- for( precno=0; precno<numOfprec; precno++){
- numOflayers = cstr_info.numlayers;
- for( layno=0; layno<numOflayers; layno++){
-
- switch ( cstr_info.prog){
- case LRCP:
- packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
- break;
- case RLCP:
- packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
- break;
- case RPCL:
- packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
- break;
- case PCRL:
- packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
- break;
- case CPRL:
- packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
- break;
- default:
- fprintf( stderr, "failed to ppix indexing\n");
- }
-
- cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */
- cio_write( cio, packet.end_ph_pos-packet.start_pos+1, size_of_coding); /* length */
-
- num_packet++;
- }
- }
- }
-
- /* PADDING */
- while( num_packet < nmax){
- cio_write( cio, 0, size_of_coding); /* start position */
- cio_write( cio, 0, size_of_coding); /* length */
- num_packet++;
- }
- }
-
- len = cio_tell( cio)-lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
-
- return len;
-}
+++ /dev/null
-/*
- * $Id: ppix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
- *
- * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2011, Professor Benoit Macq
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2010-2011, Kaori Hagihara
- * 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.
- */
-
-/*! \file
- * \brief Modification of jpip.c from 2KAN indexer
- */
-
-#include "opj_includes.h"
-
-/*
- * Write faix box of ppix
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] compno component number
- * @param[in] cstr_info codestream information
- * @param[in] EPHused true if if EPH option used
- * @param[in] j2klen length of j2k codestream
- * @param[in] cio file output handle
- * @return length of faix box
- */
-int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
-
-int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
-{
- int len, lenp, compno, i;
- opj_jp2_box_t *box;
-
- /* printf("cstr_info.packno %d\n", cstr_info.packno); //NMAX? */
-
- lenp = -1;
- box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t));
-
- for (i=0;i<2;i++){
- if (i) cio_seek( cio, lenp);
-
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_PPIX, 4); /* PPIX */
-
- write_manf( i, cstr_info.numcomps, box, cio);
-
- for (compno=0; compno<cstr_info.numcomps; compno++){
- box[compno].length = write_ppixfaix( coff, compno, cstr_info, EPHused, j2klen, cio);
- box[compno].type = JPIP_FAIX;
- }
-
- len = cio_tell( cio)-lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
- }
-
- opj_free(box);
-
- return len;
-}
-
-int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
-{
- int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8*/
- opj_tile_info_t *tile_Idx;
- opj_packet_info_t packet;
- int resno, precno, layno, num_packet;
- int numOfres, numOfprec, numOflayers;
- packet.end_pos = packet.end_ph_pos = packet.start_pos = -1;
- (void)EPHused; /* unused ? */
-
- if( j2klen > pow( 2, 32)){
- size_of_coding = 8;
- version = 1;
- }
- else{
- size_of_coding = 4;
- version = 0;
- }
-
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_FAIX, 4); /* FAIX */
- cio_write( cio, version, 1); /* Version 0 = 4 bytes */
-
- nmax = 0;
- for( i=0; i<=cstr_info.numdecompos[compno]; i++)
- nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers;
-
- cio_write( cio, nmax, size_of_coding); /* NMAX */
- cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
-
- for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
- tile_Idx = &cstr_info.tile[ tileno];
-
- num_packet=0;
- numOfres = cstr_info.numdecompos[compno] + 1;
-
- for( resno=0; resno<numOfres ; resno++){
- numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
- for( precno=0; precno<numOfprec; precno++){
- numOflayers = cstr_info.numlayers;
- for( layno=0; layno<numOflayers; layno++){
-
- switch ( cstr_info.prog){
- case LRCP:
- packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
- break;
- case RLCP:
- packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
- break;
- case RPCL:
- packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
- break;
- case PCRL:
- packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
- break;
- case CPRL:
- packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
- break;
- default:
- fprintf( stderr, "failed to ppix indexing\n");
- }
-
- cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */
- cio_write( cio, packet.end_pos-packet.start_pos+1, size_of_coding); /* length */
-
- num_packet++;
- }
- }
- }
-
- while( num_packet < nmax){ /* PADDING */
- cio_write( cio, 0, size_of_coding); /* start position */
- cio_write( cio, 0, size_of_coding); /* length */
- num_packet++;
- }
- }
-
- len = cio_tell( cio)-lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
-
- return len;
-}
+++ /dev/null
-/*
- * $Id: thix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
- *
- * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2011, Professor Benoit Macq
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2010-2011, Kaori Hagihara
- * 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.
- */
-
-/*! \file
- * \brief Modification of jpip.c from 2KAN indexer
- */
-
-#include "opj_includes.h"
-
-/*
- * Write tile-part headers mhix box
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] cstr_info codestream information
- * @param[in] tileno tile number
- * @param[in] cio file output handle
- * @return length of mhix box
- */
-int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio);
-
-int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio)
-{
- int len, lenp, i;
- int tileno;
- opj_jp2_box_t *box;
-
- lenp = 0;
- box = (opj_jp2_box_t *)opj_calloc( cstr_info.tw*cstr_info.th, sizeof(opj_jp2_box_t));
-
- for ( i = 0; i < 2 ; i++ ){
- if (i)
- cio_seek( cio, lenp);
-
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_THIX, 4); /* THIX */
- write_manf( i, cstr_info.tw*cstr_info.th, box, cio);
-
- for (tileno = 0; tileno < cstr_info.tw*cstr_info.th; tileno++){
- box[tileno].length = write_tilemhix( coff, cstr_info, tileno, cio);
- box[tileno].type = JPIP_MHIX;
- }
-
- len = cio_tell( cio)-lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
- }
-
- opj_free(box);
-
- return len;
-}
-
-int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio)
-{
- int i;
- opj_tile_info_t tile;
- opj_tp_info_t tp;
- int marknum;
- int len, lenp;
- opj_marker_info_t *marker;
-
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_MHIX, 4); /* MHIX */
-
- tile = cstr_info.tile[tileno];
- tp = tile.tp[0];
-
- cio_write( cio, tp.tp_end_header-tp.tp_start_pos+1, 8); /* TLEN */
-
- marker = cstr_info.tile[tileno].marker;
-
- for( i=0; i<cstr_info.tile[tileno].marknum; i++){ /* Marker restricted to 1 apparition */
- cio_write( cio, marker[i].type, 2);
- cio_write( cio, 0, 2);
- cio_write( cio, marker[i].pos-coff, 8);
- cio_write( cio, marker[i].len, 2);
- }
-
- /* free( marker);*/
-
- len = cio_tell( cio) - lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
-
- return len;
-}
+++ /dev/null
-/*
- * $Id: tpix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
- *
- * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
- * Copyright (c) 2002-2011, Professor Benoit Macq
- * Copyright (c) 2003-2004, Yannick Verschueren
- * Copyright (c) 2010-2011, Kaori Hagihara
- * 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.
- */
-
-/*! \file
- * \brief Modification of jpip.c from 2KAN indexer
- */
-
-#include "opj_includes.h"
-
-#define MAX(a,b) ((a)>(b)?(a):(b))
-
-
-/*
- * Write faix box of tpix
- *
- * @param[in] coff offset of j2k codestream
- * @param[in] compno component number
- * @param[in] cstr_info codestream information
- * @param[in] j2klen length of j2k codestream
- * @param[in] cio file output handle
- * @return length of faix box
- */
-int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio);
-
-
-int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio)
-{
- int len, lenp;
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_TPIX, 4); /* TPIX */
-
- write_tpixfaix( coff, 0, cstr_info, j2klen, cio);
-
- len = cio_tell( cio)-lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
-
- return len;
-}
-
-
-/*
- * Get number of maximum tile parts per tile
- *
- * @param[in] cstr_info codestream information
- * @return number of maximum tile parts per tile
- */
-int get_num_max_tile_parts( opj_codestream_info_t cstr_info);
-
-int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio)
-{
- int len, lenp;
- int i, j;
- int Aux;
- int num_max_tile_parts;
- int size_of_coding; /* 4 or 8 */
- opj_tp_info_t tp;
- int version;
-
- num_max_tile_parts = get_num_max_tile_parts( cstr_info);
-
- if( j2klen > pow( 2, 32)){
- size_of_coding = 8;
- version = num_max_tile_parts == 1 ? 1:3;
- }
- else{
- size_of_coding = 4;
- version = num_max_tile_parts == 1 ? 0:2;
- }
-
- lenp = cio_tell( cio);
- cio_skip( cio, 4); /* L [at the end] */
- cio_write( cio, JPIP_FAIX, 4); /* FAIX */
- cio_write( cio, version, 1); /* Version 0 = 4 bytes */
-
- cio_write( cio, num_max_tile_parts, size_of_coding); /* NMAX */
- cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
- for (i = 0; i < cstr_info.tw*cstr_info.th; i++){
- for (j = 0; j < cstr_info.tile[i].num_tps; j++){
- tp = cstr_info.tile[i].tp[j];
- cio_write( cio, tp.tp_start_pos-coff, size_of_coding); /* start position */
- cio_write( cio, tp.tp_end_pos-tp.tp_start_pos+1, size_of_coding); /* length */
- if (version & 0x02){
- if( cstr_info.tile[i].num_tps == 1 && cstr_info.numdecompos[compno] > 1)
- Aux = cstr_info.numdecompos[compno] + 1;
- else
- Aux = j + 1;
-
- cio_write( cio, Aux,4);
- /*cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4);*/ /* Aux_i,j : Auxiliary value */
- /* fprintf(stderr,"AUX value %d\n",Aux);*/
- }
- /*cio_write(0,4);*/
- }
- /* PADDING */
- while (j < num_max_tile_parts){
- cio_write( cio, 0, size_of_coding); /* start position */
- cio_write( cio, 0, size_of_coding); /* length */
- if (version & 0x02)
- cio_write( cio, 0,4); /* Aux_i,j : Auxiliary value */
- j++;
- }
- }
-
- len = cio_tell( cio)-lenp;
- cio_seek( cio, lenp);
- cio_write( cio, len, 4); /* L */
- cio_seek( cio, lenp+len);
-
- return len;
-
-}
-
-int get_num_max_tile_parts( opj_codestream_info_t cstr_info)
-{
- int num_max_tp = 0, i;
-
- for( i=0; i<cstr_info.tw*cstr_info.th; i++)
- num_max_tp = MAX( cstr_info.tile[i].num_tps, num_max_tp);
-
- return num_max_tp;
-}
include_regular_expression("^.*$")
+add_definitions(-DUSE_JPIP)
+
include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
${FCGI_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/session_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/jpip_parser.c
${CMAKE_CURRENT_SOURCE_DIR}/sock_manager.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/cidx_manager.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/phix_manager.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/ppix_manager.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/thix_manager.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/tpix_manager.c
)
set(SERVER_SRCS
--- /dev/null
+/*
+ * $Id: cidx_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
+ *
+ * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2011, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * 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.
+ */
+
+#include "opj_includes.h"
+
+
+/*
+ * Write CPTR Codestream finder box
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] clen length of j2k codestream
+ * @param[in] cio file output handle
+ */
+void write_cptr(int coff, int clen, opj_cio_t *cio);
+
+
+/*
+ * Write main header index table (box)
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] cstr_info codestream information
+ * @param[in] cio file output handle
+ * @return length of mainmhix box
+ */
+int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio);
+
+
+/*
+ * Check if EPH option is used
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] markers marker information
+ * @param[in] marknum number of markers
+ * @param[in] cio file output handle
+ * @return true if EPH is used
+ */
+opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio);
+
+
+int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen)
+{
+ int len, i, lenp;
+ opj_jp2_box_t *box;
+ int num_box = 0;
+ opj_bool EPHused;
+ (void)image; /* unused ? */
+
+ lenp = -1;
+ box = (opj_jp2_box_t *)opj_calloc( 32, sizeof(opj_jp2_box_t));
+
+ for (i=0;i<2;i++){
+
+ if(i)
+ cio_seek( cio, lenp);
+
+ lenp = cio_tell( cio);
+
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_CIDX, 4); /* CIDX */
+ write_cptr( offset, cstr_info.codestream_size, cio);
+
+ write_manf( i, num_box, box, cio);
+
+ num_box = 0;
+ box[num_box].length = write_mainmhix( offset, cstr_info, cio);
+ box[num_box].type = JPIP_MHIX;
+ num_box++;
+
+ box[num_box].length = write_tpix( offset, cstr_info, j2klen, cio);
+ box[num_box].type = JPIP_TPIX;
+ num_box++;
+
+ box[num_box].length = write_thix( offset, cstr_info, cio);
+ box[num_box].type = JPIP_THIX;
+ num_box++;
+
+ EPHused = check_EPHuse( offset, cstr_info.marker, cstr_info.marknum, cio);
+
+ box[num_box].length = write_ppix( offset, cstr_info, EPHused, j2klen, cio);
+ box[num_box].type = JPIP_PPIX;
+ num_box++;
+
+ box[num_box].length = write_phix( offset, cstr_info, EPHused, j2klen, cio);
+ box[num_box].type = JPIP_PHIX;
+ num_box++;
+
+ len = cio_tell( cio)-lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+ }
+
+ opj_free( box);
+
+ return len;
+}
+
+void write_cptr(int coff, int clen, opj_cio_t *cio)
+{
+ int len, lenp;
+
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_CPTR, 4); /* T */
+ cio_write( cio, 0, 2); /* DR A PRECISER !! */
+ cio_write( cio, 0, 2); /* CONT */
+ cio_write( cio, coff, 8); /* COFF A PRECISER !! */
+ cio_write( cio, clen, 8); /* CLEN */
+ len = cio_tell( cio) - lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+}
+
+void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio)
+{
+ int len, lenp, i;
+
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_MANF,4); /* T */
+
+ if (second){ /* Write only during the second pass */
+ for( i=0; i<v; i++){
+ cio_write( cio, box[i].length, 4); /* Box length */
+ cio_write( cio, box[i].type, 4); /* Box type */
+ }
+ }
+
+ len = cio_tell( cio) - lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+}
+
+int write_mainmhix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio)
+{
+ int i;
+ int len, lenp;
+
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_MHIX, 4); /* MHIX */
+
+ cio_write( cio, cstr_info.main_head_end-cstr_info.main_head_start+1, 8); /* TLEN */
+
+ for(i = 1; i < cstr_info.marknum; i++){ /* Marker restricted to 1 apparition, skip SOC marker */
+ cio_write( cio, cstr_info.marker[i].type, 2);
+ cio_write( cio, 0, 2);
+ cio_write( cio, cstr_info.marker[i].pos-coff, 8);
+ cio_write( cio, cstr_info.marker[i].len, 2);
+ }
+
+ len = cio_tell( cio) - lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+
+ return len;
+}
+
+opj_bool check_EPHuse( int coff, opj_marker_info_t *markers, int marknum, opj_cio_t *cio)
+{
+ opj_bool EPHused = OPJ_FALSE;
+ int i=0;
+ int org_pos;
+ unsigned int Scod;
+
+ for(i = 0; i < marknum; i++){
+ if( markers[i].type == J2K_MS_COD){
+ org_pos = cio_tell( cio);
+ cio_seek( cio, coff+markers[i].pos+2);
+
+ Scod = cio_read( cio, 1);
+ if( ((Scod >> 2) & 1))
+ EPHused = OPJ_TRUE;
+ cio_seek( cio, org_pos);
+
+ break;
+ }
+ }
+ return EPHused;
+}
--- /dev/null
+/*
+ * $Id: cidx_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
+ *
+ * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2011, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * 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.
+ */
+
+/*! \file
+ * \brief Modification of jpip.h from 2KAN indexer
+ */
+
+
+#ifndef CIDX_MANAGER_H_
+# define CIDX_MANAGER_H_
+
+#include "openjpeg.h"
+
+
+/*
+ * Write Codestream index box (superbox)
+ *
+ * @param[in] offset offset of j2k codestream
+ * @param[in] cio file output handle
+ * @param[in] image image data
+ * @param[in] cstr_info codestream information
+ * @param[in] j2klen length of j2k codestream
+ * @return length of cidx box
+ */
+int write_cidx( int offset, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t cstr_info, int j2klen);
+
+
+#endif /* !CIDX_MANAGER_H_ */
--- /dev/null
+/*
+ * $Id: indexbox_manager.h 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
+ *
+ * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2011, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * 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.
+ */
+
+/*! \file
+ * \brief Modification of jpip.c from 2KAN indexer
+ */
+
+#ifndef INDEXBOX_MANAGER_H_
+# define INDEXBOX_MANAGER_H_
+
+#include "openjpeg.h"
+#include "j2k.h" /* needed to use jp2.h */
+#include "jp2.h"
+
+#define JPIP_CIDX 0x63696478 /* Codestream index */
+#define JPIP_CPTR 0x63707472 /* Codestream Finder Box */
+#define JPIP_MANF 0x6d616e66 /* Manifest Box */
+#define JPIP_FAIX 0x66616978 /* Fragment array Index box */
+#define JPIP_MHIX 0x6d686978 /* Main Header Index Table */
+#define JPIP_TPIX 0x74706978 /* Tile-part Index Table box */
+#define JPIP_THIX 0x74686978 /* Tile header Index Table box */
+#define JPIP_PPIX 0x70706978 /* Precinct Packet Index Table box */
+#define JPIP_PHIX 0x70686978 /* Packet Header index Table */
+#define JPIP_FIDX 0x66696478 /* File Index */
+#define JPIP_FPTR 0x66707472 /* File Finder */
+#define JPIP_PRXY 0x70727879 /* Proxy boxes */
+#define JPIP_IPTR 0x69707472 /* Index finder box */
+#define JPIP_PHLD 0x70686c64 /* Place holder */
+
+
+/*
+ * Write tile-part Index table box (superbox)
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] cstr_info codestream information
+ * @param[in] j2klen length of j2k codestream
+ * @param[in] cio file output handle
+ * @return length of tpix box
+ */
+int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio);
+
+
+/*
+ * Write tile header index table box (superbox)
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] cstr_info codestream information pointer
+ * @param[in] cio file output handle
+ * @return length of thix box
+ */
+int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio);
+
+
+/*
+ * Write precinct packet index table box (superbox)
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] cstr_info codestream information
+ * @param[in] EPHused true if EPH option used
+ * @param[in] j2klen length of j2k codestream
+ * @param[in] cio file output handle
+ * @return length of ppix box
+ */
+int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
+
+
+/*
+ * Write packet header index table box (superbox)
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] cstr_info codestream information
+ * @param[in] EPHused true if EPH option used
+ * @param[in] j2klen length of j2k codestream
+ * @param[in] cio file output handle
+ * @return length of ppix box
+ */
+int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
+
+/*
+ * Wriet manifest box (box)
+ *
+ * @param[in] second number to be visited
+ * @param[in] v number of boxes
+ * @param[in] box box to be manifested
+ * @param[in] cio file output handle
+ */
+void write_manf(int second, int v, opj_jp2_box_t *box, opj_cio_t *cio);
+
+
+#endif /* !INDEXBOX_MANAGER_H_ */
--- /dev/null
+/*
+ * $Id: phix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
+ *
+ * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2011, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * 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.
+ */
+
+/*! \file
+ * \brief Modification of jpip.c from 2KAN indexer
+ */
+
+#include "opj_includes.h"
+
+
+/*
+ * Write faix box of phix
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] compno component number
+ * @param[in] cstr_info codestream information
+ * @param[in] EPHused true if if EPH option used
+ * @param[in] j2klen length of j2k codestream
+ * @param[in] cio file output handle
+ * @return length of faix box
+ */
+int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
+
+int write_phix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
+{
+ int len, lenp=0, compno, i;
+ opj_jp2_box_t *box;
+
+ box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t));
+
+ for( i=0;i<2;i++){
+ if (i) cio_seek( cio, lenp);
+
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_PHIX, 4); /* PHIX */
+
+ write_manf( i, cstr_info.numcomps, box, cio);
+
+ for( compno=0; compno<cstr_info.numcomps; compno++){
+ box[compno].length = write_phixfaix( coff, compno, cstr_info, EPHused, j2klen, cio);
+ box[compno].type = JPIP_FAIX;
+ }
+
+ len = cio_tell( cio)-lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+ }
+
+ opj_free(box);
+
+ return len;
+}
+
+int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
+{
+ int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8 */
+ opj_tile_info_t *tile_Idx;
+ opj_packet_info_t packet;
+ int resno, precno, layno, num_packet;
+ int numOfres, numOfprec, numOflayers;
+ packet.end_ph_pos = packet.start_pos = -1;
+ (void)EPHused; /* unused ? */
+
+ if( j2klen > pow( 2, 32)){
+ size_of_coding = 8;
+ version = 1;
+ }
+ else{
+ size_of_coding = 4;
+ version = 0;
+ }
+
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_FAIX, 4); /* FAIX */
+ cio_write( cio, version,1); /* Version 0 = 4 bytes */
+
+ nmax = 0;
+ for( i=0; i<=cstr_info.numdecompos[compno]; i++)
+ nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers;
+
+ cio_write( cio, nmax, size_of_coding); /* NMAX */
+ cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
+
+ for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
+ tile_Idx = &cstr_info.tile[ tileno];
+
+ num_packet = 0;
+ numOfres = cstr_info.numdecompos[compno] + 1;
+
+ for( resno=0; resno<numOfres ; resno++){
+ numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
+ for( precno=0; precno<numOfprec; precno++){
+ numOflayers = cstr_info.numlayers;
+ for( layno=0; layno<numOflayers; layno++){
+
+ switch ( cstr_info.prog){
+ case LRCP:
+ packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
+ break;
+ case RLCP:
+ packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
+ break;
+ case RPCL:
+ packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
+ break;
+ case PCRL:
+ packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
+ break;
+ case CPRL:
+ packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
+ break;
+ default:
+ fprintf( stderr, "failed to ppix indexing\n");
+ }
+
+ cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */
+ cio_write( cio, packet.end_ph_pos-packet.start_pos+1, size_of_coding); /* length */
+
+ num_packet++;
+ }
+ }
+ }
+
+ /* PADDING */
+ while( num_packet < nmax){
+ cio_write( cio, 0, size_of_coding); /* start position */
+ cio_write( cio, 0, size_of_coding); /* length */
+ num_packet++;
+ }
+ }
+
+ len = cio_tell( cio)-lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+
+ return len;
+}
--- /dev/null
+/*
+ * $Id: ppix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
+ *
+ * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2011, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * 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.
+ */
+
+/*! \file
+ * \brief Modification of jpip.c from 2KAN indexer
+ */
+
+#include "opj_includes.h"
+
+/*
+ * Write faix box of ppix
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] compno component number
+ * @param[in] cstr_info codestream information
+ * @param[in] EPHused true if if EPH option used
+ * @param[in] j2klen length of j2k codestream
+ * @param[in] cio file output handle
+ * @return length of faix box
+ */
+int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio);
+
+int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
+{
+ int len, lenp, compno, i;
+ opj_jp2_box_t *box;
+
+ /* printf("cstr_info.packno %d\n", cstr_info.packno); //NMAX? */
+
+ lenp = -1;
+ box = (opj_jp2_box_t *)opj_calloc( cstr_info.numcomps, sizeof(opj_jp2_box_t));
+
+ for (i=0;i<2;i++){
+ if (i) cio_seek( cio, lenp);
+
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_PPIX, 4); /* PPIX */
+
+ write_manf( i, cstr_info.numcomps, box, cio);
+
+ for (compno=0; compno<cstr_info.numcomps; compno++){
+ box[compno].length = write_ppixfaix( coff, compno, cstr_info, EPHused, j2klen, cio);
+ box[compno].type = JPIP_FAIX;
+ }
+
+ len = cio_tell( cio)-lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+ }
+
+ opj_free(box);
+
+ return len;
+}
+
+int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_bool EPHused, int j2klen, opj_cio_t *cio)
+{
+ int len, lenp, tileno, version, i, nmax, size_of_coding; /* 4 or 8*/
+ opj_tile_info_t *tile_Idx;
+ opj_packet_info_t packet;
+ int resno, precno, layno, num_packet;
+ int numOfres, numOfprec, numOflayers;
+ packet.end_pos = packet.end_ph_pos = packet.start_pos = -1;
+ (void)EPHused; /* unused ? */
+
+ if( j2klen > pow( 2, 32)){
+ size_of_coding = 8;
+ version = 1;
+ }
+ else{
+ size_of_coding = 4;
+ version = 0;
+ }
+
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_FAIX, 4); /* FAIX */
+ cio_write( cio, version, 1); /* Version 0 = 4 bytes */
+
+ nmax = 0;
+ for( i=0; i<=cstr_info.numdecompos[compno]; i++)
+ nmax += cstr_info.tile[0].ph[i] * cstr_info.tile[0].pw[i] * cstr_info.numlayers;
+
+ cio_write( cio, nmax, size_of_coding); /* NMAX */
+ cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
+
+ for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
+ tile_Idx = &cstr_info.tile[ tileno];
+
+ num_packet=0;
+ numOfres = cstr_info.numdecompos[compno] + 1;
+
+ for( resno=0; resno<numOfres ; resno++){
+ numOfprec = tile_Idx->pw[resno]*tile_Idx->ph[resno];
+ for( precno=0; precno<numOfprec; precno++){
+ numOflayers = cstr_info.numlayers;
+ for( layno=0; layno<numOflayers; layno++){
+
+ switch ( cstr_info.prog){
+ case LRCP:
+ packet = tile_Idx->packet[ ((layno*numOfres+resno)*cstr_info.numcomps+compno)*numOfprec+precno];
+ break;
+ case RLCP:
+ packet = tile_Idx->packet[ ((resno*numOflayers+layno)*cstr_info.numcomps+compno)*numOfprec+precno];
+ break;
+ case RPCL:
+ packet = tile_Idx->packet[ ((resno*numOfprec+precno)*cstr_info.numcomps+compno)*numOflayers+layno];
+ break;
+ case PCRL:
+ packet = tile_Idx->packet[ ((precno*cstr_info.numcomps+compno)*numOfres+resno)*numOflayers + layno];
+ break;
+ case CPRL:
+ packet = tile_Idx->packet[ ((compno*numOfprec+precno)*numOfres+resno)*numOflayers + layno];
+ break;
+ default:
+ fprintf( stderr, "failed to ppix indexing\n");
+ }
+
+ cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */
+ cio_write( cio, packet.end_pos-packet.start_pos+1, size_of_coding); /* length */
+
+ num_packet++;
+ }
+ }
+ }
+
+ while( num_packet < nmax){ /* PADDING */
+ cio_write( cio, 0, size_of_coding); /* start position */
+ cio_write( cio, 0, size_of_coding); /* length */
+ num_packet++;
+ }
+ }
+
+ len = cio_tell( cio)-lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+
+ return len;
+}
--- /dev/null
+/*
+ * $Id: thix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
+ *
+ * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2011, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * 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.
+ */
+
+/*! \file
+ * \brief Modification of jpip.c from 2KAN indexer
+ */
+
+#include "opj_includes.h"
+
+/*
+ * Write tile-part headers mhix box
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] cstr_info codestream information
+ * @param[in] tileno tile number
+ * @param[in] cio file output handle
+ * @return length of mhix box
+ */
+int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio);
+
+int write_thix( int coff, opj_codestream_info_t cstr_info, opj_cio_t *cio)
+{
+ int len, lenp, i;
+ int tileno;
+ opj_jp2_box_t *box;
+
+ lenp = 0;
+ box = (opj_jp2_box_t *)opj_calloc( cstr_info.tw*cstr_info.th, sizeof(opj_jp2_box_t));
+
+ for ( i = 0; i < 2 ; i++ ){
+ if (i)
+ cio_seek( cio, lenp);
+
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_THIX, 4); /* THIX */
+ write_manf( i, cstr_info.tw*cstr_info.th, box, cio);
+
+ for (tileno = 0; tileno < cstr_info.tw*cstr_info.th; tileno++){
+ box[tileno].length = write_tilemhix( coff, cstr_info, tileno, cio);
+ box[tileno].type = JPIP_MHIX;
+ }
+
+ len = cio_tell( cio)-lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+ }
+
+ opj_free(box);
+
+ return len;
+}
+
+int write_tilemhix( int coff, opj_codestream_info_t cstr_info, int tileno, opj_cio_t *cio)
+{
+ int i;
+ opj_tile_info_t tile;
+ opj_tp_info_t tp;
+ int marknum;
+ int len, lenp;
+ opj_marker_info_t *marker;
+
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_MHIX, 4); /* MHIX */
+
+ tile = cstr_info.tile[tileno];
+ tp = tile.tp[0];
+
+ cio_write( cio, tp.tp_end_header-tp.tp_start_pos+1, 8); /* TLEN */
+
+ marker = cstr_info.tile[tileno].marker;
+
+ for( i=0; i<cstr_info.tile[tileno].marknum; i++){ /* Marker restricted to 1 apparition */
+ cio_write( cio, marker[i].type, 2);
+ cio_write( cio, 0, 2);
+ cio_write( cio, marker[i].pos-coff, 8);
+ cio_write( cio, marker[i].len, 2);
+ }
+
+ /* free( marker);*/
+
+ len = cio_tell( cio) - lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+
+ return len;
+}
--- /dev/null
+/*
+ * $Id: tpix_manager.c 897 2011-08-28 21:43:57Z Kaori.Hagihara@gmail.com $
+ *
+ * Copyright (c) 2002-2011, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2011, Professor Benoit Macq
+ * Copyright (c) 2003-2004, Yannick Verschueren
+ * Copyright (c) 2010-2011, Kaori Hagihara
+ * 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.
+ */
+
+/*! \file
+ * \brief Modification of jpip.c from 2KAN indexer
+ */
+
+#include "opj_includes.h"
+
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
+
+/*
+ * Write faix box of tpix
+ *
+ * @param[in] coff offset of j2k codestream
+ * @param[in] compno component number
+ * @param[in] cstr_info codestream information
+ * @param[in] j2klen length of j2k codestream
+ * @param[in] cio file output handle
+ * @return length of faix box
+ */
+int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio);
+
+
+int write_tpix( int coff, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio)
+{
+ int len, lenp;
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_TPIX, 4); /* TPIX */
+
+ write_tpixfaix( coff, 0, cstr_info, j2klen, cio);
+
+ len = cio_tell( cio)-lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+
+ return len;
+}
+
+
+/*
+ * Get number of maximum tile parts per tile
+ *
+ * @param[in] cstr_info codestream information
+ * @return number of maximum tile parts per tile
+ */
+int get_num_max_tile_parts( opj_codestream_info_t cstr_info);
+
+int write_tpixfaix( int coff, int compno, opj_codestream_info_t cstr_info, int j2klen, opj_cio_t *cio)
+{
+ int len, lenp;
+ int i, j;
+ int Aux;
+ int num_max_tile_parts;
+ int size_of_coding; /* 4 or 8 */
+ opj_tp_info_t tp;
+ int version;
+
+ num_max_tile_parts = get_num_max_tile_parts( cstr_info);
+
+ if( j2klen > pow( 2, 32)){
+ size_of_coding = 8;
+ version = num_max_tile_parts == 1 ? 1:3;
+ }
+ else{
+ size_of_coding = 4;
+ version = num_max_tile_parts == 1 ? 0:2;
+ }
+
+ lenp = cio_tell( cio);
+ cio_skip( cio, 4); /* L [at the end] */
+ cio_write( cio, JPIP_FAIX, 4); /* FAIX */
+ cio_write( cio, version, 1); /* Version 0 = 4 bytes */
+
+ cio_write( cio, num_max_tile_parts, size_of_coding); /* NMAX */
+ cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
+ for (i = 0; i < cstr_info.tw*cstr_info.th; i++){
+ for (j = 0; j < cstr_info.tile[i].num_tps; j++){
+ tp = cstr_info.tile[i].tp[j];
+ cio_write( cio, tp.tp_start_pos-coff, size_of_coding); /* start position */
+ cio_write( cio, tp.tp_end_pos-tp.tp_start_pos+1, size_of_coding); /* length */
+ if (version & 0x02){
+ if( cstr_info.tile[i].num_tps == 1 && cstr_info.numdecompos[compno] > 1)
+ Aux = cstr_info.numdecompos[compno] + 1;
+ else
+ Aux = j + 1;
+
+ cio_write( cio, Aux,4);
+ /*cio_write(img.tile[i].tile_parts[j].num_reso_AUX,4);*/ /* Aux_i,j : Auxiliary value */
+ /* fprintf(stderr,"AUX value %d\n",Aux);*/
+ }
+ /*cio_write(0,4);*/
+ }
+ /* PADDING */
+ while (j < num_max_tile_parts){
+ cio_write( cio, 0, size_of_coding); /* start position */
+ cio_write( cio, 0, size_of_coding); /* length */
+ if (version & 0x02)
+ cio_write( cio, 0,4); /* Aux_i,j : Auxiliary value */
+ j++;
+ }
+ }
+
+ len = cio_tell( cio)-lenp;
+ cio_seek( cio, lenp);
+ cio_write( cio, len, 4); /* L */
+ cio_seek( cio, lenp+len);
+
+ return len;
+
+}
+
+int get_num_max_tile_parts( opj_codestream_info_t cstr_info)
+{
+ int num_max_tp = 0, i;
+
+ for( i=0; i<cstr_info.tw*cstr_info.th; i++)
+ num_max_tp = MAX( cstr_info.tile[i].num_tps, num_max_tp);
+
+ return num_max_tp;
+}
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/t2.c
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/tcd.c
${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/tgt.c
- ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/cidx_manager.c
- ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/phix_manager.c
- ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/ppix_manager.c
- ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/thix_manager.c
- ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/tpix_manager.c
- ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/function_list.c
+ ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2/function_list.c
)
set(JPWL_SRCS crc.c jpwl.c jpwl_lib.c rs.c)