[FFmpeg-cvslog] libopenjpeg: support decoding with bits per pixel greater than 8

Jean First git at videolan.org
Sat Dec 24 02:42:43 CET 2011


ffmpeg | branch: master | Jean First <jeanfirst at gmail.com> | Thu Dec 22 22:26:21 2011 +0100| [0d4a77472ad8a4d194e93379a992f66c33fbf144] | committer: Michael Niedermayer

libopenjpeg: support decoding with bits per pixel greater than 8

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
Approved-by: Alex Zhukov

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0d4a77472ad8a4d194e93379a992f66c33fbf144
---

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

diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index ca3ef5f..6344ad0 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -54,7 +54,7 @@ static enum PixelFormat check_image_attributes(AVCodecContext *avctx, opj_image_
     case 0111111: goto libopenjpeg_yuv444_rgb;
     case 0112121: goto libopenjpeg_yuv422;
     case 0112222: goto libopenjpeg_yuv420;
-    default: return PIX_FMT_RGB24;
+    default: goto libopenjpeg_rgb;
     }
 
 libopenjpeg_yuv420:
@@ -80,6 +80,13 @@ libopenjpeg_yuv444_rgb:
     case 10: return PIX_FMT_YUV444P10;
     case 16: return PIX_FMT_YUV444P16;
     }
+
+libopenjpeg_rgb:
+    switch (c0.prec) {
+    case 8: return PIX_FMT_RGB24;
+    default: return PIX_FMT_RGB48;
+    }
+
     return PIX_FMT_RGB24;
 }
 
@@ -107,6 +114,24 @@ 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) {
+    uint16_t *img_ptr;
+    int index, x, y, c;
+    int adjust[4];
+    for (x = 0; x < image->numcomps; x++) {
+        adjust[x] = FFMAX(FFMIN(16 - image->comps[x].prec, 8), 0);
+    }
+    for (y = 0; y < picture->height; y++) {
+        index = y*picture->width;
+        img_ptr = (uint16_t*) (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] << adjust[c];
+            }
+        }
+    }
+}
+
 static inline void libopenjpeg_copyto8(AVFrame *picture, opj_image_t *image) {
     int *comp_data;
     uint8_t *img_ptr;
@@ -275,6 +300,11 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
             libopenjpeg_copy_to_packed8(picture, image);
         }
         break;
+    case 6:
+        if (ispacked) {
+            libopenjpeg_copy_to_packed16(picture, image);
+        }
+        break;
     default:
         av_log(avctx, AV_LOG_ERROR, "unsupported pixel size %d\n", pixel_size);
         goto done;



More information about the ffmpeg-cvslog mailing list