mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-02-04 06:08:26 +02:00
acvodec/lipopenjpeg: Fix pixel value shift for 12-bit pixel formats
This fixes pixel values not being properly shifted in libopenjpeg_copyto16 and libopenjpeg_copy_to_packed16 methods. Pixel formats like xyz12le need to be shifted by AVComponentDescriptor::shift to get the correct values. Reviewed-by: Michael Bradshaw <mjbshaw@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
37ffe7f90a
commit
ff6b08141a
@ -184,10 +184,11 @@ static inline void libopenjpeg_copy_to_packed8(AVFrame *picture, opj_image_t *im
|
|||||||
|
|
||||||
static inline void libopenjpeg_copy_to_packed16(AVFrame *picture, opj_image_t *image) {
|
static inline void libopenjpeg_copy_to_packed16(AVFrame *picture, opj_image_t *image) {
|
||||||
uint16_t *img_ptr;
|
uint16_t *img_ptr;
|
||||||
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(picture->format);
|
||||||
int index, x, y, c;
|
int index, x, y, c;
|
||||||
int adjust[4];
|
int adjust[4];
|
||||||
for (x = 0; x < image->numcomps; x++)
|
for (x = 0; x < image->numcomps; x++)
|
||||||
adjust[x] = FFMAX(FFMIN(av_pix_fmt_desc_get(picture->format)->comp[x].depth_minus1 + 1 - image->comps[x].prec, 8), 0);
|
adjust[x] = FFMAX(FFMIN(desc->comp[x].depth_minus1 + 1 - image->comps[x].prec, 8), 0) + desc->comp[x].shift;
|
||||||
|
|
||||||
for (y = 0; y < picture->height; y++) {
|
for (y = 0; y < picture->height; y++) {
|
||||||
index = y * picture->width;
|
index = y * picture->width;
|
||||||
@ -220,10 +221,11 @@ static inline void libopenjpeg_copyto8(AVFrame *picture, opj_image_t *image) {
|
|||||||
static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) {
|
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;
|
||||||
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(picture->format);
|
||||||
int index, x, y;
|
int index, x, y;
|
||||||
int adjust[4];
|
int adjust[4];
|
||||||
for (x = 0; x < image->numcomps; x++)
|
for (x = 0; x < image->numcomps; x++)
|
||||||
adjust[x] = FFMAX(FFMIN(av_pix_fmt_desc_get(picture->format)->comp[x].depth_minus1 + 1 - image->comps[x].prec, 8), 0);
|
adjust[x] = FFMAX(FFMIN(desc->comp[x].depth_minus1 + 1 - image->comps[x].prec, 8), 0) + desc->comp[x].shift;
|
||||||
|
|
||||||
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user