lavfi: drop the requirement that request_frame returns a frame.
It requires a loop in filters or the framework, that makes the scheduling less efficient and more complex. This is purely an internal change since the loop is now present in buffersink. Note that no filter except buffersink did rely on the requirement.
This commit is contained in:
parent
598f8a7afa
commit
2a351f6c55
@ -232,7 +232,8 @@ Frame scheduling
|
|||||||
one of its inputs, repeatedly until at least one frame has been pushed.
|
one of its inputs, repeatedly until at least one frame has been pushed.
|
||||||
|
|
||||||
Return values:
|
Return values:
|
||||||
if request_frame could produce a frame, it should return 0;
|
if request_frame could produce a frame, or at least make progress
|
||||||
|
towards producing a frame, it should return 0;
|
||||||
if it could not for temporary reasons, it should return AVERROR(EAGAIN);
|
if it could not for temporary reasons, it should return AVERROR(EAGAIN);
|
||||||
if it could not because there are no more frames, it should return
|
if it could not because there are no more frames, it should return
|
||||||
AVERROR_EOF.
|
AVERROR_EOF.
|
||||||
@ -244,7 +245,6 @@ Frame scheduling
|
|||||||
push_one_frame();
|
push_one_frame();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
while (!frame_pushed) {
|
|
||||||
input = input_where_a_frame_is_most_needed();
|
input = input_where_a_frame_is_most_needed();
|
||||||
ret = ff_request_frame(input);
|
ret = ff_request_frame(input);
|
||||||
if (ret == AVERROR_EOF) {
|
if (ret == AVERROR_EOF) {
|
||||||
@ -252,12 +252,11 @@ Frame scheduling
|
|||||||
} else if (ret < 0) {
|
} else if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
Note that, except for filters that can have queued frames, request_frame
|
Note that, except for filters that can have queued frames, request_frame
|
||||||
does not push frames: it requests them to its input, and as a reaction,
|
does not push frames: it requests them to its input, and as a reaction,
|
||||||
the filter_frame method will be called and do the work.
|
the filter_frame method possibly will be called and do the work.
|
||||||
|
|
||||||
Legacy API
|
Legacy API
|
||||||
==========
|
==========
|
||||||
|
@ -347,9 +347,7 @@ int ff_request_frame(AVFilterLink *link)
|
|||||||
|
|
||||||
if (link->closed)
|
if (link->closed)
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
av_assert0(!link->frame_requested);
|
// TODO reindent
|
||||||
link->frame_requested = 1;
|
|
||||||
while (link->frame_requested) {
|
|
||||||
if (link->srcpad->request_frame)
|
if (link->srcpad->request_frame)
|
||||||
ret = link->srcpad->request_frame(link);
|
ret = link->srcpad->request_frame(link);
|
||||||
else if (link->src->inputs[0])
|
else if (link->src->inputs[0])
|
||||||
@ -360,13 +358,8 @@ int ff_request_frame(AVFilterLink *link)
|
|||||||
ret = ff_filter_frame_framed(link, pbuf);
|
ret = ff_filter_frame_framed(link, pbuf);
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
link->frame_requested = 0;
|
|
||||||
if (ret == AVERROR_EOF)
|
if (ret == AVERROR_EOF)
|
||||||
link->closed = 1;
|
link->closed = 1;
|
||||||
} else {
|
|
||||||
av_assert0(!link->frame_requested ||
|
|
||||||
link->flags & FF_LINK_FLAG_REQUEST_LOOP);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1088,7 +1081,6 @@ static int ff_filter_frame_framed(AVFilterLink *link, AVFrame *frame)
|
|||||||
}
|
}
|
||||||
ret = filter_frame(link, out);
|
ret = filter_frame(link, out);
|
||||||
link->frame_count++;
|
link->frame_count++;
|
||||||
link->frame_requested = 0;
|
|
||||||
ff_update_link_current_pts(link, pts);
|
ff_update_link_current_pts(link, pts);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -499,12 +499,6 @@ struct AVFilterLink {
|
|||||||
*/
|
*/
|
||||||
int channels;
|
int channels;
|
||||||
|
|
||||||
/**
|
|
||||||
* True if a frame is being requested on the link.
|
|
||||||
* Used internally by the framework.
|
|
||||||
*/
|
|
||||||
unsigned frame_requested;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link processing flags.
|
* Link processing flags.
|
||||||
*/
|
*/
|
||||||
|
@ -102,9 +102,9 @@ struct AVFilterPad {
|
|||||||
int (*poll_frame)(AVFilterLink *link);
|
int (*poll_frame)(AVFilterLink *link);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frame request callback. A call to this should result in at least one
|
* Frame request callback. A call to this should result in some progress
|
||||||
* frame being output over the given link. This should return zero on
|
* towards producing output over the given link. This should return zero
|
||||||
* success, and another value on error.
|
* on success, and another value on error.
|
||||||
*
|
*
|
||||||
* Output pads only.
|
* Output pads only.
|
||||||
*/
|
*/
|
||||||
@ -291,8 +291,11 @@ int ff_poll_frame(AVFilterLink *link);
|
|||||||
* caller (generally eventually a user application) as this step may (but does
|
* caller (generally eventually a user application) as this step may (but does
|
||||||
* not have to be) necessary to provide the input with the next frame.
|
* not have to be) necessary to provide the input with the next frame.
|
||||||
*
|
*
|
||||||
* If a request is successful then the filter_frame() function will be called
|
* If a request is successful then some progress has been made towards
|
||||||
* at least once before ff_request_frame() returns
|
* providing a frame on the link (through ff_filter_frame()). A filter that
|
||||||
|
* needs several frames to produce one is allowed to return success if one
|
||||||
|
* more frame has been processed but no output has been produced yet. A
|
||||||
|
* filter is also allowed to simply forward a success return value.
|
||||||
*
|
*
|
||||||
* @param link the input link
|
* @param link the input link
|
||||||
* @return zero on success
|
* @return zero on success
|
||||||
|
Loading…
x
Reference in New Issue
Block a user