mirror of https://git.ffmpeg.org/ffmpeg.git
avfilter/f_segment: fix sending frames with zero samples out
Fix max_samples variable type, and check for out of range values.
This commit is contained in:
parent
a0fc6c4a8e
commit
3706fb8f16
|
@ -41,6 +41,7 @@ typedef struct SegmentContext {
|
|||
|
||||
int current_point;
|
||||
int nb_points;
|
||||
int64_t last_pts;
|
||||
|
||||
int64_t *points;
|
||||
} SegmentContext;
|
||||
|
@ -186,7 +187,7 @@ static int activate(AVFilterContext *ctx)
|
|||
SegmentContext *s = ctx->priv;
|
||||
AVFrame *frame = NULL;
|
||||
int ret, status;
|
||||
int max_samples;
|
||||
int64_t max_samples;
|
||||
int64_t diff;
|
||||
int64_t pts;
|
||||
|
||||
|
@ -200,18 +201,30 @@ static int activate(AVFilterContext *ctx)
|
|||
break;
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
diff = s->points[s->current_point] - inlink->sample_count_out;
|
||||
while (diff <= 0) {
|
||||
ff_outlink_set_status(ctx->outputs[s->current_point], AVERROR_EOF, s->last_pts);
|
||||
s->current_point++;
|
||||
if (s->current_point >= s->nb_points)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
diff = s->points[s->current_point] - inlink->sample_count_out;
|
||||
}
|
||||
if (s->use_timestamps) {
|
||||
max_samples = av_rescale_q(diff, av_make_q(1, inlink->sample_rate), inlink->time_base);
|
||||
} else {
|
||||
max_samples = FFMAX(1, FFMIN(diff, INT_MAX));
|
||||
}
|
||||
ret = ff_inlink_consume_samples(inlink, 1, max_samples, &frame);
|
||||
if (max_samples <= 0 || max_samples > INT_MAX)
|
||||
ret = ff_inlink_consume_frame(inlink, &frame);
|
||||
else
|
||||
ret = ff_inlink_consume_samples(inlink, 1, max_samples, &frame);
|
||||
break;
|
||||
default:
|
||||
return AVERROR_BUG;
|
||||
}
|
||||
|
||||
if (ret > 0) {
|
||||
s->last_pts = frame->pts;
|
||||
while (current_segment_finished(ctx, frame)) {
|
||||
ff_outlink_set_status(ctx->outputs[s->current_point], AVERROR_EOF, frame->pts);
|
||||
s->current_point++;
|
||||
|
|
Loading…
Reference in New Issue