diff mbox

[FFmpeg-devel] lavc/psd: Support 1bpp images

Message ID CAJiLW2OBti_v8V=2D-kghY2-NWccY+Bs-fZZE8eWKXWc6=LSpA@mail.gmail.com
State Accepted
Headers show

Commit Message

Martin Vignali Jan. 10, 2017, 11:20 p.m. UTC
>
> Please move the uncompressed calculation
> below the color_mode switch and commit.
>
> In attach new patch.

Martin

Comments

Carl Eugen Hoyos Jan. 10, 2017, 11:26 p.m. UTC | #1
2017-01-11 0:20 GMT+01:00 Martin Vignali <martin.vignali@gmail.com>:

>> Please move the uncompressed calculation
>> below the color_mode switch and commit.

(... to fix possible rle compression.)

> In attach new patch.

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

From db1ca3645624fe8fac29f09cef3ef89dd013fef6 Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vignali@gmail.com>
Date: Wed, 11 Jan 2017 00:18:29 +0100
Subject: [PATCH] libavcodec/psd : add support for psd bitmap mode

Ticket 6044

Based on patch by Carl Eugen Hoyos
---
 libavcodec/psd.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavcodec/psd.c b/libavcodec/psd.c
index 7587ed9..c79f72a 100644
--- a/libavcodec/psd.c
+++ b/libavcodec/psd.c
@@ -316,9 +316,12 @@  static int decode_frame(AVCodecContext *avctx, void *data,
 
     s->pixel_size = s->channel_depth >> 3;/* in byte */
     s->line_size = s->width * s->pixel_size;
-    s->uncompressed_size = s->line_size * s->height * s->channel_count;
 
     switch (s->color_mode) {
+    case PSD_BITMAP:
+        s->line_size = s->width + 7 >> 3;
+        avctx->pix_fmt = AV_PIX_FMT_MONOWHITE;
+        break;
     case PSD_INDEXED:
         if (s->channel_depth != 8 || s->channel_count != 1) {
             av_log(s->avctx, AV_LOG_ERROR,
@@ -381,6 +384,8 @@  static int decode_frame(AVCodecContext *avctx, void *data,
         return AVERROR_PATCHWELCOME;
     }
 
+    s->uncompressed_size = s->line_size * s->height * s->channel_count;
+
     if ((ret = ff_get_buffer(avctx, picture, 0)) < 0)
         return ret;
 
@@ -428,9 +433,9 @@  static int decode_frame(AVCodecContext *avctx, void *data,
             plane_number = eq_channel[c];
             ptr = picture->data[plane_number];/* get the right plane */
             for (y = 0; y < s->height; y++) {
-                memcpy(ptr, ptr_data, s->width * s->pixel_size);
+                memcpy(ptr, ptr_data, s->line_size);
                 ptr += picture->linesize[plane_number];
-                ptr_data += s->width * s->pixel_size;
+                ptr_data += s->line_size;
             }
         }
     }
-- 
1.9.3 (Apple Git-50)