FFmpeg
Loading...
Searching...
No Matches
vf_fruc_vulkan.c File Reference

Frame rate up-conversion filter that synthesises intermediate frames using the NVIDIA Vulkan optical flow extension (VK_NV_optical_flow). More...

#include "libavutil/avassert.h"
#include "libavutil/eval.h"
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "vulkan_filter.h"
#include "filters.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  GrayscalePushData
 
struct  InterpolatePushData
 
struct  FRUCFlowSlot
 
struct  FRUCVulkanContext
 

Macros

#define FRUC_NB_SLOTS   2
 
#define OFFSET(x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Enumerations

enum  var_name { VAR_SOURCE_FPS , VARS_NB }
 

Functions

 AVFILTER_DEFINE_CLASS (fruc_vulkan)
 
static VkFormat pick_of_format (FRUCVulkanContext *s, VkOpticalFlowUsageFlagsNV usage, VkFormat preferred)
 
static int create_of_image (FRUCVulkanContext *s, VkImage *img, VkDeviceMemory *mem, VkImageView *view, VkFormat format, int width, int height, VkOpticalFlowUsageFlagsNV of_usage, VkImageUsageFlags usage, VkImageCreateFlags create_flags)
 
static int init_image_layouts (FRUCVulkanContext *s)
 
static int packed_rgb_channel (const AVPixFmtDescriptor *desc, VkFormat vkfmt, int comp)
 
static int packed_luma_channel (const AVPixFmtDescriptor *desc, VkFormat vkfmt)
 
static av_cold int check_sw_format (AVFilterContext *avctx, enum AVPixelFormat sw_format)
 
static int qf_transfer_preserves (FFVulkanContext *vkctx, uint32_t from, uint32_t to)
 
static av_cold int init_filter (AVFilterContext *avctx)
 
static void of_image_barrier (VkImageMemoryBarrier2 *bar, VkImage img, VkPipelineStageFlags2 src_stage, VkAccessFlags2 src_access, VkPipelineStageFlags2 dst_stage, VkAccessFlags2 dst_access)
 
static int compute_flow (AVFilterContext *avctx)
 
static void plane_wh (const AVPixFmtDescriptor *desc, int width, int height, int plane, uint32_t *w, uint32_t *h)
 
static int interpolate_frame (AVFilterContext *avctx, AVFrame *out, float t)
 
static int copy_frame (AVFilterContext *avctx, AVFrame *out, AVFrame *src)
 
static int passthrough_frame (AVFilterContext *ctx, AVFrame **work, AVFrame *src)
 
static int process_work_frame (AVFilterContext *ctx)
 
