for (bandno = 0; bandno < res->numbands; bandno++) {
opj_tcd_band_t *band = &res->bands[bandno];
+ /* Skip empty bands */
+ if (opj_tcd_is_band_empty(band)) {
+ continue;
+ }
+
for (precno = 0; precno < res->pw * res->ph; precno++) {
opj_tcd_precinct_t *prc = &band->precincts[precno];
for (bandno = 0; bandno < res->numbands; bandno++) {
opj_tcd_band_t *band = &res->bands[bandno];
+ /* Skip empty bands */
+ if (opj_tcd_is_band_empty(band)) {
+ continue;
+ }
+
for (precno = 0; precno < res->pw * res->ph; precno++) {
opj_tcd_precinct_t *prc = &band->precincts[precno];
for (bandno = 0; bandno < res->numbands; bandno++) {
opj_tcd_band_t *band = &res->bands[bandno];
+ /* Skip empty bands */
+ if (opj_tcd_is_band_empty(band)) {
+ continue;
+ }
+
for (precno = 0; precno < res->pw * res->ph; precno++) {
opj_tcd_precinct_t *prc = &band->precincts[precno];
cblkheightexpn = opj_uint_min(l_tccp->cblkh, cbgheightexpn);
l_band = l_res->bands;
- for (bandno = 0; bandno < l_res->numbands; ++bandno) {
+ for (bandno = 0; bandno < l_res->numbands; ++bandno, ++l_band, ++l_step_size) {
OPJ_INT32 numbps;
/*fprintf(stderr, "\t\t\tband_no=%d/%d\n", bandno, l_res->numbands );*/
l_level_no), (OPJ_INT32)(l_level_no + 1));
}
+ if (isEncoder) {
+ /* Skip empty bands */
+ if (opj_tcd_is_band_empty(l_band)) {
+ /* Do not zero l_band->precints to avoid leaks */
+ /* but make sure we don't use it later, since */
+ /* it will point to precincts of previous bands... */
+ continue;
+ }
+ }
+
/** avoid an if with storing function pointer */
l_gain = (*l_gain_ptr)(l_band->bandno);
numbps = (OPJ_INT32)(l_image_comp->prec + l_gain);
}
++l_current_precinct;
} /* precno */
- ++l_band;
- ++l_step_size;
} /* bandno */
++l_res;
} /* resno */
return OPJ_TRUE;
}
+
+OPJ_BOOL opj_tcd_is_band_empty(opj_tcd_band_t* band)
+{
+ return (band->x1 - band->x0 == 0) || (band->y1 - band->y0 == 0);
+}