| @@ -35,6 +35,7 @@ typedef struct { · 34 unmodified lines |
| 35 | 35 | enum PixelFormat pix_fmt; |
| 36 | 36 | AVRational time_base; ///< time_base to set in the output link |
| 37 | 37 | AVRational pixel_aspect; |
| 38 | + int eof; |
| 38 | 39 | } BufferSourceContext; |
| 39 | 40 | |
| 40 | 41 | #define CHECK_PARAM_CHANGE(s, c, width, height, format)\ |
| @@ -50,6 +51,12 @@ int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, · 9 unmodified lines |
| 50 | 51 | AVFilterBufferRef *buf; |
| 51 | 52 | int ret; |
| 52 | 53 | |
| 54 | + if (!buf) { |
| 55 | + c->eof = 1; |
| 56 | + return 0; |
| 57 | + } else if (c->eof) |
| 58 | + return AVERROR(EINVAL); |
| 59 | + |
| 53 | 60 | if (!av_fifo_space(c->fifo) && |
| 54 | 61 | (ret = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) + |
| 55 | 62 | sizeof(buf))) < 0) |
| @@ -79,6 +86,12 @@ int av_buffersrc_buffer(AVFilterContext *s, AVFilterBufferRef *buf) · 23 unmodified lines |
| 79 | 86 | BufferSourceContext *c = s->priv; |
| 80 | 87 | int ret; |
| 81 | 88 | |
| 89 | + if (!buf) { |
| 90 | + c->eof = 1; |
| 91 | + return 0; |
| 92 | + } else if (c->eof) |
| 93 | + return AVERROR(EINVAL); |
| 94 | + |
| 82 | 95 | if (!av_fifo_space(c->fifo) && |
| 83 | 96 | (ret = av_fifo_realloc2(c->fifo, av_fifo_size(c->fifo) + |
| 84 | 97 | sizeof(buf))) < 0) |
| @@ -160,6 +173,8 @@ static int request_frame(AVFilterLink *link) · 75 unmodified lines |
| 160 | 173 | AVFilterBufferRef *buf; |
| 161 | 174 | |
| 162 | 175 | if (!av_fifo_size(c->fifo)) { |
| 176 | + if (c->eof) |
| 177 | + return AVERROR_EOF; |
| 163 | 178 | av_log(link->src, AV_LOG_ERROR, |
| 164 | 179 | "request_frame() called with no available frame!\n"); |
| 165 | 180 | return AVERROR(EINVAL); |
| @@ -177,7 +192,10 @@ static int request_frame(AVFilterLink *link) · 11 unmodified lines |
| 177 | 192 | static int poll_frame(AVFilterLink *link) |
| 178 | 193 | { |
| 179 | 194 | BufferSourceContext *c = link->src->priv; |
| 180 | | − return !!av_fifo_size(c->fifo); |
| 195 | + int size = av_fifo_size(c->fifo); |
| 196 | + if (!size && c->eof) |
| 197 | + return AVERROR_EOF; |
| 198 | + return size/sizeof(AVFilterBufferRef*); |
| 181 | 199 | } |
| 182 | 200 | |
| 183 | 201 | AVFilter avfilter_vsrc_buffer = { |