>From 35466223f5921fb3bd146133031c34f299a33a00 Mon Sep 17 00:00:00 2001
From: Jean First <jeanfirst@gmail.com>
Date: Wed, 21 Dec 2011 14:21:52 +0100
Subject: [PATCH] libopenjpegdec: fix rgb24 decoding regression from commit
 eb511ef6

---
 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

