[FFmpeg-devel] [PATCH] avfilter/af_atempo: fix assertion failure on empty input

Marton Balint cus at passwd.hu
Thu Dec 15 04:27:33 EET 2016


Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavfilter/af_atempo.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c
index 59b08ec..93a9c05 100644
--- a/libavfilter/af_atempo.c
+++ b/libavfilter/af_atempo.c
@@ -74,6 +74,7 @@ typedef struct {
  * Filter state machine states
  */
 typedef enum {
+    YAE_NEW,
     YAE_LOAD_FRAGMENT,
     YAE_ADJUST_POSITION,
     YAE_RELOAD_FRAGMENT,
@@ -180,7 +181,7 @@ static void yae_clear(ATempoContext *atempo)
     atempo->tail = 0;
 
     atempo->nfrag = 0;
-    atempo->state = YAE_LOAD_FRAGMENT;
+    atempo->state = YAE_NEW;
 
     atempo->position[0] = 0;
     atempo->position[1] = 0;
@@ -828,6 +829,9 @@ yae_apply(ATempoContext *atempo,
           uint8_t *dst_end)
 {
     while (1) {
+        if (atempo->state == YAE_NEW)
+            atempo->state = YAE_LOAD_FRAGMENT;
+
         if (atempo->state == YAE_LOAD_FRAGMENT) {
             // load additional data for the current fragment:
             if (yae_load_frag(atempo, src_ref, src_end) != 0) {
@@ -983,7 +987,7 @@ static av_cold int init(AVFilterContext *ctx)
 {
     ATempoContext *atempo = ctx->priv;
     atempo->format = AV_SAMPLE_FMT_NONE;
-    atempo->state  = YAE_LOAD_FRAGMENT;
+    atempo->state  = YAE_NEW;
     return 0;
 }
 
@@ -1123,7 +1127,7 @@ static int request_frame(AVFilterLink *outlink)
 
     ret = ff_request_frame(ctx->inputs[0]);
 
-    if (ret == AVERROR_EOF) {
+    if (ret == AVERROR_EOF && atempo->state != YAE_NEW) {
         // flush the filter:
         int n_max = atempo->ring;
         int n_out;
-- 
2.10.2



More information about the ffmpeg-devel mailing list