FFmpeg
Loading...
Searching...
No Matches
vf_transpose_cuda.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/cuda_check.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "filters.h"
#include "transpose.h"
#include "video.h"
#include "cuda/load_helper.h"

Go to the source code of this file.

Data Structures

struct  TransposeCUDAContext
 

Macros

#define DIV_UP(a, b)
 
#define BLOCK_X   32
 
#define BLOCK_Y   16
 
#define CHECK_CU(x)
 
#define OFFSET(x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Functions

static av_cold int cudatranspose_init (AVFilterContext *ctx)
 
static av_cold void cudatranspose_uninit (AVFilterContext *ctx)
 
static av_cold int init_hwframe_ctx (TransposeCUDAContext *s, AVBufferRef *device_ctx, int width, int height, enum AVPixelFormat sw_format)
 
static int format_is_supported (enum AVPixelFormat fmt)
 
static int init_processing_chain (AVFilterContext *ctx, int out_width, int out_height)
 
static int cudatranspose_config_props (AVFilterLink *outlink)
 
static CUresult call_kernel (AVFilterContext *ctx, CUfunction cu_func, CUarray_format cu_format, int channels, int is_422_uv, CUdeviceptr dst0, CUdeviceptr dst1, int dst_width, int dst_height, int dst_pitch, CUdeviceptr src0, CUdeviceptr src1, int src_width, int src_height, int src_pitch)
 
static int cudatranspose_rotate (AVFilterContext *ctx, AVFrame *out, AVFrame *in)
 
static int cudatranspose_transpose (AVFilterContext *ctx, AVFrame *out, AVFrame *in)
 
static int cudatranspose_filter_frame (AVFilterLink *link, AVFrame *in)
 
static AVFramecudatranspose_get_video_buffer (AVFilterLink *inlink, int w, int h)
 
 AVFILTER_DEFINE_CLASS (cudatranspose)
 

Variables

static enum AVPixelFormat supported_formats []
 
static const AVOption cudatranspose_options []
 
static const AVFilterPad cudatranspose_inputs []
 
static const AVFilterPad cudatranspose_outputs []
 
const FFFilter ff_vf_transpose_cuda
 

Macro Definition Documentation

◆ DIV_UP

#define DIV_UP ( a,
b )
Value:
( ((a) + (b) - 1) / (b) )
int a
#define b
Definition input.c:43

Definition at line 37 of file vf_transpose_cuda.c.

Referenced by call_kernel().

◆ BLOCK_X

#define BLOCK_X   32

Definition at line 38 of file vf_transpose_cuda.c.

◆ BLOCK_Y

#define BLOCK_Y   16

Definition at line 39 of file vf_transpose_cuda.c.

◆ CHECK_CU

#define CHECK_CU ( x)
Value:
FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
static AVFormatContext * ctx
#define s(width, name)
Definition cbs_vp9.c:198
#define FF_CUDA_CHECK_DL(avclass, cudl, x)
Convenience wrapper for ff_cuda_check when dynamically loading cuda symbols.
Definition cuda_check.h:65

Definition at line 41 of file vf_transpose_cuda.c.

Referenced by call_kernel(), cudatranspose_config_props(), cudatranspose_filter_frame(), and cudatranspose_uninit().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 517 of file vf_transpose_cuda.c.

◆ FLAGS

Definition at line 518 of file vf_transpose_cuda.c.

Function Documentation

◆ cudatranspose_init()

static av_cold int cudatranspose_init ( AVFilterContext * ctx)
static

Definition at line 91 of file vf_transpose_cuda.c.

◆ cudatranspose_uninit()

static av_cold void cudatranspose_uninit ( AVFilterContext * ctx)
static

Definition at line 106 of file vf_transpose_cuda.c.

◆ init_hwframe_ctx()

static av_cold int init_hwframe_ctx ( TransposeCUDAContext * s,
AVBufferRef * device_ctx,
int width,
int height,
enum AVPixelFormat sw_format )
static

Definition at line 123 of file vf_transpose_cuda.c.

Referenced by init_processing_chain().

◆ format_is_supported()

static int format_is_supported ( enum AVPixelFormat fmt)
static

Definition at line 163 of file vf_transpose_cuda.c.

Referenced by init_processing_chain().

◆ init_processing_chain()

static int init_processing_chain ( AVFilterContext * ctx,
int out_width,
int out_height )
static

Definition at line 171 of file vf_transpose_cuda.c.

Referenced by cudatranspose_config_props().

◆ cudatranspose_config_props()

static int cudatranspose_config_props ( AVFilterLink * outlink)
static

Definition at line 212 of file vf_transpose_cuda.c.

◆ call_kernel()

static CUresult call_kernel ( AVFilterContext * ctx,
CUfunction cu_func,
CUarray_format cu_format,
int channels,
int is_422_uv,
CUdeviceptr dst0,
CUdeviceptr dst1,
int dst_width,
int dst_height,
int dst_pitch,
CUdeviceptr src0,
CUdeviceptr src1,
int src_width,
int src_height,
int src_pitch )
static

Definition at line 307 of file vf_transpose_cuda.c.

Referenced by cudatranspose_rotate().

◆ cudatranspose_rotate()

static int cudatranspose_rotate ( AVFilterContext * ctx,
AVFrame * out,
AVFrame * in )
static

Definition at line 373 of file vf_transpose_cuda.c.

Referenced by cudatranspose_transpose().

◆ cudatranspose_transpose()

static int cudatranspose_transpose ( AVFilterContext * ctx,
AVFrame * out,
AVFrame * in )
static

Definition at line 434 of file vf_transpose_cuda.c.

