From patchwork Sun Oct 29 02:23:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Zhili X-Patchwork-Id: 44422 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dd83:b0:15d:8365:d4b8 with SMTP id kw3csp727092pzb; Sat, 28 Oct 2023 19:24:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEQfWfqjTgzGK0nfbrMDbJ2OO2TYBIpIirkMZkL38boPyKW45Zs4z5nwitzF7Ak0JOR50a X-Received: by 2002:a17:907:e92:b0:9bf:60f9:9b7f with SMTP id ho18-20020a1709070e9200b009bf60f99b7fmr6011684ejc.4.1698546265943; Sat, 28 Oct 2023 19:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698546265; cv=none; d=google.com; s=arc-20160816; b=EYtMzrkUje6XEuXukIq0Jzp4BrOM7dqATjw+zqAkqIy7K52tAviy2NVb8G6i+cnIyJ UOpSHnafR3UPP9VP/YG6hid+zzJ/GUnC2lVA2M1rImEZ9ccOsY0ykb/vUj+67e3MQZvg TenKPG8IYddhjWxa35i//76IqnLbTgIpDlbIAuiCN9C/UzLl+jHI3BIJ+ZPXyhpyhzeM bhVu+PSd00ge+wC5Rby1Ufu2DeL/zIXyXKRBIzYIi0vWvTEAP8tYuXZSjYUHBgCyM4U4 lBYp+hW9OBKCHxXa6l9XHT8iwEokHCd/REjMn01uM3hTeHSCfGlyOfKAPjikmNuxjl/0 54Sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to:date :to:from:message-id:dkim-signature:delivered-to; bh=tt1dP2h88hFGwVVNVBxZLUzI7CMlaxZtXUcBtFEJtHY=; fh=HnHYuZ9XgUo86ZRXTLWWmQxhslYEI9B9taZ5X1DLFfc=; b=x0kTq37/R9Y1v+5HGPwOJ9vzxMZv4AUP4EIzxqCAxsWrrG6ZDm+eV0tCW5O7ysFeNB RRHKHEHmnYsP1p7yNylXu0gho7JjOUYMB/ztqP+65H3Zcfd3pHFzqePlN451zlIjLDNI f6NJAydAVRvxDkOFjtkizE8Fj2XLZMULjbwIIZOu0Vt6ZRCSypnJUwlMhP55TqD5uiaL o2g60MITqC4xLvhE2XlSCeRITSuXQx3lQ+AIRScjY+zOq3pfh/K1MKHNwhAJkAmCBzl8 qLkkvR3a39pBi2nTfrpNzo7dxGmQtUdiD4U41uS3dSX25z5d0NGkDmqwEPHAALdB6dIS Swmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=SYz5tuOf; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z26-20020a17090674da00b009be5c079196si2147212ejl.461.2023.10.28.19.24.25; Sat, 28 Oct 2023 19:24:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=SYz5tuOf; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9607D68CB40; Sun, 29 Oct 2023 04:24:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-236.mail.qq.com (out203-205-221-236.mail.qq.com [203.205.221.236]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 57EC368C9EA for ; Sun, 29 Oct 2023 04:23:59 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1698546230; bh=qBxoNnTJU8umS8XylqTai+1sNxLJtid+ZASp1X85D9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SYz5tuOflmzT3etJp+BK6yovsEmcb8/LsDvCLwt4aY1sgt3gRVZNxJMSxwx8c0SyO rQOqcbTGl8f8LhMx07EtlRFx9DG27AR/0WRqbRcOcteOmgjs/dGxRZHWM5unK1UzvQ 62wmaiqOMZ4rAAJ4RxQxaHSsJd03kbpqKA3Tls1o= Received: from localhost.localdomain ([113.118.105.197]) by newxmesmtplogicsvrszc2-0.qq.com (NewEsmtp) with SMTP id 5F1BE4ED; Sun, 29 Oct 2023 10:23:49 +0800 X-QQ-mid: xmsmtpt1698546229tar32wqhp Message-ID: X-QQ-XMAILINFO: MesT5uKpDagV57vacPVAevX8D/VsicibNJElP4Uofyl/9NzRug4FWtIG7HbdM4 aMrlV5ZXYya52hh9l68KpWlnhag0TWF/4JGfiqxwQLx+4ngbAOL9+iN7RmZeH6JoeYRSDTnEqXrD PHWOPnCS5BtkLO69hM9zNLQKhtqv7Wz4u98B1KEfpxaioT98gA4L4+bMxIfyltDlI+u3i5fwMiJm 0PHbpbh4Vdpb+TQAxsgf+WJ1+U5Ksrb+wvywoBae9sTUOSj4V8+dDu/Vl3cxir+x6gJ/4NQG0ExU 4bV0dZCJ+90hB4JDa+EnVwUQ1yAf7VvaFEnaPP2/M4+96MxDaxrsfh8xUP+Ann/JjIrdaNRNsa5T Yb5ofPdQXFcqYjVih9AQxuMirhBFReLdWLPMZcRyUnH4H0s8Wn2iCq7ndP0hLwoFiK4EAWygIA0a E67u4zHRHZOQodjpSK0Yluu5mYnvisxzXD6QaP/6YCehH1pnNXj7zbvNHXsxiHhssBu530dTfPwc klHXpfZ6MdjoPkGS+S4zbQpi70wMqx1Mhp5+1TBZCRMsaHVzd8nwRmEyJ/Wk3iyxzNGgQk7paBUW Sqv6lzZS0w2gQdBQyyp4gEbDNZoKxpQfdsEAoHn0DNjQuUHegai0CFLWD1i+ZyVNGEN+nKvVcQCY 0AErPqUYU0rAFcqkFzSyNQyydpx3ZNFW2JQVewE/Rj65A0GRGRqj3xbCtUMX4u52ZDyhZaNg6KXx FSKhjgzgLSusOCxx6bFt9IrhwdD3v37FQy83D3PfJxvIGSDXNL7rF0jjLvGzXGNY1fjpnpp+BB7X P0ZKuhI8r0xlCk8pInX7HVSlhz8gY/dMPeaTxprHcsQnvKQZSxk0MbuOAQGe3mZU+mgMULvAYZFo IkE2XlH6OI7Dq4q8y6Kf+jlUsKdiBxthv8v0YW73EOwUdYg9esjEdVd+z8VmGBdL2wXPb0Io8hAy Kg2fBtmijM0pJH5k8iXfIVgx4um7hWgyegMrl3/QtqhcyUZbnUApALo/8bgYGi X-QQ-XMRINFO: MPJ6Tf5t3I/ycC2BItcBVIA= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Sun, 29 Oct 2023 10:23:46 +0800 X-OQ-MSGID: <20231029022347.15243-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 1/2] fftools/ffplay: add vulkan renderer via libplacebo X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Zhao Zhili Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: QDRt/962Fel0 From: Zhao Zhili --- configure | 2 +- fftools/Makefile | 2 + fftools/ffplay.c | 46 ++++++- fftools/ffplay_renderer.c | 271 ++++++++++++++++++++++++++++++++++++++ fftools/ffplay_renderer.h | 38 ++++++ 5 files changed, 353 insertions(+), 6 deletions(-) create mode 100644 fftools/ffplay_renderer.c create mode 100644 fftools/ffplay_renderer.h diff --git a/configure b/configure index f494da204c..55329a5037 100755 --- a/configure +++ b/configure @@ -3903,7 +3903,7 @@ ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter ffmpeg_suggest="ole32 psapi shell32" ffplay_deps="avcodec avformat avfilter swscale swresample sdl2" ffplay_select="crop_filter transpose_filter hflip_filter vflip_filter rotate_filter" -ffplay_suggest="shell32" +ffplay_suggest="shell32 libplacebo vulkan" ffprobe_deps="avcodec avformat" ffprobe_suggest="shell32" diff --git a/fftools/Makefile b/fftools/Makefile index 56820e6bc8..3c763e3db9 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -22,6 +22,8 @@ OBJS-ffmpeg += \ fftools/sync_queue.o \ fftools/thread_queue.o \ +OBJS-ffplay += fftools/ffplay_renderer.o + define DOFFTOOL OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes) ifdef HAVE_GNU_WINDRES diff --git a/fftools/ffplay.c b/fftools/ffplay.c index d8c69e10bc..305d72d8b8 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -58,6 +58,7 @@ #include #include "cmdutils.h" +#include "ffplay_renderer.h" #include "opt_common.h" const char program_name[] = "ffplay"; @@ -350,6 +351,7 @@ static char *afilters = NULL; static int autorotate = 1; static int find_stream_info = 1; static int filter_nbthreads = 0; +static int enable_vulkan = 0; /* current context */ static int is_full_screen; @@ -362,6 +364,8 @@ static SDL_Renderer *renderer; static SDL_RendererInfo renderer_info = {0}; static SDL_AudioDeviceID audio_dev; +static VkRenderer *vk_renderer; + static const struct TextureFormatEntry { enum AVPixelFormat format; int texture_fmt; @@ -954,6 +958,11 @@ static void video_image_display(VideoState *is) SDL_Rect rect; vp = frame_queue_peek_last(&is->pictq); + if (vk_renderer) { + vk_renderer_display(vk_renderer, vp->frame); + return; + } + if (is->subtitle_st) { if (frame_queue_nb_remaining(&is->subpq) > 0) { sp = frame_queue_peek(&is->subpq); @@ -1289,6 +1298,8 @@ static void do_exit(VideoState *is) } if (renderer) SDL_DestroyRenderer(renderer); + if (vk_renderer) + vk_renderer_destroy(vk_renderer); if (window) SDL_DestroyWindow(window); uninit_opts(); @@ -3447,6 +3458,8 @@ static void event_loop(VideoState *cur_stream) SDL_DestroyTexture(cur_stream->vis_texture); cur_stream->vis_texture = NULL; } + if (vk_renderer) + vk_renderer_resize(vk_renderer, screen_width, screen_height); case SDL_WINDOWEVENT_EXPOSED: cur_stream->force_refresh = 1; } @@ -3611,6 +3624,7 @@ static const OptionDef options[] = { { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info }, "read and decode the streams to fill missing information with heuristics" }, { "filter_threads", HAS_ARG | OPT_INT | OPT_EXPERT, { &filter_nbthreads }, "number of filter threads per graph" }, + { "enable_vulkan", OPT_BOOL, { &enable_vulkan }, "enable vulkan render" }, { NULL, }, }; @@ -3725,9 +3739,31 @@ int main(int argc, char **argv) #ifdef SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0"); #endif + if (enable_vulkan) { + vk_renderer = vk_get_renderer(); + if (vk_renderer) { +#if SDL_VERSION_ATLEAST(2, 0, 6) + flags |= SDL_WINDOW_VULKAN; +#endif + } else { + av_log(NULL, AV_LOG_WARNING, "Doesn't support vulkan renderer, fallback to SDL renderer\n"); + enable_vulkan = 0; + } + } window = SDL_CreateWindow(program_name, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, default_width, default_height, flags); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); - if (window) { + if (!window) { + av_log(NULL, AV_LOG_FATAL, "Failed to create window: %s", SDL_GetError()); + do_exit(NULL); + } + + if (vk_renderer) { + ret = vk_renderer_create(vk_renderer, window); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "Failed to create vulkan renderer, %s\n", av_err2str(ret)); + do_exit(NULL); + } + } else { renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); if (!renderer) { av_log(NULL, AV_LOG_WARNING, "Failed to initialize a hardware accelerated renderer: %s\n", SDL_GetError()); @@ -3737,10 +3773,10 @@ int main(int argc, char **argv) if (!SDL_GetRendererInfo(renderer, &renderer_info)) av_log(NULL, AV_LOG_VERBOSE, "Initialized %s renderer.\n", renderer_info.name); } - } - if (!window || !renderer || !renderer_info.num_texture_formats) { - av_log(NULL, AV_LOG_FATAL, "Failed to create window or renderer: %s", SDL_GetError()); - do_exit(NULL); + if (!renderer || !renderer_info.num_texture_formats) { + av_log(NULL, AV_LOG_FATAL, "Failed to create window or renderer: %s", SDL_GetError()); + do_exit(NULL); + } } } diff --git a/fftools/ffplay_renderer.c b/fftools/ffplay_renderer.c new file mode 100644 index 0000000000..49e5516d5d --- /dev/null +++ b/fftools/ffplay_renderer.c @@ -0,0 +1,271 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "ffplay_renderer.h" + +#define HAVE_VULKAN_RENDERER (SDL_VERSION_ATLEAST(2, 0, 6) && CONFIG_LIBPLACEBO) + +#if HAVE_VULKAN_RENDERER + +#include +#include +#include +#include + +#endif + +struct VkRenderer { + const AVClass *class; + + int (*create)(VkRenderer *renderer, SDL_Window *window); + + int (*display)(VkRenderer *renderer, AVFrame *frame); + + int (*resize)(VkRenderer *renderer, int width, int height); + + void (*destroy)(VkRenderer *renderer); +}; + +#if HAVE_VULKAN_RENDERER + +typedef struct RendererContext { + VkRenderer api; + pl_vk_inst vk_inst; + pl_vulkan pl_vk; + pl_swapchain swapchain; + VkSurfaceKHR vk_surface; + pl_renderer renderer; + pl_tex tex[4]; + + pl_log vk_log; +} RendererContext; + +static void vk_log_cb(void *log_priv, enum pl_log_level level, const char *msg) { + static const int level_map[] = { + AV_LOG_QUIET, + AV_LOG_FATAL, + AV_LOG_ERROR, + AV_LOG_WARNING, + AV_LOG_INFO, + AV_LOG_DEBUG, + AV_LOG_TRACE, + }; + + if (level > 0 && level < FF_ARRAY_ELEMS(level_map)) + av_log(log_priv, level_map[level], "%s\n", msg); +} + +static int create(VkRenderer *renderer, SDL_Window *window) +{ + int ret = 0; + unsigned ext_num = 0; + const char **ext = NULL; + int w, h; + struct pl_log_params vk_log_params = { + .log_cb = vk_log_cb, + .log_level = PL_LOG_WARN, + .log_priv = renderer, + }; + RendererContext *ctx = (RendererContext *)renderer; + + if (!SDL_Vulkan_GetInstanceExtensions(window, &ext_num, NULL)) { + av_log(NULL, AV_LOG_FATAL, "Failed to get vulkan extensions: %s\n", SDL_GetError()); + return AVERROR_EXTERNAL; + } + + ext = av_calloc(ext_num, sizeof(*ext)); + if (!ext) { + ret = AVERROR(ENOMEM); + goto out; + } + + SDL_Vulkan_GetInstanceExtensions(window, &ext_num, ext); + + ctx->vk_log = pl_log_create(PL_API_VER, &vk_log_params); + ctx->vk_inst = pl_vk_inst_create(ctx->vk_log, pl_vk_inst_params( + .get_proc_addr = SDL_Vulkan_GetVkGetInstanceProcAddr(), + .debug = false, + .extensions = ext, + .num_extensions = ext_num, + )); + if (!ctx->vk_inst) { + ret = AVERROR_EXTERNAL; + goto out; + } + + if (!SDL_Vulkan_CreateSurface(window, ctx->vk_inst->instance, &ctx->vk_surface)) { + ret = AVERROR_EXTERNAL; + goto out; + } + + ctx->pl_vk = pl_vulkan_create(ctx->vk_log, pl_vulkan_params( + .instance = ctx->vk_inst->instance, + .get_proc_addr = ctx->vk_inst->get_proc_addr, + .surface = ctx->vk_surface, + .allow_software = false, + )); + if (!ctx->pl_vk) { + ret = AVERROR_EXTERNAL; + goto out; + } + + ctx->swapchain = pl_vulkan_create_swapchain(ctx->pl_vk, + pl_vulkan_swapchain_params(.surface = ctx->vk_surface, + .present_mode = VK_PRESENT_MODE_FIFO_KHR)); + + SDL_Vulkan_GetDrawableSize(window, &w, &h); + pl_swapchain_resize(ctx->swapchain, &w, &h); + + ctx->renderer = pl_renderer_create(ctx->vk_log, ctx->pl_vk->gpu); + if (!ctx->renderer) { + ret = AVERROR_EXTERNAL; + goto out; + } + ret = 0; + +out: + av_free(ext); + return ret; +} + +static int display(VkRenderer *renderer, AVFrame *frame) +{ + struct pl_swapchain_frame swap_frame = {0}; + struct pl_frame pl_frame = {0}; + struct pl_frame target = {0}; + RendererContext *ctx = (RendererContext *)renderer; + int ret = 0; + + if (!pl_map_avframe_ex(ctx->pl_vk->gpu, &pl_frame, pl_avframe_params( + .frame = frame, + .tex = ctx->tex))) { + av_log(NULL, AV_LOG_ERROR, "pl_map_avframe_ex failed\n"); + return AVERROR_EXTERNAL; + } + + if (!pl_swapchain_start_frame(ctx->swapchain, &swap_frame)) { + av_log(NULL, AV_LOG_ERROR, "start frame failed\n"); + ret = AVERROR_EXTERNAL; + goto out; + } + + pl_frame_from_swapchain(&target, &swap_frame); + if (!pl_render_image(ctx->renderer, &pl_frame, &target, &pl_render_default_params)) { + av_log(NULL, AV_LOG_ERROR, "pl_render_image failed\n"); + ret = AVERROR_EXTERNAL; + goto out; + } + + if (!pl_swapchain_submit_frame(ctx->swapchain)) { + av_log(NULL, AV_LOG_ERROR, "pl_swapchain_submit_frame failed\n"); + ret = AVERROR_EXTERNAL; + goto out; + } + pl_swapchain_swap_buffers(ctx->swapchain); + +out: + pl_unmap_avframe(ctx->pl_vk->gpu, &pl_frame); + return ret; +} + +static int resize(VkRenderer *renderer, int width, int height) +{ + RendererContext *ctx = (RendererContext *)renderer; + + if (!pl_swapchain_resize(ctx->swapchain, &width, &height)) + return AVERROR_EXTERNAL; + return 0; +} + +static void destroy(VkRenderer *renderer) +{ + PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR; + RendererContext *ctx = (RendererContext *)renderer; + + if (ctx->pl_vk) { + for (int i = 0; i < FF_ARRAY_ELEMS(ctx->tex); i++) + pl_tex_destroy(ctx->pl_vk->gpu, &ctx->tex[i]); + pl_renderer_destroy(&ctx->renderer); + pl_swapchain_destroy(&ctx->swapchain); + pl_vulkan_destroy(&ctx->pl_vk); + } + + if (ctx->vk_surface) { + vkDestroySurfaceKHR = (PFN_vkDestroySurfaceKHR) + ctx->vk_inst->get_proc_addr(ctx->vk_inst->instance, "vkDestroySurfaceKHR"); + vkDestroySurfaceKHR(ctx->vk_inst->instance, ctx->vk_surface, NULL); + ctx->vk_surface = NULL; + } + + pl_vk_inst_destroy(&ctx->vk_inst); + pl_log_destroy(&ctx->vk_log); +} + +static const AVClass vulkan_renderer_class = { + .class_name = "Vulkan Renderer", + .item_name = av_default_item_name, + .version = LIBAVUTIL_VERSION_INT, +}; + +VkRenderer *vk_get_renderer(void) +{ + RendererContext *ctx = av_mallocz(sizeof(*ctx)); + VkRenderer *renderer; + + if (!ctx) + return NULL; + + renderer = &ctx->api; + renderer->class = &vulkan_renderer_class; + renderer->create = create; + renderer->display = display; + renderer->resize = resize; + renderer->destroy = destroy; + + return renderer; +} + +#else + +VkRenderer *vk_get_renderer(void) +{ + return NULL; +} + +#endif + +int vk_renderer_create(VkRenderer *renderer, SDL_Window *window) +{ + return renderer->create(renderer, window); +} + +int vk_renderer_display(VkRenderer *renderer, AVFrame *frame) +{ + return renderer->display(renderer, frame); +} + +int vk_renderer_resize(VkRenderer *renderer, int width, int height) +{ + return renderer->resize(renderer, width, height); +} + +void vk_renderer_destroy(VkRenderer *renderer) +{ + renderer->destroy(renderer); +} diff --git a/fftools/ffplay_renderer.h b/fftools/ffplay_renderer.h new file mode 100644 index 0000000000..4029f154a9 --- /dev/null +++ b/fftools/ffplay_renderer.h @@ -0,0 +1,38 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef FFTOOLS_FFPLAY_RENDERER_H +#define FFTOOLS_FFPLAY_RENDERER_H + +#include + +#include "libavutil/frame.h" + +typedef struct VkRenderer VkRenderer; + +VkRenderer *vk_get_renderer(void); + +int vk_renderer_create(VkRenderer *renderer, SDL_Window *window); + +int vk_renderer_display(VkRenderer *renderer, AVFrame *frame); + +int vk_renderer_resize(VkRenderer *renderer, int width, int height); + +void vk_renderer_destroy(VkRenderer *renderer); + +#endif /* FFTOOLS_FFPLAY_RENDERER_H */