From 656628e69ba53ffdc85acef32905d768ec97e3c1 Mon Sep 17 00:00:00 2001 From: Kaori Hagihara Date: Fri, 30 Sep 2011 17:15:06 +0000 Subject: [PATCH] modified indexer for JPIP, JPP-stream --- CHANGES | 3 +++ libopenjpeg/jp2.c | 8 ++++---- libopenjpeg/phix_manager.c | 22 ++++++++++++++-------- libopenjpeg/ppix_manager.c | 19 ++++++++++++------- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/CHANGES b/CHANGES index 0b18015d..831e5877 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,9 @@ What's New for OpenJPEG ! : changed + : added +September 30, 2011 +* [kaori] modified indexer for JPIP, JPP-stream + September 27, 2011 + (mickael] WIP: enhance the event management into the new API * (mickael] WIP: fix some warnings about a static function and j2k_read_unk_v2 diff --git a/libopenjpeg/jp2.c b/libopenjpeg/jp2.c index 959366fd..1f736d37 100644 --- a/libopenjpeg/jp2.c +++ b/libopenjpeg/jp2.c @@ -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_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; 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) { - 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 */ @@ -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){ 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); - 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); diff --git a/libopenjpeg/phix_manager.c b/libopenjpeg/phix_manager.c index 43fa275f..ab1b4a94 100755 --- a/libopenjpeg/phix_manager.c +++ b/libopenjpeg/phix_manager.c @@ -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 version; 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)){ size_of_coding = 8; 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_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 */ + + 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; tilenopw[resno]*tile_Idx->ph[resno]; precno++){ - for( layno=0; laynopacket[num_packet]; + for( layno=0; laynopacket[num_packet * cstr_info.numcomps + compno]; 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 */ @@ -126,7 +132,7 @@ int write_phixfaix( int coff, int compno, opj_codestream_info_t cstr_info, opj_b } /* 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); /* length */ num_packet++; diff --git a/libopenjpeg/ppix_manager.c b/libopenjpeg/ppix_manager.c index f4f67859..4106144d 100755 --- a/libopenjpeg/ppix_manager.c +++ b/libopenjpeg/ppix_manager.c @@ -85,13 +85,15 @@ int write_ppix( int coff, opj_codestream_info_t cstr_info, opj_bool EPHused, int 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; + int i,nmax=0; + opj_tile_info_t *tile_Idx; + opj_packet_info_t packet; if( j2klen > pow( 2, 32)){ 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, 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 */ for( tileno=0; tilenopw[resno]*tile_Idx->ph[resno]; precno++){ for( layno=0; laynopacket[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.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 */ - 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); /* length */ num_packet++;