summaryrefslogtreecommitdiff
path: root/avtools
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-03-04 23:57:38 +0000
committerMark Thompson <sw@jkqxz.net>2017-04-30 16:13:50 +0100
commite669db76108de8d7a36c2274c99da82cc94d1dd1 (patch)
tree319e97635b7f98bd061332867110950d0a83b683 /avtools
parent9203aac22874c7259e155b7d00f1f33bb1355129 (diff)
avconv: 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.
Diffstat (limited to 'avtools')
-rw-r--r--avtools/avconv.h1
-rw-r--r--avtools/avconv_filter.c10
-rw-r--r--avtools/avconv_opt.c17
3 files changed, 26 insertions, 2 deletions
diff --git a/avtools/avconv.h b/avtools/avconv.h
index 9415b208be..3354c50444 100644
--- a/avtools/avconv.h
+++ b/avtools/avconv.h
@@ -489,6 +489,7 @@ extern const OptionDef options[];
extern const HWAccel hwaccels[];
extern int hwaccel_lax_profile_check;
extern AVBufferRef *hw_device_ctx;
+extern HWDevice *filter_hw_device;
void reset_options(OptionsContext *o);
void show_usage(void);
diff --git a/avtools/avconv_filter.c b/avtools/avconv_filter.c
index e53dcd271c..884478da27 100644
--- a/avtools/avconv_filter.c
+++ b/avtools/avconv_filter.c
@@ -711,9 +711,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;
+ }
}
}
diff --git a/avtools/avconv_opt.c b/avtools/avconv_opt.c
index e970c8e46c..9839a2269e 100644
--- a/avtools/avconv_opt.c
+++ b/avtools/avconv_opt.c
@@ -80,6 +80,7 @@ const HWAccel hwaccels[] = {
};
int hwaccel_lax_profile_check = 0;
AVBufferRef *hw_device_ctx;
+HWDevice *filter_hw_device;
char *vstats_filename;
@@ -369,6 +370,20 @@ static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)
}
}
+static int opt_filter_hw_device(void *optctx, const char *opt, const char *arg)
+{
+ if (filter_hw_device) {
+ av_log(NULL, AV_LOG_ERROR, "Only one filter device can be used.\n");
+ return AVERROR(EINVAL);
+ }
+ filter_hw_device = hw_device_get_by_name(arg);
+ if (!filter_hw_device) {
+ av_log(NULL, AV_LOG_ERROR, "Invalid filter device %s.\n", arg);
+ return AVERROR(EINVAL);
+ }
+ return 0;
+}
+
/**
* Parse a metadata specifier passed as 'arg' parameter.
* @param arg metadata string to parse
@@ -2775,6 +2790,8 @@ const OptionDef options[] = {
{ "init_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_init_hw_device },
"initialise hardware device", "args" },
+ { "filter_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_hw_device },
+ "set hardware device used when filtering", "device" },
{ NULL, },
};