opj_tcd_rateallocate(): make sure to use all passes for a lossless layer (#1009)
And save a useless loop, which should be a tiny faster.
This commit is contained in:
parent
7aa071aa27
commit
b428b8c7e7
|
@ -269,28 +269,33 @@ void opj_tcd_makelayer(opj_tcd_t *tcd,
|
||||||
|
|
||||||
n = cblk->numpassesinlayers;
|
n = cblk->numpassesinlayers;
|
||||||
|
|
||||||
for (passno = cblk->numpassesinlayers; passno < cblk->totalpasses; passno++) {
|
if (thresh < 0) {
|
||||||
OPJ_UINT32 dr;
|
/* Special value to indicate to use all passes */
|
||||||
OPJ_FLOAT64 dd;
|
n = cblk->totalpasses;
|
||||||
opj_tcd_pass_t *pass = &cblk->passes[passno];
|
} else {
|
||||||
|
for (passno = cblk->numpassesinlayers; passno < cblk->totalpasses; passno++) {
|
||||||
|
OPJ_UINT32 dr;
|
||||||
|
OPJ_FLOAT64 dd;
|
||||||
|
opj_tcd_pass_t *pass = &cblk->passes[passno];
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
dr = pass->rate;
|
dr = pass->rate;
|
||||||
dd = pass->distortiondec;
|
dd = pass->distortiondec;
|
||||||
} else {
|
} else {
|
||||||
dr = pass->rate - cblk->passes[n - 1].rate;
|
dr = pass->rate - cblk->passes[n - 1].rate;
|
||||||
dd = pass->distortiondec - cblk->passes[n - 1].distortiondec;
|
dd = pass->distortiondec - cblk->passes[n - 1].distortiondec;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dr) {
|
if (!dr) {
|
||||||
if (dd != 0) {
|
if (dd != 0) {
|
||||||
|
n = passno + 1;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (thresh - (dd / dr) <
|
||||||
|
DBL_EPSILON) { /* do not rely on float equality, check with DBL_EPSILON margin */
|
||||||
n = passno + 1;
|
n = passno + 1;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (thresh - (dd / dr) <
|
|
||||||
DBL_EPSILON) { /* do not rely on float equality, check with DBL_EPSILON margin */
|
|
||||||
n = passno + 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,7 +618,8 @@ OPJ_BOOL opj_tcd_rateallocate(opj_tcd_t *tcd,
|
||||||
|
|
||||||
opj_t2_destroy(t2);
|
opj_t2_destroy(t2);
|
||||||
} else {
|
} else {
|
||||||
goodthresh = min;
|
/* Special value to indicate to use all passes */
|
||||||
|
goodthresh = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cstr_info) { /* Threshold for Marcela Index */
|
if (cstr_info) { /* Threshold for Marcela Index */
|
||||||
|
|
Loading…
Reference in New Issue