[FFmpeg-devel] [PATCH 03/25] avfilter/af_headphone: Check for the existence of samples

Nicolas George george at nsup.org
Wed Sep 9 17:27:19 EEST 2020


Andreas Rheinhardt (12020-09-08):
> Not providing any samples makes no sense at all. And if no samples
> were provided for one of the HRIR streams, one would either run into
> an av_assert1 in ff_inlink_consume_samples() or into a segfault in
> take_samples() in avfilter.c.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libavfilter/af_headphone.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c
> index 1024ff57b1..f488e0e28d 100644
> --- a/libavfilter/af_headphone.c
> +++ b/libavfilter/af_headphone.c
> @@ -631,8 +631,14 @@ static int activate(AVFilterContext *ctx)
>              if ((ret = check_ir(ctx->inputs[i], i)) < 0)
>                  return ret;
>  
> -                if (ff_outlink_get_status(ctx->inputs[i]) == AVERROR_EOF)
> +            if (ff_outlink_get_status(ctx->inputs[i]) == AVERROR_EOF) {
> +                if (!ff_inlink_queued_samples(ctx->inputs[i])) {
> +                    av_log(ctx, AV_LOG_ERROR, "No samples provided for "
> +                           "HRIR stream %d.\n", i - 1);
> +                    return AVERROR_INVALIDDATA;
> +                }
>                      s->in[i].eof = 1;
> +            }

No, this is bogus. A filter should not call ff_outlink_get_status() on
its input, that is breaking the abstraction provided by the API. In
fact, everything in `git grep 'ff_outlink_get_status.*input'` is a bug.

>          }
>  
>          for (i = 1; i < s->nb_inputs; i++) {

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200909/472bd13f/attachment.sig>


More information about the ffmpeg-devel mailing list