From c4415f6ec980d1a5f3ddda79395258150747e97f Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 18 Aug 2011 16:21:47 +0200 Subject: lavfi: unify asink_buffer and vsink_buffer API The new API is more generic (no distinction between audio/video for pulling frames), and avoids code duplication. A backward compatibility layer is kept for avoiding tools ABI breaks (only for the video binary interface, audio interface was never used in the tools). --- libavdevice/lavfi.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'libavdevice/lavfi.c') diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c index ce4189ff1c..a1929ef0ec 100644 --- a/libavdevice/lavfi.c +++ b/libavdevice/lavfi.c @@ -173,10 +173,21 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx, for (i = 0, inout = output_links; inout; i++, inout = inout->next) { AVFilterContext *sink; - if ((ret = avfilter_graph_create_filter(&sink, buffersink, - inout->name, NULL, - pix_fmts, lavfi->graph)) < 0) - FAIL(ret); + AVBufferSinkParams *buffersink_params = av_buffersink_params_alloc(); +#if FF_API_OLD_VSINK_API + ret = avfilter_graph_create_filter(&sink, buffersink, + inout->name, NULL, + pix_fmts, lavfi->graph); +#else + buffersink_params->pixel_fmts = pix_fmts; + ret = avfilter_graph_create_filter(&sink, buffersink, + inout->name, NULL, + buffersink_params, lavfi->graph); +#endif + av_freep(&buffersink_params); + if (ret < 0) + goto end; + lavfi->sinks[i] = sink; if ((ret = avfilter_link(inout->filter_ctx, inout->pad_idx, sink, 0)) < 0) FAIL(ret); @@ -225,8 +236,8 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) for (i = 0; i < avctx->nb_streams; i++) { AVRational tb = lavfi->sinks[i]->inputs[0]->time_base; double d; - int ret = av_vsink_buffer_get_video_buffer_ref(lavfi->sinks[i], - &picref, AV_VSINK_BUF_FLAG_PEEK); + int ret = av_buffersink_get_buffer_ref(lavfi->sinks[i], + &picref, AV_BUFFERSINK_FLAG_PEEK); if (ret < 0) return ret; d = av_rescale_q(picref->pts, tb, AV_TIME_BASE_Q); @@ -239,8 +250,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) } av_dlog(avctx, "min_pts_sink_idx:%i\n", min_pts_sink_idx); - av_vsink_buffer_get_video_buffer_ref(lavfi->sinks[min_pts_sink_idx], - &picref, 0); + av_buffersink_get_buffer_ref(lavfi->sinks[min_pts_sink_idx], &picref, 0); size = avpicture_get_size(picref->format, picref->video->w, picref->video->h); if ((ret = av_new_packet(pkt, size)) < 0) -- cgit v1.2.3