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
2669 while (fgp->nb_outputs_done < fg->nb_outputs) {2669 while (fgp->nb_outputs_done < fg->nb_outputs) {
2670 int ret;2670 int ret;
2671 2671
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
2672 ret = avfilter_graph_request_oldest(fgt->graph);2688 ret = avfilter_graph_request_oldest(fgt->graph);
2673 if (ret == AVERROR(EAGAIN)) {2689 if (ret == AVERROR(EAGAIN)) {
2674 fgt->next_in = choose_input(fg, fgt);2690 fgt->next_in = choose_input(fg, fgt);
@@ -2684,21 +2700,6 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt, · 9 unmodified lines
2684 }2700 }
2685 fgt->next_in = fg->nb_inputs;2701 fgt->next_in = fg->nb_inputs;
2686 2702
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 }
2702 did_step = 1;2703 did_step = 1;
2703 }2704 }
2704 2705

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