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.
Unified · Split
| @@ -114,6 +114,8 @@ typedef struct LibplaceboContext { · 113 unmodified lines | ||
| 114 | 114 | |
| 115 | 115 | /* filter state */ |
| 116 | 116 | AVFifo *out_pts; ///< timestamps of wanted output frames |
| 117 | + int64_t status_pts; | |
| 118 | + int status; | |
| 117 | 119 | |
| 118 | 120 | /* settings */ |
| 119 | 121 | char *out_format_string; |
| @@ -808,19 +810,12 @@ static int libplacebo_activate(AVFilterContext *ctx) · 688 unmodified lines | ||
| 808 | 810 | if (ret < 0) |
| 809 | 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 | 814 | pts = av_rescale_q_rnd(pts, inlink->time_base, outlink->time_base, |
| 813 | 815 | 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; | |
| 824 | 819 | } |
| 825 | 820 | |
| 826 | 821 | if (ff_outlink_frame_wanted(outlink)) { |
| @@ -830,7 +825,17 @@ static int libplacebo_activate(AVFilterContext *ctx) · 3 unmodified lines | ||
| 830 | 825 | if (s->fps.num) { |
| 831 | 826 | pts = outlink->frame_count_out; |
| 832 | 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 | 839 | return 0; |
| 835 | 840 | } |
| 836 | 841 | |