[FFmpeg-devel] [PATCH 1/3] lavc/pngdec: honor skip_frame option

Matthieu Bouron matthieu.bouron at gmail.com
Thu Oct 29 12:13:20 CET 2015


On Wed, Oct 28, 2015 at 5:35 PM, Michael Niedermayer <michael at niedermayer.cc
> wrote:

> On Wed, Oct 28, 2015 at 03:09:02PM +0100, Matthieu Bouron wrote:
> > On Wed, Oct 28, 2015 at 12:59:54PM +0100, Michael Niedermayer wrote:
> > > On Mon, Oct 19, 2015 at 10:28:18AM +0200, Matthieu Bouron wrote:
> > > > On Sat, Oct 17, 2015 at 10:34:22PM +0200, Matthieu Bouron wrote:
> > > > > From: Matthieu Bouron <matthieu.bouron at stupeflix.com>
> > > > >
> > > > > ---
> > > > >  libavcodec/pngdec.c | 34 ++++++++++++++++++++++++++++++++++
> > > > >  1 file changed, 34 insertions(+)
> > > > >
> > > > > diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> > > > > index 4cfdc58..5b2befe 100644
> > > > > --- a/libavcodec/pngdec.c
> > > > > +++ b/libavcodec/pngdec.c
> > > > > @@ -1087,6 +1087,13 @@ static int
> decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
> > > > >      for (;;) {
> > > > >          length = bytestream2_get_bytes_left(&s->gb);
> > > > >          if (length <= 0) {
> > > > > +
> > > > > +            if (avctx->codec_id == AV_CODEC_ID_PNG &&
> > > > > +                avctx->skip_frame == AVDISCARD_ALL) {
> > > > > +                av_frame_set_metadata(p, metadata);
> > > > > +                return 0;
> > > > > +            }
> > > > > +
> > > > >              if (CONFIG_APNG_DECODER && avctx->codec_id ==
> AV_CODEC_ID_APNG && length == 0) {
> > > > >                  if (!(s->state & PNG_IDAT))
> > > > >                      return 0;
> > > > > @@ -1114,6 +1121,22 @@ static int
> decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
> > > > >                  ((tag >> 8) & 0xff),
> > > > >                  ((tag >> 16) & 0xff),
> > > > >                  ((tag >> 24) & 0xff), length);
> > > > > +
> > > > > +        if (avctx->codec_id == AV_CODEC_ID_PNG &&
> > > > > +            avctx->skip_frame == AVDISCARD_ALL) {
> > > > > +            int i, found = 0;
> > > > > +            static const int tags[] = { MKTAG('I', 'H', 'D',
> 'R'), MKTAG('t', 'E', 'X', 't'), MKTAG('I', 'D', 'A', 'T') };
> > > > > +            for (i = 0; i < FF_ARRAY_ELEMS(tags); i++) {
> > > > > +                if (tag == tags[i]) {
> > > > > +                    found = 1;
> > > > > +                    break;
> > > > > +                }
> > > > > +            }
> > > > > +            if (!found) {
> > > > > +                goto skip_tag;
> > > > > +            }
> > > > > +        }
> > > > > +
> > > > >          switch (tag) {
> > > > >          case MKTAG('I', 'H', 'D', 'R'):
> > > > >              if ((ret = decode_ihdr_chunk(avctx, s, length)) < 0)
> > > > > @@ -1181,6 +1204,11 @@ skip_tag:
> > > > >          }
> > > > >      }
> > > > >  exit_loop:
> > > > > +    if (avctx->codec_id == AV_CODEC_ID_PNG &&
> > > > > +        avctx->skip_frame == AVDISCARD_ALL) {
> > > > > +        av_frame_set_metadata(p, metadata);
> > > > > +        return 0;
> > > > > +    }
> > > > >
> > > > >      if (s->bits_per_pixel <= 4)
> > > > >          handle_small_bpp(s, p);
> > > > > @@ -1278,6 +1306,12 @@ static int decode_frame_png(AVCodecContext
> *avctx,
> > > > >      if ((ret = decode_frame_common(avctx, s, p, avpkt)) < 0)
> > > > >          goto the_end;
> > > > >
> > > > > +    if (avctx->skip_frame == AVDISCARD_ALL) {
> > > > > +        *got_frame = 0;
> > > > > +        ret = bytestream2_tell(&s->gb);
> > > > > +        goto the_end;
> > > > > +    }
> > > > > +
> > > > >      if ((ret = av_frame_ref(data, s->picture.f)) < 0)
> > > > >          return ret;
> > > > >
> > > > > --
> > > > > 2.6.1
> > > > >
> > > >
> > > > Patch updated, the SAR is not discarded anymore.
> > > >
> > > > Matthieu
> > >
> > > >  pngdec.c |   39 +++++++++++++++++++++++++++++++++++++++
> > > >  1 file changed, 39 insertions(+)
> > > > eddfb042e2653025b37f9deacc0357ac3e5e5148
> 0001-lavc-pngdec-honor-skip_frame-option.patch
> > > > From ca6362457eb27e623eadcadb0e33a84ea461180f Mon Sep 17 00:00:00
> 2001
> > > > From: Matthieu Bouron <matthieu.bouron at stupeflix.com>
> > > > Date: Fri, 9 Oct 2015 15:14:11 +0200
> > > > Subject: [PATCH 1/3] lavc/pngdec: honor skip_frame option
> > > >
> > > > ---
> > > >  libavcodec/pngdec.c | 39 +++++++++++++++++++++++++++++++++++++++
> > > >  1 file changed, 39 insertions(+)
> > > >
> > > > diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> > > > index 4cfdc58..cb99dbe 100644
> > > > --- a/libavcodec/pngdec.c
> > > > +++ b/libavcodec/pngdec.c
> > > > @@ -1087,6 +1087,13 @@ static int decode_frame_common(AVCodecContext
> *avctx, PNGDecContext *s,
> > > >      for (;;) {
> > > >          length = bytestream2_get_bytes_left(&s->gb);
> > > >          if (length <= 0) {
> > > > +
> > > > +            if (avctx->codec_id == AV_CODEC_ID_PNG &&
> > > > +                avctx->skip_frame == AVDISCARD_ALL) {
> > > > +                av_frame_set_metadata(p, metadata);
> > > > +                return 0;
> > > > +            }
> > > > +
> > > >              if (CONFIG_APNG_DECODER && avctx->codec_id ==
> AV_CODEC_ID_APNG && length == 0) {
> > > >                  if (!(s->state & PNG_IDAT))
> > > >                      return 0;
> > > > @@ -1114,6 +1121,27 @@ static int decode_frame_common(AVCodecContext
> *avctx, PNGDecContext *s,
> > > >                  ((tag >> 8) & 0xff),
> > > >                  ((tag >> 16) & 0xff),
> > > >                  ((tag >> 24) & 0xff), length);
> > > > +
> > > > +        if (avctx->codec_id == AV_CODEC_ID_PNG &&
> > > > +            avctx->skip_frame == AVDISCARD_ALL) {
> > >
> > > > +            int i, found = 0;
> > > > +            static const int tags[] = {
> > > > +                MKTAG('I', 'H', 'D', 'R'),
> > > > +                MKTAG('p', 'H', 'Y', 's'),
> > > > +                MKTAG('t', 'E', 'X', 't'),
> > > > +                MKTAG('I', 'D', 'A', 'T'),
> > > > +            };
> > > > +            for (i = 0; i < FF_ARRAY_ELEMS(tags); i++) {
> > > > +                if (tag == tags[i]) {
> > > > +                    found = 1;
> > > > +                    break;
> > > > +                }
> > > > +            }
> > > > +            if (!found) {
> > > > +                goto skip_tag;
> > > > +            }
> > >
> > > as sugested for jpeg, i think this too would be simpler as a switch
> > > the rest of the patch LGTM
> >
> > Patch updated using switch/case to implement the skip logic.
> >
> > [...]
>
> >  pngdec.c |   32 ++++++++++++++++++++++++++++++++
> >  1 file changed, 32 insertions(+)
> > 810aa33a2a03bdcb338ef067195b52cf40f3c4bc
> 0001-lavc-pngdec-honor-skip_frame-option.patch
> > From acf74e07fcf61f13698c5f28dcb52d3e82337815 Mon Sep 17 00:00:00 2001
> > From: Matthieu Bouron <matthieu.bouron at stupeflix.com>
> > Date: Fri, 9 Oct 2015 15:14:11 +0200
> > Subject: [PATCH 1/3] lavc/pngdec: honor skip_frame option
>
> LGTM
>

Pushed.
Thanks

[...]


More information about the ffmpeg-devel mailing list