[FFmpeg-devel] [PATCH] vp9: assign PTS to visible instead of invisible frames

Michael Niedermayer michaelni at gmx.at
Thu Feb 5 21:15:51 CET 2015


On Thu, Feb 05, 2015 at 01:22:09PM -0500, Ronald S. Bultje wrote:
> Hi,
> 
> On Thu, Feb 5, 2015 at 10:43 AM, wm4 <nfxjfg at googlemail.com> wrote:
> 
> > All the webm/vp9 files I have seen so far can have packets that contain
> > 1 invisible and 1 visible frame. The vp9 parser separates them. Since
> > the invisible frame is always (?) the first sub-packet, the new packet
> > is assigned the PTS of the original packet, while the packet containing
> > the visible frame has no PTS.
> >
> > This patch essentially reassigns the PTS from the invisible to the
> > visible frame.
> > ---
> > Not sure if DTS needs adjustment.
> > ---
> >  libavcodec/vp9_parser.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/libavcodec/vp9_parser.c b/libavcodec/vp9_parser.c
> > index b188785..220290f 100644
> > --- a/libavcodec/vp9_parser.c
> > +++ b/libavcodec/vp9_parser.c
> > @@ -24,10 +24,13 @@
> >  typedef struct VP9ParseContext {
> >      int n_frames; // 1-8
> >      int size[8];
> > +    int64_t pts;
> >  } VP9ParseContext;
> >
> >  static void parse_frame(AVCodecParserContext *ctx, const uint8_t *buf,
> > int size)
> >  {
> > +    VP9ParseContext *s = ctx->priv_data;
> > +
> >      if (buf[0] & 0x4) {
> >          ctx->pict_type = AV_PICTURE_TYPE_P;
> >          ctx->key_frame = 0;
> > @@ -35,6 +38,15 @@ static void parse_frame(AVCodecParserContext *ctx,
> > const uint8_t *buf, int size)
> >          ctx->pict_type = AV_PICTURE_TYPE_I;
> >          ctx->key_frame = 1;
> >      }
> > +
> > +    if (buf[0] & 0x2) {
> > +        if (ctx->pts == AV_NOPTS_VALUE)
> > +            ctx->pts = s->pts;
> > +        s->pts = AV_NOPTS_VALUE;
> > +    } else {
> > +        s->pts = ctx->pts;
> > +        ctx->pts = AV_NOPTS_VALUE;
> > +    }
> >  }
> >
> >  static int parse(AVCodecParserContext *ctx,
> > --
> > 2.1.4
> 
> 
> lgtm.

applied

thanks

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

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150205/6f961042/attachment.asc>


More information about the ffmpeg-devel mailing list