summaryrefslogtreecommitdiff
path: root/libavcodec/jpeg2000.c
diff options
context:
space:
mode:
authorGautam Ramakrishnan <gautamramk@gmail.com>2020-08-28 00:15:35 +0530
committerMichael Niedermayer <michael@niedermayer.cc>2020-08-30 16:18:37 +0200
commitf0e33119e4fa1cf1705c16affa5daa6f0b487b48 (patch)
treea838ae94bbb6da351e1b498140ff083de98c3526 /libavcodec/jpeg2000.c
parent3c06045a8b584a8d569547c2f4d108588cce6a37 (diff)
downloadffmpeg-f0e33119e4fa1cf1705c16affa5daa6f0b487b48.tar.gz
libavcodec/j2kenc: Support for multiple layers
This patch allows setting a compression ratio and to set multiple layers. The user has to input a compression ratio for each layer. The per layer compression ration can be set as follows: -layer_rates "r1,r2,...rn" for to create 'n' layers. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/jpeg2000.c')
-rw-r--r--libavcodec/jpeg2000.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 3d3e7ec313..6501de0d04 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -261,9 +261,11 @@ static void init_band_stepsize(AVCodecContext *avctx,
band->f_stepsize *= 0.5;
}
-static int init_prec(Jpeg2000Band *band,
+static int init_prec(AVCodecContext *avctx,
+ Jpeg2000Band *band,
Jpeg2000ResLevel *reslevel,
Jpeg2000Component *comp,
+ Jpeg2000CodingStyle *codsty,
int precno, int bandno, int reslevelno,
int log2_band_prec_width,
int log2_band_prec_height)
@@ -366,6 +368,11 @@ static int init_prec(Jpeg2000Band *band,
cblk->lblock = 3;
cblk->length = 0;
cblk->npasses = 0;
+ if (av_codec_is_encoder(avctx->codec)) {
+ cblk->layers = av_mallocz_array(codsty->nlayers, sizeof(*cblk->layers));
+ if (!cblk->layers)
+ return AVERROR(ENOMEM);
+ }
}
return 0;
@@ -439,7 +446,7 @@ static int init_band(AVCodecContext *avctx,
return AVERROR(ENOMEM);
for (precno = 0; precno < nb_precincts; precno++) {
- ret = init_prec(band, reslevel, comp,
+ ret = init_prec(avctx, band, reslevel, comp, codsty,
precno, bandno, reslevelno,
log2_band_prec_width, log2_band_prec_height);
if (ret < 0)
@@ -614,6 +621,7 @@ void ff_jpeg2000_cleanup(Jpeg2000Component *comp, Jpeg2000CodingStyle *codsty)
av_freep(&cblk->passes);
av_freep(&cblk->lengthinc);
av_freep(&cblk->data_start);
+ av_freep(&cblk->layers);
}
av_freep(&prec->cblk);
}