lavfi: loop on request_frame if necessary.
Some filters need several input frames before producing output. For these filter, it becomes simpler to return 0 in request_frame() and let the framework call it again until output has been produced.
This commit is contained in:
+15
-2
@@ -323,6 +323,10 @@ int ff_request_frame(AVFilterLink *link)
|
||||
|
||||
if (link->closed)
|
||||
return AVERROR_EOF;
|
||||
av_assert0(!link->frame_requested);
|
||||
link->frame_requested = 1;
|
||||
while (link->frame_requested) {
|
||||
/* TODO reindent */
|
||||
if (link->srcpad->request_frame)
|
||||
ret = link->srcpad->request_frame(link);
|
||||
else if (link->src->inputs[0])
|
||||
@@ -332,8 +336,15 @@ int ff_request_frame(AVFilterLink *link)
|
||||
link->partial_buf = NULL;
|
||||
ret = ff_filter_frame_framed(link, pbuf);
|
||||
}
|
||||
if (ret == AVERROR_EOF)
|
||||
link->closed = 1;
|
||||
if (ret < 0) {
|
||||
link->frame_requested = 0;
|
||||
if (ret == AVERROR_EOF)
|
||||
link->closed = 1;
|
||||
} else {
|
||||
av_assert0(!link->frame_requested ||
|
||||
link->flags & FF_LINK_FLAG_REQUEST_LOOP);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -702,6 +713,7 @@ static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame)
|
||||
|
||||
pts = out->pts;
|
||||
ret = filter_frame(link, out);
|
||||
link->frame_requested = 0;
|
||||
ff_update_link_current_pts(link, pts);
|
||||
return ret;
|
||||
}
|
||||
@@ -713,6 +725,7 @@ static int ff_filter_frame_needs_framing(AVFilterLink *link, AVFrame *frame)
|
||||
int nb_channels = av_frame_get_channels(frame);
|
||||
int ret = 0;
|
||||
|
||||
link->flags |= FF_LINK_FLAG_REQUEST_LOOP;
|
||||
/* Handle framing (min_samples, max_samples) */
|
||||
while (insamples) {
|
||||
if (!pbuf) {
|
||||
|
||||
Reference in New Issue
Block a user