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

Submitted by Wang Bin on Oct. 3, 2018, 3:01 p.m.

Details

Message ID 20181003150144.50245-1-wbsecg1@gmail.com
State New
Headers show

Commit Message

Wang Bin Oct. 3, 2018, 3:01 p.m.
From: wang-bin <wbsecg1@gmail.com>

---
 libavfilter/af_atempo.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

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) {
+        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);
 
     while (atempo->position[0] < stop_here && src < src_end) {
         int src_samples = (src_end - src) / atempo->stride;