~ubuntu-branches/ubuntu/utopic/libav/utopic

« back to all changes in this revision

Viewing changes to libavfilter/vf_select.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-12-21 15:32:13 UTC
  • mto: (1.2.18)
  • mto: This revision was merged to the branch mainline in revision 34.
  • Revision ID: package-import@ubuntu.com-20121221153213-fudzrugjzivtv0wp
Tags: upstream-9~beta3
ImportĀ upstreamĀ versionĀ 9~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
228
228
    return res;
229
229
}
230
230
 
231
 
static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
 
231
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
232
232
{
233
233
    SelectContext *select = inlink->dst->priv;
234
234
 
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");
243
 
            else
244
 
                av_fifo_generic_write(select->pending_frames, &picref,
245
 
                                      sizeof(picref), NULL);
 
242
                avfilter_unref_bufferp(&frame);
 
243
            } else
 
244
                av_fifo_generic_write(select->pending_frames, &frame,
 
245
                                      sizeof(frame), NULL);
246
246
            return 0;
247
247
        }
248
 
        buf_out = avfilter_ref_buffer(picref, ~0);
249
 
        if (!buf_out)
250
 
            return AVERROR(ENOMEM);
251
 
        return ff_start_frame(inlink->dst->outputs[0], buf_out);
252
 
    }
253
 
 
254
 
    return 0;
255
 
}
256
 
 
257
 
static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
258
 
{
259
 
    SelectContext *select = inlink->dst->priv;
260
 
 
261
 
    if (select->select && !select->cache_frames)
262
 
        return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
263
 
    return 0;
264
 
}
265
 
 
266
 
static int end_frame(AVFilterLink *inlink)
267
 
{
268
 
    SelectContext *select = inlink->dst->priv;
269
 
 
270
 
    if (select->select) {
271
 
        if (select->cache_frames)
272
 
            return 0;
273
 
        return ff_end_frame(inlink->dst->outputs[0]);
274
 
    }
 
248
        return ff_filter_frame(inlink->dst->outputs[0], frame);
 
249
    }
 
250
 
 
251
    avfilter_unref_bufferp(&frame);
275
252
    return 0;
276
253
}
277
254
 
284
261
 
285
262
    if (av_fifo_size(select->pending_frames)) {
286
263
        AVFilterBufferRef *picref;
287
 
        int ret;
288
264
 
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);
293
 
 
294
 
        return ret;
 
266
        return ff_filter_frame(outlink, picref);
295
267
    }
296
268
 
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,
352
322
    },
353
323
    { NULL }
354
324
};