summaryrefslogtreecommitdiff
path: root/libavfilter/vulkan.c
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2021-11-19 15:13:35 +0100
committerLynne <dev@lynne.ee>2021-11-19 16:47:26 +0100
commitf6dd30df242cbf0a59c9ddfe66b23dc0ddaede66 (patch)
treeca79fdef17d0a709e24e005f96a6d05c660d5503 /libavfilter/vulkan.c
parente7f3279ba0ecd89eded5f91cb3bf5754761966db (diff)
lavfi/vulkan: split off lavfi-specific code into vulkan_filter.c
The issue is that libavfilter depends on libavcodec, and when doing a static build, if libavcodec also includes "libavfilter/vulkan.c", then during link-time, compiling programs will fail as there would be multiple definitions of the same symbols in both libavfilter and libavcodec's object files. Linkers are, however, more permitting if both files that include a common file that's used as a template are one-to-one identical. Hence, to make both files the same in the future, export all avfilter specific functions to a separate file. There is some work in progress to make templated files like this be compiled only once, so this is not a long-term solution. This also removes a macro that could be used to toggle SPIRV compilation capability on #include-time, as this could cause the files to be different.
Diffstat (limited to 'libavfilter/vulkan.c')
-rw-r--r--libavfilter/vulkan.c173
1 files changed, 0 insertions, 173 deletions
diff --git a/libavfilter/vulkan.c b/libavfilter/vulkan.c
index 08e0c37cc4..fc8a1fa47b 100644
--- a/libavfilter/vulkan.c
+++ b/libavfilter/vulkan.c
@@ -16,177 +16,4 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "vulkan.h"
#include "libavutil/vulkan.c"
-
-static int vulkan_filter_set_device(AVFilterContext *avctx,
- AVBufferRef *device)
-{
- FFVulkanContext *s = avctx->priv;
-
- av_buffer_unref(&s->device_ref);
-
- s->device_ref = av_buffer_ref(device);
- if (!s->device_ref)
- return AVERROR(ENOMEM);
-
- s->device = (AVHWDeviceContext*)s->device_ref->data;
- s->hwctx = s->device->hwctx;
-
- return 0;
-}
-
-static int vulkan_filter_set_frames(AVFilterContext *avctx,
- AVBufferRef *frames)
-{
- FFVulkanContext *s = avctx->priv;
-
- av_buffer_unref(&s->frames_ref);
-
- s->frames_ref = av_buffer_ref(frames);
- if (!s->frames_ref)
- return AVERROR(ENOMEM);
-
- return 0;
-}
-
-int ff_vk_filter_config_input(AVFilterLink *inlink)
-{
- int err;
- AVFilterContext *avctx = inlink->dst;
- FFVulkanContext *s = avctx->priv;
- FFVulkanFunctions *vk = &s->vkfn;
- AVHWFramesContext *input_frames;
-
- if (!inlink->hw_frames_ctx) {
- av_log(avctx, AV_LOG_ERROR, "Vulkan filtering requires a "
- "hardware frames context on the input.\n");
- return AVERROR(EINVAL);
- }
-
- /* Extract the device and default output format from the first input. */
- if (avctx->inputs[0] != inlink)
- return 0;
-
- input_frames = (AVHWFramesContext *)inlink->hw_frames_ctx->data;
- if (input_frames->format != AV_PIX_FMT_VULKAN)
- return AVERROR(EINVAL);
-
- err = vulkan_filter_set_device(avctx, input_frames->device_ref);
- if (err < 0)
- return err;
- err = vulkan_filter_set_frames(avctx, inlink->hw_frames_ctx);
- if (err < 0)
- return err;
-
- s->extensions = ff_vk_extensions_to_mask(s->hwctx->enabled_dev_extensions,
- s->hwctx->nb_enabled_dev_extensions);
-
- err = ff_vk_load_functions(s->device, &s->vkfn, s->extensions, 1, 1);
- if (err < 0)
- return err;
-
- vk->GetPhysicalDeviceProperties(s->hwctx->phys_dev, &s->props);
- vk->GetPhysicalDeviceMemoryProperties(s->hwctx->phys_dev, &s->mprops);
-
- /* Default output parameters match input parameters. */
- s->input_format = input_frames->sw_format;
- if (s->output_format == AV_PIX_FMT_NONE)
- s->output_format = input_frames->sw_format;
- if (!s->output_width)
- s->output_width = inlink->w;
- if (!s->output_height)
- s->output_height = inlink->h;
-
- return 0;
-}
-
-int ff_vk_filter_config_output_inplace(AVFilterLink *outlink)
-{
- int err;
- AVFilterContext *avctx = outlink->src;
- FFVulkanContext *s = avctx->priv;
-
- av_buffer_unref(&outlink->hw_frames_ctx);
-
- if (!s->device_ref) {
- if (!avctx->hw_device_ctx) {
- av_log(avctx, AV_LOG_ERROR, "Vulkan filtering requires a "
- "Vulkan device.\n");
- return AVERROR(EINVAL);
- }
-
- err = vulkan_filter_set_device(avctx, avctx->hw_device_ctx);
- if (err < 0)
- return err;
- }
-
- outlink->hw_frames_ctx = av_buffer_ref(s->frames_ref);
- if (!outlink->hw_frames_ctx)
- return AVERROR(ENOMEM);
-
- outlink->w = s->output_width;
- outlink->h = s->output_height;
-
- return 0;
-}
-
-int ff_vk_filter_config_output(AVFilterLink *outlink)
-{
- int err;
- AVFilterContext *avctx = outlink->src;
- FFVulkanContext *s = avctx->priv;
- AVBufferRef *output_frames_ref;
- AVHWFramesContext *output_frames;
-
- av_buffer_unref(&outlink->hw_frames_ctx);
-
- if (!s->device_ref) {
- if (!avctx->hw_device_ctx) {
- av_log(avctx, AV_LOG_ERROR, "Vulkan filtering requires a "
- "Vulkan device.\n");
- return AVERROR(EINVAL);
- }
-
- err = vulkan_filter_set_device(avctx, avctx->hw_device_ctx);
- if (err < 0)
- return err;
- }
-
- output_frames_ref = av_hwframe_ctx_alloc(s->device_ref);
- if (!output_frames_ref) {
- err = AVERROR(ENOMEM);
- goto fail;
- }
- output_frames = (AVHWFramesContext*)output_frames_ref->data;
-
- output_frames->format = AV_PIX_FMT_VULKAN;
- output_frames->sw_format = s->output_format;
- output_frames->width = s->output_width;
- output_frames->height = s->output_height;
-
- err = av_hwframe_ctx_init(output_frames_ref);
- if (err < 0) {
- av_log(avctx, AV_LOG_ERROR, "Failed to initialise output "
- "frames: %d.\n", err);
- goto fail;
- }
-
- outlink->hw_frames_ctx = output_frames_ref;
- outlink->w = s->output_width;
- outlink->h = s->output_height;
-
- return 0;
-fail:
- av_buffer_unref(&output_frames_ref);
- return err;
-}
-
-int ff_vk_filter_init(AVFilterContext *avctx)
-{
- FFVulkanContext *s = avctx->priv;
-
- s->output_format = AV_PIX_FMT_NONE;
-
- return 0;
-}