[FFmpeg-devel] [PATCH 2/4] vf_pad: reinit on input parameter changes.

Michael Niedermayer michaelni at gmx.at
Tue Jul 17 16:30:00 CEST 2012


On Tue, Jul 17, 2012 at 09:18:59AM +0200, Stefano Sabatini wrote:
> On date Monday 2012-07-16 20:17:33 +0200, Michael Niedermayer encoded:
> > Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> > ---
> >  libavfilter/vf_pad.c |   22 ++++++++++++++++++++++
> >  1 file changed, 22 insertions(+)
> > 
> > diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
> > index aeff424..9bca4a2 100644
> > --- a/libavfilter/vf_pad.c
> > +++ b/libavfilter/vf_pad.c
> > @@ -78,6 +78,7 @@ typedef struct {
> >      int w, h;               ///< output dimensions, a value of 0 will result in the input size
> >      int x, y;               ///< offsets of the input area with respect to the padded area
> >      int in_w, in_h;         ///< width and height for the padded input video, which has to be aligned to the chroma values in order to avoid chroma issues
> > +    int inlink_w, inlink_h;
> >  
> >      char w_expr[256];       ///< width  expression string
> >      char h_expr[256];       ///< height expression string
> > @@ -183,6 +184,8 @@ static int config_input(AVFilterLink *inlink)
> >      pad->y    = ff_draw_round_to_sub(&pad->draw, 1, -1, pad->y);
> >      pad->in_w = ff_draw_round_to_sub(&pad->draw, 0, -1, inlink->w);
> >      pad->in_h = ff_draw_round_to_sub(&pad->draw, 1, -1, inlink->h);
> > +    pad->inlink_w = inlink->w;
> > +    pad->inlink_h = inlink->h;
> >  
> >      av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d -> w:%d h:%d x:%d y:%d color:0x%02X%02X%02X%02X\n",
> >             inlink->w, inlink->h, pad->w, pad->h, pad->x, pad->y,
> > @@ -262,9 +265,28 @@ static int does_clip(PadContext *pad, AVFilterBufferRef *outpicref, int plane, i
> >  static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
> >  {
> >      PadContext *pad = inlink->dst->priv;
> > +    AVFilterLink *outlink = inlink->dst->outputs[0];
> >      AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
> >      int plane;
> >  
> > +    if(   inpicref->video->w != pad->inlink_w
> > +       || inpicref->video->h != pad->inlink_h
> > +       || inpicref->format   != outlink->format
> > +       || av_cmp_q(inpicref->video->sample_aspect_ratio, outlink->sample_aspect_ratio)
> > +    ) {
> > +        int ret;
> > +
> > +        inlink->dst->inputs[0]->format = inpicref->format;
> > +        inlink->dst->inputs[0]->w      = inpicref->video->w;
> > +        inlink->dst->inputs[0]->h      = inpicref->video->h;
> > +        inlink->dst->inputs[0]->sample_aspect_ratio = inpicref->video->sample_aspect_ratio;
> 
> inlink->dst->inputs[0] == inlink?

yes, the code is copied from vf_scale, i will simplify both after
this is pushed


> 
> > +
> 
> > +        if ((ret = config_input(inlink)) < 0)
> > +            av_assert0(0); //what to do here ?
> > +        if ((ret = config_output(outlink)) < 0)
> 
> > +            av_assert0(0); //what to do here ?
> 
> We should fail returning an error code (Anton is already working on
> this on the Libav side).

yes


> 
> Also I'm not sure this can work. Link properties are assumed to be
> invariant, if you change them you need to reconfigure the whole
> filtergraph as the attached filters may need to do some
> reinintialization, the problem should be tackled at the framework
> level rather than in each single filter.

thats not possible in some cases. And also not how vf_scale works

reconfiguring the whole filtergraph destroys the state of all filters
in the use case for this patchset the output of vf_scale changes in
size and vf_pad again makes it constant so filters downstream of pad
dont need to be reinited.


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

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120717/15ae863c/attachment.asc>


More information about the ffmpeg-devel mailing list