| 853 | } |
| 854 | |
| 855 | static av_cold int encode_init(AVCodecContext *avctx) |
| 856 | { |
| 857 | ProresVulkanContext *pv = avctx->priv_data; |
| 858 | ProresContext *ctx = &pv->ctx; |
| 859 | int err = 0, i, q; |
| 860 | FFVulkanContext *vkctx = &pv->vkctx; |
| 861 | |
| 862 | /* Init vulkan */ |
| 863 | RET(ff_vk_init(vkctx, avctx, NULL, avctx->hw_frames_ctx)); |
| 864 | |
| 865 | pv->qf = ff_vk_qf_find(vkctx, VK_QUEUE_COMPUTE_BIT, 0); |
| 866 | if (!pv->qf) { |
| 867 | av_log(avctx, AV_LOG_ERROR, "Device has no compute queues!\n"); |
| 868 | return AVERROR(ENOTSUP); |
| 869 | } |
| 870 | |
| 871 | RET(ff_vk_exec_pool_init(vkctx, pv->qf, &pv->e, 1, 0, 0, 0, NULL)); |
| 872 | |
| 873 | pv->transfer_qf = ff_vk_qf_find(vkctx, VK_QUEUE_TRANSFER_BIT, 0); |
| 874 | if (!pv->transfer_qf) { |
| 875 | av_log(avctx, AV_LOG_ERROR, "Device has no transfer queues!\n"); |
| 876 | return err; |
| 877 | } |
| 878 | |
| 879 | RET(ff_vk_exec_pool_init(vkctx, pv->transfer_qf, &pv->transfer_exec_pool, |
| 880 | pv->async_depth, 0, 0, 0, NULL)); |
| 881 | |
| 882 | /* Init common prores structures */ |
| 883 | err = ff_prores_kostya_encode_init(avctx, ctx, vkctx->frames->sw_format); |
| 884 | if (err < 0) |
| 885 | return err; |
| 886 | |
| 887 | /* Temporary frame */ |
| 888 | pv->frame = av_frame_alloc(); |
| 889 | if (!pv->frame) |
| 890 | return AVERROR(ENOMEM); |
| 891 | |
| 892 | /* Async data pool */ |
| 893 | pv->async_depth = pv->e.pool_size; |
| 894 | pv->exec_ctx_info = av_calloc(pv->async_depth, sizeof(*pv->exec_ctx_info)); |
| 895 | if (!pv->exec_ctx_info) |
| 896 | return AVERROR(ENOMEM); |
| 897 | for (int i = 0; i < pv->async_depth; i++) |
| 898 | pv->e.contexts[i].opaque = &pv->exec_ctx_info[i]; |
| 899 | |
| 900 | /* Compile shaders used by encoder */ |
| 901 | init_slice_data_pipeline(pv, &pv->slice_data_shd[0], 2); |
| 902 | init_slice_data_pipeline(pv, &pv->slice_data_shd[1], 4); |
| 903 | init_estimate_slice_pipeline(pv, &pv->estimate_slice_shd); |
| 904 | init_trellis_node_pipeline(pv, &pv->trellis_node_shd); |
| 905 | init_encode_slice_pipeline(pv, &pv->encode_slice_shd); |
| 906 | |
| 907 | if (ctx->alpha_bits) |
| 908 | init_alpha_data_pipeline(pv, &pv->alpha_data_shd); |
| 909 | |
| 910 | /* Create prores data tables uniform buffer. */ |
| 911 | RET(ff_vk_create_buf(vkctx, &pv->prores_data_tables_buf, |
| 912 | sizeof(ProresDataTables), NULL, NULL, |
nothing calls this directly
no test coverage detected