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

Function ff_jpeg2000_init_component

libavcodec/jpeg2000.c:470–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468}
469
470int ff_jpeg2000_init_component(Jpeg2000Component *comp,
471 Jpeg2000CodingStyle *codsty,
472 Jpeg2000QuantStyle *qntsty,
473 const int cbps, int dx, int dy,
474 AVCodecContext *avctx)
475{
476 int reslevelno, bandno, gbandno = 0, ret, i, j;
477 uint32_t csize;
478
479 if (codsty->nreslevels2decode <= 0) {
480 av_log(avctx, AV_LOG_ERROR, "nreslevels2decode %d invalid or uninitialized\n", codsty->nreslevels2decode);
481 return AVERROR_INVALIDDATA;
482 }
483
484 if (ret = ff_jpeg2000_dwt_init(&comp->dwt, comp->coord,
485 codsty->nreslevels2decode - 1,
486 codsty->transform))
487 return ret;
488
489 if (av_image_check_size(comp->coord[0][1] - comp->coord[0][0],
490 comp->coord[1][1] - comp->coord[1][0], 0, avctx))
491 return AVERROR_INVALIDDATA;
492 csize = (comp->coord[0][1] - comp->coord[0][0]) *
493 (comp->coord[1][1] - comp->coord[1][0]);
494 if (comp->coord[0][1] - comp->coord[0][0] > 32768 ||
495 comp->coord[1][1] - comp->coord[1][0] > 32768) {
496 av_log(avctx, AV_LOG_ERROR, "component size too large\n");
497 return AVERROR_PATCHWELCOME;
498 }
499
500 if (codsty->transform == FF_DWT97) {
501 csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->f_data);
502 comp->i_data = NULL;
503 comp->f_data = av_calloc(csize, sizeof(*comp->f_data));
504 if (!comp->f_data)
505 return AVERROR(ENOMEM);
506 } else {
507 csize += AV_INPUT_BUFFER_PADDING_SIZE / sizeof(*comp->i_data);
508 comp->f_data = NULL;
509 comp->i_data = av_calloc(csize, sizeof(*comp->i_data));
510 if (!comp->i_data)
511 return AVERROR(ENOMEM);
512 }
513 comp->reslevel = av_calloc(codsty->nreslevels, sizeof(*comp->reslevel));
514 if (!comp->reslevel)
515 return AVERROR(ENOMEM);
516 /* LOOP on resolution levels */
517 for (reslevelno = 0; reslevelno < codsty->nreslevels; reslevelno++) {
518 int declvl = codsty->nreslevels - reslevelno; // N_L -r see ISO/IEC 15444-1:2002 B.5
519 Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno;
520
521 /* Compute borders for each resolution level.
522 * Computation of trx_0, trx_1, try_0 and try_1.
523 * see ISO/IEC 15444-1:2002 eq. B.5 and B-14 */
524 for (i = 0; i < 2; i++)
525 for (j = 0; j < 2; j++)
526 reslevel->coord[i][j] =
527 ff_jpeg2000_ceildivpow2(comp->coord_o[i][j], declvl - 1);

Callers 2

init_tilesFunction · 0.85
init_tileFunction · 0.85

Calls 6

av_logFunction · 0.85
ff_jpeg2000_dwt_initFunction · 0.85
av_image_check_sizeFunction · 0.85
av_callocFunction · 0.85
ff_jpeg2000_ceildivpow2Function · 0.85
init_bandFunction · 0.85

Tested by

no test coverage detected