diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-03-15 19:09:11 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-03-24 10:23:52 +0100 |
commit | 3f63685c3554aea7f72bab1fdbde440820816d37 (patch) | |
tree | c99e10a11043d9c8e5af16403240ad1d7641fc28 /fftools/ffmpeg_hw.c | |
parent | 632c34993195f716e9fa575af3de80d07fd50991 (diff) |
fftools/ffmpeg: supply hw_device_ctx to filters before initializing them
This is more correct, but was not possible before the recently-added
filtergraph parsing API.
Also, only pass hw devices to filters that are flagged as capable of
using them.
Tested-by: Niklas Haas
Diffstat (limited to 'fftools/ffmpeg_hw.c')
-rw-r--r-- | fftools/ffmpeg_hw.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index 88fa782470..e67145211c 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -548,17 +548,14 @@ int hwaccel_decode_init(AVCodecContext *avctx) return 0; } -int hw_device_setup_for_filter(FilterGraph *fg) +AVBufferRef *hw_device_for_filter(void) { - HWDevice *dev; - int i; - // Pick the last hardware device if the user doesn't pick the device for // filters explicitly with the filter_hw_device option. if (filter_hw_device) - dev = filter_hw_device; + return filter_hw_device->device_ref; else if (nb_hw_devices > 0) { - dev = hw_devices[nb_hw_devices - 1]; + HWDevice *dev = hw_devices[nb_hw_devices - 1]; if (nb_hw_devices > 1) av_log(NULL, AV_LOG_WARNING, "There are %d hardware devices. device " @@ -567,17 +564,9 @@ int hw_device_setup_for_filter(FilterGraph *fg) "%s is not usable for filters.\n", nb_hw_devices, dev->name, av_hwdevice_get_type_name(dev->type), dev->name); - } else - dev = NULL; - if (dev) { - for (i = 0; i < fg->graph->nb_filters; i++) { - fg->graph->filters[i]->hw_device_ctx = - av_buffer_ref(dev->device_ref); - if (!fg->graph->filters[i]->hw_device_ctx) - return AVERROR(ENOMEM); - } + return dev->device_ref; } - return 0; + return NULL; } |