MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / init_band

Function init_band

libavcodec/jpeg2000.c:392–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390}
391
392static int init_band(AVCodecContext *avctx,
393 Jpeg2000ResLevel *reslevel,
394 Jpeg2000Component *comp,
395 Jpeg2000CodingStyle *codsty,
396 Jpeg2000QuantStyle *qntsty,
397 int bandno, int gbandno, int reslevelno,
398 const int cbps, int dx, int dy)
399{
400 Jpeg2000Band *band = reslevel->band + bandno;
401 uint8_t log2_band_prec_width, log2_band_prec_height;
402 int declvl = codsty->nreslevels - reslevelno; // N_L -r see ISO/IEC 15444-1:2002 B.5
403 int precno;
404 int nb_precincts;
405 int i, j, ret;
406
407 init_band_stepsize(avctx, band, codsty, qntsty, bandno, gbandno, reslevelno, cbps);
408
409 /* computation of tbx_0, tbx_1, tby_0, tby_1
410 * see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1
411 * codeblock width and height is computed for
412 * DCI JPEG 2000 codeblock_width = codeblock_width = 32 = 2 ^ 5 */
413 if (reslevelno == 0) {
414 /* for reslevelno = 0, only one band, x0_b = y0_b = 0 */
415 for (i = 0; i < 2; i++)
416 for (j = 0; j < 2; j++)
417 band->coord[i][j] =
418 ff_jpeg2000_ceildivpow2(comp->coord_o[i][j],
419 declvl - 1);
420 log2_band_prec_width = reslevel->log2_prec_width;
421 log2_band_prec_height = reslevel->log2_prec_height;
422 /* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
423 band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
424 reslevel->log2_prec_width);
425 band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
426 reslevel->log2_prec_height);
427 } else {
428 /* 3 bands x0_b = 1 y0_b = 0; x0_b = 0 y0_b = 1; x0_b = y0_b = 1 */
429 /* x0_b and y0_b are computed with ((bandno + 1 >> i) & 1) */
430 for (i = 0; i < 2; i++)
431 for (j = 0; j < 2; j++)
432 /* Formula example for tbx_0 = ceildiv((tcx_0 - 2 ^ (declvl - 1) * x0_b) / declvl) */
433 band->coord[i][j] =
434 ff_jpeg2000_ceildivpow2(comp->coord_o[i][j] -
435 (((bandno + 1 >> i) & 1LL) << declvl - 1),
436 declvl);
437 /* TODO: Manage case of 3 band offsets here or
438 * in coding/decoding function? */
439
440 /* see ISO/IEC 15444-1:2002 eq. B-17 and eq. B-15 */
441 band->log2_cblk_width = FFMIN(codsty->log2_cblk_width,
442 reslevel->log2_prec_width - 1);
443 band->log2_cblk_height = FFMIN(codsty->log2_cblk_height,
444 reslevel->log2_prec_height - 1);
445
446 log2_band_prec_width = reslevel->log2_prec_width - 1;
447 log2_band_prec_height = reslevel->log2_prec_height - 1;
448 }
449

Callers 1

Calls 4

init_band_stepsizeFunction · 0.85
ff_jpeg2000_ceildivpow2Function · 0.85
av_callocFunction · 0.85
init_precFunction · 0.85

Tested by

no test coverage detected