[FFmpeg-devel] [PATCH v1 1/2] avfilter/vf_scale: split the scale_frame function from filter_frame for activate function support

Michael Niedermayer michael at niedermayer.cc
Fri Sep 6 21:08:48 EEST 2019


On Sat, Jul 27, 2019 at 08:18:16PM +0800, lance.lmwang at gmail.com wrote:
> From: Limin Wang <lance.lmwang at gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
> ---
>  libavfilter/vf_scale.c | 29 +++++++++++++++++++++++++----
>  1 file changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> index 7aebf56..efb480d 100644
> --- a/libavfilter/vf_scale.c
> +++ b/libavfilter/vf_scale.c
> @@ -400,7 +400,7 @@ static int scale_slice(AVFilterLink *link, AVFrame *out_buf, AVFrame *cur_pic, s
>                           out,out_stride);
>  }
>  
> -static int filter_frame(AVFilterLink *link, AVFrame *in)
> +static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out, int *got_frame)
>  {
>      ScaleContext *scale = link->dst->priv;
>      AVFilterLink *outlink = link->dst->outputs[0];
> @@ -409,6 +409,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
>      char buf[32];
>      int in_range;
>  
> +    *got_frame = 0;
>      if (in->colorspace == AVCOL_SPC_YCGCO)
>          av_log(link->dst, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n");
>  
> @@ -437,8 +438,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
>              return ret;
>      }
>  
> -    if (!scale->sws)
> -        return ff_filter_frame(outlink, in);
> +    if (!scale->sws) {
> +        *got_frame = 1;
> +        *frame_out = in;
> +        return 0;
> +    }
>  
>      scale->hsub = desc->log2_chroma_w;
>      scale->vsub = desc->log2_chroma_h;
> @@ -448,6 +452,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
>          av_frame_free(&in);
>          return AVERROR(ENOMEM);
>      }
> +    *frame_out = out;
>  
>      av_frame_copy_props(out, in);
>      out->width  = outlink->w;
> @@ -521,7 +526,23 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
>      }
>  
>      av_frame_free(&in);
> -    return ff_filter_frame(outlink, out);
> +    *got_frame = 1;
> +    return 0;
> +}
> +
> +static int filter_frame(AVFilterLink *link, AVFrame *in)
> +{
> +    AVFilterContext *ctx = link->dst;
> +    AVFilterLink *outlink = ctx->outputs[0];
> +    int got_frame = 0;
> +    AVFrame *out;
> +    int ret;
> +
> +    ret = scale_frame(link, in, &out, &got_frame);
> +    if (got_frame)
> +        return ff_filter_frame(outlink, out);

can this be simplified by using out != NULL instead of got_frame ?

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190906/e8b5eba8/attachment.sig>


More information about the ffmpeg-devel mailing list