| 2649 | } |
| 2650 | |
| 2651 | static int create_hwaccel(AVBufferRef **device_ctx) |
| 2652 | { |
| 2653 | enum AVHWDeviceType type; |
| 2654 | int ret; |
| 2655 | AVBufferRef *vk_dev; |
| 2656 | |
| 2657 | *device_ctx = NULL; |
| 2658 | |
| 2659 | if (!hwaccel) |
| 2660 | return 0; |
| 2661 | |
| 2662 | type = av_hwdevice_find_type_by_name(hwaccel); |
| 2663 | if (type == AV_HWDEVICE_TYPE_NONE) |
| 2664 | return AVERROR(ENOTSUP); |
| 2665 | |
| 2666 | if (!vk_renderer) { |
| 2667 | av_log(NULL, AV_LOG_ERROR, "Vulkan renderer is not available\n"); |
| 2668 | return AVERROR(ENOTSUP); |
| 2669 | } |
| 2670 | |
| 2671 | ret = vk_renderer_get_hw_dev(vk_renderer, &vk_dev); |
| 2672 | if (ret < 0) |
| 2673 | return ret; |
| 2674 | |
| 2675 | ret = av_hwdevice_ctx_create_derived(device_ctx, type, vk_dev, 0); |
| 2676 | if (!ret) |
| 2677 | return 0; |
| 2678 | |
| 2679 | if (ret != AVERROR(ENOSYS)) |
| 2680 | return ret; |
| 2681 | |
| 2682 | av_log(NULL, AV_LOG_WARNING, "Derive %s from vulkan not supported.\n", hwaccel); |
| 2683 | ret = av_hwdevice_ctx_create(device_ctx, type, NULL, NULL, 0); |
| 2684 | return ret; |
| 2685 | } |
| 2686 | |
| 2687 | /* open a given stream. Return 0 if OK */ |
| 2688 | static int stream_component_open(VideoState *is, int stream_index) |
no test coverage detected