summaryrefslogtreecommitdiffstats
path: root/player/lavfi.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-02-20 13:42:08 +0100
committerwm4 <wm4@nowhere>2017-02-20 13:42:08 +0100
commite5df57c7554da08c812252c5c2d8bf5d372e19e3 (patch)
tree5f542ad56b1146407efa1f72e4f40a083a5a90af /player/lavfi.c
parent134c9d9df5c5d38960f2cd4fd5f23dcb9205811e (diff)
downloadmpv-e5df57c7554da08c812252c5c2d8bf5d372e19e3.tar.bz2
mpv-e5df57c7554da08c812252c5c2d8bf5d372e19e3.tar.xz
lavfi: support hwdec filters for --lavfi-complex
Not so important by itself, but important for when we replace the vf libavfilter wrapper with the common implementation. (Which will hopefully happen, but not too soon.)
Diffstat (limited to 'player/lavfi.c')
-rw-r--r--player/lavfi.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/player/lavfi.c b/player/lavfi.c
index 953ccc5956..2573a92833 100644
--- a/player/lavfi.c
+++ b/player/lavfi.c
@@ -40,6 +40,7 @@
#include "video/mp_image.h"
#include "audio/fmt-conversion.h"
#include "video/fmt-conversion.h"
+#include "video/hwdec.h"
#include "lavfi.h"
@@ -52,6 +53,8 @@ struct lavfi {
struct mp_log *log;
char *graph_string;
+ struct mp_hwdec_devices *hwdec_devs;
+
AVFilterGraph *graph;
// Set to true once all inputs have been initialized, and the graph is
// linked.
@@ -423,6 +426,7 @@ static bool init_pads(struct lavfi *c)
params->height = pad->in_fmt_v->h;
params->sample_aspect_ratio.num = pad->in_fmt_v->params.p_w;
params->sample_aspect_ratio.den = pad->in_fmt_v->params.p_h;
+ params->hw_frames_ctx = pad->in_fmt_v->hwctx;
filter_name = "buffer";
} else {
assert(0);
@@ -471,6 +475,11 @@ static void dump_graph(struct lavfi *c)
#endif
}
+void lavfi_set_hwdec_devs(struct lavfi *c, struct mp_hwdec_devices *hwdevs)
+{
+ c->hwdec_devs = hwdevs;
+}
+
// Initialize the graph if all inputs have formats set. If it's already
// initialized, or can't be initialized yet, do nothing.
static void init_graph(struct lavfi *c)
@@ -478,6 +487,15 @@ static void init_graph(struct lavfi *c)
assert(!c->initialized);
if (init_pads(c)) {
+ if (c->hwdec_devs) {
+ struct mp_hwdec_ctx *hwdec = hwdec_devices_get_first(c->hwdec_devs);
+ for (int n = 0; n < c->graph->nb_filters; n++) {
+ AVFilterContext *filter = c->graph->filters[n];
+ if (hwdec && hwdec->av_device_ref)
+ filter->hw_device_ctx = av_buffer_ref(hwdec->av_device_ref);
+ }
+ }
+
// And here the actual libavfilter initialization happens.
if (avfilter_graph_config(c->graph, NULL) < 0) {
MP_FATAL(c, "failed to configure the filter graph\n");