diff mbox

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

Message ID CAJiLW2ONvkeRmRHJ30MXrzNTPisoC8Sxc3fA=yEWT4qaAv9HJQ@mail.gmail.com
State Accepted
Headers show

Commit Message

Martin Vignali Nov. 24, 2016, 8:35 p.m. UTC
Hello

New patchs in attach

I changed the dimensions check, the check is now :
----------------------------------------
if ((s->height > 30000) && (s->avctx->strict_std_compliance >
FF_COMPLIANCE_EXPERIMENTAL)) {
        av_log(s->avctx, AV_LOG_ERROR,
               "Height > 30000 is experimental, add "
               "'-strict %d' if you want to try to decode the picture.\n",
               FF_COMPLIANCE_EXPERIMENTAL);
        return AVERROR_EXPERIMENTAL;
    }

    s->width = bytestream2_get_be32(&s->gb);
    if ((s->width > 30000) && (s->avctx->strict_std_compliance >
FF_COMPLIANCE_EXPERIMENTAL)) {
        av_log(s->avctx, AV_LOG_ERROR,
               "Width > 30000 is experimental, add "
               "'-strict %d' if you want to try to decode the picture.\n",
               FF_COMPLIANCE_EXPERIMENTAL);
        return AVERROR_EXPERIMENTAL;
    }
----------------------------------------

and change the line_size variable (in PSD Context) to uint_64 (because now,
width can be > 30000 if -strict set to experimental)

I will send a patch for fate test in another discussion.

Martin

Comments

Michael Niedermayer Nov. 24, 2016, 11:32 p.m. UTC | #1
On Thu, Nov 24, 2016 at 09:35:42PM +0100, Martin Vignali wrote:
> Hello
> 
> New patchs in attach
> 
> I changed the dimensions check, the check is now :
> ----------------------------------------
> if ((s->height > 30000) && (s->avctx->strict_std_compliance >
> FF_COMPLIANCE_EXPERIMENTAL)) {
>         av_log(s->avctx, AV_LOG_ERROR,
>                "Height > 30000 is experimental, add "
>                "'-strict %d' if you want to try to decode the picture.\n",
>                FF_COMPLIANCE_EXPERIMENTAL);
>         return AVERROR_EXPERIMENTAL;
>     }
> 
>     s->width = bytestream2_get_be32(&s->gb);
>     if ((s->width > 30000) && (s->avctx->strict_std_compliance >
> FF_COMPLIANCE_EXPERIMENTAL)) {
>         av_log(s->avctx, AV_LOG_ERROR,
>                "Width > 30000 is experimental, add "
>                "'-strict %d' if you want to try to decode the picture.\n",
>                FF_COMPLIANCE_EXPERIMENTAL);
>         return AVERROR_EXPERIMENTAL;
>     }
> ----------------------------------------
> 
> and change the line_size variable (in PSD Context) to uint_64 (because now,
> width can be > 30000 if -strict set to experimental)
> 
> I will send a patch for fate test in another discussion.
> 
> Martin

>  Changelog               |    1 
>  doc/general.texi        |    2 
>  libavcodec/Makefile     |    1 
>  libavcodec/allcodecs.c  |    1 
>  libavcodec/avcodec.h    |    1 
>  libavcodec/codec_desc.c |    7 
>  libavcodec/psd.c        |  435 ++++++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/version.h    |    4 
>  8 files changed, 450 insertions(+), 2 deletions(-)

If you want to maintain this code, then please add yourself to the
MAINTAINER file too

[...]
Martin Vignali Nov. 25, 2016, 11:13 a.m. UTC | #2
Hello

>
> If you want to maintain this code, then please add yourself to the
> MAINTAINER file too
>

I'm not very familiar with git. So it's probably not a good idea to be a
maintainer.
But i can take a look for patch on psd (and exr) if need.

Martin
Martin Vignali Dec. 13, 2016, 9:23 p.m. UTC | #3
2016-11-24 21:35 GMT+01:00 Martin Vignali <martin.vignali@gmail.com>:

