diff mbox

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

Message ID CAJiLW2PT=YSDuJqEmttOaL8cTO1k5JBT1DemKWouRm5JdTvurA@mail.gmail.com
State Superseded
Headers show

Commit Message

Martin Vignali Oct. 24, 2016, 8:21 p.m. UTC
Hello,

In attach new patchs.

I tested with zzuf using

zzuf -c -s0:10000  -r0.01 ./ffmpeg -i inFile -f null -
on one sample

and with
zzuf -c -s0:5000  -r0.01 ./ffmpeg -i inFile -f null
on 10 others samples


Martin

Comments

Carl Eugen Hoyos Oct. 24, 2016, 10:07 p.m. UTC | #1
2016-10-24 22:21 GMT+02:00 Martin Vignali <martin.vignali@gmail.com>:
> Hello,
>
> In attach new patchs.

> /* reorganize uncompress data. Each channel is stored one after the other */

(Sorry if I misread the code.)
Did you see AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRP16
and AV_PIX_FMT_GBRAP16?
And the more I think of it, the more likely it seems that (GBR) 9, 10, 12 and 14
could also be of use.

Carl Eugen
diff mbox

Patch

From 5d3bdad458987ece0dfdbaf6518208bba0fde321 Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vignali@gmail.com>
Date: Mon, 24 Oct 2016 22:17:19 +0200
Subject: [PATCH 2/2] libavformat : add Photoshop PSD file.

---
 libavformat/Makefile     |  1 +
 libavformat/allformats.c |  1 +
 libavformat/img2dec.c    | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 5d827d31..5ce4cab 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -235,6 +235,7 @@  OBJS-$(CONFIG_IMAGE_PGM_PIPE_DEMUXER)     += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_PICTOR_PIPE_DEMUXER)  += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_PNG_PIPE_DEMUXER)     += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_PPM_PIPE_DEMUXER)     += img2dec.o img2.o
+OBJS-$(CONFIG_IMAGE_PSD_PIPE_DEMUXER)     += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_QDRAW_PIPE_DEMUXER)   += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_SGI_PIPE_DEMUXER)     += img2dec.o img2.o
 OBJS-$(CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER) += img2dec.o img2.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 6a216ef..9d77b9c 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -366,6 +366,7 @@  void av_register_all(void)
     REGISTER_DEMUXER (IMAGE_PICTOR_PIPE,     image_pictor_pipe);
     REGISTER_DEMUXER (IMAGE_PNG_PIPE,        image_png_pipe);
     REGISTER_DEMUXER (IMAGE_PPM_PIPE,        image_ppm_pipe);
+    REGISTER_DEMUXER (IMAGE_PSD_PIPE,        image_psd_pipe);
     REGISTER_DEMUXER (IMAGE_QDRAW_PIPE,      image_qdraw_pipe);
     REGISTER_DEMUXER (IMAGE_SGI_PIPE,        image_sgi_pipe);
     REGISTER_DEMUXER (IMAGE_SUNRAST_PIPE,    image_sunrast_pipe);
diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index a920f46..d668249 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -822,6 +822,39 @@  static int png_probe(AVProbeData *p)
     return 0;
 }
 
+static int psd_probe(AVProbeData *p)
+{
+    const uint8_t *b = p->buf;
+    int ret = 0;
+    uint16_t color_mode;
+
+    if (AV_RL32(b) == MKTAG('8','B','P','S')) {
+        ret += 1;
+    } else {
+        return 0;
+    }
+
+    if ((b[4] == 0) && (b[5] == 1)) {/* version 1 is PSD, version 2 is PSB */
+        ret += 1;
+    } else {
+        return 0;
+    }
+
+    if ((AV_RL32(b+6) == 0) && (AV_RL16(b+10) == 0))/* reserved must be 0 */
+        ret += 1;
+    if (p->buf_size < 26)
+        return 0;
+
+    color_mode = AV_RB16(b+24);
+    if ((color_mode <= 9) && (color_mode != 5) && (color_mode != 6))
+        ret += 1;
+
+    if (ret)
+        return AVPROBE_SCORE_EXTENSION + ret;
+
+    return 0;
+}
+
 static int sgi_probe(AVProbeData *p)
 {
     const uint8_t *b = p->buf;
@@ -947,6 +980,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)
-- 
1.9.3 (Apple Git-50)