[FFmpeg-cvslog] jpeg2000: do not compute the same value twice
Vittorio Giovara
git at videolan.org
Thu Nov 13 15:26:20 CET 2014
ffmpeg | branch: master | Vittorio Giovara <vittorio.giovara at gmail.com> | Wed Nov 12 11:13:11 2014 +0100| [a2448cfe167a4cd4eb631318550d4eef38fca24a] | committer: Vittorio Giovara
jpeg2000: do not compute the same value twice
CC: libav-stable at libav.org
Bug-Id: CID 1026771 / CID 1026772 / CID 1026773
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a2448cfe167a4cd4eb631318550d4eef38fca24a
---
libavcodec/jpeg2000.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index fadb5cb..2ccd078 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -373,16 +373,14 @@ 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_mallocz_array(reslevel->num_precincts_x *
- reslevel->num_precincts_y,
- sizeof(*band->prec));
+ nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
+ band->prec = av_mallocz_array(nb_precincts, sizeof(*band->prec));
if (!band->prec)
return AVERROR(ENOMEM);
- nb_precincts = reslevel->num_precincts_x * reslevel->num_precincts_y;
-
for (precno = 0; precno < nb_precincts; precno++) {
Jpeg2000Prec *prec = band->prec + precno;
+ int nb_codeblocks;
/* TODO: Explain formula for JPEG200 DCINEMA. */
/* TODO: Verify with previous count of codeblocks per band */
@@ -429,12 +427,11 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
if (!prec->zerobits)
return AVERROR(ENOMEM);
- prec->cblk = av_mallocz_array(prec->nb_codeblocks_width *
- prec->nb_codeblocks_height,
- sizeof(*prec->cblk));
+ nb_codeblocks = prec->nb_codeblocks_width * prec->nb_codeblocks_height;
+ prec->cblk = av_mallocz_array(nb_codeblocks, sizeof(*prec->cblk));
if (!prec->cblk)
return AVERROR(ENOMEM);
- for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) {
+ for (cblkno = 0; cblkno < nb_codeblocks; cblkno++) {
Jpeg2000Cblk *cblk = prec->cblk + cblkno;
uint16_t Cx0, Cy0;
More information about the ffmpeg-cvslog
mailing list