mirror of https://github.com/mpv-player/mpv
vf_lavfi: don't crash with VOs without hardware decoding support
When playing with VOs which do not provide mp_hwdec_ctx, vf->hwdec_devs will remain NULL. This would make it crash on hwdec_devices_get_first(), even if no hardware decoding or filters using hardware decoding were involved. Fixes #4064.
This commit is contained in:
parent
04376fa024
commit
39adaf3dcc
|
@ -174,12 +174,14 @@ static bool recreate_graph(struct vf_instance *vf, struct mp_image_params *fmt)
|
||||||
if (graph_parse(graph, p->cfg_graph, inputs, outputs, NULL) < 0)
|
if (graph_parse(graph, p->cfg_graph, inputs, outputs, NULL) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (vf->hwdec_devs) {
|
||||||
struct mp_hwdec_ctx *hwdec = hwdec_devices_get_first(vf->hwdec_devs);
|
struct mp_hwdec_ctx *hwdec = hwdec_devices_get_first(vf->hwdec_devs);
|
||||||
for (int n = 0; n < graph->nb_filters; n++) {
|
for (int n = 0; n < graph->nb_filters; n++) {
|
||||||
AVFilterContext *filter = graph->filters[n];
|
AVFilterContext *filter = graph->filters[n];
|
||||||
if (hwdec && hwdec->av_device_ref)
|
if (hwdec && hwdec->av_device_ref)
|
||||||
filter->hw_device_ctx = av_buffer_ref(hwdec->av_device_ref);
|
filter->hw_device_ctx = av_buffer_ref(hwdec->av_device_ref);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (avfilter_graph_config(graph, NULL) < 0)
|
if (avfilter_graph_config(graph, NULL) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
Loading…
Reference in New Issue