summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2007-06-15 13:27:43 +0000
committerFrancois-Olivier Devaux <fodevaux@users.noreply.github.com>2007-06-15 13:27:43 +0000
commit3d626da232e8b7e3a812e145f22627df256c02a0 (patch)
treeea024622e683f291a48cce22d00703c30926ecc9
parentf428a306a192cfc576911d064a6f4e7bacf56c76 (diff)
Fixed the generation of index files. Now works with cinema formats.
-rw-r--r--ChangeLog4
-rw-r--r--codec/image_to_j2k.c8
-rw-r--r--libopenjpeg/j2k.c150
-rw-r--r--libopenjpeg/t2.c52
4 files changed, 110 insertions, 104 deletions
diff --git a/ChangeLog b/ChangeLog
index 9766cea9..ed4ec633 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@ What's New for OpenJPEG
! : changed
+ : added
+June 15, 2007
+* [FOD] Fixed the generation of index files
+
+
----------------------
MAY 4, 2007
VERSION 1.2.0 RELEASED
diff --git a/codec/image_to_j2k.c b/codec/image_to_j2k.c
index eab3c0c5..113f2f1d 100644
--- a/codec/image_to_j2k.c
+++ b/codec/image_to_j2k.c
@@ -483,7 +483,9 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
parameters->numresolution = 6;
}
if (!((image->comps[0].w == 2048) | (image->comps[0].h == 1080))){
- fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3 (2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",image->comps[0].w,image->comps[0].h);
+ fprintf(stdout,"Image coordinates %d x %d is not 2K compliant.\nJPEG Digital Cinema Profile-3"
+ "(2K profile) compliance requires that at least one of coordinates match 2048 x 1080\n",
+ image->comps[0].w,image->comps[0].h);
parameters->cp_rsiz = STD_RSIZ;
}
break;
@@ -495,7 +497,9 @@ void cinema_setup_encoder(opj_cparameters_t *parameters,opj_image_t *image){
parameters->numresolution = 7;
}
if (!((image->comps[0].w == 4096) | (image->comps[0].h == 2160))){
- fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4 (4K profile) compliance requires that atleast one of coordinates match 4096 x 2160\n",image->comps[0].w,image->comps[0].h);
+ fprintf(stdout,"Image coordinates %d x %d is not 4K compliant.\nJPEG Digital Cinema Profile-4"
+ "(4K profile) compliance requires that at least one of coordinates match 4096 x 2160\n",
+ image->comps[0].w,image->comps[0].h);
parameters->cp_rsiz = STD_RSIZ;
}
parameters->numpocs = initialise_4K_poc(parameters->POC,parameters->numresolution);
diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c
index 1ef653ee..556833c6 100644
--- a/libopenjpeg/j2k.c
+++ b/libopenjpeg/j2k.c
@@ -1354,11 +1354,16 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) {
if (j2k->curtileno == 0) {
j2k->sod_start = cio_tell(cio) + j2k->pos_correction;
}
-
+
/* INDEX >> */
image_info = j2k->image_info;
if (image_info && image_info->index_on) {
- image_info->tile[j2k->curtileno].end_header = cio_tell(cio) + j2k->pos_correction - 1;
+ if (!j2k->cur_tp_num ){
+ image_info->tile[j2k->curtileno].end_header = cio_tell(cio) + j2k->pos_correction - 1;
+ }else{
+ if(image_info->tile[j2k->curtileno].packet[image_info->num - 1].end_pos < cio_tell(cio))
+ image_info->tile[j2k->curtileno].packet[image_info->num].start_pos = cio_tell(cio);
+ }
}
/* << INDEX */
@@ -1366,7 +1371,7 @@ static void j2k_write_sod(opj_j2k_t *j2k, void *tile_coder) {
for (layno = 0; layno < tcp->numlayers; layno++) {
tcp->rates[layno] -= tcp->rates[layno] ? (j2k->sod_start / (cp->th * cp->tw)) : 0;
}
- if(image_info) {
+ if(image_info && (j2k->cur_tp_num == 0)) {
image_info->num = 0;
}
@@ -2253,15 +2258,11 @@ static int j2k_create_index(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_info_t *im
int start_pos, end_pos;
double disto = 0;
pack_nb = 0;
-
- /*
- fprintf(stream, "pkno tileno layerno resno compno precno start_pos end_pos deltaSE \n");
- */
-
+
if (image_info->prog == LRCP) { /* LRCP */
- /*
- fprintf(stream, "pack_nb tileno layno resno compno precno start_pos end_pos disto");
- */
+
+ fprintf(stream, "pack_nb tileno layno resno compno precno start_pos end_pos disto\n");
+
for (layno = 0; layno < image_info->layer; layno++) {
for (resno = 0; resno < image_info->decomposition + 1; resno++) {
for (compno = 0; compno < image_info->comp; compno++) {
@@ -2280,9 +2281,9 @@ static int j2k_create_index(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_info_t *im
}
} /* LRCP */
else if (image_info->prog == RLCP) { /* RLCP */
- /*
- fprintf(stream, "pack_nb tileno resno layno compno precno start_pos end_pos disto");
- */
+
+ fprintf(stream, "pack_nb tileno resno layno compno precno start_pos end_pos disto\n");
+
for (resno = 0; resno < image_info->decomposition + 1; resno++) {
for (layno = 0; layno < image_info->layer; layno++) {
for (compno = 0; compno < image_info->comp; compno++) {
@@ -2301,26 +2302,26 @@ static int j2k_create_index(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_info_t *im
}
} /* RLCP */
else if (image_info->prog == RPCL) { /* RPCL */
- /*
- fprintf(stream, "\npack_nb tileno resno precno compno layno start_pos end_pos disto\n");
- */
+
+ fprintf(stream, "\npack_nb tileno resno precno compno layno start_pos end_pos disto\n");
+
for (resno = 0; resno < image_info->decomposition + 1; resno++) {
/* I suppose components have same XRsiz, YRsiz */
int x0 = image_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)image_info->tw ) * image_info->tw * image_info->tile_x;
int y0 = image_info->tile_Ox + (int)floor( (float)tileno/(float)image_info->tw ) * image_info->tile_y;
int x1 = x0 + image_info->tile_x;
int y1 = y0 + image_info->tile_y;
- for(y = y0; y < y1; y++) {
- for(x = x0; x < x1; x++) {
- for (compno = 0; compno < image_info->comp; compno++) {
- int prec_max = image_info->tile[tileno].pw[resno] * image_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- int pcnx = image_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, image_info->tile[tileno].pdx[resno] + image_info->decomposition - resno );
- int pcy = (int) pow( 2, image_info->tile[tileno].pdy[resno] + image_info->decomposition - resno );
- int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
- int precno_y = (int) floor( (float)precno/(float)pcnx );
- if (precno_y*pcy == y ) {
+ for (compno = 0; compno < image_info->comp; compno++) {
+ int prec_max = image_info->tile[tileno].pw[resno] * image_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < prec_max; precno++) {
+ int pcnx = image_info->tile[tileno].pw[resno];
+ int pcx = (int) pow( 2, image_info->tile[tileno].pdx[resno] + image_info->decomposition - resno );
+ int pcy = (int) pow( 2, image_info->tile[tileno].pdy[resno] + image_info->decomposition - resno );
+ int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
+ int precno_y = (int) floor( (float)precno/(float)pcnx );
+ for(y = y0; y < y1; y++) {
+ if (precno_y*pcy == y ) {
+ for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
for (layno = 0; layno < image_info->layer; layno++) {
start_pos = image_info->tile[tileno].packet[pack_nb].start_pos;
@@ -2332,11 +2333,11 @@ static int j2k_create_index(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_info_t *im
pack_nb++;
}
}
- }
- } /* precno */
- } /* compno */
- } /* x = x0..x1 */
- } /* y = y0..y1 */
+ }/* x = x0..x1 */
+ }
+ } /* y = y0..y1 */
+ } /* precno */
+ } /* compno */
} /* resno */
} /* RPCL */
else if (image_info->prog == PCRL) { /* PCRL */
@@ -2345,21 +2346,21 @@ static int j2k_create_index(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_info_t *im
int y0 = image_info->tile_Ox + (int)floor( (float)tileno/(float)image_info->tw ) * image_info->tile_y;
int x1 = x0 + image_info->tile_x;
int y1 = y0 + image_info->tile_y;
- /*
- fprintf(stream, "\npack_nb tileno precno compno resno layno start_pos end_pos disto\n");
- */
- for(y = y0; y < y1; y++) {
- for(x = x0; x < x1; x++) {
- for (compno = 0; compno < image_info->comp; compno++) {
- for (resno = 0; resno < image_info->decomposition + 1; resno++) {
- int prec_max = image_info->tile[tileno].pw[resno] * image_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- int pcnx = image_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, image_info->tile[tileno].pdx[resno] + image_info->decomposition - resno );
- int pcy = (int) pow( 2, image_info->tile[tileno].pdy[resno] + image_info->decomposition - resno );
- int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
- int precno_y = (int) floor( (float)precno/(float)pcnx );
- if (precno_y*pcy == y ) {
+
+ fprintf(stream, "\npack_nb tileno precno compno resno layno start_pos end_pos disto\n");
+
+ for (compno = 0; compno < image_info->comp; compno++) {
+ for (resno = 0; resno < image_info->decomposition + 1; resno++) {
+ int prec_max = image_info->tile[tileno].pw[resno] * image_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < prec_max; precno++) {
+ int pcnx = image_info->tile[tileno].pw[resno];
+ int pcx = (int) pow( 2, image_info->tile[tileno].pdx[resno] + image_info->decomposition - resno );
+ int pcy = (int) pow( 2, image_info->tile[tileno].pdy[resno] + image_info->decomposition - resno );
+ int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
+ int precno_y = (int) floor( (float)precno/(float)pcnx );
+ for(y = y0; y < y1; y++) {
+ if (precno_y*pcy == y ) {
+ for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
for (layno = 0; layno < image_info->layer; layno++) {
start_pos = image_info->tile[tileno].packet[pack_nb].start_pos;
@@ -2371,34 +2372,35 @@ static int j2k_create_index(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_info_t *im
pack_nb++;
}
}
- }
- } /* precno */
- } /* resno */
- } /* compno */
- } /* x = x0..x1 */
- } /* y = y0..y1 */
+ }/* x = x0..x1 */
+ }
+ } /* y = y0..y1 */
+ } /* precno */
+ } /* resno */
+ } /* compno */
} /* PCRL */
else { /* CPRL */
- /*
- fprintf(stream, "\npack_nb tileno compno precno resno layno start_pos end_pos disto\n");
- */
+
+ fprintf(stream, "\npack_nb tileno compno precno resno layno start_pos end_pos disto\n");
+
for (compno = 0; compno < image_info->comp; compno++) {
/* I suppose components have same XRsiz, YRsiz */
int x0 = image_info->tile_Ox + tileno - (int)floor( (float)tileno/(float)image_info->tw ) * image_info->tw * image_info->tile_x;
int y0 = image_info->tile_Ox + (int)floor( (float)tileno/(float)image_info->tw ) * image_info->tile_y;
int x1 = x0 + image_info->tile_x;
int y1 = y0 + image_info->tile_y;
- for(y = y0; y < y1; y++) {
- for(x = x0; x < x1; x++) {
- for (resno = 0; resno < image_info->decomposition + 1; resno++) {
- int prec_max = image_info->tile[tileno].pw[resno] * image_info->tile[tileno].ph[resno];
- for (precno = 0; precno < prec_max; precno++) {
- int pcnx = image_info->tile[tileno].pw[resno];
- int pcx = (int) pow( 2, image_info->tile[tileno].pdx[resno] + image_info->decomposition - resno );
- int pcy = (int) pow( 2, image_info->tile[tileno].pdy[resno] + image_info->decomposition - resno );
- int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
- int precno_y = (int) floor( (float)precno/(float)pcnx );
- if (precno_y*pcy == y ) {
+
+ for (resno = 0; resno < image_info->decomposition + 1; resno++) {
+ int prec_max = image_info->tile[tileno].pw[resno] * image_info->tile[tileno].ph[resno];
+ for (precno = 0; precno < prec_max; precno++) {
+ int pcnx = image_info->tile[tileno].pw[resno];
+ int pcx = (int) pow( 2, image_info->tile[tileno].pdx[resno] + image_info->decomposition - resno );
+ int pcy = (int) pow( 2, image_info->tile[tileno].pdy[resno] + image_info->decomposition - resno );
+ int precno_x = precno - (int) floor( (float)precno/(float)pcnx ) * pcnx;
+ int precno_y = (int) floor( (float)precno/(float)pcnx );
+ for(y = y0; y < y1; y++) {
+ if (precno_y*pcy == y ) {
+ for (x = x0; x < x1; x++) {
if (precno_x*pcx == x ) {
for (layno = 0; layno < image_info->layer; layno++) {
start_pos = image_info->tile[tileno].packet[pack_nb].start_pos;
@@ -2410,12 +2412,12 @@ static int j2k_create_index(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_info_t *im
pack_nb++;
}
}
- }
- } /* precno */
- } /* resno */
- } /* x = x0..x1 */
- } /* y = y0..y1 */
- } /* comno */
+ }/* x = x0..x1 */
+ }
+ } /* y = y0..y1 */
+ } /* precno */
+ } /* resno */
+ } /* compno */
} /* CPRL */
} /* tileno */
diff --git a/libopenjpeg/t2.c b/libopenjpeg/t2.c
index dc8e24ed..f8bda1ca 100644
--- a/libopenjpeg/t2.c
+++ b/libopenjpeg/t2.c
@@ -581,11 +581,7 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
return -999;
}
- if(image_info) {
- image_info->num = 0;
- }
-
- if(t2_mode == THRESH_CALC ){
+ if(t2_mode == THRESH_CALC ){ /* Calculating threshold */
for(compno = 0; compno < maxcomp; compno++ ){
for(poc = 0; poc < pocno ; poc++){
int comp_len = 0;
@@ -605,14 +601,14 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
if (e == -999) break;
if (cp->max_comp_size){
if (comp_len > cp->max_comp_size){
- e = -999;
- break;
+ e = -999;
+ break;
}
}
}
if (e == -999) break;
}
- }else{
+ }else{ /* t2_mode == FINAL_PASS */
pi_create_encode(pi, cp,tileno,pino,tpnum,tppos);
while (pi_next(&pi[pino])) {
if (pi[pino].layno < maxlayers) {
@@ -622,33 +618,33 @@ int t2_encode_packets(opj_t2_t* t2,int tileno, opj_tcd_tile_t *tile, int maxlaye
} else {
c += e;
}
- }
- }
- }
-
- /* INDEX >> */
- if(image_info && image_info->index_on) {
- if(image_info->index_write) {
- opj_tile_info_t *info_TL = &image_info->tile[tileno];
- opj_packet_info_t *info_PK = &info_TL->packet[image_info->num];
- if (!image_info->num) {
- info_PK->start_pos = info_TL->end_header + 1;
- } else {
- info_PK->start_pos = info_TL->packet[image_info->num - 1].end_pos + 1;
+ /* INDEX >> */
+ if(image_info && image_info->index_on) {
+ if(image_info->index_write) {
+ opj_tile_info_t *info_TL = &image_info->tile[tileno];
+ opj_packet_info_t *info_PK = &info_TL->packet[image_info->num];
+ if (!image_info->num) {
+ info_PK->start_pos = info_TL->end_header + 1;
+ } else {
+ info_PK->start_pos = (cp->tp_on && info_PK->start_pos) ? info_PK->start_pos : info_TL->packet[image_info->num - 1].end_pos + 1;
+ }
+ info_PK->end_pos = info_PK->start_pos + e - 1;
}
- info_PK->end_pos = info_PK->start_pos + e - 1;
+
+ image_info->num++;
}
-
- image_info->num++;
+ /* << INDEX */
}
- /* << INDEX */
- pi_destroy(pi, cp, tileno);
+ }
+ }
+
+ pi_destroy(pi, cp, tileno);
if (e == -999) {
return e;
}
-
- return (c - dest);
+
+ return (c - dest);
}
int t2_decode_packets(opj_t2_t *t2, unsigned char *src, int len, int tileno, opj_tcd_tile_t *tile) {