Fixed the DCinema filesize allocation. It now includes the SOT marker size

This commit is contained in:
Francois-Olivier Devaux 2007-08-08 09:41:16 +00:00
parent 9cf692e897
commit 7dcb817e6a
7 changed files with 23 additions and 10 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed ! : changed
+ : added + : added
August 08, 2008
* [Parvatha] Fixed the DCinema filesize allocation. It now includes the SOT marker size
August 02, 2007 August 02, 2007
+ [GB] Added a basic saving capability to OPJViewer + [GB] Added a basic saving capability to OPJViewer

View File

@ -1188,7 +1188,7 @@ int imagetotif(opj_image_t * image, const char *outfile) {
dat8[i+1] = (image->comps[0].data[index]<<4)|((image->comps[1].data[index]>>8)& 0x0f); dat8[i+1] = (image->comps[0].data[index]<<4)|((image->comps[1].data[index]>>8)& 0x0f);
dat8[i+2] = (image->comps[1].data[index]); dat8[i+2] = (image->comps[1].data[index]);
dat8[i+3] = (image->comps[2].data[index]>>8)<<4 | (image->comps[2].data[index]>>4); dat8[i+3] = (image->comps[2].data[index]>>8)<<4 | (image->comps[2].data[index]>>4);
dat8[i+4] = (image->comps[2].data[index]<<4)|((image->comps[1].data[index+1]>>8)& 0x0f); dat8[i+4] = (image->comps[2].data[index]<<4)|((image->comps[0].data[index+1]>>8)& 0x0f);
dat8[i+5] = (image->comps[0].data[index+1]); dat8[i+5] = (image->comps[0].data[index+1]);
dat8[i+6] = (image->comps[1].data[index+1]>>8)<<4 | (image->comps[1].data[index+1]>>4); dat8[i+6] = (image->comps[1].data[index+1]>>8)<<4 | (image->comps[1].data[index+1]>>4);
dat8[i+7] = (image->comps[1].data[index+1]<<4)|((image->comps[2].data[index+1]>>8)& 0x0f); dat8[i+7] = (image->comps[1].data[index+1]<<4)|((image->comps[2].data[index+1]>>8)& 0x0f);

View File

@ -1348,7 +1348,6 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) {
tcd->tp_num = j2k->tp_num ; tcd->tp_num = j2k->tp_num ;
tcd->cur_tp_num = j2k->cur_tp_num; tcd->cur_tp_num = j2k->cur_tp_num;
tcd->cur_totnum_tp = j2k->cur_totnum_tp[j2k->curtileno];
cio_write(cio, J2K_MS_SOD, 2); cio_write(cio, J2K_MS_SOD, 2);
if (j2k->curtileno == 0) { if (j2k->curtileno == 0) {
@ -2515,7 +2514,7 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, char *index)
j2k->curtileno = tileno; j2k->curtileno = tileno;
j2k->cur_tp_num = 0; j2k->cur_tp_num = 0;
tcd->cur_totnum_tp = j2k->cur_totnum_tp[j2k->curtileno];
/* initialisation before tile encoding */ /* initialisation before tile encoding */
if (tileno == 0) { if (tileno == 0) {
tcd_malloc_encode(tcd, image, cp, j2k->curtileno); tcd_malloc_encode(tcd, image, cp, j2k->curtileno);
@ -2632,3 +2631,4 @@ bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, char *index)
return true; return true;
} }

View File

@ -665,7 +665,7 @@ opj_pi_iterator_t *pi_initialise_encode(opj_image_t *image, opj_cp_t *cp, int ti
} }
/* Generation of boundaries for each prog flag*/ /* Generation of boundaries for each prog flag*/
if(tcp->POC & (t2_mode == FINAL_PASS)){ if(tcp->POC && ( cp->cinema || ((!cp->cinema) && (t2_mode == FINAL_PASS)))){
tcp->pocs[pino].compS= tcp->pocs[pino].compno0; tcp->pocs[pino].compS= tcp->pocs[pino].compno0;
tcp->pocs[pino].compE= tcp->pocs[pino].compno1; tcp->pocs[pino].compE= tcp->pocs[pino].compno1;
tcp->pocs[pino].resS = tcp->pocs[pino].resno0; tcp->pocs[pino].resS = tcp->pocs[pino].resno0;
@ -820,7 +820,7 @@ int pi_check_next_level(int pos,opj_cp_t *cp,int tileno, int pino, char *prog){
} }
void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos){ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode){
char *prog; char *prog;
int i,l; int i,l;
int incr_top=1,resetX=0; int incr_top=1,resetX=0;
@ -831,7 +831,7 @@ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
pi[pino].first = 1; pi[pino].first = 1;
pi[pino].poc.prg = tcp->prg; pi[pino].poc.prg = tcp->prg;
if(!(cp->tp_on)){ if(!(cp->tp_on && ((!cp->cinema && (t2_mode == FINAL_PASS)) || cp->cinema))){
pi[pino].poc.resno0 = tcp->resS; pi[pino].poc.resno0 = tcp->resS;
pi[pino].poc.resno1 = tcp->resE; pi[pino].poc.resno1 = tcp->resE;
pi[pino].poc.compno0 = tcp->compS; pi[pino].poc.compno0 = tcp->compS;
@ -1076,3 +1076,4 @@ void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,
} }

View File

@ -118,7 +118,7 @@ Modify the packet iterator for enabling tile part generation
@param tpnum Tile part number of the current tile @param tpnum Tile part number of the current tile
@param tppos The position of the tile part flag in the progression order @param tppos The position of the tile part flag in the progression order
*/ */
void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos); void pi_create_encode( opj_pi_iterator_t *pi, opj_cp_t *cp,int tileno, int pino,int tpnum, int tppos, J2K_T2_MODE t2_mode);
/** /**
Create a packet iterator for Decoder Create a packet iterator for Decoder
@param image Raw image for which the packets will be listed @param image Raw image for which the packets will be listed

View File

@ -586,7 +586,7 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
for(poc = 0; poc < pocno ; poc++){ for(poc = 0; poc < pocno ; poc++){
int comp_len = 0; int comp_len = 0;
int tpnum = compno; int tpnum = compno;
pi_create_encode(pi, cp,tileno,poc,tpnum,tppos); pi_create_encode(pi, cp,tileno,poc,tpnum,tppos,t2_mode);
while (pi_next(&pi[poc])) { while (pi_next(&pi[poc])) {
if (pi[poc].layno < maxlayers) { if (pi[poc].layno < maxlayers) {
e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[poc], c, dest + len - c, image_info, tileno); e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[poc], c, dest + len - c, image_info, tileno);
@ -609,7 +609,7 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
if (e == -999) break; if (e == -999) break;
} }
}else{ /* t2_mode == FINAL_PASS */ }else{ /* t2_mode == FINAL_PASS */
pi_create_encode(pi, cp,tileno,pino,tpnum,tppos); pi_create_encode(pi, cp,tileno,pino,tpnum,tppos,t2_mode);
while (pi_next(&pi[pino])) { while (pi_next(&pi[pino])) {
if (pi[pino].layno < maxlayers) { if (pi[pino].layno < maxlayers) {
e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[pino], c, dest + len - c, image_info, tileno); e = t2_encode_packet(tile, &cp->tcps[tileno], &pi[pino], c, dest + len - c, image_info, tileno);
@ -715,3 +715,4 @@ void t2_destroy(opj_t2_t *t2) {
} }
} }

View File

@ -151,6 +151,13 @@ void tcd_malloc_encode(opj_tcd_t *tcd, opj_image_t * image, opj_cp_t * cp, int c
/* Modification of the RATE >> */ /* Modification of the RATE >> */
for (j = 0; j < tcp->numlayers; j++) { for (j = 0; j < tcp->numlayers; j++) {
tcp->rates[j] = tcp->rates[j] ? tcp->rates[j] = tcp->rates[j] ?
cp->tp_on ?
(((float) (tile->numcomps
* (tile->x1 - tile->x0)
* (tile->y1 - tile->y0)
* image->comps[0].prec))
/(tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy)) - (((tcd->cur_totnum_tp - 1) * 14 )/ tcp->numlayers)
:
((float) (tile->numcomps ((float) (tile->numcomps
* (tile->x1 - tile->x0) * (tile->x1 - tile->x0)
* (tile->y1 - tile->y0) * (tile->y1 - tile->y0)
@ -1049,7 +1056,7 @@ bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_image_in
double hi = max; double hi = max;
int success = 0; int success = 0;
/* TODO: remove maxlen */ /* TODO: remove maxlen */
int maxlen = tcd_tcp->rates[layno] ? int_min(((int) ceil(tcd_tcp->rates[layno])), len) : len; int maxlen = tcd_tcp->rates[layno] ? int_min(((int) ceil(tcd_tcp->rates[layno]- 2)), len) : len;
double goodthresh = 0; double goodthresh = 0;
double stable_thresh = 0; double stable_thresh = 0;
int i; int i;
@ -1436,3 +1443,4 @@ void tcd_free_decode_tile(opj_tcd_t *tcd, int tileno) {
} }