mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
libopenjpegdec.c: Correctly scale gray16 output if precision < 16
Fixes ticket #2943. Signed-off-by: Carl Eugen Hoyos <cehoyos@ag.or.at>
This commit is contained in:
parent
d73565d5dd
commit
7412a4a48f
@ -207,12 +207,16 @@ static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) {
|
|||||||
int *comp_data;
|
int *comp_data;
|
||||||
uint16_t *img_ptr;
|
uint16_t *img_ptr;
|
||||||
int index, x, y;
|
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++) {
|
for (index = 0; index < image->numcomps; index++) {
|
||||||
comp_data = image->comps[index].data;
|
comp_data = image->comps[index].data;
|
||||||
for (y = 0; y < image->comps[index].h; y++) {
|
for (y = 0; y < image->comps[index].h; y++) {
|
||||||
img_ptr = (uint16_t*) (picture->data[index] + y * picture->linesize[index]);
|
img_ptr = (uint16_t*) (picture->data[index] + y * picture->linesize[index]);
|
||||||
for (x = 0; x < image->comps[index].w; x++) {
|
for (x = 0; x < image->comps[index].w; x++) {
|
||||||
*img_ptr = *comp_data;
|
*img_ptr = *comp_data << adjust[index];
|
||||||
img_ptr++;
|
img_ptr++;
|
||||||
comp_data++;
|
comp_data++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user