[FFmpeg-cvslog] j2k/jpeg2000: merge pix_fmt setting code

Michael Niedermayer git at videolan.org
Thu May 30 16:51:32 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu May 30 16:45:30 2013 +0200| [310f9dd6988c286ab98b44796105440892f329de] | committer: Michael Niedermayer

j2k/jpeg2000: merge pix_fmt setting code

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

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

 libavcodec/j2kdec.c      |   25 ++++++++++++++++++-------
 libavcodec/jpeg2000dec.c |   42 ++++++++++++++++++++----------------------
 2 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/libavcodec/j2kdec.c b/libavcodec/j2kdec.c
index f263573..1ade0c7 100644
--- a/libavcodec/j2kdec.c
+++ b/libavcodec/j2kdec.c
@@ -215,22 +215,33 @@ static int get_siz(Jpeg2000DecoderContext *s)
                                                s->reduction_factor);
     switch(s->ncomponents) {
     case 1:
-        if (s->precision > 8) {
+        if (s->precision > 8)
             s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
-        } else {
+        else
             s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
-        }
         break;
     case 3:
-        if (s->precision > 8) {
-            s->avctx->pix_fmt = AV_PIX_FMT_RGB48;
-        } else {
-            s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
+        switch (s->avctx->profile) {
+        case FF_PROFILE_JPEG2000_DCINEMA_2K:
+        case FF_PROFILE_JPEG2000_DCINEMA_4K:
+            /* XYZ color-space for digital cinema profiles */
+            s->avctx->pix_fmt = AV_PIX_FMT_XYZ12;
+            break;
+        default:
+            if (s->precision > 8)
+                s->avctx->pix_fmt = AV_PIX_FMT_RGB48;
+            else
+                s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
+            break;
         }
         break;
     case 4:
         s->avctx->pix_fmt = AV_PIX_FMT_RGBA;
         break;
+    default:
+        /* pixel format can not be identified */
+        s->avctx->pix_fmt = AV_PIX_FMT_NONE;
+        break;
     }
 
 
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 4e8104c..08ac3dc 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -213,37 +213,35 @@ static int get_siz(Jpeg2000DecoderContext *s)
     s->avctx->height = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
                                                s->reduction_factor);
 
-    switch (s->avctx->profile) {
-    case FF_PROFILE_JPEG2000_DCINEMA_2K:
-    case FF_PROFILE_JPEG2000_DCINEMA_4K:
-        /* XYZ color-space for digital cinema profiles */
-        s->avctx->pix_fmt = AV_PIX_FMT_XYZ12;
+    switch(s->ncomponents) {
+    case 1:
+        if (s->precision > 8)
+            s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
+        else
+            s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
         break;
-    default:
-        /* For other profiles selects color-space according number of
-         * components and bit depth precision. */
-        switch (s->ncomponents) {
-        case 1:
-            if (s->precision > 8)
-                s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
-            else
-                s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
+    case 3:
+        switch (s->avctx->profile) {
+        case FF_PROFILE_JPEG2000_DCINEMA_2K:
+        case FF_PROFILE_JPEG2000_DCINEMA_4K:
+            /* XYZ color-space for digital cinema profiles */
+            s->avctx->pix_fmt = AV_PIX_FMT_XYZ12;
             break;
-        case 3:
+        default:
             if (s->precision > 8)
                 s->avctx->pix_fmt = AV_PIX_FMT_RGB48;
             else
                 s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
             break;
-        case 4:
-            s->avctx->pix_fmt = AV_PIX_FMT_BGRA;
-            break;
-        default:
-            /* pixel format can not be identified */
-            s->avctx->pix_fmt = AV_PIX_FMT_NONE;
-            break;
         }
         break;
+    case 4:
+        s->avctx->pix_fmt = AV_PIX_FMT_RGBA;
+        break;
+    default:
+        /* pixel format can not be identified */
+        s->avctx->pix_fmt = AV_PIX_FMT_NONE;
+        break;
     }
     return 0;
 }



More information about the ffmpeg-cvslog mailing list