[FFmpeg-devel] [PATCH]lavc/psd: Support 1bpp images
Martin Vignali
martin.vignali at gmail.com
Wed Jan 11 00:42:19 EET 2017
2017-01-10 20:00 GMT+01:00 Carl Eugen Hoyos <ceffmpeg at gmail.com>:
> 2017-01-10 19:45 GMT+01:00 Gonzalo GarramuƱo <ggarra13 at gmail.com>:
> >
> >
> > El 10/01/2017 a las 10:21, Carl Eugen Hoyos escribiĆ³:
> >>
> >> }
> >> + } else if (avctx->pix_fmt == AV_PIX_FMT_MONOWHITE) {
> >> + ptr = picture->data[0];
> >> + for (y = 0; y < s->height; y++) {
> >> + memcpy(ptr, ptr_data, s->width + 7 >> 3);
> >> + ptr_data += s->width + 7 >> 3;
> >> + ptr += picture->linesize[0];
> >> + }
> >
> > Just a nitpick. I would put s->width + 7 >> 3 in a variable outside the
> > loop and use it in memcpy and in the ptr_data.
>
> Fixed locally.
>
>
Tested on some sample, seems to work.
But maybe you can put the Store data code inside the planar part (it's very
similar)
Something like that
-------------------
s->uncompressed_size = s->line_size * s->height * s->channel_count;
switch (s->color_mode) {
+ case PSD_BITMAP:
Overwrite here the linesize :
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,
@@ -420,6 +423,13 @@ static int decode_frame(AVCodecContext *avctx, void
*data,
}
}
}
This special case can be delete :
+ } else if (avctx->pix_fmt == AV_PIX_FMT_MONOWHITE) {
+ ptr = picture->data[0];
+ for (y = 0; y < s->height; y++) {
+ memcpy(ptr, ptr_data, s->width + 7 >> 3);
+ ptr_data += s->width + 7 >> 3;
+ ptr += picture->linesize[0];
+ }
and the planar part, can use s->line_size instead of s->width *
s->pixel_size;
so will work for both i think
Martin
More information about the ffmpeg-devel
mailing list