changeset 9002:eb98d61af310 libavcodec

Support 48-bit RGB PPM image.
author pross
date Sun, 22 Feb 2009 00:56:55 +0000
parents ec04c3c5a3e5
children b595a8a59967
files pnm.c pnmenc.c
diffstat 2 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pnm.c	Sun Feb 22 00:55:49 2009 +0000
+++ b/pnm.c	Sun Feb 22 00:56:55 2009 +0000
@@ -138,8 +138,11 @@
                 avctx->pix_fmt = PIX_FMT_GRAY16BE;
                 if (s->maxval != 65535)
                     avctx->pix_fmt = PIX_FMT_GRAY16;
+            } if (avctx->pix_fmt == PIX_FMT_RGB24) {
+                if (s->maxval > 255)
+                    avctx->pix_fmt = PIX_FMT_RGB48BE;
             } else {
-                av_log(avctx, AV_LOG_ERROR, "16-bit components are only supported for grayscale\n");
+                av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format\n");
                 avctx->pix_fmt = PIX_FMT_NONE;
                 return -1;
             }
--- a/pnmenc.c	Sun Feb 22 00:55:49 2009 +0000
+++ b/pnmenc.c	Sun Feb 22 00:56:55 2009 +0000
@@ -63,6 +63,9 @@
     switch(avctx->pix_fmt) {
     default:
         return -1;
+    case PIX_FMT_RGB48BE:
+        n = avctx->width * 6;
+        goto do_read;
     case PIX_FMT_RGB24:
         n = avctx->width * 3;
         goto do_read;
@@ -195,6 +198,10 @@
         c = '6';
         n = avctx->width * 3;
         break;
+    case PIX_FMT_RGB48BE:
+        c = '6';
+        n = avctx->width * 6;
+        break;
     case PIX_FMT_YUV420P:
         c = '5';
         n = avctx->width;
@@ -209,7 +216,7 @@
     s->bytestream += strlen(s->bytestream);
     if (avctx->pix_fmt != PIX_FMT_MONOWHITE) {
         snprintf(s->bytestream, s->bytestream_end - s->bytestream,
-                 "%d\n", (avctx->pix_fmt != PIX_FMT_GRAY16BE) ? 255 : 65535);
+                 "%d\n", (avctx->pix_fmt != PIX_FMT_GRAY16BE && avctx->pix_fmt != PIX_FMT_RGB48BE) ? 255 : 65535);
         s->bytestream += strlen(s->bytestream);
     }
 
@@ -394,7 +401,7 @@
     pnm_encode_frame,
     NULL, //encode_end,
     pnm_decode_frame,
-    .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_NONE},
+    .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
     .long_name= NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
 };
 #endif // CONFIG_PPM_ENCODER