[FFmpeg-devel] [PATCH] lavfi/atempo: fix range check if tempo is set by command

Nicolas George george at nsup.org
Wed Oct 3 18:05:35 EEST 2018


wbsecg1 at gmail.com (2018-10-03):
> From: wang-bin <wbsecg1 at gmail.com>
> 
> ---
>  libavfilter/af_atempo.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c
> index 52f15f2769..1a004212a7 100644
> --- a/libavfilter/af_atempo.c
> +++ b/libavfilter/af_atempo.c
> @@ -331,9 +331,10 @@ static int yae_set_tempo(AVFilterContext *ctx, const char *arg_tempo)
>          return AVERROR(EINVAL);
>      }
>  
> -    if (tempo < 0.5 || tempo > 2.0) {
> -        av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [0.5, 2.0] range\n",
> -               tempo);

> +    const AVOption *o = av_opt_find(&atempo->class, "tempo", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ);
> +    if (tempo < o->min || tempo > o->max) {

The option is defined in the very same file and the min and max values
are hardcoded there. There is no need for a fragile lookup.

> +        av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [%.1f, %.1f] range\n",
> +               tempo, o->min, o->max);
>          return AVERROR(EINVAL);
>      }
>  
> @@ -439,8 +440,8 @@ static int yae_load_data(ATempoContext *atempo,
>          return 0;
>      }
>  

> -    // samples are not expected to be skipped, unless tempo is greater than 2:
> -    av_assert0(read_size <= atempo->ring || atempo->tempo > 2.0);
> +    // samples are not expected to be skipped:
> +    av_assert0(read_size <= atempo->ring);

Looks unrelated. Can you explain?

>  
>      while (atempo->position[0] < stop_here && src < src_end) {
>          int src_samples = (src_end - src) / atempo->stride;

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20181003/ba6e8864/attachment.sig>


More information about the ffmpeg-devel mailing list