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

2016-12-14 Thread Michael Niedermayer
On Wed, Dec 14, 2016 at 08:46:28AM +0100, Paul B Mahol wrote:
> On 12/14/16, Michael Niedermayer  wrote:
> > On Tue, Dec 13, 2016 at 10:23:48PM +0100, Martin Vignali wrote:
> >> 2016-11-24 21:35 GMT+01:00 Martin Vignali :
> >>
> >> > Hello
> >> >
> >> > New patchs in attach
> >> >
> >> > I changed the dimensions check, the check is now :
> >> > 
> >> > if ((s->height > 3) && (s->avctx->strict_std_compliance >
> >> > FF_COMPLIANCE_EXPERIMENTAL)) {
> >> > av_log(s->avctx, AV_LOG_ERROR,
> >> >"Height > 3 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(>gb);
> >> > if ((s->width > 3) && (s->avctx->strict_std_compliance >
> >> > FF_COMPLIANCE_EXPERIMENTAL)) {
> >> > av_log(s->avctx, AV_LOG_ERROR,
> >> >"Width > 3 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 > 3 if -strict set to experimental)
> >> >
> >> > I will send a patch for fate test in another discussion.
> >> >
> >> > Martin
> >> >
> >>
> >> Ping
> >
> > applied
> 
> Without minor bumps.

bumped

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Good people do not need laws to tell them to act responsibly, while bad
people will find a way around the laws. -- Plato


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-12-13 Thread Paul B Mahol
On 12/14/16, Michael Niedermayer  wrote:
> On Tue, Dec 13, 2016 at 10:23:48PM +0100, Martin Vignali wrote:
>> 2016-11-24 21:35 GMT+01:00 Martin Vignali :
>>
>> > Hello
>> >
>> > New patchs in attach
>> >
>> > I changed the dimensions check, the check is now :
>> > 
>> > if ((s->height > 3) && (s->avctx->strict_std_compliance >
>> > FF_COMPLIANCE_EXPERIMENTAL)) {
>> > av_log(s->avctx, AV_LOG_ERROR,
>> >"Height > 3 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(>gb);
>> > if ((s->width > 3) && (s->avctx->strict_std_compliance >
>> > FF_COMPLIANCE_EXPERIMENTAL)) {
>> > av_log(s->avctx, AV_LOG_ERROR,
>> >"Width > 3 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 > 3 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
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-12-13 Thread Michael Niedermayer
On Tue, Dec 13, 2016 at 10:23:48PM +0100, Martin Vignali wrote:
> 2016-11-24 21:35 GMT+01:00 Martin Vignali :
> 
> > Hello
> >
> > New patchs in attach
> >
> > I changed the dimensions check, the check is now :
> > 
> > if ((s->height > 3) && (s->avctx->strict_std_compliance >
> > FF_COMPLIANCE_EXPERIMENTAL)) {
> > av_log(s->avctx, AV_LOG_ERROR,
> >"Height > 3 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(>gb);
> > if ((s->width > 3) && (s->avctx->strict_std_compliance >
> > FF_COMPLIANCE_EXPERIMENTAL)) {
> > av_log(s->avctx, AV_LOG_ERROR,
> >"Width > 3 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 > 3 if -strict set to experimental)
> >
> > I will send a patch for fate test in another discussion.
> >
> > Martin
> >
> 
> Ping

applied

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-12-13 Thread Martin Vignali
2016-11-24 21:35 GMT+01:00 Martin Vignali :

> Hello
>
> New patchs in attach
>
> I changed the dimensions check, the check is now :
> 
> if ((s->height > 3) && (s->avctx->strict_std_compliance >
> FF_COMPLIANCE_EXPERIMENTAL)) {
> av_log(s->avctx, AV_LOG_ERROR,
>"Height > 3 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(>gb);
> if ((s->width > 3) && (s->avctx->strict_std_compliance >
> FF_COMPLIANCE_EXPERIMENTAL)) {
> av_log(s->avctx, AV_LOG_ERROR,
>"Width > 3 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 > 3 if -strict set to experimental)
>
> I will send a patch for fate test in another discussion.
>
> Martin
>

Ping

Martin
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-25 Thread Martin Vignali
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
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-24 Thread Michael Niedermayer
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 > 3) && (s->avctx->strict_std_compliance >
> FF_COMPLIANCE_EXPERIMENTAL)) {
> av_log(s->avctx, AV_LOG_ERROR,
>"Height > 3 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(>gb);
> if ((s->width > 3) && (s->avctx->strict_std_compliance >
> FF_COMPLIANCE_EXPERIMENTAL)) {
> av_log(s->avctx, AV_LOG_ERROR,
>"Width > 3 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 > 3 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

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-24 Thread Martin Vignali
Hello

New patchs in attach

I changed the dimensions check, the check is now :

if ((s->height > 3) && (s->avctx->strict_std_compliance >
FF_COMPLIANCE_EXPERIMENTAL)) {
av_log(s->avctx, AV_LOG_ERROR,
   "Height > 3 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(>gb);
if ((s->width > 3) && (s->avctx->strict_std_compliance >
FF_COMPLIANCE_EXPERIMENTAL)) {
av_log(s->avctx, AV_LOG_ERROR,
   "Width > 3 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 > 3 if -strict set to experimental)

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

Martin
From 485ad4b332be492d2ff542f229e473db14fba610 Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Thu, 24 Nov 2016 21:26:42 +0100
Subject: [PATCH 1/3] libavcodec : add decoder for Photoshop PSD image files

Decode the Image Data Section (which contains merged pictures).
Support RGB/A and Grayscale/A in 8bits and 16 bits per channel.
Support uncompress and rle decompression in Image Data Section.
---
 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(-)
 create mode 100644 libavcodec/psd.c

diff --git a/Changelog b/Changelog
index 8456022..bdad732 100644
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,7 @@ version :
 - CrystalHD decoder moved to new decode API
 - add internal ebur128 library, remove external libebur128 dependency
 - Pro-MPEG CoP #3-R2 FEC protocol
+- PSD Decoder
 
 version 3.2:
 - libopenmpt demuxer
diff --git a/doc/general.texi b/doc/general.texi
index 56b9e4d..9ea3ba3 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -584,6 +584,8 @@ following image formats are supported:
 @item PNG  @tab X @tab X
 @item PPM  @tab X @tab X
 @tab Portable PixelMap image
+@item PSD  @tab   @tab X
+@tab Photoshop
 @item PTX  @tab   @tab X
 @tab V.Flash PTX format
 @item SGI  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 82f7fa2..343329e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -462,6 +462,7 @@ OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdat
 OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_AW_ENCODER)   += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_KS_ENCODER)   += proresenc_kostya.o proresdata.o
+OBJS-$(CONFIG_PSD_DECODER) += psd.o
 OBJS-$(CONFIG_PTX_DECODER) += ptx.o
 OBJS-$(CONFIG_QCELP_DECODER)   += qcelpdec.o \
   celp_filters.o acelp_vectors.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ada9481..bbcecce 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -287,6 +287,7 @@ void avcodec_register_all(void)
 REGISTER_ENCODER(PRORES_AW, prores_aw);
 REGISTER_ENCODER(PRORES_KS, prores_ks);
 REGISTER_DECODER(PRORES_LGPL,   prores_lgpl);
+REGISTER_DECODER(PSD,   psd);
 REGISTER_DECODER(PTX,   ptx);
 REGISTER_DECODER(QDRAW, qdraw);
 REGISTER_DECODER(QPEG,  qpeg);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e5e7f42..538e701 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -411,6 +411,7 @@ enum AVCodecID {
 AV_CODEC_ID_MAGICYUV,
 AV_CODEC_ID_SHEERVIDEO,
 AV_CODEC_ID_YLC,
+AV_CODEC_ID_PSD,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9dbe2dc..29ffcb9 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1461,6 +1461,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
 {
+.id= AV_CODEC_ID_PSD,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "psd",
+.long_name = NULL_IF_CONFIG_SMALL("Photoshop PSD file"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
 .id= AV_CODEC_ID_PTX,
 .type  = 

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

2016-11-21 Thread Michael Niedermayer
On Tue, Nov 22, 2016 at 12:15:16AM +0100, Martin Vignali wrote:
> Hello,
> 
> 2016-11-21 23:16 GMT+01:00 Moritz Barsnick :
> 
> > On Mon, Nov 21, 2016 at 21:44:55 +0100, Martin Vignali wrote:
> > > +avpriv_request_sample(s->avctx, "ZIP without predictor
> > compression");
> > > +return AVERROR_PATCHWELCOME;
> > > +break;
> > > +case 3:
> > > +avpriv_request_sample(s->avctx, "ZIP with predictor
> > compression");
> > > +return AVERROR_PATCHWELCOME;
> > > +break;
> >
> > Are these the only two (detectable) unsupported features? I.e. all
> > other error messages are true errors, not "unsupported"?
> > 
> >
> 
> I think,  i use AVERROR_PATCHWELCOME, for each documented features, that
> the decoder does not support.
> Do you have a specific place where you think i return the wrong message ?
> 
> I mainly use this link, for the psd specification :
> https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
> 
> 
> @Rostislav :
> > I don't think you need the checks, it was pointed out that
> > ff_set_dimensions already does that.
> > Also IIRC lavc doesn't support widths or heights over 16384 anyway.
> 
> Andreas ask why i choose 30 000 for check widths/heights
> And the choice come from the Adobe documentation : "Supported range is 1 to
> 30,000."
> 
> But i doesn't know about the 16384 limit, in lavc. I wrongly suppose, it
> was int max

./ffmpeg -i matrixbench_mpeg2.mpg -vf scale=6:16 -vcodec ffv1 test.nut
works fine

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Lou Logan
On Tue, 22 Nov 2016 01:21:08 +0100, Carl Eugen Hoyos wrote:

> If an application writes psd files with width or height > 3 (or,
> horribile dictu, Adobe changes the limits), we want to decode
> such images (unless strict strict was set).

We shouldn't be encouraging theoretical random broken crapware that
ignores specs. Anything over 3 should be using PSB anyway.

Instead of blindly decoding a garbage example it should require
"-strict experimental" to "allow non standardized experimental things".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Carl Eugen Hoyos
2016-11-22 0:57 GMT+01:00 Andreas Cadhalpun :
> On 20.11.2016 17:57, Martin Vignali wrote:

 +s->height = bytestream2_get_be32(>gb);
 +
 +if ((s->height < 1) || (s->height > 3)) {
>>>
>>> Why 3?
>>> ff_set_dimensions already checks for sane dimensions.
>>>
>>
>> Following adobe specs :
>> http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_pgfId-1055726
>> in a psd file, the width or height, can't be > to 30 000 pixels.
>
> I see. In that case it makes sense to explicitly check this, as
> the check in ff_set_dimensions is more general and might
> change in the future.

If an application writes psd files with width or height > 3 (or,
horribile dictu, Adobe changes the limits), we want to decode
such images (unless strict strict was set).

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Andreas Cadhalpun
On 20.11.2016 17:57, Martin Vignali wrote:
>>> Support uncompress and rle compression in Image Data Section.
>>   ^
>> decompression
>>
> 
> Not sure i understand, do you mean :
> Support uncompress and rle decompression in Image Data Section.
> ?
> Because currently, the psd reader, can manage uncompress or rle.

Never mind, I just didn't parse this sentence correctly.

>>
>> Also a fate test would be nice.
>>
> Il would add a fate test, with the samples (in the previous link, when the
> path will be apply (to not mix, path and fate test).

OK. Alternatively you could already send a separate patch adding the fate test.

>>> diff --git a/libavcodec/psd.c b/libavcodec/psd.c
>>> new file mode 100644
>>> index 000..90ee337
>>> --- /dev/null
>>> +++ b/libavcodec/psd.c
>>> @@ -0,0 +1,428 @@
>> [...]
>>> +s->height = bytestream2_get_be32(>gb);
>>> +
>>> +if ((s->height < 1) || (s->height > 3)) {
>>
>> Why 3?
>> ff_set_dimensions already checks for sane dimensions.
>>
> 
> Following adobe specs :
> http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_pgfId-1055726
> in a psd file, the width or height, can't be > to 30 000 pixels.

I see. In that case it makes sense to explicitly check this, as
the check in ff_set_dimensions is more general and might change
in the future.

On 20.11.2016 18:32, Martin Vignali wrote:
>> However, all the rle samples seem to not decode entirely correct, instead
>> > containing blue/white rectangular areas.
>> >
>> >
>> > Sorry, forget to answer to that.
> The white/blue rect have been add by me to the sample file, in order to
> "enable" the rle compression of photoshop.
> So i think, the conversion is correct for RLE compression

Thanks for explaining that.

Best regards,
Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Martin Vignali
Hello,

2016-11-21 23:16 GMT+01:00 Moritz Barsnick :

> On Mon, Nov 21, 2016 at 21:44:55 +0100, Martin Vignali wrote:
> > +avpriv_request_sample(s->avctx, "ZIP without predictor
> compression");
> > +return AVERROR_PATCHWELCOME;
> > +break;
> > +case 3:
> > +avpriv_request_sample(s->avctx, "ZIP with predictor
> compression");
> > +return AVERROR_PATCHWELCOME;
> > +break;
>
> Are these the only two (detectable) unsupported features? I.e. all
> other error messages are true errors, not "unsupported"?
> 
>

I think,  i use AVERROR_PATCHWELCOME, for each documented features, that
the decoder does not support.
Do you have a specific place where you think i return the wrong message ?

I mainly use this link, for the psd specification :
https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/


@Rostislav :
> I don't think you need the checks, it was pointed out that
> ff_set_dimensions already does that.
> Also IIRC lavc doesn't support widths or heights over 16384 anyway.

Andreas ask why i choose 30 000 for check widths/heights
And the choice come from the Adobe documentation : "Supported range is 1 to
30,000."

But i doesn't know about the 16384 limit, in lavc. I wrongly suppose, it
was int max

So if this is the real limit value is under 30 000, you're right, the check
is not need.

Martin
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Moritz Barsnick
On Mon, Nov 21, 2016 at 21:44:55 +0100, Martin Vignali wrote:
> +avpriv_request_sample(s->avctx, "ZIP without predictor compression");
> +return AVERROR_PATCHWELCOME;
> +break;
> +case 3:
> +avpriv_request_sample(s->avctx, "ZIP with predictor compression");
> +return AVERROR_PATCHWELCOME;
> +break;

Are these the only two (detectable) unsupported features? I.e. all
other error messages are true errors, not "unsupported"?

Just wondering,
Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Rostislav Pehlivanov
On 21 November 2016 at 21:47, Ronald S. Bultje  wrote:

> Hi,
>
> On Mon, Nov 21, 2016 at 4:40 PM, Rostislav Pehlivanov  >
> wrote:
>
> > On 21 November 2016 at 20:44, Martin Vignali 
> > wrote:
> >
> > > Hello,
> > >
> > > New patchs in attach.
> > > Correction have been made followings comments from Andreas and Carl.
> > >
> > > @Rotislav : thanks for your answer.
> > >
> > > Martin
> > >
> > > ___
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> > >
> > I don't think you need the checks, it was pointed out that
> > ff_set_dimensions already does that.
> > Also IIRC lavc doesn't support widths or heights over 16384 anyway.
> >
> > >unsigned int pixel_size
> > Please use uint32_t instead of unsigned ints throughout the patches.. I'm
> > paranoid about unspecified sizes.
>
>
> I don't think we typically encourage that, except for things that are
> arrays...
>
> Ronald
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Didn't know that, ignore it.

Still though, I don't think there's a need to check the dimensions.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Ronald S. Bultje
Hi,

On Mon, Nov 21, 2016 at 4:40 PM, Rostislav Pehlivanov 
wrote:

> On 21 November 2016 at 20:44, Martin Vignali 
> wrote:
>
> > Hello,
> >
> > New patchs in attach.
> > Correction have been made followings comments from Andreas and Carl.
> >
> > @Rotislav : thanks for your answer.
> >
> > Martin
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >
> I don't think you need the checks, it was pointed out that
> ff_set_dimensions already does that.
> Also IIRC lavc doesn't support widths or heights over 16384 anyway.
>
> >unsigned int pixel_size
> Please use uint32_t instead of unsigned ints throughout the patches.. I'm
> paranoid about unspecified sizes.


I don't think we typically encourage that, except for things that are
arrays...

Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Rostislav Pehlivanov
On 21 November 2016 at 20:44, Martin Vignali 
wrote:

> Hello,
>
> New patchs in attach.
> Correction have been made followings comments from Andreas and Carl.
>
> @Rotislav : thanks for your answer.
>
> Martin
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
I don't think you need the checks, it was pointed out that
ff_set_dimensions already does that.
Also IIRC lavc doesn't support widths or heights over 16384 anyway.

>unsigned int pixel_size
Please use uint32_t instead of unsigned ints throughout the patches.. I'm
paranoid about unspecified sizes.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Martin Vignali
Hello,

New patchs in attach.
Correction have been made followings comments from Andreas and Carl.

@Rotislav : thanks for your answer.

Martin
From d923d4e8031fae4fa87cab39b431d055d2744ffe Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Mon, 21 Nov 2016 21:39:07 +0100
Subject: [PATCH 1/2] libavcodec : add decoder for Photoshop PSD image files

Decode the Image Data Section (which contains merged pictures).
Support RGB/A and Grayscale/A in 8bits and 16 bits per channel.
Support uncompress and rle decompression in Image Data Section.
---
 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| 429 
 libavcodec/version.h|   4 +-
 8 files changed, 444 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/psd.c

diff --git a/Changelog b/Changelog
index 8456022..bdad732 100644
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,7 @@ version :
 - CrystalHD decoder moved to new decode API
 - add internal ebur128 library, remove external libebur128 dependency
 - Pro-MPEG CoP #3-R2 FEC protocol
+- PSD Decoder
 
 version 3.2:
 - libopenmpt demuxer
diff --git a/doc/general.texi b/doc/general.texi
index 56b9e4d..9ea3ba3 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -584,6 +584,8 @@ following image formats are supported:
 @item PNG  @tab X @tab X
 @item PPM  @tab X @tab X
 @tab Portable PixelMap image
+@item PSD  @tab   @tab X
+@tab Photoshop
 @item PTX  @tab   @tab X
 @tab V.Flash PTX format
 @item SGI  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 82f7fa2..343329e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -462,6 +462,7 @@ OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdat
 OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_AW_ENCODER)   += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_KS_ENCODER)   += proresenc_kostya.o proresdata.o
+OBJS-$(CONFIG_PSD_DECODER) += psd.o
 OBJS-$(CONFIG_PTX_DECODER) += ptx.o
 OBJS-$(CONFIG_QCELP_DECODER)   += qcelpdec.o \
   celp_filters.o acelp_vectors.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ada9481..bbcecce 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -287,6 +287,7 @@ void avcodec_register_all(void)
 REGISTER_ENCODER(PRORES_AW, prores_aw);
 REGISTER_ENCODER(PRORES_KS, prores_ks);
 REGISTER_DECODER(PRORES_LGPL,   prores_lgpl);
+REGISTER_DECODER(PSD,   psd);
 REGISTER_DECODER(PTX,   ptx);
 REGISTER_DECODER(QDRAW, qdraw);
 REGISTER_DECODER(QPEG,  qpeg);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e5e7f42..538e701 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -411,6 +411,7 @@ enum AVCodecID {
 AV_CODEC_ID_MAGICYUV,
 AV_CODEC_ID_SHEERVIDEO,
 AV_CODEC_ID_YLC,
+AV_CODEC_ID_PSD,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9dbe2dc..29ffcb9 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1461,6 +1461,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
 {
+.id= AV_CODEC_ID_PSD,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "psd",
+.long_name = NULL_IF_CONFIG_SMALL("Photoshop PSD file"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
 .id= AV_CODEC_ID_PTX,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "ptx",
diff --git a/libavcodec/psd.c b/libavcodec/psd.c
new file mode 100644
index 000..e026845
--- /dev/null
+++ b/libavcodec/psd.c
@@ -0,0 +1,429 @@
+/*
+ * Photoshop (PSD) image decoder
+ * Copyright (c) 2016 Jokyo Images
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free 

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

2016-11-21 Thread Nicolas George
Le primidi 1er frimaire, an CCXXV, wm4 a écrit :
> I do not understand this. Please explain why requesting features is
> against policy or not useful.

Please stop your passive-aggressive flame bait.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread wm4
On Mon, 21 Nov 2016 13:08:37 +0100
Carl Eugen Hoyos  wrote:

> 2016-11-21 13:06 GMT+01:00 wm4 :
> > On Mon, 21 Nov 2016 12:48:31 +0100
> > Carl Eugen Hoyos  wrote:
> >  
> >> 2016-11-21 12:04 GMT+01:00 wm4 :  
> >> > On Mon, 21 Nov 2016 07:36:44 +  
> >>  
> >> > Can we get support for .doc and .html too? I think these would be great
> >> > features.  
> >>
> >> Maybe such comments are not against our policy (that you requested so
> >> much), in any case they are not useful.  
> >
> > I do not understand this. Please explain why requesting features is
> > against policy or not useful.  
> 
> The development mailing list is not the right place for a feature request
> (so your email is in fact a policy violation).
> 
> Apart from the fact that doc support does not seem realistic to me:
> What would FFmpeg do with the files once it contains a decoder?

The same as our teletype decoder does.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Carl Eugen Hoyos
2016-11-21 13:06 GMT+01:00 wm4 :
> On Mon, 21 Nov 2016 12:48:31 +0100
> Carl Eugen Hoyos  wrote:
>
>> 2016-11-21 12:04 GMT+01:00 wm4 :
>> > On Mon, 21 Nov 2016 07:36:44 +
>>
>> > Can we get support for .doc and .html too? I think these would be great
>> > features.
>>
>> Maybe such comments are not against our policy (that you requested so
>> much), in any case they are not useful.
>
> I do not understand this. Please explain why requesting features is
> against policy or not useful.

The development mailing list is not the right place for a feature request
(so your email is in fact a policy violation).

Apart from the fact that doc support does not seem realistic to me:
What would FFmpeg do with the files once it contains a decoder?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread wm4
On Mon, 21 Nov 2016 12:48:31 +0100
Carl Eugen Hoyos  wrote:

> 2016-11-21 12:04 GMT+01:00 wm4 :
> > On Mon, 21 Nov 2016 07:36:44 +  
> 
> > Can we get support for .doc and .html too? I think these would be great
> > features.  
> 
> Maybe such comments are not against our policy (that you requested so
> much), in any case they are not useful.

I do not understand this. Please explain why requesting features is
against policy or not useful.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread Carl Eugen Hoyos
2016-11-21 12:04 GMT+01:00 wm4 :
> On Mon, 21 Nov 2016 07:36:44 +

> Can we get support for .doc and .html too? I think these would be great
> features.

Maybe such comments are not against our policy (that you requested so
much), in any case they are not useful.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-21 Thread wm4
On Mon, 21 Nov 2016 07:36:44 +
Rostislav Pehlivanov  wrote:

> On 20 November 2016 at 17:05, Kieran Kunhya  wrote:
> 
> > I object to this patch for the reasons Rostislav outlined..
> >
> > Kieran
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >  
> 
> I actually don't mind the decoder anymore. The code looks simple and neat,
> and it would be nice to be able to view the few random psd files I have and
> which the decoder can open. No full decoding support is planned, which
> would require inhuman effort to complete even like 20% of anyway, so I
> doubt the decoder will grow into a huge mess. I mean viewing psd files is a
> big pain anyway, so eh, if the decoder can open a few of them and save
> people the effort of having gimp (which also doesn't support some psd
> features) without being a security disaster it's okay. When you think about
> it png is also a mess, its been extended to hell with nonstandard chunks,
> but we even have pretty good encoding support for the base of it. Not sure
> what the fuss is here, because there's no public standard?

Can we get support for .doc and .html too? I think these would be great
features.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-20 Thread Rostislav Pehlivanov
On 20 November 2016 at 17:05, Kieran Kunhya  wrote:

> I object to this patch for the reasons Rostislav outlined..
>
> Kieran
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

I actually don't mind the decoder anymore. The code looks simple and neat,
and it would be nice to be able to view the few random psd files I have and
which the decoder can open. No full decoding support is planned, which
would require inhuman effort to complete even like 20% of anyway, so I
doubt the decoder will grow into a huge mess. I mean viewing psd files is a
big pain anyway, so eh, if the decoder can open a few of them and save
people the effort of having gimp (which also doesn't support some psd
features) without being a security disaster it's okay. When you think about
it png is also a mess, its been extended to hell with nonstandard chunks,
but we even have pretty good encoding support for the base of it. Not sure
what the fuss is here, because there's no public standard?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-20 Thread Carl Eugen Hoyos
2016-11-20 18:05 GMT+01:00 Kieran Kunhya :
> I object to this patch for the reasons Rostislav outlined..

Since this version of the decoder does not only support
uncompressed images, I don't think the "reasons" are
still valid.

Iirc, FFmpeg does not support all features of practically
every standard implemented (think of yuv422 asp, h264
with transparency and the mentioned exr decoder), so
this doesn't seem like a strong argument either.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-20 Thread Carl Eugen Hoyos
2016-11-20 18:04 GMT+01:00 Martin Vignali :
>>
>> > I doesn't find a planar, for YA, so there is now two way to store data
>> > one for YA, and one for Gray and GBR.
>>
>> Sorry, I don't understand this sentence...
>
> Not sure i understand what is your question.
> I use planar for RGB and Gray, bu for YA, i doesn't find a planar
> something like YAP and YAP_16BE.
> So i use the "interleaved" pixel format (YA and YA16BE).
> These two mode explain, the if/else part in the storage data part of
> decode_frame.

Of course, thank you for explaining.

(And reminding me that there are more indications that GRAY is RGB...)

>> >> And the more I think of it, the more likely it seems that (GBR) 9, 10,
>> >> 12 and 14 could also be of use.
>> >>
>> > Don't think GBR 9, 10, 12, 14, can be use now for psd file.
>>
>> Then why do you return AVERROR_PATCHWELCOME for the non-8,
>> non-16 case?
>>
> Not sure i understand.
> In this version, there is no support for 9, 10, 12, 14 bitdepth. (and i
> doesn't think psd file can store these kinds of pixel depth).
> But PSD support other pixel depth than 8, and 16 (like float for example).

Ok.

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-20 Thread Martin Vignali
> However, all the rle samples seem to not decode entirely correct, instead
> containing blue/white rectangular areas.
>
>
> Sorry, forget to answer to that.
The white/blue rect have been add by me to the sample file, in order to
"enable" the rle compression of photoshop.
So i think, the conversion is correct for RLE compression

Martin
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-20 Thread Martin Vignali
Hello,

2016-11-20 18:05 GMT+01:00 Kieran Kunhya :

> I object to this patch for the reasons Rostislav outlined..
>

 Thanks for saying this now.

I answer to Rotislav in July.
No answer from him from this moment,
and the answers from other people, doesn't seems to go in the same way.


Martin
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-20 Thread Martin Vignali
>
> > I doesn't find a planar, for YA, so there is now two way to store data
> > one for YA, and one for Gray and GBR.
>
> Sorry, I don't understand this sentence...
>

Not sure i understand what is your question.
I use planar for RGB and Gray, bu for YA, i doesn't find a planar something
like YAP and YAP_16BE.
So i use the "interleaved" pixel format (YA and YA16BE).
These two mode explain, the if/else part in the storage data part of
decode_frame.


>
> >> And the more I think of it, the more likely it seems that (GBR) 9, 10,
> 12
> >> and 14
> >> could also be of use.
> >>
> > Don't think GBR 9, 10, 12, 14, can be use now for psd file.
>
> Then why do you return AVERROR_PATCHWELCOME for the non-8,
> non-16 case?
>
Not sure i understand.
In this version, there is no support for 9, 10, 12, 14 bitdepth. (and i
doesn't think psd file can store these kinds of pixel depth).
But PSD support other pixel depth than 8, and 16 (like float for example).


>
> > +if (s->channel_depth == 8) {
> > +avctx->pix_fmt = AV_PIX_FMT_GBRP;
> > +} else if (s->channel_depth == 16) {
> > +avctx->pix_fmt = AV_PIX_FMT_GBRP16BE;
> > +} else {
> > +avpriv_report_missing_feature(avctx, "channel depth %d
> unsupported for rgb", s->channel_depth);
> > +return AVERROR_PATCHWELCOME;
> > +}
>
> > +color_mode = bytestream2_get_be16(>gb);
> > +switch (color_mode) {
>
> Why is this not "s->color_mode = bytestream2_get_be16(>gb);" instead?
>
Seems more clean for me, considering color mode are not "continuous".
so the switch case assign the value after checking it, using the enum.

>
> > +compression = bytestream2_get_be16(>gb);
> > +switch (compression) {
>
> Same here: Why not "s->compression = bytestream2_get_be16(>gb);"?
>
> Correct locally


> From the demuxer patch:
> > +if (p->buf_size < 26)
> > +return 0;
>
> Padding alone is 32, so this check is not necessary.
>
>
> Correct locally

Martin
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-20 Thread Kieran Kunhya
I object to this patch for the reasons Rostislav outlined..

Kieran
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-20 Thread Martin Vignali
> > Subject: [PATCH 1/2] libavcodec : add decoder for Photoshop PSD image
> file.
>
>   ^
> image file*s* and no dot at the end
>
> > Decode the Image Data Section (who contain merge picture).
>  ^
> (which contains merged pictures)
>
> > Support RGB/A and Grayscale/A in 8bits and 16 bits by channel.
>  ^
> per channel
>

Correct locally


>
> > Support uncompress and rle compression in Image Data Section.
>   ^
> decompression
>

Not sure i understand, do you mean :
Support uncompress and rle decompression in Image Data Section.
?
Because currently, the psd reader, can manage uncompress or rle.


>
> > ---
> >  Changelog  |   1 +
> >  doc/general.texi   |   2 +
> >  libavcodec/Makefile|   1 +
> >  libavcodec/allcodecs.c |   1 +
> >  libavcodec/avcodec.h   |   1 +
> >  libavcodec/psd.c   | 428 ++
> +++
> >  6 files changed, 434 insertions(+)
> >  create mode 100644 libavcodec/psd.c
>
> Have you read doc/developers.texi, section "New codecs or formats
> checklist"?
>  * needs minor version bump
>  * codec should be added to libavcodec/codec_desc.c
>
Correct locally.

>
> Also a fate test would be nice.
>
Il would add a fate test, with the samples (in the previous link, when the
path will be apply (to not mix, path and fate test).

>
> > diff --git a/libavcodec/psd.c b/libavcodec/psd.c
> > new file mode 100644
> > index 000..90ee337
> > --- /dev/null
> > +++ b/libavcodec/psd.c
> > @@ -0,0 +1,428 @@
> [...]
> > +s->height = bytestream2_get_be32(>gb);
> > +
> > +if ((s->height < 1) || (s->height > 3)) {
>
> Why 3?
> ff_set_dimensions already checks for sane dimensions.
>

Following adobe specs :
http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/#50577409_pgfId-1055726
in a psd file, the width or height, can't be > to 30 000 pixels.


>
> > +av_log(s->avctx, AV_LOG_ERROR, "Invalid height %d.\n",
> s->height);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +s->width = bytestream2_get_be32(>gb);
> > +if ((s->width < 1) || (s->width > 3)) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Invalid width %d.\n", s->width);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +if ((ret = ff_set_dimensions(s->avctx, s->width, s->height)) < 0)
> > +return ret;
> > +
> > +s->channel_depth = bytestream2_get_be16(>gb);
> > +
> > +color_mode = bytestream2_get_be16(>gb);
> > +switch (color_mode) {
> > +case 0:
> > +s->color_mode = PSD_BITMAP;
> > +break;
> > +case 1:
> > +s->color_mode = PSD_GRAYSCALE;
> > +break;
> > +case 2:
> > +s->color_mode = PSD_INDEXED;
> > +break;
> > +case 3:
> > +s->color_mode = PSD_RGB;
> > +break;
> > +case 4:
> > +s->color_mode = PSD_CMYK;
> > +break;
> > +case 7:
> > +s->color_mode = PSD_MULTICHANNEL;
> > +break;
> > +case 8:
> > +s->color_mode = PSD_DUOTONE;
> > +break;
> > +case 9:
> > +s->color_mode = PSD_LAB;
> > +break;
> > +default:
> > +av_log(s->avctx, AV_LOG_ERROR, "Unknown color mode %d.\n",
> color_mode);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +/* color map data */
> > +len_section = bytestream2_get_be32(>gb);
> > +if (len_section < 0)
>
> Please add an error message.
>
Correct locally

>
> > +return AVERROR_INVALIDDATA;
> > +
> > +if (bytestream2_get_bytes_left(>gb) < (len_section + 4)) { /*
> section and len next section */
> > +av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
> > +return AVERROR_INVALIDDATA;
> > +}
> > +bytestream2_skip(>gb, len_section);
> > +
> > +/* image ressources */
> > +len_section = bytestream2_get_be32(>gb);
> > +if (len_section < 0)
>
> Here too.
>
Correct locally

>
> > +return AVERROR_INVALIDDATA;
> > +
> > +if (bytestream2_get_bytes_left(>gb) < (len_section + 4)) { /*
> section and len next section */
> > +av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
> > +return AVERROR_INVALIDDATA;
> > +}
> > +bytestream2_skip(>gb, len_section);
> > +
> > +/* layers and masks */
> > +len_section = bytestream2_get_be32(>gb);
> > +if (len_section < 0)
>
> And here.
>
Correct locally

>
> [...]
> > +static int decode_frame(AVCodecContext *avctx, void *data,
> > +int *got_frame, AVPacket *avpkt)
> > +{
> > +int ret;
> > +uint8_t *ptr;
> > +const uint8_t * ptr_data;
>   ^
> nit: no space between * and variable name. (Also elsewhere.)
>
Correct locally

>
> > +int index_out, c, y, x, p;
> > +uint8_t eq_channel[4] = {2,0,1,3};;/* RGBA -> GBRA channel order */
>  ^
> One ';' too much, use a space instead.
>

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

2016-11-20 Thread Carl Eugen Hoyos
2016-11-18 18:27 GMT+01:00 Martin Vignali :

>> Did you see AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRP16
>> and AV_PIX_FMT_GBRAP16?
>>
>
> New patch in attach use AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
> AV_PIX_FMT_GBRP16BE
> and AV_PIX_FMT_GBRAP16BE for RGB mode

> I doesn't find a planar, for YA, so there is now two way to store data
> one for YA, and one for Gray and GBR.

Sorry, I don't understand this sentence...

>> And the more I think of it, the more likely it seems that (GBR) 9, 10, 12
>> and 14
>> could also be of use.
>>
> Don't think GBR 9, 10, 12, 14, can be use now for psd file.

Then why do you return AVERROR_PATCHWELCOME for the non-8,
non-16 case?

> +if (s->channel_depth == 8) {
> +avctx->pix_fmt = AV_PIX_FMT_GBRP;
> +} else if (s->channel_depth == 16) {
> +avctx->pix_fmt = AV_PIX_FMT_GBRP16BE;
> +} else {
> +avpriv_report_missing_feature(avctx, "channel depth %d 
> unsupported for rgb", s->channel_depth);
> +return AVERROR_PATCHWELCOME;
> +}

> +color_mode = bytestream2_get_be16(>gb);
> +switch (color_mode) {

Why is this not "s->color_mode = bytestream2_get_be16(>gb);" instead?

> +compression = bytestream2_get_be16(>gb);
> +switch (compression) {

Same here: Why not "s->compression = bytestream2_get_be16(>gb);"?

From the demuxer patch:
> +if (p->buf_size < 26)
> +return 0;

Padding alone is 32, so this check is not necessary.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-19 Thread Andreas Cadhalpun
On 18.11.2016 18:27, Martin Vignali wrote:
> From c41e6c79ed42478a1658c8922d19c832d3a89424 Mon Sep 17 00:00:00 2001
> From: Martin Vignali 
> Date: Fri, 18 Nov 2016 18:18:20 +0100
> Subject: [PATCH 1/2] libavcodec : add decoder for Photoshop PSD image file.
^
image file*s* and no dot at the end

> Decode the Image Data Section (who contain merge picture).
 ^
(which contains merged pictures)

> Support RGB/A and Grayscale/A in 8bits and 16 bits by channel.
 ^
per channel

> Support uncompress and rle compression in Image Data Section.
  ^
decompression

> ---
>  Changelog  |   1 +
>  doc/general.texi   |   2 +
>  libavcodec/Makefile|   1 +
>  libavcodec/allcodecs.c |   1 +
>  libavcodec/avcodec.h   |   1 +
>  libavcodec/psd.c   | 428 
> +
>  6 files changed, 434 insertions(+)
>  create mode 100644 libavcodec/psd.c

Have you read doc/developers.texi, section "New codecs or formats checklist"?
 * needs minor version bump
 * codec should be added to libavcodec/codec_desc.c

Also a fate test would be nice.

> diff --git a/libavcodec/psd.c b/libavcodec/psd.c
> new file mode 100644
> index 000..90ee337
> --- /dev/null
> +++ b/libavcodec/psd.c
> @@ -0,0 +1,428 @@
[...]
> +s->height = bytestream2_get_be32(>gb);
> +
> +if ((s->height < 1) || (s->height > 3)) {

Why 3?
ff_set_dimensions already checks for sane dimensions.

> +av_log(s->avctx, AV_LOG_ERROR, "Invalid height %d.\n", s->height);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +s->width = bytestream2_get_be32(>gb);
> +if ((s->width < 1) || (s->width > 3)) {
> +av_log(s->avctx, AV_LOG_ERROR, "Invalid width %d.\n", s->width);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +if ((ret = ff_set_dimensions(s->avctx, s->width, s->height)) < 0)
> +return ret;
> +
> +s->channel_depth = bytestream2_get_be16(>gb);
> +
> +color_mode = bytestream2_get_be16(>gb);
> +switch (color_mode) {
> +case 0:
> +s->color_mode = PSD_BITMAP;
> +break;
> +case 1:
> +s->color_mode = PSD_GRAYSCALE;
> +break;
> +case 2:
> +s->color_mode = PSD_INDEXED;
> +break;
> +case 3:
> +s->color_mode = PSD_RGB;
> +break;
> +case 4:
> +s->color_mode = PSD_CMYK;
> +break;
> +case 7:
> +s->color_mode = PSD_MULTICHANNEL;
> +break;
> +case 8:
> +s->color_mode = PSD_DUOTONE;
> +break;
> +case 9:
> +s->color_mode = PSD_LAB;
> +break;
> +default:
> +av_log(s->avctx, AV_LOG_ERROR, "Unknown color mode %d.\n", 
> color_mode);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +/* color map data */
> +len_section = bytestream2_get_be32(>gb);
> +if (len_section < 0)

Please add an error message.

> +return AVERROR_INVALIDDATA;
> +
> +if (bytestream2_get_bytes_left(>gb) < (len_section + 4)) { /* section 
> and len next section */
> +av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
> +return AVERROR_INVALIDDATA;
> +}
> +bytestream2_skip(>gb, len_section);
> +
> +/* image ressources */
> +len_section = bytestream2_get_be32(>gb);
> +if (len_section < 0)

Here too.

> +return AVERROR_INVALIDDATA;
> +
> +if (bytestream2_get_bytes_left(>gb) < (len_section + 4)) { /* section 
> and len next section */
> +av_log(s->avctx, AV_LOG_ERROR, "Incomplete file.\n");
> +return AVERROR_INVALIDDATA;
> +}
> +bytestream2_skip(>gb, len_section);
> +
> +/* layers and masks */
> +len_section = bytestream2_get_be32(>gb);
> +if (len_section < 0)

And here.

[...]
> +static int decode_frame(AVCodecContext *avctx, void *data,
> +int *got_frame, AVPacket *avpkt)
> +{
> +int ret;
> +uint8_t *ptr;
> +const uint8_t * ptr_data;
  ^
nit: no space between * and variable name. (Also elsewhere.)

> +int index_out, c, y, x, p;
> +uint8_t eq_channel[4] = {2,0,1,3};;/* RGBA -> GBRA channel order */
 ^
One ';' too much, use a space instead.

> +uint8_t plane_number;
> +
> +AVFrame *picture = data;
> +
> +PSDContext *s = avctx->priv_data;
> +s->avctx = avctx;
> +s->channel_count = 0;
> +s->channel_depth = 0;
> +s->tmp   = NULL;
> +s->line_size = 0;
> +
> +bytestream2_init(>gb, avpkt->data, avpkt->size);
> +
> +if ((ret = decode_header(s)) < 0)
> +return ret;
> +
> +s->pixel_size = s->channel_depth >> 3;/* in byte */
> +s->line_size = s->width * s->pixel_size;
> +s->uncompressed_size = s->line_size * s->height * s->channel_count;
> +
> +switch 

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

2016-11-18 Thread Martin Vignali
>
> Can you share a few small samples?
> I'd like to fuzz test this decoder a bit.
>
> You can find sample here :
https://we.tl/BHKIQCDZZm

Martin
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-18 Thread Andreas Cadhalpun
On 18.11.2016 18:27, Martin Vignali wrote:
> From c41e6c79ed42478a1658c8922d19c832d3a89424 Mon Sep 17 00:00:00 2001
> From: Martin Vignali 
> Date: Fri, 18 Nov 2016 18:18:20 +0100
> Subject: [PATCH 1/2] libavcodec : add decoder for Photoshop 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.
> Support uncompress and rle compression in Image Data Section.

Can you share a few small samples?
I'd like to fuzz test this decoder a bit.

Best regards,
Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-11-18 Thread Martin Vignali
Hello,

Did you see AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRP16
> and AV_PIX_FMT_GBRAP16?
>

New patch in attach use AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
AV_PIX_FMT_GBRP16BE
and AV_PIX_FMT_GBRAP16BE for RGB mode

I doesn't find a planar, for YA, so there is now two way to store data
one for YA, and one for Gray and GBR.


> And the more I think of it, the more likely it seems that (GBR) 9, 10, 12
> and 14
> could also be of use.
>
>
Don't think GBR 9, 10, 12, 14, can be use now for psd file.

Martin
From c41e6c79ed42478a1658c8922d19c832d3a89424 Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Fri, 18 Nov 2016 18:18:20 +0100
Subject: [PATCH 1/2] libavcodec : add decoder for Photoshop 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.
Support uncompress and rle compression in Image Data Section.
---
 Changelog  |   1 +
 doc/general.texi   |   2 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/avcodec.h   |   1 +
 libavcodec/psd.c   | 428 +
 6 files changed, 434 insertions(+)
 create mode 100644 libavcodec/psd.c

diff --git a/Changelog b/Changelog
index 8456022..bdad732 100644
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,7 @@ version :
 - CrystalHD decoder moved to new decode API
 - add internal ebur128 library, remove external libebur128 dependency
 - Pro-MPEG CoP #3-R2 FEC protocol
+- PSD Decoder
 
 version 3.2:
 - libopenmpt demuxer
diff --git a/doc/general.texi b/doc/general.texi
index 56b9e4d..9ea3ba3 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -584,6 +584,8 @@ following image formats are supported:
 @item PNG  @tab X @tab X
 @item PPM  @tab X @tab X
 @tab Portable PixelMap image
+@item PSD  @tab   @tab X
+@tab Photoshop
 @item PTX  @tab   @tab X
 @tab V.Flash PTX format
 @item SGI  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 82f7fa2..343329e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -462,6 +462,7 @@ OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdat
 OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_AW_ENCODER)   += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_KS_ENCODER)   += proresenc_kostya.o proresdata.o
+OBJS-$(CONFIG_PSD_DECODER) += psd.o
 OBJS-$(CONFIG_PTX_DECODER) += ptx.o
 OBJS-$(CONFIG_QCELP_DECODER)   += qcelpdec.o \
   celp_filters.o acelp_vectors.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index ada9481..bbcecce 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -287,6 +287,7 @@ void avcodec_register_all(void)
 REGISTER_ENCODER(PRORES_AW, prores_aw);
 REGISTER_ENCODER(PRORES_KS, prores_ks);
 REGISTER_DECODER(PRORES_LGPL,   prores_lgpl);
+REGISTER_DECODER(PSD,   psd);
 REGISTER_DECODER(PTX,   ptx);
 REGISTER_DECODER(QDRAW, qdraw);
 REGISTER_DECODER(QPEG,  qpeg);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e5e7f42..538e701 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -411,6 +411,7 @@ enum AVCodecID {
 AV_CODEC_ID_MAGICYUV,
 AV_CODEC_ID_SHEERVIDEO,
 AV_CODEC_ID_YLC,
+AV_CODEC_ID_PSD,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs
diff --git a/libavcodec/psd.c b/libavcodec/psd.c
new file mode 100644
index 000..90ee337
--- /dev/null
+++ b/libavcodec/psd.c
@@ -0,0 +1,428 @@
+/*
+ * Photoshop (PSD) image decoder
+ * Copyright (c) 2016 Jokyo Images
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "bytestream.h"
+#include "internal.h"
+
+enum PsdCompr {
+PSD_RAW,
+PSD_RLE,
+PSD_ZIP_WITHOUT_P,
+PSD_ZIP_WITH_P,
+};
+
+enum PsdColorMode {
+PSD_BITMAP,
+PSD_GRAYSCALE,
+PSD_INDEXED,
+PSD_RGB,
+PSD_CMYK,
+PSD_MULTICHANNEL,
+PSD_DUOTONE,
+PSD_LAB,
+};
+
+typedef struct 

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

2016-10-24 Thread Carl Eugen Hoyos
2016-10-24 22:21 GMT+02:00 Martin Vignali :
> 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
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-08-06 Thread Michael Niedermayer
On Fri, Aug 05, 2016 at 01:05:38PM +0200, Martin Vignali wrote:
[...]
> >
> > did you test this code with a fuzzer ?
> >
> 
> No i didn't know how to do that.

there are many fuzzers, an older one is:

zzuf -c -s0:  -r0.01 ./ffmpeg -i someinputfile -f null -

see the zzuf manual page for mor information and adjust anything you
like

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-08-05 Thread Martin Vignali
>
>
> > +static int decode_header(PSDContext * s)
> > +{
> > +int signature, version, color_mode, len_section, compression;
> > +int ret = 0;
> > +
> > +if (bytestream2_get_bytes_left(>gb) < 30) {/* File header
> section + color map data section length */
> > +av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +signature = bytestream2_get_le32(>gb);
> > +if (signature != MKTAG('8','B','P','S')) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Wrong signature %d.\n",
> signature);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +version = bytestream2_get_be16(>gb);
> > +if (version != 1) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Wrong version %d.\n", version);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +bytestream2_skip(>gb, 6);/* reserved */
> > +
> > +s->channel_count = bytestream2_get_be16(>gb);
> > +if ((s->channel_count < 1) || (s->channel_count > 56)) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Invalid channel count %d.\n",
> s->channel_count);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +s->height = bytestream2_get_be32(>gb);
> > +
> > +if ((s->height < 1) || (s->height > 3)) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Invalid height %d.\n",
> s->height);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +s->width = bytestream2_get_be32(>gb);
> > +if ((s->width < 1) || (s->width > 3)) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Invalid width %d.\n", s->width);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +if ((ret = ff_set_dimensions(s->avctx, s->width, s->height)) < 0)
> > +return ret;
> > +
> > +s->channel_depth = bytestream2_get_be16(>gb);
> > +
> > +color_mode = bytestream2_get_be16(>gb);
> > +switch (color_mode) {
> > +case 0:
> > +s->color_mode = PSD_BITMAP;
> > +break;
> > +case 1:
> > +s->color_mode = PSD_GRAYSCALE;
> > +break;
> > +case 2:
> > +s->color_mode = PSD_INDEXED;
> > +break;
> > +case 3:
> > +s->color_mode = PSD_RGB;
> > +break;
> > +case 4:
> > +s->color_mode = PSD_CMYK;
> > +break;
> > +case 7:
> > +s->color_mode = PSD_MULTICHANNEL;
> > +break;
> > +case 8:
> > +s->color_mode = PSD_DUOTONE;
> > +break;
> > +case 9:
> > +s->color_mode = PSD_LAB;
> > +break;
> > +default:
> > +av_log(s->avctx, AV_LOG_ERROR, "Unknown color mode %d.\n",
> color_mode);
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +/* color map data */
> > +len_section = bytestream2_get_be32(>gb);
> > +if (bytestream2_get_bytes_left(>gb) < (len_section + 4)) { /*
> section and len next section */
>
> len_section + 4 can overflow, len_section is signed here so can be
> negative too
>
Ok i will correct that.

>
>
> [...]
> > +static int decode_frame(AVCodecContext *avctx, void *data,
> > +int *got_frame, AVPacket *avpkt)
> > +{
> > +int ret;
> > +uint8_t *ptr;
> > +const uint8_t * ptr_data;
> > +int index_out, c, y, x, p;
> > +
> > +AVFrame *picture = data;
> > +
> > +PSDContext *s = avctx->priv_data;
> > +s->avctx = avctx;
> > +s->channel_count = 0;
> > +s->channel_depth = 0;
> > +s->tmp   = NULL;
> > +s->line_size = 0;
> > +
> > +bytestream2_init(>gb, avpkt->data, avpkt->size);
> > +
> > +if ((ret = decode_header(s)) < 0)
> > +return ret;
> > +
> > +s->pixel_size = s->channel_depth >> 3;/* in byte */
>
> > +s->line_size = s->width * s->pixel_size;
>

For this one i doesn't think there can be an overflow, width can't be > 30
000 (checked before), and pixel_size is 16bit



> > +s->uncompressed_size = s->line_size * s->height * s->channel_count;
>
> Does it seems ok, if i replace unsigned long by uint_64 ?



>
> did you test this code with a fuzzer ?
>

No i didn't know how to do that.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-08-05 Thread Michael Niedermayer
On Thu, Aug 04, 2016 at 05:00:27PM +0200, Martin Vignali wrote:
> >
> > I think you should fail probe with less than 26 bytes
> > or are there smaller files that can be valid ?
> >
> >
> > Fix
> 
> >
> > this is not based on git master
> >
> 
> New patch in attach
> 
> Martin

[...]

> +static int decode_header(PSDContext * s)
> +{
> +int signature, version, color_mode, len_section, compression;
> +int ret = 0;
> +
> +if (bytestream2_get_bytes_left(>gb) < 30) {/* File header section + 
> color map data section length */
> +av_log(s->avctx, AV_LOG_ERROR, "Header too short to parse.\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +signature = bytestream2_get_le32(>gb);
> +if (signature != MKTAG('8','B','P','S')) {
> +av_log(s->avctx, AV_LOG_ERROR, "Wrong signature %d.\n", signature);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +version = bytestream2_get_be16(>gb);
> +if (version != 1) {
> +av_log(s->avctx, AV_LOG_ERROR, "Wrong version %d.\n", version);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +bytestream2_skip(>gb, 6);/* reserved */
> +
> +s->channel_count = bytestream2_get_be16(>gb);
> +if ((s->channel_count < 1) || (s->channel_count > 56)) {
> +av_log(s->avctx, AV_LOG_ERROR, "Invalid channel count %d.\n", 
> s->channel_count);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +s->height = bytestream2_get_be32(>gb);
> +
> +if ((s->height < 1) || (s->height > 3)) {
> +av_log(s->avctx, AV_LOG_ERROR, "Invalid height %d.\n", s->height);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +s->width = bytestream2_get_be32(>gb);
> +if ((s->width < 1) || (s->width > 3)) {
> +av_log(s->avctx, AV_LOG_ERROR, "Invalid width %d.\n", s->width);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +if ((ret = ff_set_dimensions(s->avctx, s->width, s->height)) < 0)
> +return ret;
> +
> +s->channel_depth = bytestream2_get_be16(>gb);
> +
> +color_mode = bytestream2_get_be16(>gb);
> +switch (color_mode) {
> +case 0:
> +s->color_mode = PSD_BITMAP;
> +break;
> +case 1:
> +s->color_mode = PSD_GRAYSCALE;
> +break;
> +case 2:
> +s->color_mode = PSD_INDEXED;
> +break;
> +case 3:
> +s->color_mode = PSD_RGB;
> +break;
> +case 4:
> +s->color_mode = PSD_CMYK;
> +break;
> +case 7:
> +s->color_mode = PSD_MULTICHANNEL;
> +break;
> +case 8:
> +s->color_mode = PSD_DUOTONE;
> +break;
> +case 9:
> +s->color_mode = PSD_LAB;
> +break;
> +default:
> +av_log(s->avctx, AV_LOG_ERROR, "Unknown color mode %d.\n", 
> color_mode);
> +return AVERROR_INVALIDDATA;
> +}
> +
> +/* color map data */
> +len_section = bytestream2_get_be32(>gb);
> +if (bytestream2_get_bytes_left(>gb) < (len_section + 4)) { /* section 
> and len next section */

len_section + 4 can overflow, len_section is signed here so can be
negative too


[...]
> +static int decode_frame(AVCodecContext *avctx, void *data,
> +int *got_frame, AVPacket *avpkt)
> +{
> +int ret;
> +uint8_t *ptr;
> +const uint8_t * ptr_data;
> +int index_out, c, y, x, p;
> +
> +AVFrame *picture = data;
> +
> +PSDContext *s = avctx->priv_data;
> +s->avctx = avctx;
> +s->channel_count = 0;
> +s->channel_depth = 0;
> +s->tmp   = NULL;
> +s->line_size = 0;
> +
> +bytestream2_init(>gb, avpkt->data, avpkt->size);
> +
> +if ((ret = decode_header(s)) < 0)
> +return ret;
> +
> +s->pixel_size = s->channel_depth >> 3;/* in byte */

> +s->line_size = s->width * s->pixel_size;
> +s->uncompressed_size = s->line_size * s->height * s->channel_count;

cant these multplications overflow ?

did you test this code with a fuzzer ?

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-08-04 Thread Martin Vignali
>
> I think you should fail probe with less than 26 bytes
> or are there smaller files that can be valid ?
>
>
> Fix

>
> this is not based on git master
>

New patch in attach

Martin
From 7af7660813e2abe7174d12fef80f9198ee612192 Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Thu, 4 Aug 2016 16:58:17 +0200
Subject: [PATCH 1/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 e2cb474..413d6a1 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -234,6 +234,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 10c9bcc..5289e67 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -365,6 +365,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 bac0114..e06ae6f 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -821,6 +821,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;
@@ -946,6 +979,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)

From c19f74e5c6456056635252abad80f83bff51292c Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Thu, 4 Aug 2016 16:58:30 +0200
Subject: [PATCH 2/2] libavcodec : add decoder for Photoshop 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.
Support uncompress and rle compression in Image Data Section.
---
 Changelog  |   1 +
 doc/general.texi   |   2 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/avcodec.h   |   1 +
 libavcodec/psd.c   | 402 +
 6 files changed, 408 insertions(+)
 create mode 100644 libavcodec/psd.c

diff --git a/Changelog b/Changelog
index 0f9b4cf..750a14b 100644
--- a/Changelog
+++ b/Changelog
@@ -12,6 +12,7 @@ version :
 - 16-bit support in selectivecolor filter
 - OpenH264 decoder wrapper
 - MediaCodec hwaccel
+- PSD Decoder
 
 
 version 3.1:
diff --git a/doc/general.texi b/doc/general.texi
index 6b5975c..6879666 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -584,6 +584,8 @@ following image formats are supported:
 @item PNG  @tab X @tab X
 @item PPM  @tab X @tab X
 @tab Portable PixelMap image
+@item PSD  @tab   @tab X
+@tab Photoshop
 @item PTX  @tab   @tab X
 @tab V.Flash PTX format
 @item SGI  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b375720..dd07a7b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -459,6 +459,7 @@ OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdat
 

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

2016-08-02 Thread Michael Niedermayer
On Tue, Jul 26, 2016 at 03:07:37PM +0200, Martin Vignali wrote:
> Sorry, forgot one out of array issue in the previous patch
> 
> Correct patch in attach
> 
> Martin

>  Makefile |1 +
>  allformats.c |1 +
>  img2dec.c|   33 +
>  3 files changed, 35 insertions(+)
> 2fe2603c097f52ade37e93ab20e7d7c7c9cf3920  
> 0001-libavformat-add-Photoshop-PSD-file.patch
> From 99c60ace42f29b681fc8e5729f4b0081a204cfe5 Mon Sep 17 00:00:00 2001
> From: Martin Vignali 
> Date: Tue, 26 Jul 2016 15:05:57 +0200
> Subject: [PATCH 1/2] libavformat : add Photoshop PSD file.
> 
> ---
>  libavformat/Makefile |  1 +
>  libavformat/allformats.c |  1 +
>  libavformat/img2dec.c| 33 +
>  3 files changed, 35 insertions(+)
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index c49f9de..a79ca8f 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -234,6 +234,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 d490cc4..3d631e1 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -364,6 +364,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 9d6796f..c23f379 100644
> --- a/libavformat/img2dec.c
> +++ b/libavformat/img2dec.c
> @@ -821,6 +821,38 @@ 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) {

I think you should fail probe with less than 26 bytes
or are there smaller files that can be valid ?


[...]

>  Changelog  |1 
>  doc/general.texi   |2 
>  libavcodec/Makefile|1 
>  libavcodec/allcodecs.c |1 
>  libavcodec/avcodec.h   |1 
>  libavcodec/psd.c   |  402 
> +
>  6 files changed, 408 insertions(+)
> a29c64726b8c030e370c552fc6535d8a48fca550  
> 0002-libavcodec-add-decoder-for-Photoshop-PSD-image-file.patch
> From df3cfa66fa71e512125526c226c1629f00949409 Mon Sep 17 00:00:00 2001
> From: Martin Vignali 
> Date: Tue, 26 Jul 2016 15:06:10 +0200
> Subject: [PATCH 2/2] libavcodec : add decoder for Photoshop 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.
> Support uncompress and rle compression in Image Data Section.
> ---
>  Changelog  |   1 +
>  doc/general.texi   |   2 +
>  libavcodec/Makefile|   1 +
>  libavcodec/allcodecs.c |   1 +
>  libavcodec/avcodec.h   |   1 +
>  libavcodec/psd.c   | 402 
> +
>  6 files changed, 408 insertions(+)
>  create mode 100644 libavcodec/psd.c
> 

> diff --git a/Changelog b/Changelog
> index 99cdb80..f41d2b6 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
>  
>  version :
>  
> +- PSD Decoder

this is not based on git master


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-26 Thread Martin Vignali
Sorry, forgot one out of array issue in the previous patch

Correct patch in attach

Martin
From 99c60ace42f29b681fc8e5729f4b0081a204cfe5 Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Tue, 26 Jul 2016 15:05:57 +0200
Subject: [PATCH 1/2] libavformat : add Photoshop PSD file.

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

diff --git a/libavformat/Makefile b/libavformat/Makefile
index c49f9de..a79ca8f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -234,6 +234,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 d490cc4..3d631e1 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -364,6 +364,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 9d6796f..c23f379 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -821,6 +821,38 @@ 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) {
+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;
@@ -946,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)
-- 
1.9.3 (Apple Git-50)

From df3cfa66fa71e512125526c226c1629f00949409 Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Tue, 26 Jul 2016 15:06:10 +0200
Subject: [PATCH 2/2] libavcodec : add decoder for Photoshop 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.
Support uncompress and rle compression in Image Data Section.
---
 Changelog  |   1 +
 doc/general.texi   |   2 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/avcodec.h   |   1 +
 libavcodec/psd.c   | 402 +
 6 files changed, 408 insertions(+)
 create mode 100644 libavcodec/psd.c

diff --git a/Changelog b/Changelog
index 99cdb80..f41d2b6 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
 
 version :
 
+- PSD Decoder
 
 version 3.1:
 - DXVA2-accelerated HEVC Main10 decoding
diff --git a/doc/general.texi b/doc/general.texi
index 4db209f..06775f4 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -577,6 +577,8 @@ following image formats are supported:
 @item PNG  @tab X @tab X
 @item PPM  @tab X @tab X
 @tab Portable PixelMap image
+@item PSD  @tab   @tab X
+@tab Photoshop
 @item PTX  @tab   @tab X
 @tab V.Flash PTX format
 @item SGI  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fd0d1f0..913b4a8 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -456,6 +456,7 @@ OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdat
 OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_AW_ENCODER)   += 

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

2016-07-25 Thread Martin Vignali
2016-07-25 2:46 GMT+02:00 Michael Niedermayer :

> On Sun, Jul 24, 2016 at 03:21:00PM +0200, Martin Vignali wrote:
> > > breaks fate
> > >
> > > make: *** [fate-filter-metadata-ebur128] Error 1
> > > --- -   2016-07-23 18:50:11.633752058 +0200
> > > +++ tests/data/fate/probe-format-roundup14142016-07-23
> > > 18:50:10.913635588 +0200
> > > @@ -1 +1 @@
> > > -mpeg
> > > +psd_pipe
> > > Test probe-format-roundup1414 failed. Look at
> > > tests/data/fate/probe-format-roundup1414.err for details.
> > > make: *** [fate-probe-format-roundup1414] Error 1
> > > --- -   2016-07-23 18:50:11.657384876 +0200
> > > +++ tests/data/fate/probe-format-roundup997 2016-07-23
> > > 18:50:10.917635588 +0200
> > > @@ -1 +1 @@
> > > -mpeg
> > > +psd_pipe
> > > Test probe-format-roundup997 failed. Look at
> > > tests/data/fate/probe-format-roundup997.err for details.
> > > make: *** [fate-probe-format-roundup997] Error 1
> > > --- -   2016-07-23 18:50:11.667958765 +0200
> > > +++ tests/data/fate/probe-format-roundup13832016-07-23
> > > 18:50:10.917635588 +0200
> > > @@ -1 +1 @@
> > > -mp3
> > > +psd_pipe
> > > Test probe-format-roundup1383 failed. Look at
> > > tests/data/fate/probe-format-roundup1383.err for details.
> > > make: *** [fate-probe-format-roundup1383] Error 1
> > > make: Target `fate' not remade because of errors.
> > >
> > >
> > Hello,
> >
> > Corrected patch in attach who fix the psd_probe function.
> >
> > Comments welcome
> >
> > 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 |  395
> +++
> >  libavformat/Makefile |1
> >  libavformat/allformats.c |1
> >  libavformat/img2.c   |1
> >  libavformat/img2dec.c|   35 
> >  11 files changed, 446 insertions(+)
>
> this should be split into 2 patches one for libavcodec and libavformat
>
>
> [...]
> > +static int decode_rle(PSDContext * s){
> > +unsigned int scanline_count;
> > +unsigned int sl, count;
> > +unsigned long target_index = 0;
> > +
> > +scanline_count = s->height * s->channel_count;
> > +
> > +/* scanline table */
> > +if (bytestream2_get_bytes_left(>gb) < scanline_count * 2) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Not enough data for rle
> scanline table.\n");
> > +return AVERROR_INVALIDDATA;
> > +}
> > +bytestream2_skip(>gb, scanline_count * 2);/* size of each
> scanline */
> > +
> > +/* decode rle data scanline by scanline */
> > +for (sl = 0; sl < scanline_count; sl++) {
> > +count = 0;
> > +
> > +while (count < s->line_size) {
>
> > +char rle_char = bytestream2_get_byte(>gb);
>
> please use intXY_t or int, char can be unsigned
>
>
> > +
> > +if (rle_char <= 0) {/* byte repeat */
>
> > +rle_char *= -1;
>
> this is not safe
> rle_char is just 8 bit -128 cannot be represented as positive value
>
>
> > +
> > +if (bytestream2_get_bytes_left(>gb) < 1) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Not enough data for
> rle scanline.\n");
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +if (target_index + rle_char > s->uncompressed_size) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Invalid rle
> char.\n");
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
>
> > +uint8_t v = bytestream2_get_byte(>gb);
>
> mixed declarations and code, please move the uint8_t v up
>
>
> > +for (unsigned char p = 0; p <= rle_char; p++) {
> > +s->tmp[target_index++] = v;
> > +}
> > +} else {
> > +if (bytestream2_get_bytes_left(>gb) < rle_char) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Not enough data for
> rle scanline.\n");
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
>
> > +if (target_index + rle_char > s->uncompressed_size) {
> > +av_log(s->avctx, AV_LOG_ERROR, "Invalid rle
> char.\n");
> > +return AVERROR_INVALIDDATA;
> > +}
>
> isnt this off by 1?
> rle_char = 0
> target_index == uncompressed_size would pass but write at
> uncompressed_size whch would be after the array if iam not mistaken
>
>
> > +
> > +for (int p = 0; p <= rle_char; p++) {
> > +uint8_t v = bytestream2_get_byte(>gb);
> > +s->tmp[target_index++] = v;
> > +}
> > +}
> > +count += rle_char + 1;
> > +}
> > +}
> > +
> > +return 0;
> > +}
> > +
> > +static int decode_frame(AVCodecContext *avctx, void *data,
> > +int 

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

2016-07-24 Thread Martin Vignali
2016-07-24 16:36 GMT+02:00 Moritz Barsnick :

> On Sun, Jul 24, 2016 at 15:21:00 +0200, Martin Vignali wrote:
> > Subject: [PATCH] libavcodec : add decoder for .psd image file.
> [...]
> > +- Psd Decoder
> [...]
> > +@item PSD  @tab   @tab X
> > +@tab Photoshop
> [...]
> > +.long_name = NULL_IF_CONFIG_SMALL("Photoshop file"),
>
> ".psd", "psd", "Psd", "Photoshop file". I think some consistency would
> be nice. E.g. use "Photoshop PSD file" as long name, "PSD" in the
> descriptions (and not the name of the extension with dot).
>
> But that's just cosmetics...
>
> > +if ((s->channel_count < 1)||(s->channel_count > 56)) {
> [...]
> > +if ((s->height < 1)||(s->height > 3)) {
> [...]
> > +if ((s->width < 1)||(s->width > 3)) {
>
> You could leave whitespace around the operators, for readability.
>
> > +avpriv_report_missing_feature(avctx, "channel depth
> unsupported for rgb %d", s->channel_depth);
>
> For the sake of "grammar", I would say:
> avpriv_report_missing_feature(avctx, "channel depth %d
> unsupported for rgb", s->channel_depth);
> (Same with channel_count and with grayscale below.)
>
> > +/* reorganize uncompress data. each channel is store one after the
> other */
>   ^E   ^stored
>
> > +if ((b[4] == 0)&&(b[5] == 1)) {/* version 1 is PSD, version 2 is
> PSB */
> [...]
> > +if ((AV_RL32(b+6) == 0)&&(AV_RL16(b+10) == 0))/* reserved must be 0
> */
> [...]
> > +if ((color_mode <= 9)&&(color_mode != 5)&&(color_mode != 6))
> Whitespace, as mentioned above.
>
>
> Correct locally.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-24 Thread Moritz Barsnick
On Sun, Jul 24, 2016 at 15:21:00 +0200, Martin Vignali wrote:
> Subject: [PATCH] libavcodec : add decoder for .psd image file.
[...]
> +- Psd Decoder
[...]
> +@item PSD  @tab   @tab X
> +@tab Photoshop
[...]
> +.long_name = NULL_IF_CONFIG_SMALL("Photoshop file"),

".psd", "psd", "Psd", "Photoshop file". I think some consistency would
be nice. E.g. use "Photoshop PSD file" as long name, "PSD" in the
descriptions (and not the name of the extension with dot).

But that's just cosmetics...

> +if ((s->channel_count < 1)||(s->channel_count > 56)) {
[...]
> +if ((s->height < 1)||(s->height > 3)) {
[...]
> +if ((s->width < 1)||(s->width > 3)) {

You could leave whitespace around the operators, for readability.

> +avpriv_report_missing_feature(avctx, "channel depth 
> unsupported for rgb %d", s->channel_depth);

For the sake of "grammar", I would say:
avpriv_report_missing_feature(avctx, "channel depth %d 
unsupported for rgb", s->channel_depth);
(Same with channel_count and with grayscale below.)

> +/* reorganize uncompress data. each channel is store one after the other 
> */
  ^E   ^stored 

> +if ((b[4] == 0)&&(b[5] == 1)) {/* version 1 is PSD, version 2 is PSB */
[...]
> +if ((AV_RL32(b+6) == 0)&&(AV_RL16(b+10) == 0))/* reserved must be 0 */
[...]
> +if ((color_mode <= 9)&&(color_mode != 5)&&(color_mode != 6))
Whitespace, as mentioned above.

Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-24 Thread Martin Vignali
> breaks fate
>
> make: *** [fate-filter-metadata-ebur128] Error 1
> --- -   2016-07-23 18:50:11.633752058 +0200
> +++ tests/data/fate/probe-format-roundup14142016-07-23
> 18:50:10.913635588 +0200
> @@ -1 +1 @@
> -mpeg
> +psd_pipe
> Test probe-format-roundup1414 failed. Look at
> tests/data/fate/probe-format-roundup1414.err for details.
> make: *** [fate-probe-format-roundup1414] Error 1
> --- -   2016-07-23 18:50:11.657384876 +0200
> +++ tests/data/fate/probe-format-roundup997 2016-07-23
> 18:50:10.917635588 +0200
> @@ -1 +1 @@
> -mpeg
> +psd_pipe
> Test probe-format-roundup997 failed. Look at
> tests/data/fate/probe-format-roundup997.err for details.
> make: *** [fate-probe-format-roundup997] Error 1
> --- -   2016-07-23 18:50:11.667958765 +0200
> +++ tests/data/fate/probe-format-roundup13832016-07-23
> 18:50:10.917635588 +0200
> @@ -1 +1 @@
> -mp3
> +psd_pipe
> Test probe-format-roundup1383 failed. Look at
> tests/data/fate/probe-format-roundup1383.err for details.
> make: *** [fate-probe-format-roundup1383] Error 1
> make: Target `fate' not remade because of errors.
>
>
Hello,

Corrected patch in attach who fix the psd_probe function.

Comments welcome

Martin
From 2b368b8592cf0c278da0954e41705ddfc0f342b6 Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Sun, 24 Jul 2016 15:17:18 +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.
Support uncompress and rle compression in Image Data Section
---
 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 | 395 +++
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/img2.c   |   1 +
 libavformat/img2dec.c|  35 +
 11 files changed, 446 insertions(+)
 create mode 100644 libavcodec/psd.c

diff --git a/Changelog b/Changelog
index 99cdb80..97b11f1 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
 
 version :
 
+- Psd Decoder
 
 version 3.1:
 - DXVA2-accelerated HEVC Main10 decoding
diff --git a/doc/general.texi b/doc/general.texi
index 4db209f..06775f4 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -577,6 +577,8 @@ following image formats are supported:
 @item PNG  @tab X @tab X
 @item PPM  @tab X @tab X
 @tab Portable PixelMap image
+@item PSD  @tab   @tab X
+@tab Photoshop
 @item PTX  @tab   @tab X
 @tab V.Flash PTX format
 @item SGI  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fd0d1f0..913b4a8 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -456,6 +456,7 @@ OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdat
 OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_AW_ENCODER)   += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_KS_ENCODER)   += proresenc_kostya.o proresdata.o
+OBJS-$(CONFIG_PSD_DECODER) += psd.o
 OBJS-$(CONFIG_PTX_DECODER) += ptx.o
 OBJS-$(CONFIG_QCELP_DECODER)   += qcelpdec.o \
   celp_filters.o acelp_vectors.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 54efaad..458f603 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -278,6 +278,7 @@ void avcodec_register_all(void)
 REGISTER_ENCODER(PRORES_AW, prores_aw);
 REGISTER_ENCODER(PRORES_KS, prores_ks);
 REGISTER_DECODER(PRORES_LGPL,   prores_lgpl);
+REGISTER_DECODER(PSD,   psd);
 REGISTER_DECODER(PTX,   ptx);
 REGISTER_DECODER(QDRAW, qdraw);
 REGISTER_DECODER(QPEG,  qpeg);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 39713ed..75a9970 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -409,6 +409,7 @@ enum AVCodecID {
 AV_CODEC_ID_MAGICYUV,
 AV_CODEC_ID_SHEERVIDEO,
 AV_CODEC_ID_YLC,
+AV_CODEC_ID_PSD,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9d94b72..427553c 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1425,6 +1425,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
 {
+.id= AV_CODEC_ID_PSD,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "psd",
+.long_name = NULL_IF_CONFIG_SMALL("Photoshop file"),
+.props = AV_CODEC_PROP_INTRA_ONLY | 

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

2016-07-23 Thread Michael Niedermayer
On Sat, Jul 23, 2016 at 04:37:19PM +0200, Martin Vignali wrote:
> Hello,
> 
> New patch in attach.
> 
> - add support for RLE compression (who can be use by Photoshop and After
> Effects)
> 
> RLE samples can be found here :
> https://we.tl/LCQLqwuvZ4
> 
> - fix trouble with not even width.
> - modification of the probe function, but i'm not sure of mine for this
> - cosmetics fix.
> 
> 
> Comments welcome
> 
> 
> Martin
> Jokyo Images

>  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 |  395 
> +++
>  libavformat/Makefile |1 
>  libavformat/allformats.c |1 
>  libavformat/img2.c   |1 
>  libavformat/img2dec.c|   25 ++
>  11 files changed, 436 insertions(+)
> f973f04b071009eefd40211d7ccc759a0236d358  
> 0001-libavcodec-add-decoder-for-.psd-image-file.patch
> From 18de7ec132fb1c599a40baa7c1a04ca08134ed7e Mon Sep 17 00:00:00 2001
> From: Martin Vignali 
> Date: Sat, 23 Jul 2016 16:20:07 +0200
> Subject: [PATCH] libavcodec : add decoder for .psd image file.

breaks fate

make: *** [fate-filter-metadata-ebur128] Error 1
--- -   2016-07-23 18:50:11.633752058 +0200
+++ tests/data/fate/probe-format-roundup14142016-07-23 18:50:10.913635588 
+0200
@@ -1 +1 @@
-mpeg
+psd_pipe
Test probe-format-roundup1414 failed. Look at 
tests/data/fate/probe-format-roundup1414.err for details.
make: *** [fate-probe-format-roundup1414] Error 1
--- -   2016-07-23 18:50:11.657384876 +0200
+++ tests/data/fate/probe-format-roundup997 2016-07-23 18:50:10.917635588 
+0200
@@ -1 +1 @@
-mpeg
+psd_pipe
Test probe-format-roundup997 failed. Look at 
tests/data/fate/probe-format-roundup997.err for details.
make: *** [fate-probe-format-roundup997] Error 1
--- -   2016-07-23 18:50:11.667958765 +0200
+++ tests/data/fate/probe-format-roundup13832016-07-23 18:50:10.917635588 
+0200
@@ -1 +1 @@
-mp3
+psd_pipe
Test probe-format-roundup1383 failed. Look at 
tests/data/fate/probe-format-roundup1383.err for details.
make: *** [fate-probe-format-roundup1383] Error 1
make: Target `fate' not remade because of errors.

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-23 Thread Martin Vignali
Hello,

New patch in attach.

- add support for RLE compression (who can be use by Photoshop and After
Effects)

RLE samples can be found here :
https://we.tl/LCQLqwuvZ4

- fix trouble with not even width.
- modification of the probe function, but i'm not sure of mine for this
- cosmetics fix.


Comments welcome


Martin
Jokyo Images
From 18de7ec132fb1c599a40baa7c1a04ca08134ed7e Mon Sep 17 00:00:00 2001
From: Martin Vignali 
Date: Sat, 23 Jul 2016 16:20:07 +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.
Support uncompress and rle compression in Image Data Section
---
 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 | 395 +++
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/img2.c   |   1 +
 libavformat/img2dec.c|  25 +++
 11 files changed, 436 insertions(+)
 create mode 100644 libavcodec/psd.c

diff --git a/Changelog b/Changelog
index 99cdb80..97b11f1 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
 
 version :
 
+- Psd Decoder
 
 version 3.1:
 - DXVA2-accelerated HEVC Main10 decoding
diff --git a/doc/general.texi b/doc/general.texi
index 4db209f..06775f4 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -577,6 +577,8 @@ following image formats are supported:
 @item PNG  @tab X @tab X
 @item PPM  @tab X @tab X
 @tab Portable PixelMap image
+@item PSD  @tab   @tab X
+@tab Photoshop
 @item PTX  @tab   @tab X
 @tab V.Flash PTX format
 @item SGI  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fd0d1f0..913b4a8 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -456,6 +456,7 @@ OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdat
 OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_AW_ENCODER)   += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_KS_ENCODER)   += proresenc_kostya.o proresdata.o
+OBJS-$(CONFIG_PSD_DECODER) += psd.o
 OBJS-$(CONFIG_PTX_DECODER) += ptx.o
 OBJS-$(CONFIG_QCELP_DECODER)   += qcelpdec.o \
   celp_filters.o acelp_vectors.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 54efaad..458f603 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -278,6 +278,7 @@ void avcodec_register_all(void)
 REGISTER_ENCODER(PRORES_AW, prores_aw);
 REGISTER_ENCODER(PRORES_KS, prores_ks);
 REGISTER_DECODER(PRORES_LGPL,   prores_lgpl);
+REGISTER_DECODER(PSD,   psd);
 REGISTER_DECODER(PTX,   ptx);
 REGISTER_DECODER(QDRAW, qdraw);
 REGISTER_DECODER(QPEG,  qpeg);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 39713ed..75a9970 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -409,6 +409,7 @@ enum AVCodecID {
 AV_CODEC_ID_MAGICYUV,
 AV_CODEC_ID_SHEERVIDEO,
 AV_CODEC_ID_YLC,
+AV_CODEC_ID_PSD,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9d94b72..427553c 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1425,6 +1425,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
 {
+.id= AV_CODEC_ID_PSD,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "psd",
+.long_name = NULL_IF_CONFIG_SMALL("Photoshop file"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
 .id= AV_CODEC_ID_PTX,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "ptx",
diff --git a/libavcodec/psd.c b/libavcodec/psd.c
new file mode 100644
index 000..5e5fc77
--- /dev/null
+++ b/libavcodec/psd.c
@@ -0,0 +1,395 @@
+/*
+ * Photoshop (.psd) image decoder
+ * Copyright (c) 2016 Jokyo Images
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * 

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

2016-07-09 Thread Thomas Volkert

On 09.07.2016 19:37, Martin Vignali wrote:
You're right, this is a very complex file format, with lot of features. 

indeed..


But i disagree, with the idea, that this decoder have no interest. The
"useful question", highly depend of the point of view.
I write this decoder, because i sometime need to convert PSD image sequence
to video, or need to get a quick preview of a PSD file, without open
Photoshop.

This decoder for now, decode file created using "Maximize Compatibity"
option of Adobe Photoshop software (this option is recommand by Adobe for
compatibilty with other software).

I plan to add RLE decoding, in a future patch (After effects for example
use it for PSD sequence).

So i think a decoder, without all the feature of the file format, can be
useful.


Yes, don't stop your work. It might be only a starting point for PSD 
support - but, apparently, it is a start and it's not the worst one.


Best regards,
Thomas.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-09 Thread Martin Vignali
Thanks for your comments

@James Almer : MKTAG, is maybe more comprehensive, than the 32i value.
Modify locally

@Carl Eugen Hoyos :


> > +{ AV_CODEC_ID_EXR,   MKTAG('p', 's', 'd', ' ') }, /* Psd */
>
> What produces such files?
>

I think i do a mistake here. Remove locally


> psd_probe()
>
> Please also test for version (and color mode) and increase
> the probe score / if easily possible, don't detect things
> that are immediately rejected by the decoder.
>
> And don't remove the empty line from Changelog...
>
>
i will modify the probe function.

@Paul B Mahol :
Correct locally


@Rostislav Pehlivanov :


> This has the potential to turn into the shittiest thing in libavcodec. PSD
> is a notoriously horrible format and I believe code needed to read and
> render it belongs outside of libavcodec. Not to mention that close to 90%
> of the features it has are unsupported by the framework, be it vectors, the
> colorspaces, layers, etc. The decoder's also pretty raw and only supports
> uncompressed images, with every other mode currently unsupported, giving
> the deceptive idea it's a simple decoder for a simple format. A decoder
> which can open a very small part of all psd files floating around isn't a
> very useful one.
> There is simply no simple way to expose all the quirks of the format in a
> nice way to libavcodec, given that this decoder can be potentially as
> complex and bad as photoshop. Please make this a separate library or a
> program, you don't even need any framework features since it's a simple
> bytestream.
>
> In case you need the testament of someone who's done the work already take
> a read at this:
> https://github.com/gco/xee/blob/master/XeePhotoshopLoader.m#L108-L136
> ___
>
>
You're right, this is a very complex file format, with lot of features.
But i disagree, with the idea, that this decoder have no interest. The
"useful question", highly depend of the point of view.
I write this decoder, because i sometime need to convert PSD image sequence
to video, or need to get a quick preview of a PSD file, without open
Photoshop.

This decoder for now, decode file created using "Maximize Compatibity"
option of Adobe Photoshop software (this option is recommand by Adobe for
compatibilty with other software).

I plan to add RLE decoding, in a future patch (After effects for example
use it for PSD sequence).

So i think a decoder, without all the feature of the file format, can be
useful.


Martin
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-09 Thread Paul B Mahol
On 7/9/16, Rostislav Pehlivanov  wrote:
> On 9 July 2016 at 16:29, 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
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>>
> This has the potential to turn into the shittiest thing in libavcodec. PSD
> is a notoriously horrible format and I believe code needed to read and
> render it belongs outside of libavcodec. Not to mention that close to 90%
> of the features it has are unsupported by the framework, be it vectors, the
> colorspaces, layers, etc. The decoder's also pretty raw and only supports
> uncompressed images, with every other mode currently unsupported, giving
> the deceptive idea it's a simple decoder for a simple format. A decoder
> which can open a very small part of all psd files floating around isn't a
> very useful one.

Why? Neither exr decoder was good, at beginning it supported only raw.

> There is simply no simple way to expose all the quirks of the format in a
> nice way to libavcodec, given that this decoder can be potentially as
> complex and bad as photoshop. Please make this a separate library or a
> program, you don't even need any framework features since it's a simple
> bytestream.
>
> In case you need the testament of someone who's done the work already take
> a read at this:
> https://github.com/gco/xee/blob/master/XeePhotoshopLoader.m#L108-L136
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-09 Thread Rostislav Pehlivanov
On 9 July 2016 at 16:29, 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
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
This has the potential to turn into the shittiest thing in libavcodec. PSD
is a notoriously horrible format and I believe code needed to read and
render it belongs outside of libavcodec. Not to mention that close to 90%
of the features it has are unsupported by the framework, be it vectors, the
colorspaces, layers, etc. The decoder's also pretty raw and only supports
uncompressed images, with every other mode currently unsupported, giving
the deceptive idea it's a simple decoder for a simple format. A decoder
which can open a very small part of all psd files floating around isn't a
very useful one.
There is simply no simple way to expose all the quirks of the format in a
nice way to libavcodec, given that this decoder can be potentially as
complex and bad as photoshop. Please make this a separate library or a
program, you don't even need any framework features since it's a simple
bytestream.

In case you need the testament of someone who's done the work already take
a read at this:
https://github.com/gco/xee/blob/master/XeePhotoshopLoader.m#L108-L136
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-09 Thread Paul B Mahol
On 7/9/16, 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
>

Switch cases should be aligned with switch, like in rest of ffmpeg codebase.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-09 Thread James Almer
On 7/9/2016 1:09 PM, James Almer wrote:
> On 7/9/2016 12:29 PM, Martin Vignali wrote:
>> +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'))
> 

MKTAG('8','B','P','S'), sorry.

Also, this is mostly cosmetic, so if you prefer consistency write the
value in hex like in the other probe functions instead of using this
macro.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-09 Thread Carl Eugen Hoyos
Martin Vignali  gmail.com> writes:

> psd_probe()

Please also test for version (and color mode) and increase 
the probe score / if easily possible, don't detect things 
that are immediately rejected by the decoder.

And don't remove the empty line from Changelog...

> +{ AV_CODEC_ID_EXR,   MKTAG('p', 's', 'd', ' ') }, /* Psd */

What produces such files?

Thank you!

Please wait for a real review, Carl Eugen

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-09 Thread James Almer
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 
> 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.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2016-07-09 Thread Martin Vignali
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
From a4b9c1373cc62d1bb38997704a924ecfe78ee4b4 Mon Sep 17 00:00:00 2001
From: Martin Vignali 
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/Changelog b/Changelog
index 99cdb80..c7b9908 100644
--- a/Changelog
+++ b/Changelog
@@ -2,7 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
 version :
-
+- Psd Decoder
 
 version 3.1:
 - DXVA2-accelerated HEVC Main10 decoding
diff --git a/doc/general.texi b/doc/general.texi
index 4db209f..06775f4 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -577,6 +577,8 @@ following image formats are supported:
 @item PNG  @tab X @tab X
 @item PPM  @tab X @tab X
 @tab Portable PixelMap image
+@item PSD  @tab   @tab X
+@tab Photoshop
 @item PTX  @tab   @tab X
 @tab V.Flash PTX format
 @item SGI  @tab X @tab X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fd0d1f0..913b4a8 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -456,6 +456,7 @@ OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o proresdat
 OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_AW_ENCODER)   += proresenc_anatoliy.o
 OBJS-$(CONFIG_PRORES_KS_ENCODER)   += proresenc_kostya.o proresdata.o
+OBJS-$(CONFIG_PSD_DECODER) += psd.o
 OBJS-$(CONFIG_PTX_DECODER) += ptx.o
 OBJS-$(CONFIG_QCELP_DECODER)   += qcelpdec.o \
   celp_filters.o acelp_vectors.o \
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 54efaad..458f603 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -278,6 +278,7 @@ void avcodec_register_all(void)
 REGISTER_ENCODER(PRORES_AW, prores_aw);
 REGISTER_ENCODER(PRORES_KS, prores_ks);
 REGISTER_DECODER(PRORES_LGPL,   prores_lgpl);
+REGISTER_DECODER(PSD,   psd);
 REGISTER_DECODER(PTX,   ptx);
 REGISTER_DECODER(QDRAW, qdraw);
 REGISTER_DECODER(QPEG,  qpeg);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 39713ed..75a9970 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -409,6 +409,7 @@ enum AVCodecID {
 AV_CODEC_ID_MAGICYUV,
 AV_CODEC_ID_SHEERVIDEO,
 AV_CODEC_ID_YLC,
+AV_CODEC_ID_PSD,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 9d94b72..427553c 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1425,6 +1425,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
 {
+.id= AV_CODEC_ID_PSD,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "psd",
+.long_name = NULL_IF_CONFIG_SMALL("Photoshop file"),
+.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
+},
+{
 .id= AV_CODEC_ID_PTX,
 .type  = AVMEDIA_TYPE_VIDEO,
 .name  = "ptx",
diff --git a/libavcodec/psd.c b/libavcodec/psd.c
new file mode 100644
index 000..da9036f
--- /dev/null
+++ b/libavcodec/psd.c
@@ -0,0 +1,310 @@
+/*
+ * Photoshop (.psd) image decoder
+ * Copyright (c) 2016 Jokyo Images
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the