[FFmpeg-devel] [PATCH] libopenjpegdec: fix rgb24 decoding regression from commit eb511ef6

Jean First jeanfirst at gmail.com
Wed Dec 21 14:33:17 CET 2011


Hi,

attached patch fixes a regression introduced with commit eb511ef6.
maybe libopenjpeg_copyto8 and libopenjpeg_copyto16 need this fix too.  Alex Zhukov, can you please check this ?

Jean

---
 libavcodec/libopenjpegdec.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index baa516b..713effe 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -96,12 +96,16 @@ static inline int libopenjpeg_ispacked(enum PixelFormat pix_fmt) {
 static inline void libopenjpeg_copy_to_packed8(AVFrame *picture, opj_image_t *image) {
     uint8_t *img_ptr;
     int index, x, y, c;
+    int adjust[4];
+    for(x = 0; x < image->numcomps; x++) {
+        adjust[x] = FFMAX(image->comps[x].prec - 8, 0);
+    }
     for(y = 0; y < picture->height; y++) {
         index = y*picture->width;
         img_ptr = picture->data[0] + y*picture->linesize[0];
         for(x = 0; x < picture->width; x++, index++) {
             for(c = 0; c < image->numcomps; c++) {
-                *img_ptr++ = image->comps[c].data[index];
+                *img_ptr++ = image->comps[c].data[index] >> adjust[c];
             }
         }
     }
-- 
1.7.6.1



More information about the ffmpeg-devel mailing list