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
114 114
115 /* filter state */115 /* filter state */
116 AVFifo *out_pts; ///< timestamps of wanted output frames116 AVFifo *out_pts; ///< timestamps of wanted output frames
117 int64_t status_pts;
118 int status;
117 119
118 /* settings */120 /* settings */
119 char *out_format_string;121 char *out_format_string;
@@ -808,19 +810,12 @@ static int libplacebo_activate(AVFilterContext *ctx) · 688 unmodified lines
808 if (ret < 0)810 if (ret < 0)
809 return ret;811 return ret;
810 812
811 if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {813 if (!s->status && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
812 pts = av_rescale_q_rnd(pts, inlink->time_base, outlink->time_base,814 pts = av_rescale_q_rnd(pts, inlink->time_base, outlink->time_base,
813 AV_ROUND_UP);815 AV_ROUND_UP);
814 if (status == AVERROR_EOF) {816 pl_queue_push(s->queue, NULL); /* Signal EOF to pl_queue */
815 /* Signal EOF to pl_queue, and enqueue this output frame to817 s->status = status;
816 * make sure we see PL_QUEUE_EOF returned eventually */818 s->status_pts = pts;
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 }
824 }819 }
825 820
826 if (ff_outlink_frame_wanted(outlink)) {821 if (ff_outlink_frame_wanted(outlink)) {
@@ -830,7 +825,17 @@ static int libplacebo_activate(AVFilterContext *ctx) · 3 unmodified lines
830 if (s->fps.num) {825 if (s->fps.num) {
831 pts = outlink->frame_count_out;826 pts = outlink->frame_count_out;
832 } else if (av_fifo_peek(s->out_pts, &pts, 1, 0) < 0) {827 } 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);
834 return 0;839 return 0;
835 }840 }
836 841

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