231
static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
231
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
233
233
SelectContext *select = inlink->dst->priv;
235
select->select = select_frame(inlink->dst, picref);
235
select->select = select_frame(inlink->dst, frame);
236
236
if (select->select) {
237
AVFilterBufferRef *buf_out;
238
237
/* frame was requested through poll_frame */
239
238
if (select->cache_frames) {
240
if (!av_fifo_space(select->pending_frames))
239
if (!av_fifo_space(select->pending_frames)) {
241
240
av_log(inlink->dst, AV_LOG_ERROR,
242
241
"Buffering limit reached, cannot cache more frames\n");
244
av_fifo_generic_write(select->pending_frames, &picref,
245
sizeof(picref), NULL);
242
avfilter_unref_bufferp(&frame);
244
av_fifo_generic_write(select->pending_frames, &frame,
245
sizeof(frame), NULL);
248
buf_out = avfilter_ref_buffer(picref, ~0);
250
return AVERROR(ENOMEM);
251
return ff_start_frame(inlink->dst->outputs[0], buf_out);
257
static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
259
SelectContext *select = inlink->dst->priv;
261
if (select->select && !select->cache_frames)
262
return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
266
static int end_frame(AVFilterLink *inlink)
268
SelectContext *select = inlink->dst->priv;
270
if (select->select) {
271
if (select->cache_frames)
273
return ff_end_frame(inlink->dst->outputs[0]);
248
return ff_filter_frame(inlink->dst->outputs[0], frame);
251
avfilter_unref_bufferp(&frame);
285
262
if (av_fifo_size(select->pending_frames)) {
286
263
AVFilterBufferRef *picref;
289
265
av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL);
290
if ((ret = ff_start_frame(outlink, picref)) < 0 ||
291
(ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 ||
292
(ret = ff_end_frame(outlink)) < 0);
266
return ff_filter_frame(outlink, picref);
297
269
while (!select->select) {
346
318
.type = AVMEDIA_TYPE_VIDEO,
347
319
.get_video_buffer = ff_null_get_video_buffer,
348
320
.config_props = config_input,
349
.start_frame = start_frame,
350
.draw_slice = draw_slice,
351
.end_frame = end_frame
321
.filter_frame = filter_frame,