avfilter/aeval: trim last frame's number of samples to match requested duration

Fixes #6181.

Signed-off-by: Paul B Mahol <onemda@gmail.com>
pull/233/merge
Paul B Mahol 8 years ago
parent 353f509ee3
commit dbc7f02a72
  1. 14
      libavfilter/aeval.c
  2. 3
      tests/ref/fate/filter-hls
  3. 2683
      tests/ref/fate/filter-hls-append

@ -277,16 +277,24 @@ static int request_frame(AVFilterLink *outlink)
AVFrame *samplesref;
int i, j;
int64_t t = av_rescale(eval->n, AV_TIME_BASE, eval->sample_rate);
int nb_samples;
if (eval->duration >= 0 && t >= eval->duration)
return AVERROR_EOF;
samplesref = ff_get_audio_buffer(outlink, eval->nb_samples);
if (eval->duration >= 0) {
nb_samples = FFMIN(eval->nb_samples, av_rescale(eval->duration, eval->sample_rate, AV_TIME_BASE) - eval->pts);
if (!nb_samples)
return AVERROR_EOF;
} else {
nb_samples = eval->nb_samples;
}
samplesref = ff_get_audio_buffer(outlink, nb_samples);
if (!samplesref)
return AVERROR(ENOMEM);
/* evaluate expression for each single sample and for each channel */
for (i = 0; i < eval->nb_samples; i++, eval->n++) {
for (i = 0; i < nb_samples; i++, eval->n++) {
eval->var_values[VAR_N] = eval->n;
eval->var_values[VAR_T] = eval->var_values[VAR_N] * (double)1/eval->sample_rate;
@ -298,7 +306,7 @@ static int request_frame(AVFilterLink *outlink)
samplesref->pts = eval->pts;
samplesref->sample_rate = eval->sample_rate;
eval->pts += eval->nb_samples;
eval->pts += nb_samples;
return ff_filter_frame(outlink, samplesref);
}

@ -769,5 +769,4 @@
0, 877824, 877824, 1152, 2304, 0xb2ae7741
0, 878976, 878976, 1152, 2304, 0x4de169e4
0, 880128, 880128, 1152, 2304, 0x3cb18530
0, 881280, 881280, 1152, 2304, 0x48b95d6c
0, 882432, 882432, 1152, 2304, 0xcff707ef
0, 881280, 881280, 1152, 2304, 0x5a0c5e7b

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save