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

Stefano Sabatini stefasab at gmail.com
Tue Jul 17 09:18:59 CEST 2012


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?

> +

> +        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).

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.

[...]
-- 
FFmpeg = Fanciful and Friendly Mastering Philosofic Empowered God


More information about the ffmpeg-devel mailing list