static int activate (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static av_cold int init (AVFilterContext *avctx)
 
static av_cold void uninit (AVFilterContext *avctx)
 

Variables

const unsigned char ff_fruc_grayscale_comp_spv_data []
 
const unsigned int ff_fruc_grayscale_comp_spv_len
 
const unsigned char ff_fruc_interpolate_comp_spv_data []
 
const unsigned int ff_fruc_interpolate_comp_spv_len
 
static const char *const var_names []
 
static const AVOption fruc_vulkan_options []
 
static const AVFilterPad fruc_vulkan_inputs []
 
static const AVFilterPad fruc_vulkan_outputs []
 
const FFFilter ff_vf_fruc_vulkan
 

Detailed Description

Frame rate up-conversion filter that synthesises intermediate frames using the NVIDIA Vulkan optical flow extension (VK_NV_optical_flow).

Definition in file vf_fruc_vulkan.c.

Macro Definition Documentation

◆ FRUC_NB_SLOTS

#define FRUC_NB_SLOTS   2

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 162 of file vf_fruc_vulkan.c.

◆ FLAGS

Definition at line 163 of file vf_fruc_vulkan.c.

Enumeration Type Documentation

◆ var_name

enum var_name
Enumerator
VAR_SOURCE_FPS 
VARS_NB 

Definition at line 50 of file vf_fruc_vulkan.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( fruc_vulkan )

◆ pick_of_format()

static VkFormat pick_of_format ( FRUCVulkanContext * s,
VkOpticalFlowUsageFlagsNV usage,
VkFormat preferred )
static

Definition at line 191 of file vf_fruc_vulkan.c.

Referenced by init_filter().

◆ create_of_image()

static int create_of_image ( FRUCVulkanContext * s,
VkImage * img,
VkDeviceMemory * mem,
VkImageView * view,
VkFormat format,
int width,
int height,
VkOpticalFlowUsageFlagsNV of_usage,
VkImageUsageFlags usage,
VkImageCreateFlags create_flags )
static

Definition at line 232 of file vf_fruc_vulkan.c.

Referenced by init_filter().

◆ init_image_layouts()

static int init_image_layouts ( FRUCVulkanContext * s)
static

Definition at line 282 of file vf_fruc_vulkan.c.

Referenced by init_filter().

◆ packed_rgb_channel()

static int packed_rgb_channel ( const AVPixFmtDescriptor * desc,
VkFormat vkfmt,
int comp )
static

Definition at line 335 of file vf_fruc_vulkan.c.

Referenced by init_filter().

◆ packed_luma_channel()

static int packed_luma_channel ( const AVPixFmtDescriptor * desc,
VkFormat vkfmt )
static

Definition at line 354 of file vf_fruc_vulkan.c.

Referenced by init_filter().

◆ check_sw_format()

static av_cold int check_sw_format ( AVFilterContext * avctx,
enum AVPixelFormat sw_format )
static

Definition at line 367 of file vf_fruc_vulkan.c.

Referenced by init_filter().

◆ qf_transfer_preserves()

static int qf_transfer_preserves ( FFVulkanContext * vkctx,
uint32_t from,
uint32_t to )
static

Definition at line 404 of file vf_fruc_vulkan.c.

Referenced by init_filter().

◆ init_filter()

static av_cold int init_filter ( AVFilterContext * avctx)
static

Definition at line 415 of file vf_fruc_vulkan.c.

Referenced by config_output().

◆ of_image_barrier()

static void of_image_barrier ( VkImageMemoryBarrier2 * bar,
VkImage img,
VkPipelineStageFlags2 src_stage,
VkAccessFlags2 src_access,
VkPipelineStageFlags2 dst_stage,
VkAccessFlags2 dst_access )
static

Definition at line 865 of file vf_fruc_vulkan.c.

Referenced by compute_flow(), and interpolate_frame().

◆ compute_flow()

static int compute_flow ( AVFilterContext * avctx)
static

Definition at line 889 of file vf_fruc_vulkan.c.

Referenced by interpolate_frame().

◆ plane_wh()

static void plane_wh ( const AVPixFmtDescriptor * desc,
int width,
int height,
int plane,
uint32_t * w,
uint32_t * h )
static

Definition at line 1043 of file vf_fruc_vulkan.c.

Referenced by copy_frame(), and interpolate_frame().

◆ interpolate_frame()

static int interpolate_frame ( AVFilterContext * avctx,
AVFrame * out,
float t )
static

Definition at line 1054 of file vf_fruc_vulkan.c.

Referenced by process_work_frame().

◆ copy_frame()

static int copy_frame ( AVFilterContext * avctx,
AVFrame * out,
AVFrame * src )
static

Definition at line 1189 of file vf_fruc_vulkan.c.

Referenced by passthrough_frame().

◆ passthrough_frame()

static int passthrough_frame ( AVFilterContext * ctx,
AVFrame ** work,
AVFrame * src )
static

Definition at line 1264 of file vf_fruc_vulkan.c.

Referenced by process_work_frame().

◆ process_work_frame()

static int process_work_frame ( AVFilterContext * ctx)
static

Definition at line 1284 of file vf_fruc_vulkan.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 1348 of file vf_fruc_vulkan.c.

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 1425 of file vf_fruc_vulkan.c.

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 1435 of file vf_fruc_vulkan.c.

◆ init()

static av_cold int init ( AVFilterContext * avctx)
static

Definition at line 1511 of file vf_fruc_vulkan.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * avctx)
static