Referenced by cudatranspose_filter_frame().

◆ cudatranspose_filter_frame()

static int cudatranspose_filter_frame ( AVFilterLink * link,
AVFrame * in )
static

Definition at line 467 of file vf_transpose_cuda.c.

◆ cudatranspose_get_video_buffer()

static AVFrame * cudatranspose_get_video_buffer ( AVFilterLink * inlink,
int w,
int h )
static

Definition at line 508 of file vf_transpose_cuda.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( cudatranspose )

Variable Documentation

◆ supported_formats

enum AVPixelFormat supported_formats[]
static
Initial value:
= {
}
#define AV_PIX_FMT_0RGB32
Definition pixfmt.h:521
#define AV_PIX_FMT_P212
Definition pixfmt.h:624
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:545
#define AV_PIX_FMT_P210
Definition pixfmt.h:622
#define AV_PIX_FMT_P012
Definition pixfmt.h:609
#define AV_PIX_FMT_P216
Definition pixfmt.h:626
#define AV_PIX_FMT_P010
Definition pixfmt.h:608
#define AV_PIX_FMT_P016
Definition pixfmt.h:610
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:546
#define AV_PIX_FMT_YUV444P12MSB
Definition pixfmt.h:561
#define AV_PIX_FMT_BGR32
Definition pixfmt.h:519
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition pixfmt.h:96
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:198
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P10MSB
Definition pixfmt.h:560
#define AV_PIX_FMT_0BGR32
Definition pixfmt.h:522
#define AV_PIX_FMT_RGB32
Definition pixfmt.h:517
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548

Definition at line 43 of file vf_transpose_cuda.c.

◆ cudatranspose_options

const AVOption cudatranspose_options[]
static
Initial value:
= {
{ "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = TRANSPOSE_CCLOCK_FLIP }, 0, 6, FLAGS, .unit = "dir" },
{ "cclock_flip", "rotate counter-clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, 0, 0, FLAGS, .unit = "dir" },
{ "clock", "rotate clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK }, 0, 0, FLAGS, .unit = "dir" },
{ "cclock", "rotate counter-clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK }, 0, 0, FLAGS, .unit = "dir" },
{ "clock_flip", "rotate clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP }, 0, 0, FLAGS, .unit = "dir" },
{ "reversal", "rotate by half-turn", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_REVERSAL }, 0, 0, FLAGS, .unit = "dir" },
{ "hflip", "flip horizontally", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_HFLIP }, 0, 0, FLAGS, .unit = "dir" },
{ "vflip", "flip vertically", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_VFLIP }, 0, 0, FLAGS, .unit = "dir" },
{ "passthrough", "do not apply transposition if the input matches the specified geometry", OFFSET(passthrough), AV_OPT_TYPE_INT, { .i64 = TRANSPOSE_PT_TYPE_NONE }, 0, 2, FLAGS, .unit = "passthrough" },
{ "none", "always apply transposition", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_PT_TYPE_NONE }, 0, 0, FLAGS, .unit = "passthrough" },
{ "landscape", "preserve landscape geometry", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_PT_TYPE_LANDSCAPE }, 0, 0, FLAGS, .unit = "passthrough" },
{ "portrait", "preserve portrait geometry", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_PT_TYPE_PORTRAIT }, 0, 0, FLAGS, .unit = "passthrough" },
{ NULL },
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#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
@ TRANSPOSE_CLOCK_FLIP
Definition transpose.h:34
@ TRANSPOSE_HFLIP
Definition transpose.h:36
@ TRANSPOSE_CCLOCK
Definition transpose.h:33
@ TRANSPOSE_CCLOCK_FLIP
Definition transpose.h:31
@ TRANSPOSE_VFLIP
Definition transpose.h:37
@ TRANSPOSE_REVERSAL
Definition transpose.h:35
@ TRANSPOSE_CLOCK
Definition transpose.h:32
@ TRANSPOSE_PT_TYPE_NONE
Definition transpose.h:25
@ TRANSPOSE_PT_TYPE_PORTRAIT
Definition transpose.h:27
@ TRANSPOSE_PT_TYPE_LANDSCAPE
Definition transpose.h:26

Definition at line 520 of file vf_transpose_cuda.c.

◆ cudatranspose_inputs

const AVFilterPad cudatranspose_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = cudatranspose_filter_frame,
.get_buffer.video = cudatranspose_get_video_buffer,
},
}
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static AVFrame * cudatranspose_get_video_buffer(AVFilterLink *inlink, int w, int h)
static int cudatranspose_filter_frame(AVFilterLink *link, AVFrame *in)

Definition at line 540 of file vf_transpose_cuda.c.

◆ cudatranspose_outputs

const AVFilterPad cudatranspose_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = cudatranspose_config_props,
},
}
static int cudatranspose_config_props(AVFilterLink *outlink)

Definition at line 549 of file vf_transpose_cuda.c.

◆ ff_vf_transpose_cuda

const FFFilter ff_vf_transpose_cuda
Initial value:
= {
.p.name = "transpose_cuda",
.p.description = NULL_IF_CONFIG_SMALL("Transpose input video using CUDA"),
.p.priv_class = &cudatranspose_class,
.priv_size = sizeof(TransposeCUDAContext),
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}
#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_CUDA
HW acceleration through CUDA.
Definition pixfmt.h:260
static av_cold void cudatranspose_uninit(AVFilterContext *ctx)
static av_cold int cudatranspose_init(AVFilterContext *ctx)
static const AVFilterPad cudatranspose_inputs[]
static const AVFilterPad cudatranspose_outputs[]

Definition at line 557 of file vf_transpose_cuda.c.