[FFmpeg-cvslog] libavcodec/jpeg2000dec.c: Modify image dimensions
Gautam Ramakrishnan
git at videolan.org
Sat Jun 27 13:46:43 EEST 2020
ffmpeg | branch: master | Gautam Ramakrishnan <gautamramk at gmail.com> | Mon Jun 22 00:30:05 2020 +0530| [2760de16bc91449b617e3c8dd0d1db1866ba72a8] | committer: Michael Niedermayer
libavcodec/jpeg2000dec.c: Modify image dimensions
Reduce image size of the image if all components have
a non zero sample separation. This is to replicate the
output of opj_decompress.
Improves: p1_01.j2k
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2760de16bc91449b617e3c8dd0d1db1866ba72a8
---
libavcodec/jpeg2000dec.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index ab36009a2d..05e85f4317 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -269,6 +269,8 @@ static int get_siz(Jpeg2000DecoderContext *s)
const enum AVPixelFormat *possible_fmts = NULL;
int possible_fmts_nb = 0;
int ret;
+ int o_dimx, o_dimy; //original image dimensions.
+ int dimx, dimy;
if (bytestream2_get_bytes_left(&s->g) < 36) {
av_log(s->avctx, AV_LOG_ERROR, "Insufficient space for SIZ\n");
@@ -371,11 +373,18 @@ static int get_siz(Jpeg2000DecoderContext *s)
}
/* compute image size with reduction factor */
- ret = ff_set_dimensions(s->avctx,
- ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,
- s->reduction_factor),
- ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
- s->reduction_factor));
+ o_dimx = ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,
+ s->reduction_factor);
+ o_dimy = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
+ s->reduction_factor);
+ dimx = ff_jpeg2000_ceildiv(o_dimx, s->cdx[0]);
+ dimy = ff_jpeg2000_ceildiv(o_dimy, s->cdy[0]);
+ for (i = 1; i < s->ncomponents; i++) {
+ dimx = FFMAX(dimx, ff_jpeg2000_ceildiv(o_dimx, s->cdx[i]));
+ dimy = FFMAX(dimy, ff_jpeg2000_ceildiv(o_dimy, s->cdy[i]));
+ }
+
+ ret = ff_set_dimensions(s->avctx, dimx, dimy);
if (ret < 0)
return ret;
More information about the ffmpeg-cvslog
mailing list