aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-07-23 10:19:08 +0200
committerAnton Khirnov <anton@khirnov.net>2023-08-30 11:53:50 +0200
commitd9c862b57f078852eb8f5604784e2b2e69096926 (patch)
tree68af29b9692fa2cd4a2dac96e62641cf0bd6f33c
parent82dd4dbe3f465bc11ea8a3b05733b43ca8d44c5c (diff)
downloadffmpeg-d9c862b57f078852eb8f5604784e2b2e69096926.tar.gz
fftools/ffmpeg_filter: factor processing a single frame out of reap_filters()
This is easier to read.
-rw-r--r--fftools/ffmpeg_filter.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 177a6f7e5c..5f4a7bfcc6 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1741,25 +1741,14 @@ int filtergraph_is_simple(const FilterGraph *fg)
return fgp->is_simple;
}
-int reap_filters(FilterGraph *fg, int flush)
+static int fg_output_step(OutputFilterPriv *ofp, int flush)
{
- FilterGraphPriv *fgp = fgp_from_fg(fg);
+ FilterGraphPriv *fgp = fgp_from_fg(ofp->ofilter.graph);
+ OutputStream *ost = ofp->ofilter.ost;
AVFrame *filtered_frame = fgp->frame;
-
- if (!fg->graph)
- return 0;
-
- /* Reap all buffers present in the buffer sinks */
- for (int i = 0; i < fg->nb_outputs; i++) {
- OutputFilter *ofilter = fg->outputs[i];
- OutputStream *ost = ofilter->ost;
- OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
AVFilterContext *filter = ofp->filter;
-
- int ret = 0;
-
- while (1) {
FrameData *fd;
+ int ret;
ret = av_buffersink_get_frame_flags(filter, filtered_frame,
AV_BUFFERSINK_FLAG_NO_REQUEST);
@@ -1774,11 +1763,11 @@ int reap_filters(FilterGraph *fg, int flush)
return ret;
}
- break;
+ return 1;
}
if (ost->finished) {
av_frame_unref(filtered_frame);
- continue;
+ return 0;
}
if (filtered_frame->pts != AV_NOPTS_VALUE) {
@@ -1817,6 +1806,24 @@ int reap_filters(FilterGraph *fg, int flush)
return ret;
ofp->got_frame = 1;
+
+ return 0;
+}
+
+int reap_filters(FilterGraph *fg, int flush)
+{
+ if (!fg->graph)
+ return 0;
+
+ /* Reap all buffers present in the buffer sinks */
+ for (int i = 0; i < fg->nb_outputs; i++) {
+ OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[i]);
+ int ret = 0;
+
+ while (!ret) {
+ ret = fg_output_step(ofp, flush);
+ if (ret < 0)
+ return ret;
}
}