[FFmpeg-devel] [PATCH] Add a time_base field to AVFilterPad.

Michael Niedermayer michaelni
Thu Oct 7 03:08:40 CEST 2010


On Wed, Oct 06, 2010 at 11:32:42PM +0200, Stefano Sabatini wrote:
> On date Wednesday 2010-10-06 22:48:16 +0200, Michael Niedermayer encoded:
> > On Wed, Oct 06, 2010 at 10:07:54PM +0200, Stefano Sabatini wrote:
> > > On date Wednesday 2010-10-06 21:43:46 +0200, Michael Niedermayer encoded:
> > > > On Wed, Oct 06, 2010 at 08:20:18PM +0200, Stefano Sabatini wrote:
> > > [...]
> > > > >  avfilter.c |   21 +++++++++++++++++++++
> > > > >  avfilter.h |   15 ++++++++++++++-
> > > > >  defaults.c |    1 +
> > > > >  3 files changed, 36 insertions(+), 1 deletion(-)
> > > > > dffa3d20b8e8d74cbbf2d67ab170242471e1dbfa  0001-Add-a-time_base-field-to-AVFilterPad.patch
> > > > > From 01f1ac855d628bfb1ddea394dea3bad5fd74350b Mon Sep 17 00:00:00 2001
> > > > > From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> > > > > Date: Mon, 27 Sep 2010 20:24:44 +0200
> > > > > Subject: [PATCH 1/9] Add a time_base field to AVFilterPad.
> > > > > 
> > > > > This is required for allowing a filter to use a time base different
> > > > > from AV_TIME_BASE_Q, as it was previously assumed.
> > > > > ---
> > > > >  libavfilter/avfilter.c |   21 +++++++++++++++++++++
> > > > >  libavfilter/avfilter.h |   15 ++++++++++++++-
> > > > >  libavfilter/defaults.c |    1 +
> > > > >  3 files changed, 36 insertions(+), 1 deletions(-)
> > > > > 
> > > > > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> > > > > index ea6f9fe..bbe8d78 100644
> > > > > --- a/libavfilter/avfilter.c
> > > > > +++ b/libavfilter/avfilter.c
> > > > > @@ -23,6 +23,7 @@
> > > > >  
> > > > >  #include "libavcodec/audioconvert.c"
> > > > >  #include "libavutil/pixdesc.h"
> > > > > +#include "libavutil/rational.h"
> > > > >  #include "libavcore/imgutils.h"
> > > > >  #include "avfilter.h"
> > > > >  #include "internal.h"
> > > > > @@ -179,10 +180,20 @@ int avfilter_config_links(AVFilterContext *filter)
> > > > >              if (config_link(link))
> > > > >                  return -1;
> > > > >  
> > > > > +            if (link->srcpad->time_base.num == 0 && link->srcpad->time_base.den == 0) {
> > > > > +                if (link->src->input_count)
> > > > > +                    link->srcpad->time_base = link->src->input_pads[0].time_base;
> > > > > +                else
> > > > 
> > > > {}
> > > > 
> > > > 
> > > > [...]
> > > > > @@ -336,6 +348,15 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
> > > > >      else
> > > > >          link->cur_buf = picref;
> > > > >  
> > > > > +    if (av_cmp_q(dst->time_base, src->time_base)) {
> > > > > +        int64_t av_unused pts1 = picref->pts;
> > > > > +        link->cur_buf->pts = av_rescale_q(picref->pts, src->time_base, dst->time_base);
> > > > 
> > > > missing AV_NOPTS check
> > > > 
> > > > 
> > > > [...]
> > > > > @@ -424,6 +431,12 @@ struct AVFilterPad {
> > > > >       * and another value on error.
> > > > >       */
> > > > >      int (*config_props)(AVFilterLink *link);
> > > > > +
> > > > > +    /**
> > > > > +     * Define the time base used by the PTS of the frames/samples
> > > > > +     * which will pass through this link.
> > > > > +     */
> > > > > +    AVRational time_base;
> > > > >  };
> > > > 
> > > > Belongs to AVFilterLink not Pad IMHO
> > > 
> > > Would be acceptable to create a src_time_base and dst_time_base in the
> > > link?
> > > 
> > > BTW we need to set the timebase in the two ends of a link (either in
> > > the link itself or in the input and output pads) if we want to keep
> > > the timestamp conversion code in the framework rather than in the
> > > filters code.
> > 
> > when does this design simplify filters?
> > do you have an example?
> > it seems simpler to have just one tb per link
> 
> A filter in general may to set the output timebase, and another filter
> the input timebase.
> 
> Think for example of a source, which generates video frames with given
> framerate, or a movie sink which needs to use the same timebase as set
> in the muxer, so I believe this in general is a useful feature that we
> want to keep.

the movie sink can contain that 1 line of code to rescale
any other filters that would need that?

if not then this really seems the more logic approuch

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

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101007/f238e731/attachment.pgp>



More information about the ffmpeg-devel mailing list