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:
wm4 2017-01-25 08:32:35 +01:00
parent 04376fa024
commit 39adaf3dcc
1 changed files with 7 additions and 5 deletions

View File

@ -174,11 +174,13 @@ static bool recreate_graph(struct vf_instance *vf, struct mp_image_params *fmt)
if (graph_parse(graph, p->cfg_graph, inputs, outputs, NULL) < 0)
goto error;
struct mp_hwdec_ctx *hwdec = hwdec_devices_get_first(vf->hwdec_devs);
for (int n = 0; n < graph->nb_filters; n++) {
AVFilterContext *filter = graph->filters[n];
if (hwdec && hwdec->av_device_ref)
filter->hw_device_ctx = av_buffer_ref(hwdec->av_device_ref);
if (vf->hwdec_devs) {
struct mp_hwdec_ctx *hwdec = hwdec_devices_get_first(vf->hwdec_devs);
for (int n = 0; n < graph->nb_filters; n++) {
AVFilterContext *filter = graph->filters[n];
if (hwdec && hwdec->av_device_ref)
filter->hw_device_ctx = av_buffer_ref(hwdec->av_device_ref);
}
}
if (avfilter_graph_config(graph, NULL) < 0)