From 7ce47090ce36fbe72f807d1e35fea3a699adad17 Mon Sep 17 00:00:00 2001 From: Mark Thompson Date: Sat, 4 Mar 2017 23:57:38 +0000 Subject: ffmpeg: Support setting the hardware device to use when filtering This only supports one device globally, but more can be used by passing them with input streams in hw_frames_ctx or by deriving new devices inside a filter graph with hwmap. (cherry picked from commit e669db76108de8d7a36c2274c99da82cc94d1dd1) --- ffmpeg_filter.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ffmpeg_filter.c') diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c index 817f48f473..aacc185059 100644 --- a/ffmpeg_filter.c +++ b/ffmpeg_filter.c @@ -1046,9 +1046,15 @@ int configure_filtergraph(FilterGraph *fg) if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0) goto fail; - if (hw_device_ctx) { + if (filter_hw_device || hw_device_ctx) { + AVBufferRef *device = filter_hw_device ? filter_hw_device->device_ref + : hw_device_ctx; for (i = 0; i < fg->graph->nb_filters; i++) { - fg->graph->filters[i]->hw_device_ctx = av_buffer_ref(hw_device_ctx); + fg->graph->filters[i]->hw_device_ctx = av_buffer_ref(device); + if (!fg->graph->filters[i]->hw_device_ctx) { + ret = AVERROR(ENOMEM); + goto fail; + } } } -- cgit v1.2.3