summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--player/lavfi.c18
-rw-r--r--player/lavfi.h1
-rw-r--r--player/video.c3
3 files changed, 22 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");
diff --git a/player/lavfi.h b/player/lavfi.h
index d39ecb0219..0f2ae7705f 100644
--- a/player/lavfi.h
+++ b/player/lavfi.h
@@ -22,6 +22,7 @@ bool lavfi_get_connected(struct lavfi_pad *pad);
bool lavfi_process(struct lavfi *c);
bool lavfi_has_failed(struct lavfi *c);
void lavfi_seek_reset(struct lavfi *c);
+void lavfi_set_hwdec_devs(struct lavfi *c, struct mp_hwdec_devices *hwdevs);
int lavfi_request_frame_a(struct lavfi_pad *pad, struct mp_audio **out_aframe);
int lavfi_request_frame_v(struct lavfi_pad *pad, struct mp_image **out_vframe);
bool lavfi_needs_input(struct lavfi_pad *pad);
diff --git a/player/video.c b/player/video.c
index 6ea3e4c6e8..ee0e89c93a 100644
--- a/player/video.c
+++ b/player/video.c
@@ -496,6 +496,9 @@ int reinit_video_chain_src(struct MPContext *mpctx, struct lavfi_pad *src)
vo_c->hwdec_devs = vo_c->vo->hwdec_devs;
+ if (mpctx->lavfi)
+ lavfi_set_hwdec_devs(mpctx->lavfi, vo_c->hwdec_devs);
+
vo_c->filter_src = src;
if (!vo_c->filter_src) {
vo_c->track = track;