TRUNK:added a new indexer functionality to the library. With the new -jpip option at encoding, the user can now generate a JP2 file including an XML box with the index used when browsing the image with JPIP
This commit is contained in:
parent
bc7c3e44d5
commit
fa720c1858
|
@ -216,6 +216,9 @@ void encode_help_display() {
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n");
|
fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout,"-jpip : write jpip codestream index box in JP2 output file\n");
|
||||||
|
fprintf(stdout," NOTICE: currently supports only RPCL order\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
|
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
|
||||||
|
@ -502,6 +505,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
{"POC",REQ_ARG, NULL ,'P'},
|
{"POC",REQ_ARG, NULL ,'P'},
|
||||||
{"ROI",REQ_ARG, NULL ,'R'},
|
{"ROI",REQ_ARG, NULL ,'R'},
|
||||||
|
{"jpip",NO_ARG, NULL, 'J'}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
|
@ -1238,7 +1242,13 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
break;
|
break;
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'J': /* jpip on */
|
||||||
|
{
|
||||||
|
parameters->jpip_on = OPJ_TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -209,6 +209,9 @@ void encode_help_display(void) {
|
||||||
fprintf(stdout," -F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
|
fprintf(stdout," -F rawWidth,rawHeight,rawComp,rawBitDepth,s/u (Signed/Unsigned)\n");
|
||||||
fprintf(stdout," Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
|
fprintf(stdout," Example: -i lena.raw -o lena.j2k -F 512,512,3,8,u\n");
|
||||||
fprintf(stdout,"\n");
|
fprintf(stdout,"\n");
|
||||||
|
fprintf(stdout,"-jpip : write jpip codestream index box in JP2 output file\n");
|
||||||
|
fprintf(stdout," NOTICE: currently supports only RPCL order\n");
|
||||||
|
fprintf(stdout,"\n");
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
|
fprintf(stdout,"-W : adoption of JPWL (Part 11) capabilities (-W params)\n");
|
||||||
|
@ -584,6 +587,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
{"OutFor",REQ_ARG, NULL ,'O'},
|
{"OutFor",REQ_ARG, NULL ,'O'},
|
||||||
{"POC",REQ_ARG, NULL ,'P'},
|
{"POC",REQ_ARG, NULL ,'P'},
|
||||||
{"ROI",REQ_ARG, NULL ,'R'},
|
{"ROI",REQ_ARG, NULL ,'R'},
|
||||||
|
{"jpip",NO_ARG, NULL, 'J'}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* parse the command line */
|
/* parse the command line */
|
||||||
|
@ -1369,9 +1373,16 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters,
|
||||||
break;
|
break;
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
|
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
case 'J': /* jpip on */
|
||||||
|
{
|
||||||
|
parameters->jpip_on = OPJ_TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
/* ------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "ERROR -> Command line not valid\n");
|
fprintf(stderr, "ERROR -> Command line not valid\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1725,9 +1736,10 @@ int main(int argc, char **argv) {
|
||||||
int codestream_length;
|
int codestream_length;
|
||||||
opj_cio_t *cio = NULL;
|
opj_cio_t *cio = NULL;
|
||||||
FILE *f = NULL;
|
FILE *f = NULL;
|
||||||
|
opj_cinfo_t *cinfo = NULL;
|
||||||
|
|
||||||
/* get a JP2 compressor handle */
|
/* get a JP2 compressor handle */
|
||||||
opj_cinfo_t* cinfo = opj_create_compress(CODEC_JP2);
|
cinfo = opj_create_compress(CODEC_JP2);
|
||||||
|
|
||||||
/* catch events using our callbacks and give a local context */
|
/* catch events using our callbacks and give a local context */
|
||||||
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
|
opj_set_event_mgr((opj_common_ptr)cinfo, &event_mgr, stderr);
|
||||||
|
@ -1740,7 +1752,7 @@ int main(int argc, char **argv) {
|
||||||
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
|
cio = opj_cio_open((opj_common_ptr)cinfo, NULL, 0);
|
||||||
|
|
||||||
/* encode the image */
|
/* encode the image */
|
||||||
if (*indexfilename) // If need to extract codestream information
|
if (*indexfilename || parameters.jpip_on) // If need to extract codestream information
|
||||||
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
|
bSuccess = opj_encode_with_info(cinfo, cio, image, &cstr_info);
|
||||||
else
|
else
|
||||||
bSuccess = opj_encode(cinfo, cio, image, NULL);
|
bSuccess = opj_encode(cinfo, cio, image, NULL);
|
||||||
|
|
|
@ -22,6 +22,11 @@ ${OPENJPEG_SOURCE_DIR}/libopenjpeg/t1.c
|
||||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/t2.c
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg/t2.c
|
||||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/tcd.c
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg/tcd.c
|
||||||
${OPENJPEG_SOURCE_DIR}/libopenjpeg/tgt.c
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg/tgt.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg/cidx_manager.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg/phix_manager.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg/ppix_manager.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg/thix_manager.c
|
||||||
|
${OPENJPEG_SOURCE_DIR}/libopenjpeg/tpix_manager.c
|
||||||
)
|
)
|
||||||
|
|
||||||
SET(MJ2_SRCS mj2.c mj2_convert.c)
|
SET(MJ2_SRCS mj2.c mj2_convert.c)
|
||||||
|
|
|
@ -18,7 +18,12 @@ OPJ_SRC = \
|
||||||
../../libopenjpeg/t1.c \
|
../../libopenjpeg/t1.c \
|
||||||
../../libopenjpeg/t2.c \
|
../../libopenjpeg/t2.c \
|
||||||
../../libopenjpeg/tcd.c \
|
../../libopenjpeg/tcd.c \
|
||||||
../../libopenjpeg/tgt.c
|
../../libopenjpeg/tgt.c \
|
||||||
|
../../libopenjpeg/cidx_manager.c \
|
||||||
|
../../libopenjpeg/phix_manager.c \
|
||||||
|
../../libopenjpeg/ppix_manager.c \
|
||||||
|
../../libopenjpeg/thix_manager.c \
|
||||||
|
../../libopenjpeg/tpix_manager.c
|
||||||
|
|
||||||
bin_PROGRAMS = \
|
bin_PROGRAMS = \
|
||||||
frames_to_mj2 \
|
frames_to_mj2 \
|
||||||
|
|
|
@ -19,6 +19,11 @@ SET(OPENJPEG_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/t2.c
|
${CMAKE_CURRENT_SOURCE_DIR}/t2.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/tcd.c
|
${CMAKE_CURRENT_SOURCE_DIR}/tcd.c
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/tgt.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
|
||||||
)
|
)
|
||||||
|
|
||||||
# Build the library
|
# Build the library
|
||||||
|
|
|
@ -41,6 +41,11 @@ t1_generate_luts.c \
|
||||||
t2.c \
|
t2.c \
|
||||||
tcd.c \
|
tcd.c \
|
||||||
tgt.c \
|
tgt.c \
|
||||||
|
cidx_manager.c \
|
||||||
|
phix_manager.c \
|
||||||
|
ppix_manager.c \
|
||||||
|
thix_manager.c \
|
||||||
|
tpix_manager.c \
|
||||||
bio.h \
|
bio.h \
|
||||||
cio.h \
|
cio.h \
|
||||||
dwt.h \
|
dwt.h \
|
||||||
|
@ -62,7 +67,8 @@ t1.h \
|
||||||
t1_luts.h \
|
t1_luts.h \
|
||||||
t2.h \
|
t2.h \
|
||||||
tcd.h \
|
tcd.h \
|
||||||
tgt.h
|
tgt.h \
|
||||||
|
cidx_manager.h
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
CMakeLists.txt
|
CMakeLists.txt
|
||||||
|
|
|
@ -0,0 +1,213 @@
|
||||||
|
/*
|
||||||
|
* $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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "cidx_manager.h"
|
||||||
|
#include "indexbox_manager.h"
|
||||||
|
#include "cio.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;
|
||||||
|
|
||||||
|
box = (opj_jp2_box_t *)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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* $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_ */
|
|
@ -152,7 +152,7 @@ unsigned char cio_bytein(opj_cio_t *cio) {
|
||||||
* v : value to write
|
* v : value to write
|
||||||
* n : number of bytes to write
|
* n : number of bytes to write
|
||||||
*/
|
*/
|
||||||
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n) {
|
unsigned int cio_write(opj_cio_t *cio, unsigned long long int v, int n) {
|
||||||
int i;
|
int i;
|
||||||
for (i = n - 1; i >= 0; i--) {
|
for (i = n - 1; i >= 0; i--) {
|
||||||
if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
|
if( !cio_byteout(cio, (unsigned char) ((v >> (i << 3)) & 0xff)) )
|
||||||
|
|
|
@ -63,7 +63,7 @@ Write some bytes
|
||||||
@param n Number of bytes to write
|
@param n Number of bytes to write
|
||||||
@return Returns the number of bytes written or 0 if an error occured
|
@return Returns the number of bytes written or 0 if an error occured
|
||||||
*/
|
*/
|
||||||
unsigned int cio_write(opj_cio_t *cio, unsigned int v, int n);
|
unsigned int cio_write(opj_cio_t *cio, unsigned long long int v, int n);
|
||||||
/**
|
/**
|
||||||
Read some bytes
|
Read some bytes
|
||||||
@param cio CIO handle
|
@param cio CIO handle
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
/*
|
||||||
|
* $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_ */
|
|
@ -6,6 +6,7 @@
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -228,6 +229,23 @@ Read an unknown marker
|
||||||
@param j2k J2K handle
|
@param j2k J2K handle
|
||||||
*/
|
*/
|
||||||
static void j2k_read_unk(opj_j2k_t *j2k);
|
static void j2k_read_unk(opj_j2k_t *j2k);
|
||||||
|
/**
|
||||||
|
Add main header marker information
|
||||||
|
@param cstr_info Codestream information structure
|
||||||
|
@param type marker type
|
||||||
|
@param pos byte offset of marker segment
|
||||||
|
@param len length of marker segment
|
||||||
|
*/
|
||||||
|
static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
|
||||||
|
/**
|
||||||
|
Add tile header marker information
|
||||||
|
@param tileno tile index number
|
||||||
|
@param cstr_info Codestream information structure
|
||||||
|
@param type marker type
|
||||||
|
@param pos byte offset of marker segment
|
||||||
|
@param len length of marker segment
|
||||||
|
*/
|
||||||
|
static void j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len);
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
@ -328,12 +346,14 @@ static void j2k_write_soc(opj_j2k_t *j2k) {
|
||||||
opj_cio_t *cio = j2k->cio;
|
opj_cio_t *cio = j2k->cio;
|
||||||
cio_write(cio, J2K_MS_SOC, 2);
|
cio_write(cio, J2K_MS_SOC, 2);
|
||||||
|
|
||||||
|
if(j2k->cstr_info)
|
||||||
|
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio), 0);
|
||||||
|
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
|
|
||||||
/* update markers struct */
|
/* update markers struct */
|
||||||
j2k_add_marker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio) - 2, 2);
|
j2k_add_marker(j2k->cstr_info, J2K_MS_SOC, cio_tell(cio) - 2, 2);
|
||||||
|
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
}
|
}
|
||||||
|
@ -377,6 +397,9 @@ static void j2k_write_siz(opj_j2k_t *j2k) {
|
||||||
cio_seek(cio, lenp);
|
cio_seek(cio, lenp);
|
||||||
cio_write(cio, len, 2); /* Lsiz */
|
cio_write(cio, len, 2); /* Lsiz */
|
||||||
cio_seek(cio, lenp + len);
|
cio_seek(cio, lenp + len);
|
||||||
|
|
||||||
|
if(j2k->cstr_info)
|
||||||
|
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_SIZ, lenp, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void j2k_read_siz(opj_j2k_t *j2k) {
|
static void j2k_read_siz(opj_j2k_t *j2k) {
|
||||||
|
@ -607,6 +630,11 @@ static void j2k_write_com(opj_j2k_t *j2k) {
|
||||||
cio_seek(cio, lenp);
|
cio_seek(cio, lenp);
|
||||||
cio_write(cio, len, 2);
|
cio_write(cio, len, 2);
|
||||||
cio_seek(cio, lenp + len);
|
cio_seek(cio, lenp + len);
|
||||||
|
|
||||||
|
|
||||||
|
if(j2k->cstr_info)
|
||||||
|
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_COM, lenp, len);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,6 +738,10 @@ static void j2k_write_cod(opj_j2k_t *j2k) {
|
||||||
cio_seek(cio, lenp);
|
cio_seek(cio, lenp);
|
||||||
cio_write(cio, len, 2); /* Lcod */
|
cio_write(cio, len, 2); /* Lcod */
|
||||||
cio_seek(cio, lenp + len);
|
cio_seek(cio, lenp + len);
|
||||||
|
|
||||||
|
if(j2k->cstr_info)
|
||||||
|
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_COD, lenp, len);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void j2k_read_cod(opj_j2k_t *j2k) {
|
static void j2k_read_cod(opj_j2k_t *j2k) {
|
||||||
|
@ -890,6 +922,9 @@ static void j2k_write_qcd(opj_j2k_t *j2k) {
|
||||||
cio_seek(cio, lenp);
|
cio_seek(cio, lenp);
|
||||||
cio_write(cio, len, 2); /* Lqcd */
|
cio_write(cio, len, 2); /* Lqcd */
|
||||||
cio_seek(cio, lenp + len);
|
cio_seek(cio, lenp + len);
|
||||||
|
|
||||||
|
if(j2k->cstr_info)
|
||||||
|
j2k_add_mhmarker(j2k->cstr_info, J2K_MS_QCD, lenp, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void j2k_read_qcd(opj_j2k_t *j2k) {
|
static void j2k_read_qcd(opj_j2k_t *j2k) {
|
||||||
|
@ -1211,6 +1246,10 @@ static void j2k_write_sot(opj_j2k_t *j2k) {
|
||||||
j2k_add_marker(j2k->cstr_info, J2K_MS_SOT, j2k->sot_start, len + 2);
|
j2k_add_marker(j2k->cstr_info, J2K_MS_SOT, j2k->sot_start, len + 2);
|
||||||
#endif /* USE_JPWL */
|
#endif /* USE_JPWL */
|
||||||
/* <<UniPG */
|
/* <<UniPG */
|
||||||
|
|
||||||
|
if( j2k->cstr_info && j2k->cur_tp_num==0){
|
||||||
|
j2k_add_tlmarker( j2k->curtileno, j2k->cstr_info, J2K_MS_SOT, lenp, len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void j2k_read_sot(opj_j2k_t *j2k) {
|
static void j2k_read_sot(opj_j2k_t *j2k) {
|
||||||
|
@ -1357,6 +1396,11 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) {
|
||||||
tcd->cur_tp_num = j2k->cur_tp_num;
|
tcd->cur_tp_num = j2k->cur_tp_num;
|
||||||
|
|
||||||
cio_write(cio, J2K_MS_SOD, 2);
|
cio_write(cio, J2K_MS_SOD, 2);
|
||||||
|
|
||||||
|
if( j2k->cstr_info && j2k->cur_tp_num==0){
|
||||||
|
j2k_add_tlmarker( j2k->curtileno, j2k->cstr_info, J2K_MS_SOD, cio_tell(cio), 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (j2k->curtileno == 0) {
|
if (j2k->curtileno == 0) {
|
||||||
j2k->sod_start = cio_tell(cio) + j2k->pos_correction;
|
j2k->sod_start = cio_tell(cio) + j2k->pos_correction;
|
||||||
}
|
}
|
||||||
|
@ -1849,7 +1893,6 @@ opj_image_t* j2k_decode(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *c
|
||||||
if (j2k->state != J2K_STATE_MT) {
|
if (j2k->state != J2K_STATE_MT) {
|
||||||
opj_event_msg(cinfo, EVT_WARNING, "Incomplete bitstream\n");
|
opj_event_msg(cinfo, EVT_WARNING, "Incomplete bitstream\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2337,6 +2380,9 @@ opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_code
|
||||||
/* INDEX >> */
|
/* INDEX >> */
|
||||||
if(cstr_info) {
|
if(cstr_info) {
|
||||||
cstr_info->tile[j2k->curtileno].start_pos = cio_tell(cio) + j2k->pos_correction;
|
cstr_info->tile[j2k->curtileno].start_pos = cio_tell(cio) + j2k->pos_correction;
|
||||||
|
cstr_info->tile[j2k->curtileno].maxmarknum = 10;
|
||||||
|
cstr_info->tile[j2k->curtileno].marker = (opj_marker_info_t *) opj_malloc(cstr_info->tile[j2k->curtileno].maxmarknum * sizeof(opj_marker_info_t));
|
||||||
|
cstr_info->tile[j2k->curtileno].marknum = 0;
|
||||||
}
|
}
|
||||||
/* << INDEX */
|
/* << INDEX */
|
||||||
|
|
||||||
|
@ -2446,8 +2492,43 @@ opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_code
|
||||||
return OPJ_TRUE;
|
return OPJ_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) {
|
||||||
|
|
||||||
|
if (!cstr_info)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* expand the list? */
|
||||||
|
if ((cstr_info->marknum + 1) > cstr_info->maxmarknum) {
|
||||||
|
cstr_info->maxmarknum = 100 + (int) ((float) cstr_info->maxmarknum * 1.0F);
|
||||||
|
cstr_info->marker = (opj_marker_info_t*)opj_realloc(cstr_info->marker, cstr_info->maxmarknum);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add the marker */
|
||||||
|
cstr_info->marker[cstr_info->marknum].type = type;
|
||||||
|
cstr_info->marker[cstr_info->marknum].pos = pos;
|
||||||
|
cstr_info->marker[cstr_info->marknum].len = len;
|
||||||
|
cstr_info->marknum++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) {
|
||||||
|
|
||||||
|
opj_marker_info_t *marker;
|
||||||
|
|
||||||
|
if (!cstr_info)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* expand the list? */
|
||||||
|
if ((cstr_info->tile[tileno].marknum + 1) > cstr_info->tile[tileno].maxmarknum) {
|
||||||
|
cstr_info->tile[tileno].maxmarknum = 100 + (int) ((float) cstr_info->tile[tileno].maxmarknum * 1.0F);
|
||||||
|
cstr_info->tile[tileno].marker = (opj_marker_info_t*)opj_realloc(cstr_info->tile[tileno].marker, cstr_info->maxmarknum);
|
||||||
|
}
|
||||||
|
|
||||||
|
marker = &(cstr_info->tile[tileno].marker[cstr_info->tile[tileno].marknum]);
|
||||||
|
|
||||||
|
/* add the marker */
|
||||||
|
marker->type = type;
|
||||||
|
marker->pos = pos;
|
||||||
|
marker->len = len;
|
||||||
|
cstr_info->tile[tileno].marknum++;
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
* Copyright (c) 2002-2003, Yannick Verschueren
|
* Copyright (c) 2002-2003, Yannick Verschueren
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -124,6 +125,32 @@ Collect colour specification data
|
||||||
*/
|
*/
|
||||||
static opj_bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio,
|
static opj_bool jp2_read_colr(opj_jp2_t *jp2, opj_cio_t *cio,
|
||||||
opj_jp2_box_t *box, opj_jp2_color_t *color);
|
opj_jp2_box_t *box, opj_jp2_color_t *color);
|
||||||
|
/**
|
||||||
|
Write file Index (superbox)
|
||||||
|
@param[in] offset_jp2c offset of jp2c box
|
||||||
|
@param[in] length_jp2c length of jp2c box
|
||||||
|
@param[in] offset_idx offset of cidx box
|
||||||
|
@param[in] length_idx length of cidx box
|
||||||
|
@param[in] cio file output handle
|
||||||
|
@return length of fidx box
|
||||||
|
*/
|
||||||
|
static int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio);
|
||||||
|
/**
|
||||||
|
Write index Finder box
|
||||||
|
@param[in] offset offset of fidx box
|
||||||
|
@param[in] length length of fidx box
|
||||||
|
@param[in] cio file output handle
|
||||||
|
*/
|
||||||
|
static void write_iptr( int offset, int length, opj_cio_t *cio);
|
||||||
|
/**
|
||||||
|
Write proxy box
|
||||||
|
@param[in] offset_jp2c offset of jp2c box
|
||||||
|
@param[in] length_jp2c length of jp2c box
|
||||||
|
@param[in] offset_idx offset of cidx box
|
||||||
|
@param[in] length_idx length of cidx box
|
||||||
|
@param[in] cio file output handle
|
||||||
|
*/
|
||||||
|
static void write_prxy( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio);
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
@ -925,6 +952,67 @@ static opj_bool jp2_read_struct(opj_jp2_t *jp2, opj_cio_t *cio,
|
||||||
return OPJ_TRUE;
|
return OPJ_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio)
|
||||||
|
{
|
||||||
|
int len, lenp;
|
||||||
|
|
||||||
|
lenp = cio_tell( cio);
|
||||||
|
cio_skip( cio, 4); /* L [at the end] */
|
||||||
|
cio_write( cio, JPIP_FIDX, 4); /* IPTR */
|
||||||
|
|
||||||
|
write_prxy( offset_jp2c, length_jp2c, offset_idx, offset_jp2c, cio);
|
||||||
|
|
||||||
|
len = cio_tell( cio)-lenp;
|
||||||
|
cio_seek( cio, lenp);
|
||||||
|
cio_write( cio, len, 4); /* L */
|
||||||
|
cio_seek( cio, lenp+len);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_prxy( int offset_jp2c, int length_jp2c, int offset_idx, int length_idx, opj_cio_t *cio)
|
||||||
|
{
|
||||||
|
int len, lenp;
|
||||||
|
|
||||||
|
lenp = cio_tell( cio);
|
||||||
|
cio_skip( cio, 4); /* L [at the end] */
|
||||||
|
cio_write( cio, JPIP_PRXY, 4); /* IPTR */
|
||||||
|
|
||||||
|
cio_write( cio, offset_jp2c, 8); /* OOFF */
|
||||||
|
cio_write( cio, length_jp2c, 4); /* OBH part 1 */
|
||||||
|
cio_write( cio, JP2_JP2C, 4); /* OBH part 2 */
|
||||||
|
|
||||||
|
cio_write( cio, 1,1); /* NI */
|
||||||
|
|
||||||
|
cio_write( cio, offset_idx, 8); /* IOFF */
|
||||||
|
cio_write( cio, length_idx, 4); /* IBH part 1 */
|
||||||
|
cio_write( cio, JPIP_CIDX, 4); /* IBH part 2 */
|
||||||
|
|
||||||
|
len = cio_tell( cio)-lenp;
|
||||||
|
cio_seek( cio, lenp);
|
||||||
|
cio_write( cio, len, 4); /* L */
|
||||||
|
cio_seek( cio, lenp+len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void write_iptr( int offset, int length, opj_cio_t *cio)
|
||||||
|
{
|
||||||
|
int len, lenp;
|
||||||
|
|
||||||
|
lenp = cio_tell( cio);
|
||||||
|
cio_skip( cio, 4); /* L [at the end] */
|
||||||
|
cio_write( cio, JPIP_IPTR, 4); /* IPTR */
|
||||||
|
|
||||||
|
cio_write( cio, offset, 8);
|
||||||
|
cio_write( cio, length, 8);
|
||||||
|
|
||||||
|
len = cio_tell( cio)-lenp;
|
||||||
|
cio_seek( cio, lenp);
|
||||||
|
cio_write( cio, len, 4); /* L */
|
||||||
|
cio_seek( cio, lenp+len);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* JP2 decoder interface */
|
/* JP2 decoder interface */
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
@ -1061,10 +1149,13 @@ void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_
|
||||||
jp2->precedence = 0; /* PRECEDENCE */
|
jp2->precedence = 0; /* PRECEDENCE */
|
||||||
jp2->approx = 0; /* APPROX */
|
jp2->approx = 0; /* APPROX */
|
||||||
|
|
||||||
|
jp2->jpip_on = parameters->jpip_on;
|
||||||
}
|
}
|
||||||
|
|
||||||
opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
|
opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
|
||||||
|
|
||||||
|
int pos_iptr, pos_cidx, pos_jp2c, len_jp2c, end_pos, pos_fidx, len_fidx;
|
||||||
|
|
||||||
/* JP2 encoding */
|
/* JP2 encoding */
|
||||||
|
|
||||||
/* JPEG 2000 Signature box */
|
/* JPEG 2000 Signature box */
|
||||||
|
@ -1074,14 +1165,34 @@ opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_
|
||||||
/* JP2 Header box */
|
/* JP2 Header box */
|
||||||
jp2_write_jp2h(jp2, cio);
|
jp2_write_jp2h(jp2, cio);
|
||||||
|
|
||||||
/* J2K encoding */
|
if( jp2->jpip_on){
|
||||||
|
pos_iptr = cio_tell( cio);
|
||||||
|
cio_skip( cio, 24); /* IPTR further ! */
|
||||||
|
|
||||||
if(!jp2_write_jp2c(jp2, cio, image, cstr_info)) {
|
pos_jp2c = cio_tell( cio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* J2K encoding */
|
||||||
|
if(!(len_jp2c = jp2_write_jp2c( jp2, cio, image, cstr_info))){
|
||||||
opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n");
|
opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n");
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OPJ_TRUE;
|
if( jp2->jpip_on){
|
||||||
|
pos_cidx = cio_tell( cio);
|
||||||
|
|
||||||
|
write_cidx( pos_jp2c+8, cio, image, *cstr_info, len_jp2c-8);
|
||||||
|
|
||||||
|
pos_fidx = cio_tell( cio);
|
||||||
|
len_fidx = write_fidx( pos_jp2c, len_jp2c, pos_cidx, cio_tell(cio), cio);
|
||||||
|
|
||||||
|
end_pos = cio_tell( cio);
|
||||||
|
|
||||||
|
cio_seek( cio, pos_iptr);
|
||||||
|
write_iptr( pos_fidx, len_fidx, cio);
|
||||||
|
|
||||||
|
cio_seek( cio, end_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return OPJ_TRUE;
|
||||||
|
}
|
||||||
|
|
|
@ -140,6 +140,7 @@ typedef struct opj_jp2 {
|
||||||
opj_jp2_comps_t *comps;
|
opj_jp2_comps_t *comps;
|
||||||
unsigned int j2k_codestream_offset;
|
unsigned int j2k_codestream_offset;
|
||||||
unsigned int j2k_codestream_length;
|
unsigned int j2k_codestream_length;
|
||||||
|
opj_bool jpip_on;
|
||||||
} opj_jp2_t;
|
} opj_jp2_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -222,6 +223,7 @@ Encode an image into a JPEG-2000 file stream
|
||||||
@return Returns true if successful, returns false otherwise
|
@return Returns true if successful, returns false otherwise
|
||||||
*/
|
*/
|
||||||
opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
|
opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete
|
||||||
parameters->cp_disto_alloc = 0;
|
parameters->cp_disto_alloc = 0;
|
||||||
parameters->cp_fixed_alloc = 0;
|
parameters->cp_fixed_alloc = 0;
|
||||||
parameters->cp_fixed_quality = 0;
|
parameters->cp_fixed_quality = 0;
|
||||||
|
parameters->jpip_on = OPJ_FALSE;
|
||||||
/* UniPG>> */
|
/* UniPG>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
parameters->jpwl_epc_on = OPJ_FALSE;
|
parameters->jpwl_epc_on = OPJ_FALSE;
|
||||||
|
@ -333,6 +333,7 @@ void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info) {
|
||||||
opj_free(tile_info->thresh);
|
opj_free(tile_info->thresh);
|
||||||
opj_free(tile_info->packet);
|
opj_free(tile_info->packet);
|
||||||
opj_free(tile_info->tp);
|
opj_free(tile_info->tp);
|
||||||
|
opj_free(tile_info->marker);
|
||||||
}
|
}
|
||||||
opj_free(cstr_info->tile);
|
opj_free(cstr_info->tile);
|
||||||
opj_free(cstr_info->marker);
|
opj_free(cstr_info->marker);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
* Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
|
||||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||||
* Copyright (c) 2006-2007, Parvatha Elangovan
|
* Copyright (c) 2006-2007, Parvatha Elangovan
|
||||||
|
* Copyright (c) 2010-2011, Kaori Hagihara
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -141,7 +142,7 @@ typedef enum CODEC_FORMAT {
|
||||||
CODEC_UNKNOWN = -1, /**< place-holder */
|
CODEC_UNKNOWN = -1, /**< place-holder */
|
||||||
CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */
|
CODEC_J2K = 0, /**< JPEG-2000 codestream : read/write */
|
||||||
CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */
|
CODEC_JPT = 1, /**< JPT-stream (JPEG 2000, JPIP) : read only */
|
||||||
CODEC_JP2 = 2 /**< JPEG-2000 file format : read/write */
|
CODEC_JP2 = 2, /**< JPEG-2000 file format : read/write */
|
||||||
} OPJ_CODEC_FORMAT;
|
} OPJ_CODEC_FORMAT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -346,6 +347,8 @@ typedef struct opj_cparameters {
|
||||||
char tp_flag;
|
char tp_flag;
|
||||||
/** MCT (multiple component transform) */
|
/** MCT (multiple component transform) */
|
||||||
char tcp_mct;
|
char tcp_mct;
|
||||||
|
/** Enable JPIP indexing*/
|
||||||
|
opj_bool jpip_on;
|
||||||
} opj_cparameters_t;
|
} opj_cparameters_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -585,6 +588,21 @@ typedef struct opj_packet_info {
|
||||||
double disto;
|
double disto;
|
||||||
} opj_packet_info_t;
|
} opj_packet_info_t;
|
||||||
|
|
||||||
|
|
||||||
|
/* UniPG>> */
|
||||||
|
/**
|
||||||
|
Marker structure
|
||||||
|
*/
|
||||||
|
typedef struct opj_marker_info_t {
|
||||||
|
/** marker type */
|
||||||
|
unsigned short int type;
|
||||||
|
/** position in codestream */
|
||||||
|
int pos;
|
||||||
|
/** length, marker val included */
|
||||||
|
int len;
|
||||||
|
} opj_marker_info_t;
|
||||||
|
/* <<UniPG */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Index structure : Information concerning tile-parts
|
Index structure : Information concerning tile-parts
|
||||||
*/
|
*/
|
||||||
|
@ -629,26 +647,18 @@ typedef struct opj_tile_info {
|
||||||
int numpix;
|
int numpix;
|
||||||
/** add fixed_quality */
|
/** add fixed_quality */
|
||||||
double distotile;
|
double distotile;
|
||||||
|
/** number of markers */
|
||||||
|
int marknum;
|
||||||
|
/** list of markers */
|
||||||
|
opj_marker_info_t *marker;
|
||||||
|
/** actual size of markers array */
|
||||||
|
int maxmarknum;
|
||||||
/** number of tile parts */
|
/** number of tile parts */
|
||||||
int num_tps;
|
int num_tps;
|
||||||
/** information concerning tile parts */
|
/** information concerning tile parts */
|
||||||
opj_tp_info_t *tp;
|
opj_tp_info_t *tp;
|
||||||
} opj_tile_info_t;
|
} opj_tile_info_t;
|
||||||
|
|
||||||
/* UniPG>> */
|
|
||||||
/**
|
|
||||||
Marker structure
|
|
||||||
*/
|
|
||||||
typedef struct opj_marker_info_t {
|
|
||||||
/** marker type */
|
|
||||||
unsigned short int type;
|
|
||||||
/** position in codestream */
|
|
||||||
int pos;
|
|
||||||
/** length, marker val included */
|
|
||||||
int len;
|
|
||||||
} opj_marker_info_t;
|
|
||||||
/* <<UniPG */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Index structure of the codestream
|
Index structure of the codestream
|
||||||
*/
|
*/
|
||||||
|
@ -867,7 +877,7 @@ Setup the encoder parameters using the current image and using user parameters.
|
||||||
OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
|
OPJ_API void OPJ_CALLCONV opj_setup_encoder(opj_cinfo_t *cinfo, opj_cparameters_t *parameters, opj_image_t *image);
|
||||||
/**
|
/**
|
||||||
Encode an image into a JPEG-2000 codestream
|
Encode an image into a JPEG-2000 codestream
|
||||||
@param cinfo compressor handle
|
3@param cinfo compressor handle
|
||||||
@param cio Output buffer stream
|
@param cio Output buffer stream
|
||||||
@param image Image to encode
|
@param image Image to encode
|
||||||
@param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
|
@param index Depreacted -> Set to NULL. To extract index, used opj_encode_wci()
|
||||||
|
@ -889,6 +899,7 @@ Destroy Codestream information after compression or decompression
|
||||||
*/
|
*/
|
||||||
OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
|
OPJ_API void OPJ_CALLCONV opj_destroy_cstr_info(opj_codestream_info_t *cstr_info);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -127,6 +127,9 @@ static INLINE long lrintf(float f){
|
||||||
#include "int.h"
|
#include "int.h"
|
||||||
#include "fix.h"
|
#include "fix.h"
|
||||||
|
|
||||||
|
#include "cidx_manager.h"
|
||||||
|
#include "indexbox_manager.h"
|
||||||
|
|
||||||
/* JPWL>> */
|
/* JPWL>> */
|
||||||
#ifdef USE_JPWL
|
#ifdef USE_JPWL
|
||||||
#include "./jpwl/jpwl.h"
|
#include "./jpwl/jpwl.h"
|
||||||
|
|
|
@ -0,0 +1,142 @@
|
||||||
|
/*
|
||||||
|
* $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 <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "indexbox_manager.h"
|
||||||
|
#include "cio.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 *)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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
int size_of_coding; // 4 or 8
|
||||||
|
int version;
|
||||||
|
int tileno, resno, precno, layno, num_packet=0;
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
cio_write( cio, cstr_info.packno, 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++){
|
||||||
|
|
||||||
|
opj_tile_info_t *tile_Idx = &cstr_info.tile[ tileno];
|
||||||
|
// int correction = EPHused ? 3 : 1;
|
||||||
|
num_packet = 0;
|
||||||
|
|
||||||
|
for( resno=0; resno<cstr_info.numdecompos[compno]+1; resno++){
|
||||||
|
for( precno=0; precno<tile_Idx->pw[resno]*tile_Idx->ph[resno]; precno++){
|
||||||
|
for( layno=0; layno<cstr_info.numlayers; layno++){
|
||||||
|
opj_packet_info_t packet = tile_Idx->packet[num_packet];
|
||||||
|
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 < cstr_info.packno){
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,147 @@
|
||||||
|
/*
|
||||||
|
* $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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include "indexbox_manager.h"
|
||||||
|
#include "cio.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?
|
||||||
|
|
||||||
|
box = (opj_jp2_box_t *)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);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(box);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NMAX might be wrong , phix too, do sth to correction
|
||||||
|
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;
|
||||||
|
int tileno, resno, precno, layno, num_packet=0;
|
||||||
|
int size_of_coding; // 4 or 8
|
||||||
|
int version;
|
||||||
|
|
||||||
|
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 */
|
||||||
|
|
||||||
|
cio_write( cio, cstr_info.packno, 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++){
|
||||||
|
|
||||||
|
opj_tile_info_t *tile_Idx = &cstr_info.tile[ tileno];
|
||||||
|
// int correction = EPHused ? 3 : 1;
|
||||||
|
num_packet=0;
|
||||||
|
|
||||||
|
for( resno=0; resno< cstr_info.numdecompos[compno]+1; resno++){
|
||||||
|
for( precno=0; precno<tile_Idx->pw[resno]*tile_Idx->ph[resno]; precno++){
|
||||||
|
for( layno=0; layno<cstr_info.numlayers; layno++){
|
||||||
|
opj_packet_info_t packet = tile_Idx->packet[num_packet];
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* PADDING */
|
||||||
|
while( num_packet < cstr_info.packno){
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,122 @@
|
||||||
|
/*
|
||||||
|
* $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 <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "indexbox_manager.h"
|
||||||
|
#include "cio.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 *)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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
|
@ -0,0 +1,154 @@
|
||||||
|
/*
|
||||||
|
* $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 <math.h>
|
||||||
|
#include "indexbox_manager.h"
|
||||||
|
#include "cio.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;
|
||||||
|
}
|
Loading…
Reference in New Issue