History

fftools/ffmpeg_filter: always reap all available frames before requesting new ones

alfilter_graph_request_oldest() might return EAGAIN and produce a frame on not the oldest sink. Fixes ticket #11597. Fixes excessive frame buffering in #10959. Fixes excessive frame buffering in #11366.

Marton Balint committed 1 year ago

Commit 42bcbdd1 parent af189e41 file · +16 −15Browse files

Unified · Split

fftools/ffmpeg_filter.c+16−15
@@ -2669,6 +2669,22 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt, · 2668 unmodified lines
26692669 while (fgp->nb_outputs_done < fg->nb_outputs) {
26702670 int ret;
26712671
2672+ /* Reap all buffers present in the buffer sinks */
2673+ for (int i = 0; i < fg->nb_outputs; i++) {
2674+ OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[i]);
2675+
2676+ ret = 0;
2677+ while (!ret) {
2678+ ret = fg_output_step(ofp, fgt, frame);
2679+ if (ret < 0)
2680+ return ret;
2681+ }
2682+ }
2683+
2684+ // return after one iteration, so that scheduler can rate-control us
2685+ if (did_step && fgp->have_sources)
2686+ return 0;
2687+
26722688 ret = avfilter_graph_request_oldest(fgt->graph);
26732689 if (ret == AVERROR(EAGAIN)) {
26742690 fgt->next_in = choose_input(fg, fgt);
@@ -2684,21 +2700,6 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt, · 9 unmodified lines
26842700 }
26852701 fgt->next_in = fg->nb_inputs;
26862702
2687− // return after one iteration, so that scheduler can rate-control us
2688− if (did_step && fgp->have_sources)
2689− return 0;
2690−
2691− /* Reap all buffers present in the buffer sinks */
2692− for (int i = 0; i < fg->nb_outputs; i++) {
2693− OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[i]);
2694−
2695− ret = 0;
2696− while (!ret) {
2697− ret = fg_output_step(ofp, fgt, frame);
2698− if (ret < 0)
2699− return ret;
2700− }
2701− }
27022703 did_step = 1;
27032704 }
27042705

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t