diff mbox

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

Message ID CAJiLW2OfA940O8-VV+v_r5ioqCtLKXiAVUrWqnxyKAsHBWs5zw@mail.gmail.com
State Superseded
Headers show

Commit Message

Martin Vignali Jan. 10, 2017, 11:07 p.m. UTC
2017-01-10 23:56 GMT+01:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:

> 2017-01-10 23:53 GMT+01:00 Martin Vignali <martin.vignali@gmail.com>:
> >> > But maybe you can put the Store data code inside the planar part
> >> > (it's very similar)
> >>
> >> That means I have to remove the pixel_size context variable:
> >> Do you want me to do that?
> >
> > No i don't think you need to remove it.
>
> Then I don't know how to do it, please send a patch.
> (Please mention the ticket.)
>
> I though about something like the patch in attach.

I just quickly test this patch, pass fate test, and decode a test sample.
Seems strange, that the uncompress size, doesn't need to be adapt.

Martin

Comments

Carl Eugen Hoyos Jan. 10, 2017, 11:09 p.m. UTC | #1
2017-01-11 0:07 GMT+01:00 Martin Vignali <martin.vignali@gmail.com>:
> 2017-01-10 23:56 GMT+01:00 Carl Eugen Hoyos <ceffmpeg@gmail.com>:
>
>> 2017-01-10 23:53 GMT+01:00 Martin Vignali <martin.vignali@gmail.com>:
>> >> > But maybe you can put the Store data code inside the planar part
>> >> > (it's very similar)
>> >>
>> >> That means I have to remove the pixel_size context variable:
>> >> Do you want me to do that?
>> >
>> > No i don't think you need to remove it.
>>
>> Then I don't know how to do it, please send a patch.
>> (Please mention the ticket.)
>
> I though about something like the patch in attach.
>
> I just quickly test this patch, pass fate test, and decode a test sample.

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

Carl Eugen
diff mbox

Patch

From 7527be4ae13d3e134e5eb607e5e7ccd060eb5446 Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vignali@gmail.com>
Date: Tue, 10 Jan 2017 23:59:59 +0100
Subject: [PATCH] libavcodec/psd : add support for psd bitmap mode

Ticket 6044

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

diff --git a/libavcodec/psd.c b/libavcodec/psd.c
index 7587ed9..074df51 100644
--- a/libavcodec/psd.c
+++ b/libavcodec/psd.c
@@ -319,6 +319,10 @@  static int decode_frame(AVCodecContext *avctx, void *data,
     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,
@@ -428,9 +432,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)