> Hello
>
> New patchs in attach
>
> I changed the dimensions check, the check is now :
> ----------------------------------------
> if ((s->height > 30000) && (s->avctx->strict_std_compliance >
> FF_COMPLIANCE_EXPERIMENTAL)) {
>         av_log(s->avctx, AV_LOG_ERROR,
>                "Height > 30000 is experimental, add "
>                "'-strict %d' if you want to try to decode the picture.\n",
>                FF_COMPLIANCE_EXPERIMENTAL);
>         return AVERROR_EXPERIMENTAL;
>     }
>
>     s->width = bytestream2_get_be32(&s->gb);
>     if ((s->width > 30000) && (s->avctx->strict_std_compliance >
> FF_COMPLIANCE_EXPERIMENTAL)) {
>         av_log(s->avctx, AV_LOG_ERROR,
>                "Width > 30000 is experimental, add "
>                "'-strict %d' if you want to try to decode the picture.\n",
>                FF_COMPLIANCE_EXPERIMENTAL);
>         return AVERROR_EXPERIMENTAL;
>     }
> ----------------------------------------
>
> and change the line_size variable (in PSD Context) to uint_64 (because
> now, width can be > 30000 if -strict set to experimental)
>
> I will send a patch for fate test in another discussion.
>
> Martin
>

Ping

Martin
Michael Niedermayer Dec. 14, 2016, 2:20 a.m. UTC | #4
On Tue, Dec 13, 2016 at 10:23:48PM +0100, Martin Vignali wrote:
> 2016-11-24 21:35 GMT+01:00 Martin Vignali <martin.vignali@gmail.com>:
> 
> > Hello
> >
> > New patchs in attach
> >
> > I changed the dimensions check, the check is now :
> > ----------------------------------------
> > if ((s->height > 30000) && (s->avctx->strict_std_compliance >
> > FF_COMPLIANCE_EXPERIMENTAL)) {
> >         av_log(s->avctx, AV_LOG_ERROR,
> >                "Height > 30000 is experimental, add "
> >                "'-strict %d' if you want to try to decode the picture.\n",
> >                FF_COMPLIANCE_EXPERIMENTAL);
> >         return AVERROR_EXPERIMENTAL;
> >     }
> >
> >     s->width = bytestream2_get_be32(&s->gb);
> >     if ((s->width > 30000) && (s->avctx->strict_std_compliance >
> > FF_COMPLIANCE_EXPERIMENTAL)) {
> >         av_log(s->avctx, AV_LOG_ERROR,
> >                "Width > 30000 is experimental, add "
> >                "'-strict %d' if you want to try to decode the picture.\n",
> >                FF_COMPLIANCE_EXPERIMENTAL);
> >         return AVERROR_EXPERIMENTAL;
> >     }
> > ----------------------------------------
> >
> > and change the line_size variable (in PSD Context) to uint_64 (because
> > now, width can be > 30000 if -strict set to experimental)
> >
> > I will send a patch for fate test in another discussion.
> >
> > Martin
> >
> 
> Ping

applied

thx

[...]
Paul B Mahol Dec. 14, 2016, 7:46 a.m. UTC | #5
On 12/14/16, Michael Niedermayer <michael@niedermayer.cc> wrote:
> On Tue, Dec 13, 2016 at 10:23:48PM +0100, Martin Vignali wrote:
>> 2016-11-24 21:35 GMT+01:00 Martin Vignali <martin.vignali@gmail.com>:
>>
>> > Hello
>> >
>> > New patchs in attach
>> >
>> > I changed the dimensions check, the check is now :
>> > ----------------------------------------
>> > if ((s->height > 30000) && (s->avctx->strict_std_compliance >
>> > FF_COMPLIANCE_EXPERIMENTAL)) {
>> >         av_log(s->avctx, AV_LOG_ERROR,
>> >                "Height > 30000 is experimental, add "
>> >                "'-strict %d' if you want to try to decode the
>> > picture.\n",
>> >                FF_COMPLIANCE_EXPERIMENTAL);
>> >         return AVERROR_EXPERIMENTAL;
>> >     }
>> >
>> >     s->width = bytestream2_get_be32(&s->gb);
>> >     if ((s->width > 30000) && (s->avctx->strict_std_compliance >
>> > FF_COMPLIANCE_EXPERIMENTAL)) {
>> >         av_log(s->avctx, AV_LOG_ERROR,
>> >                "Width > 30000 is experimental, add "
>> >                "'-strict %d' if you want to try to decode the
>> > picture.\n",
>> >                FF_COMPLIANCE_EXPERIMENTAL);
>> >         return AVERROR_EXPERIMENTAL;
>> >     }
>> > ----------------------------------------
>> >
>> > and change the line_size variable (in PSD Context) to uint_64 (because
>> > now, width can be > 30000 if -strict set to experimental)
>> >
>> > I will send a patch for fate test in another discussion.
>> >
>> > Martin
>> >
>>
>> Ping
>
> applied

