X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2Fffmpeg%2Flibavcodec%2Fjpeg2000.c;h=ede1a791c813f93cf8541585c6510ad46c6aef9e;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=f3658c2c8404640c500173003a0ebe718d8af392;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/ffmpeg/libavcodec/jpeg2000.c b/src/third_party/ffmpeg/libavcodec/jpeg2000.c index f3658c2..ede1a79 100644 --- a/src/third_party/ffmpeg/libavcodec/jpeg2000.c +++ b/src/third_party/ffmpeg/libavcodec/jpeg2000.c @@ -25,6 +25,7 @@ * JPEG 2000 image encoder and decoder common functions */ +#include "libavutil/attributes.h" #include "libavutil/avassert.h" #include "libavutil/common.h" #include "libavutil/mem.h" @@ -153,7 +154,7 @@ static int getsgnctxno(int flag, uint8_t *xorbit) return ctxlbltab[hcontrib][vcontrib]; } -void ff_jpeg2000_init_tier1_luts(void) +void av_cold ff_jpeg2000_init_tier1_luts(void) { int i, j; for (i = 0; i < 256; i++) @@ -224,7 +225,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, if (!comp->i_data) return AVERROR(ENOMEM); } - comp->reslevel = av_calloc(codsty->nreslevels, sizeof(*comp->reslevel)); + comp->reslevel = av_mallocz_array(codsty->nreslevels, sizeof(*comp->reslevel)); if (!comp->reslevel) return AVERROR(ENOMEM); /* LOOP on resolution levels */ @@ -249,7 +250,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, else reslevel->nbands = 3; - /* Number of precincts wich span the tile for resolution level reslevelno + /* Number of precincts which span the tile for resolution level reslevelno * see B.6 in ISO/IEC 15444-1:2002 eq. B-16 * num_precincts_x = |- trx_1 / 2 ^ log2_prec_width) -| - (trx_0 / 2 ^ log2_prec_width) * num_precincts_y = |- try_1 / 2 ^ log2_prec_width) -| - (try_0 / 2 ^ log2_prec_width) @@ -272,7 +273,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, reslevel->log2_prec_height) - (reslevel->coord[1][0] >> reslevel->log2_prec_height); - reslevel->band = av_calloc(reslevel->nbands, sizeof(*reslevel->band)); + reslevel->band = av_mallocz_array(reslevel->nbands, sizeof(*reslevel->band)); if (!reslevel->band) return AVERROR(ENOMEM); @@ -368,9 +369,9 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp, for (j = 0; j < 2; j++) band->coord[1][j] = ff_jpeg2000_ceildiv(band->coord[1][j], dy); - band->prec = av_calloc(reslevel->num_precincts_x * - (uint64_t)reslevel->num_precincts_y, - sizeof(*band->prec)); + band->prec = av_mallocz_array(reslevel->num_precincts_x * + (uint64_t)reslevel->num_precincts_y, + sizeof(*band->prec)); if (!band->prec) return AVERROR(ENOMEM); @@ -504,22 +505,29 @@ void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty) for (reslevelno = 0; comp->reslevel && reslevelno < codsty->nreslevels; reslevelno++) { - Jpeg2000ResLevel *reslevel = comp->reslevel + reslevelno; + Jpeg2000ResLevel *reslevel; + + if (!comp->reslevel) + continue; + reslevel = comp->reslevel + reslevelno; for (bandno = 0; bandno < reslevel->nbands; bandno++) { - if (reslevel->band) { - Jpeg2000Band *band = reslevel->band + bandno; - for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++) { - if (band->prec) { - Jpeg2000Prec *prec = band->prec + precno; - av_freep(&prec->zerobits); - av_freep(&prec->cblkincl); - av_freep(&prec->cblk); - } + Jpeg2000Band *band; + + if (!reslevel->band) + continue; + + band = reslevel->band + bandno; + for (precno = 0; precno < reslevel->num_precincts_x * reslevel->num_precincts_y; precno++) { + if (band->prec) { + Jpeg2000Prec *prec = band->prec + precno; + av_freep(&prec->zerobits); + av_freep(&prec->cblkincl); + av_freep(&prec->cblk); } - - av_freep(&band->prec); } + + av_freep(&band->prec); } av_freep(&reslevel->band); }