[FFmpeg-cvslog] Simplify 32bit pam decoding.

Carl Eugen Hoyos git at videolan.org
Thu Jan 19 23:31:12 CET 2012


ffmpeg | branch: master | Carl Eugen Hoyos <cehoyos at ag.or.at> | Thu Jan 19 23:08:12 2012 +0100| [b614c147672aa3c1d38596c587a0921987cf94b7] | committer: Carl Eugen Hoyos

Simplify 32bit pam decoding.

Reviewed-by: Paul B Mahol

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

 libavcodec/pnm.c     |    2 +-
 libavcodec/pnmdec.c  |   23 +++++------------------
 libavcodec/version.h |    2 +-
 3 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index 212ec06..67df8c2 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -129,7 +129,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s)
             }
         } else if (depth == 4) {
             if (maxval < 256) {
-                avctx->pix_fmt = PIX_FMT_RGB32;
+                avctx->pix_fmt = PIX_FMT_RGBA;
             } else {
                 avctx->pix_fmt = PIX_FMT_RGBA64BE;
             }
diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c
index 324ec3f..e6c91ef 100644
--- a/libavcodec/pnmdec.c
+++ b/libavcodec/pnmdec.c
@@ -67,6 +67,11 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
         components=3;
         sample_len=16;
         goto do_read;
+    case PIX_FMT_RGBA:
+        n = avctx->width * 4;
+        components=4;
+        sample_len=8;
+        goto do_read;
     case PIX_FMT_RGB24:
         n = avctx->width * 3;
         components=3;
@@ -177,24 +182,6 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data,
             }
         }
         break;
-    case PIX_FMT_RGB32:
-        ptr      = p->data[0];
-        linesize = p->linesize[0];
-        if (s->bytestream + avctx->width * avctx->height * 4 > s->bytestream_end)
-            return -1;
-        for (i = 0; i < avctx->height; i++) {
-            int j, r, g, b, a;
-
-            for (j = 0; j < avctx->width; j++) {
-                r = *s->bytestream++;
-                g = *s->bytestream++;
-                b = *s->bytestream++;
-                a = *s->bytestream++;
-                ((uint32_t *)ptr)[j] = (a << 24) | (r << 16) | (g << 8) | b;
-            }
-            ptr += linesize;
-        }
-        break;
     }
     *picture   = *(AVFrame*)&s->picture;
     *data_size = sizeof(AVPicture);
diff --git a/libavcodec/version.h b/libavcodec/version.h
index e0e50ea..f9ccb49 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -22,7 +22,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 53
 #define LIBAVCODEC_VERSION_MINOR 57
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MICRO 102
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list