Without minor bumps.

>
> thx
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Republics decline into democracies and democracies degenerate into
> despotisms. -- Aristotle
>
Michael Niedermayer Dec. 14, 2016, 10:51 a.m. UTC | #6
On Wed, Dec 14, 2016 at 08:46:28AM +0100, Paul B Mahol wrote:
> On 12/14/16, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > On Tue, Dec 13, 2016 at 10:23:48PM +0100, Martin Vignali wrote:
> >> 2016-11-24 21:35 GMT+01:00 Martin Vignali <martin.vignali@gmail.com>:
> >>
> >> > Hello
> >> >
> >> > New patchs in attach
> >> >
> >> > I changed the dimensions check, the check is now :
> >> > ----------------------------------------
> >> > if ((s->height > 30000) && (s->avctx->strict_std_compliance >
> >> > FF_COMPLIANCE_EXPERIMENTAL)) {
> >> >         av_log(s->avctx, AV_LOG_ERROR,
> >> >                "Height > 30000 is experimental, add "
> >> >                "'-strict %d' if you want to try to decode the
> >> > picture.\n",
> >> >                FF_COMPLIANCE_EXPERIMENTAL);
> >> >         return AVERROR_EXPERIMENTAL;
> >> >     }
> >> >
> >> >     s->width = bytestream2_get_be32(&s->gb);
> >> >     if ((s->width > 30000) && (s->avctx->strict_std_compliance >
> >> > FF_COMPLIANCE_EXPERIMENTAL)) {
> >> >         av_log(s->avctx, AV_LOG_ERROR,
> >> >                "Width > 30000 is experimental, add "
> >> >                "'-strict %d' if you want to try to decode the
> >> > picture.\n",
> >> >                FF_COMPLIANCE_EXPERIMENTAL);
> >> >         return AVERROR_EXPERIMENTAL;
> >> >     }
> >> > ----------------------------------------
> >> >
> >> > and change the line_size variable (in PSD Context) to uint_64 (because
> >> > now, width can be > 30000 if -strict set to experimental)
> >> >
> >> > I will send a patch for fate test in another discussion.
> >> >
> >> > Martin
> >> >
> >>
> >> Ping
> >
> > applied
> 
> Without minor bumps.

bumped

thx

[...]
diff mbox

Patch

From c5d39f653cc13d1466b2f624944dc9ee4015307c Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vignali@gmail.com>
Date: Thu, 24 Nov 2016 21:26:56 +0100
Subject: [PATCH 2/3] libavformat : add Photoshop PSD demuxer.

---
 libavformat/Makefile     |  1 +
 libavformat/allformats.c |  1 +
 libavformat/img2dec.c    | 32 ++++++++++++++++++++++++++++++++
 libavformat/version.h    |  2 +-
 4 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index f93658d..f803d04 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..f1a0e7f 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -822,6 +822,37 @@  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;
+
+    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 +978,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/version.h b/libavformat/version.h
index 24a7534..192b790 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@ 
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  57
-#define LIBAVFORMAT_VERSION_MINOR  58
+#define LIBAVFORMAT_VERSION_MINOR  59
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
-- 
1.9.3 (Apple Git-50)