Message ID | 20161215022733.409-1-cus@passwd.hu |
---|---|
State | Superseded |
Headers | show |
On Wed, Dec 14, 2016 at 7:27 PM, Marton Balint <cus@passwd.hu> wrote: > Signed-off-by: Marton Balint <cus@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; I'd like to understand these changes a little better ... how can I reproduce the problem this is trying to fix? Pavel.
On Wed, 14 Dec 2016, Pavel Koshevoy wrote: > On Wed, Dec 14, 2016 at 7:27 PM, Marton Balint <cus@passwd.hu> wrote: >> Signed-off-by: Marton Balint <cus@passwd.hu> >> --- >> libavfilter/af_atempo.c | 10 +++++++--- >> 1 file changed, 7 insertions(+), 3 deletions(-) >> > > > I'd like to understand these changes a little better ... how can I > reproduce the problem this is trying to fix? > Basically it happens on empty input: ffmpeg -f s16be -i /dev/null -af atempo output.wav Regards, Marton
On Thu, Dec 15, 2016 at 3:31 AM, Marton Balint <cus@passwd.hu> wrote: > > > On Wed, 14 Dec 2016, Pavel Koshevoy wrote: > >> On Wed, Dec 14, 2016 at 7:27 PM, Marton Balint <cus@passwd.hu> wrote: >>> >>> Signed-off-by: Marton Balint <cus@passwd.hu> >>> --- >>> libavfilter/af_atempo.c | 10 +++++++--- >>> 1 file changed, 7 insertions(+), 3 deletions(-) >>> >> >> >> I'd like to understand these changes a little better ... how can I >> reproduce the problem this is trying to fix? >> > > Basically it happens on empty input: > > ffmpeg -f s16be -i /dev/null -af atempo output.wav I've posted a smaller alternative fix -- http://ffmpeg.org/pipermail/ffmpeg-devel/2016-December/204591.html Pavel.
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;
Signed-off-by: Marton Balint <cus@passwd.hu> --- libavfilter/af_atempo.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)