[FFmpeg-devel] [PATCH 3/7] Set timebase in the ffplay input and output filters.

Stefano Sabatini stefano.sabatini-lala
Tue Oct 12 12:00:59 CEST 2010


On date Monday 2010-10-11 15:47:01 +0200, Michael Niedermayer encoded:
> On Mon, Oct 11, 2010 at 02:04:02PM +0200, Stefano Sabatini wrote:
> > ---
> >  ffplay.c |   28 ++++++++++++++++++++++++++--
> >  1 files changed, 26 insertions(+), 2 deletions(-)
> > 
> > diff --git a/ffplay.c b/ffplay.c
> > index 9927006..5d6e2d1 100644
> > --- a/ffplay.c
> > +++ b/ffplay.c
> > @@ -1755,6 +1755,7 @@ static int input_config_props(AVFilterLink *link)
> >  
> >      link->w = c->width;
> >      link->h = c->height;
> > +    link->time_base = priv->is->video_st->time_base;
> >  
> >      return 0;
> >  }
> > @@ -1778,8 +1779,29 @@ static AVFilter input_filter =
> >                                    { .name = NULL }},
> >  };
> >  
> > -static void output_end_frame(AVFilterLink *link)
> > +static int output_init(AVFilterContext *ctx, const char *args, void *opaque)
> >  {
> > +    FilterPriv *priv = ctx->priv;
> > +    if (!opaque) return AVERROR(EINVAL);
> > +
> > +    priv->is = opaque;
> > +    return 0;
> > +}
> > +
> > +static void output_end_frame(AVFilterLink *inlink)
> > +{
> > +    AVFilterContext *ctx = inlink->dst;
> > +    FilterPriv *priv = ctx->priv;
> > +    AVRational dst_time_base = priv->is->video_st->time_base;
> > +
> > +    if (av_cmp_q(inlink->time_base, dst_time_base)) {
> > +        int64_t pts1 = inlink->cur_buf->pts;
> > +        inlink->cur_buf->pts = av_rescale_q(pts1, inlink->time_base, dst_time_base);
> > +        av_log(ctx, AV_LOG_DEBUG,
> > +               "tb:%d/%d pts:%"PRId64" -> tb:%d/%d pts:%"PRId64"\n",
> > +               inlink->time_base.num, inlink->time_base.den, pts1,
> > +               dst_time_base.num, dst_time_base.den, inlink->cur_buf->pts);
> > +    }
> >  }
> 
> isnt it simpler to let get_filtered_video_frame()
> return the tb and do the rescaling outside?

Sligthly simpler, acceptable by me, if we see that the other way turns
more convenient (e.g. if we need for other reasons an output init and
end_frame() function) we can change again later.

Regards.
-- 
FFmpeg = Freak & Fundamental Minimalistic Portable Enhancing God



More information about the ffmpeg-devel mailing list