Definition at line 1520 of file vf_fruc_vulkan.c.

Variable Documentation

◆ ff_fruc_grayscale_comp_spv_data

const unsigned char ff_fruc_grayscale_comp_spv_data[]
extern

Referenced by init_filter().

◆ ff_fruc_grayscale_comp_spv_len

const unsigned int ff_fruc_grayscale_comp_spv_len
extern

Referenced by init_filter().

◆ ff_fruc_interpolate_comp_spv_data

const unsigned char ff_fruc_interpolate_comp_spv_data[]
extern

Referenced by init_filter().

◆ ff_fruc_interpolate_comp_spv_len

const unsigned int ff_fruc_interpolate_comp_spv_len
extern

Referenced by init_filter().

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"source_fps",
}
#define NULL
Definition coverity.c:32

Definition at line 45 of file vf_fruc_vulkan.c.

◆ fruc_vulkan_options

const AVOption fruc_vulkan_options[]
static
Initial value:
= {
{ "fps", "A string describing the desired output frame rate",
OFFSET(requested_frame_rate), AV_OPT_TYPE_STRING, { .str = "60" }, 0, 0, FLAGS },
{ "perf", "Optical flow performance level (quality versus speed)",
OFFSET(perf_level), AV_OPT_TYPE_INT, { .i64 = VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_SLOW_NV },
VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_SLOW_NV, VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_FAST_NV,
FLAGS, .unit = "perf" },
{ "slow", "Highest quality, slowest", 0, AV_OPT_TYPE_CONST,
{ .i64 = VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_SLOW_NV }, 0, 0, FLAGS, .unit = "perf" },
{ "medium", "Balanced quality and speed", 0, AV_OPT_TYPE_CONST,
{ .i64 = VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_MEDIUM_NV }, 0, 0, FLAGS, .unit = "perf" },
{ "fast", "Lowest quality, fastest", 0, AV_OPT_TYPE_CONST,
{ .i64 = VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_FAST_NV }, 0, 0, FLAGS, .unit = "perf" },
{ "grid", "Optical flow output grid size in pixels (coarser is faster)",
OFFSET(opt_grid_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 8, FLAGS, .unit = "grid" },
{ "auto", "Finest grid the device supports", 0, AV_OPT_TYPE_CONST,
{ .i64 = 0 }, 0, 0, FLAGS, .unit = "grid" },
{ "1", "1x1", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, .unit = "grid" },
{ "2", "2x2", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, FLAGS, .unit = "grid" },
{ "4", "4x4", 0, AV_OPT_TYPE_CONST, { .i64 = 4 }, 0, 0, FLAGS, .unit = "grid" },
{ "8", "8x8", 0, AV_OPT_TYPE_CONST, { .i64 = 8 }, 0, 0, FLAGS, .unit = "grid" },
{ NULL }
}
#define FLAGS
Definition cmdutils.c:598
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 165 of file vf_fruc_vulkan.c.

◆ fruc_vulkan_inputs

const AVFilterPad fruc_vulkan_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}
static int config_input(AVFilterLink *inlink)
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 1572 of file vf_fruc_vulkan.c.

◆ fruc_vulkan_outputs

const AVFilterPad fruc_vulkan_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 1580 of file vf_fruc_vulkan.c.

◆ ff_vf_fruc_vulkan

const FFFilter ff_vf_fruc_vulkan
Initial value:
= {
.p.name = "fruc_vulkan",
.p.description = NULL_IF_CONFIG_SMALL("Frame rate up-conversion using the Vulkan NV optical flow extension"),
.p.priv_class = &fruc_vulkan_class,
.priv_size = sizeof(FRUCVulkanContext),
.init = init,
.activate = activate,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
Definition avfilter.h:187
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition filters.h:208
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition filters.h:254
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
Definition pixfmt.h:379
static const AVFilterPad fruc_vulkan_outputs[]
static const AVFilterPad fruc_vulkan_inputs[]

Definition at line 1588 of file vf_fruc_vulkan.c.