History

lavfi/libplacebo: properly handle EOF

The current code relied on pl_queue eventually returning EOF back to the caller, which didn't work in all situations (e.g. single frame input). Also, the current code assumed that ff_inlink_acknowledge_status only fired once, which was patently not true, as the above edge cases demonstrated. Solve both issues by keeping track of the acknowledged link status and forwarding it (instead of trying to probe the pl_queue again) in the event that we run out of queued input frames, as well as (in CFR mode) when we pass the indicated status PTS.

Niklas Haas committed 3 years ago

Commit c00fd021 parent 7428f1e1 file · +17 −12Browse files

Unified · Split

libavfilter/vf_libplacebo.c+17−12
@@ -114,6 +114,8 @@ typedef struct LibplaceboContext { · 113 unmodified lines
114114
115115 /* filter state */
116116 AVFifo *out_pts; ///< timestamps of wanted output frames
117+ int64_t status_pts;
118+ int status;
117119
118120 /* settings */
119121 char *out_format_string;
@@ -808,19 +810,12 @@ static int libplacebo_activate(AVFilterContext *ctx) · 688 unmodified lines
808810 if (ret < 0)
809811 return ret;
810812
811− if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
813+ if (!s->status && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
812814 pts = av_rescale_q_rnd(pts, inlink->time_base, outlink->time_base,
813815 AV_ROUND_UP);
814− if (status == AVERROR_EOF) {
815− /* Signal EOF to pl_queue, and enqueue this output frame to
816− * make sure we see PL_QUEUE_EOF returned eventually */
817− pl_queue_push(s->queue, NULL);
818− if (!s->fps.num)
819− av_fifo_write(s->out_pts, &pts, 1);
820− } else {
821− ff_outlink_set_status(outlink, status, pts);
822− return 0;
823− }
816+ pl_queue_push(s->queue, NULL); /* Signal EOF to pl_queue */
817+ s->status = status;
818+ s->status_pts = pts;
824819 }
825820
826821 if (ff_outlink_frame_wanted(outlink)) {
@@ -830,7 +825,17 @@ static int libplacebo_activate(AVFilterContext *ctx) · 3 unmodified lines
830825 if (s->fps.num) {
831826 pts = outlink->frame_count_out;
832827 } else if (av_fifo_peek(s->out_pts, &pts, 1, 0) < 0) {
833− ff_inlink_request_frame(inlink);
828+ /* No frames queued */
829+ if (s->status) {
830+ pts = s->status_pts;
831+ } else {
832+ ff_inlink_request_frame(inlink);
833+ return 0;
834+ }
835+ }
836+
837+ if (s->status && pts >= s->status_pts) {
838+ ff_outlink_set_status(outlink, s->status, s->status_pts);
834839 return 0;
835840 }
836841

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