/*
+ * Copyright (c) 2002-2007, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
+ * Copyright (c) 2002-2007, Professor Benoit Macq
* Copyright (c) 2001-2003, David Janssens
* Copyright (c) 2002-2003, Yannick Verschueren
- * Copyright (c) 2003-2005, Francois Devaux and Antonin Descampe
- * Copyright (c) 2005, Herv� Drolon, FreeImage Team
- * Copyright (c) 2002-2005, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
+ * Copyright (c) 2003-2007, Francois-Olivier Devaux and Antonin Descampe
+ * Copyright (c) 2005, Herve Drolon, FreeImage Team
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
/* Modification of the RATE >> */
for (j = 0; j < tcp->numlayers; j++) {
tcp->rates[j] = tcp->rates[j] ?
- int_ceildiv(tile->numcomps
+ ((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))
+ * image->comps[0].prec))/
+ (tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy)
: 0;
if (tcp->rates[j]) {
/* Modification of the RATE >> */
for (j = 0; j < tcp->numlayers; j++) {
tcp->rates[j] = tcp->rates[j] ?
- int_ceildiv(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))
- : 0;
+ ((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)
+ : 0;
if (tcp->rates[j]) {
if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) {
int compno, resno, bandno, precno, cblkno, passno, layno;
double min, max;
double cumdisto[100]; /* fixed_quality */
- const double K = 1; /* 1.1; // fixed_quality */
+ const double K = 1; /* 1.1; fixed_quality */
double maxSE = 0;
opj_cp_t *cp = tcd->cp;
double lo = min;
double hi = max;
int success = 0;
- // TODO: remove maxlen
- int maxlen = tcd_tcp->rates[layno] ? int_min(tcd_tcp->rates[layno], len) : len;
+ /* TODO: remove maxlen */
+ int maxlen = tcd_tcp->rates[layno] ? int_min(((int) ceil(tcd_tcp->rates[layno])), len) : len;
double goodthresh = 0;
int i;
double distotarget; /* fixed_quality */
tcd_makelayer(tcd, layno, thresh, 0);
if (cp->fixed_quality) { /* fixed_quality */
- distoachieved = (layno == 0) ?
- tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
- if (distoachieved < distotarget) {
- hi = thresh;
- continue;
+ if(cp->cinema){
+ l = t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest, maxlen, image_info);
+ if (l == -999) {
+ lo = thresh;
+ continue;
+ }else{
+ distoachieved = layno == 0 ?
+ tcd_tile->distolayer[0] : cumdisto[layno - 1] + tcd_tile->distolayer[layno];
+ if (distoachieved < distotarget) {
+ hi=thresh; continue;
+ }else{
+ lo=thresh;
+ }
+ }
+ }else{
+ distoachieved = (layno == 0) ?
+ tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]);
+ if (distoachieved < distotarget) {
+ hi = thresh;
+ continue;
+ }
+ lo = thresh;
}
- lo = thresh;
} else {
l = t2_encode_packets(t2, tcd->tcd_tileno, tcd_tile, layno + 1, dest, maxlen, image_info);
- // TODO: what to do with l ??? seek / tell ???
+ /* TODO: what to do with l ??? seek / tell ??? */
/* opj_event_msg(tcd->cinfo, EVT_INFO, "rate alloc: len=%d, max=%d\n", l, maxlen); */
if (l == -999) {
lo = thresh;