[FFmpeg-devel] libavcodec : add psd image file decoder

James Almer jamrial at gmail.com
Sat Jul 9 19:09:00 EEST 2016


On 7/9/2016 12:29 PM, Martin Vignali wrote:
> Hello,
> 
> In attach patch to add decoding of .psd file (Photoshop file).
> 
> PSD file can contain merge layers data at the end of the file (Image Data
> Section)
> 
> This patch add support for this kind of files, using uncompress data Image
> Data Section
> 
> Support Gray/A, and RGB/A with 8b or 16 bits by channel.
> 
> 
> Samples can be found here :
> 
> https://we.tl/GK6yQhUV8j
> 
> 
> Comments welcome
> 
> Martin
> 
> 
> 0001-libavcodec-add-decoder-for-.psd-image-file.patch
> 
> 
> From a4b9c1373cc62d1bb38997704a924ecfe78ee4b4 Mon Sep 17 00:00:00 2001
> From: Martin Vignali <martin.vignali at gmail.com>
> Date: Sat, 9 Jul 2016 15:59:41 +0200
> Subject: [PATCH] libavcodec : add decoder for .psd image file. Decode the
>  Image Data Section (who contain merge picture) Support RGB/A and Grayscale/A
>  in 8bits and 16 bits by channel. Only support now, uncompress Image Data
>  Section.
> 
> ---
>  Changelog                |   2 +-
>  doc/general.texi         |   2 +
>  libavcodec/Makefile      |   1 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/avcodec.h     |   1 +
>  libavcodec/codec_desc.c  |   7 ++
>  libavcodec/psd.c         | 310 +++++++++++++++++++++++++++++++++++++++++++++++
>  libavformat/Makefile     |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/img2.c       |   1 +
>  libavformat/img2dec.c    |  10 ++
>  libavformat/isom.c       |   1 +
>  12 files changed, 337 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/psd.c
> 

[...]

> diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
> index 9d6796f..a6a2148 100644
> --- a/libavformat/img2dec.c
> +++ b/libavformat/img2dec.c
> @@ -821,6 +821,15 @@ static int png_probe(AVProbeData *p)
>      return 0;
>  }
>  
> +static int psd_probe(AVProbeData *p)
> +{
> +    const uint8_t *b = p->buf;
> +
> +    if (AV_RL32(b) == 1397768760)

if (AV_RL32(b) == MKTAG('S','P','B','8'))

> +        return AVPROBE_SCORE_EXTENSION + 1;
> +    return 0;
> +}
> +
>  static int sgi_probe(AVProbeData *p)
>  {
>      const uint8_t *b = p->buf;
> @@ -946,6 +955,7 @@ IMAGEAUTO_DEMUXER(pgmyuv,  AV_CODEC_ID_PGMYUV)
>  IMAGEAUTO_DEMUXER(pictor,  AV_CODEC_ID_PICTOR)
>  IMAGEAUTO_DEMUXER(png,     AV_CODEC_ID_PNG)
>  IMAGEAUTO_DEMUXER(ppm,     AV_CODEC_ID_PPM)
> +IMAGEAUTO_DEMUXER(psd,     AV_CODEC_ID_PSD)
>  IMAGEAUTO_DEMUXER(qdraw,   AV_CODEC_ID_QDRAW)
>  IMAGEAUTO_DEMUXER(sgi,     AV_CODEC_ID_SGI)
>  IMAGEAUTO_DEMUXER(sunrast, AV_CODEC_ID_SUNRAST)
> diff --git a/libavformat/isom.c b/libavformat/isom.c
> index d412f06..75fbf2f 100644
> --- a/libavformat/isom.c
> +++ b/libavformat/isom.c
> @@ -254,6 +254,7 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
>      { AV_CODEC_ID_SGI,       MKTAG('s', 'g', 'i', ' ') }, /* SGI  */
>      { AV_CODEC_ID_DPX,       MKTAG('d', 'p', 'x', ' ') }, /* DPX */
>      { AV_CODEC_ID_EXR,       MKTAG('e', 'x', 'r', ' ') }, /* OpenEXR */
> +    { AV_CODEC_ID_EXR,       MKTAG('p', 's', 'd', ' ') }, /* Psd */

You probably meant to use AV_CODEC_ID_PSD here.

>  
>      { AV_CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'h') }, /* Apple ProRes 422 High Quality */
>      { AV_CODEC_ID_PRORES, MKTAG('a', 'p', 'c', 'n') }, /* Apple ProRes 422 Standard Definition */
> -- 1.9.3 (Apple Git-50)
> 

Wait for a real review before resending the patch.



More information about the ffmpeg-devel mailing list