diff options
author | Michael Bradshaw <mjbshaw@gmail.com> | 2013-09-12 09:21:51 +0200 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2013-09-12 09:21:51 +0200 |
commit | 7412a4a48f23fd1a08fd30e75bbf116b6186fef9 (patch) | |
tree | 2684f41f71e9afa4b0f00efda46f7caa8a8d6e5f /libavcodec/libopenjpegdec.c | |
parent | d73565d5ddf41d4b7805327cdb271c59d8c3fc59 (diff) | |
download | ffmpeg-7412a4a48f23fd1a08fd30e75bbf116b6186fef9.tar.gz |
libopenjpegdec.c: Correctly scale gray16 output if precision < 16
Fixes ticket #2943.
Signed-off-by: Carl Eugen Hoyos <cehoyos@ag.or.at>
Diffstat (limited to 'libavcodec/libopenjpegdec.c')
-rw-r--r-- | libavcodec/libopenjpegdec.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c index c331b590e8..27fb56e03f 100644 --- a/libavcodec/libopenjpegdec.c +++ b/libavcodec/libopenjpegdec.c @@ -207,12 +207,16 @@ static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) { int *comp_data; uint16_t *img_ptr; int index, x, y; + int adjust[4]; + for (x = 0; x < image->numcomps; x++) + adjust[x] = FFMAX(FFMIN(16 - image->comps[x].prec, 8), 0); + for (index = 0; index < image->numcomps; index++) { comp_data = image->comps[index].data; for (y = 0; y < image->comps[index].h; y++) { img_ptr = (uint16_t*) (picture->data[index] + y * picture->linesize[index]); for (x = 0; x < image->comps[index].w; x++) { - *img_ptr = *comp_data; + *img_ptr = *comp_data << adjust[index]; img_ptr++; comp_data++; } |