modified indexer for JPIP, JPP-stream

This commit is contained in:
Kaori Hagihara 2011-09-30 17:15:06 +00:00
parent 6b1bca80ee
commit 656628e69b
4 changed files with 33 additions and 19 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed ! : changed
+ : added + : added
September 30, 2011
* [kaori] modified indexer for JPIP, JPP-stream
September 27, 2011 September 27, 2011
+ (mickael] WIP: enhance the event management into the new API + (mickael] WIP: enhance the event management into the new API
* (mickael] WIP: fix some warnings about a static function and j2k_read_unk_v2 * (mickael] WIP: fix some warnings about a static function and j2k_read_unk_v2

View File

@ -1659,7 +1659,7 @@ static int write_fidx( int offset_jp2c, int length_jp2c, int offset_idx, int len
cio_skip( cio, 4); /* L [at the end] */ cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_FIDX, 4); /* IPTR */ cio_write( cio, JPIP_FIDX, 4); /* IPTR */
write_prxy( offset_jp2c, length_jp2c, offset_idx, offset_jp2c, cio); write_prxy( offset_jp2c, length_jp2c, offset_idx, length_idx, cio);
len = cio_tell( cio)-lenp; len = cio_tell( cio)-lenp;
cio_seek( cio, lenp); cio_seek( cio, lenp);
@ -1862,7 +1862,7 @@ void jp2_setup_encoder(opj_jp2_t *jp2, opj_cparameters_t *parameters, opj_image_
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; int pos_iptr, pos_cidx, pos_jp2c, len_jp2c, len_cidx, end_pos, pos_fidx, len_fidx;
/* JP2 encoding */ /* JP2 encoding */
@ -1889,10 +1889,10 @@ opj_bool opj_jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_
if( jp2->jpip_on){ if( jp2->jpip_on){
pos_cidx = cio_tell( cio); pos_cidx = cio_tell( cio);
write_cidx( pos_jp2c+8, cio, image, *cstr_info, len_jp2c-8); len_cidx = write_cidx( pos_jp2c+8, cio, image, *cstr_info, len_jp2c-8);
pos_fidx = cio_tell( cio); pos_fidx = cio_tell( cio);
len_fidx = write_fidx( pos_jp2c, len_jp2c, pos_cidx, cio_tell(cio), cio); len_fidx = write_fidx( pos_jp2c, len_jp2c, pos_cidx, len_cidx, cio);
end_pos = cio_tell( cio); end_pos = cio_tell( cio);

View File

@ -89,7 +89,10 @@ int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
int size_of_coding; // 4 or 8 int size_of_coding; // 4 or 8
int version; int version;
int tileno, resno, precno, layno, num_packet=0; int tileno, resno, precno, layno, num_packet=0;
int i,nmax=0;
opj_tile_info_t *tile_Idx;
opj_packet_info_t packet;
if( j2klen > pow( 2, 32)){ if( j2klen > pow( 2, 32)){
size_of_coding = 8; size_of_coding = 8;
version = 1; version = 1;
@ -103,20 +106,23 @@ int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
cio_skip( cio, 4); /* L [at the end] */ cio_skip( cio, 4); /* L [at the end] */
cio_write( cio, JPIP_FAIX, 4); /* FAIX */ cio_write( cio, JPIP_FAIX, 4); /* FAIX */
cio_write( cio, version,1); /* Version 0 = 4 bytes */ cio_write( cio, version,1); /* Version 0 = 4 bytes */
cio_write( cio, cstr_info.packno, size_of_coding); /* NMAX */ 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 */ cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){ for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
opj_tile_info_t *tile_Idx = &cstr_info.tile[ tileno]; tile_Idx = &cstr_info.tile[ tileno];
// int correction = EPHused ? 3 : 1; // int correction = EPHused ? 3 : 1;
num_packet = 0; num_packet = 0;
for( resno=0; resno<cstr_info.numdecompos[compno]+1; resno++){ for( resno=0; resno<=cstr_info.numdecompos[compno]; resno++){
for( precno=0; precno<tile_Idx->pw[resno]*tile_Idx->ph[resno]; precno++){ for( precno=0; precno<tile_Idx->pw[resno]*tile_Idx->ph[resno]; precno++){
for( layno=0; layno<cstr_info.numlayers; layno++){ for( layno=0; layno<cstr_info.numlayers; layno++){
opj_packet_info_t packet = tile_Idx->packet[num_packet]; packet = tile_Idx->packet[num_packet * cstr_info.numcomps + compno];
cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */ 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 */ cio_write( cio, packet.end_ph_pos-packet.start_pos+1, size_of_coding); /* length */
@ -126,7 +132,7 @@ int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
} }
/* PADDING */ /* PADDING */
while( num_packet < cstr_info.packno){ while( num_packet < nmax){
cio_write( cio, 0, size_of_coding); /* start position */ cio_write( cio, 0, size_of_coding); /* start position */
cio_write( cio, 0, size_of_coding); /* length */ cio_write( cio, 0, size_of_coding); /* length */
num_packet++; num_packet++;

View File

@ -85,13 +85,15 @@ int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int
return len; 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 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 len, lenp;
int tileno, resno, precno, layno, num_packet=0; int tileno, resno, precno, layno, num_packet=0;
int size_of_coding; // 4 or 8 int size_of_coding; // 4 or 8
int version; int version;
int i,nmax=0;
opj_tile_info_t *tile_Idx;
opj_packet_info_t packet;
if( j2klen > pow( 2, 32)){ if( j2klen > pow( 2, 32)){
size_of_coding = 8; size_of_coding = 8;
@ -107,19 +109,22 @@ int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
cio_write( cio, JPIP_FAIX, 4); /* FAIX */ cio_write( cio, JPIP_FAIX, 4); /* FAIX */
cio_write( cio, version, 1); /* Version 0 = 4 bytes */ cio_write( cio, version, 1); /* Version 0 = 4 bytes */
cio_write( cio, cstr_info.packno, size_of_coding); /* NMAX */ 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 */ cio_write( cio, cstr_info.tw*cstr_info.th, size_of_coding); /* M */
for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){ for( tileno=0; tileno<cstr_info.tw*cstr_info.th; tileno++){
opj_tile_info_t *tile_Idx = &cstr_info.tile[ tileno]; tile_Idx = &cstr_info.tile[ tileno];
// int correction = EPHused ? 3 : 1; // int correction = EPHused ? 3 : 1;
num_packet=0; num_packet=0;
for( resno=0; resno< cstr_info.numdecompos[compno]+1; resno++){ for( resno=0; resno<=cstr_info.numdecompos[compno]; resno++){
for( precno=0; precno<tile_Idx->pw[resno]*tile_Idx->ph[resno]; precno++){ for( precno=0; precno<tile_Idx->pw[resno]*tile_Idx->ph[resno]; precno++){
for( layno=0; layno<cstr_info.numlayers; layno++){ for( layno=0; layno<cstr_info.numlayers; layno++){
opj_packet_info_t packet = tile_Idx->packet[num_packet]; packet = tile_Idx->packet[num_packet * cstr_info.numcomps + compno];
cio_write( cio, packet.start_pos-coff, size_of_coding); /* start position */ 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 */ cio_write( cio, packet.end_pos-packet.start_pos+1, size_of_coding); /* length */
@ -129,7 +134,7 @@ int write_ppixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b
} }
/* PADDING */ /* PADDING */
while( num_packet < cstr_info.packno){ while( num_packet < nmax){
cio_write( cio, 0, size_of_coding); /* start position */ cio_write( cio, 0, size_of_coding); /* start position */
cio_write( cio, 0, size_of_coding); /* length */ cio_write( cio, 0, size_of_coding); /* length */
num_packet++; num_packet++;