FFmpeg
Data Structures | Macros | Functions | Variables
vf_colorspace_cuda.c File Reference
#include <string.h>
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/cuda_check.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "scale_eval.h"
#include "video.h"
#include "cuda/load_helper.h"

Go to the source code of this file.

Data Structures

struct  CUDAColorspaceContext
 

Macros

#define DIV_UP(a, b)   (((a) + (b)-1) / (b))
 
#define BLOCKX   32
 
#define BLOCKY   16
 
#define CHECK_CU(x)   FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
 
#define OFFSET(x)   offsetof(CUDAColorspaceContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Functions

static av_cold int cudacolorspace_init (AVFilterContext *ctx)
 
static av_cold void cudacolorspace_uninit (AVFilterContext *ctx)
 
static av_cold int init_hwframe_ctx (CUDAColorspaceContext *s, AVBufferRef *device_ctx, int width, int height)
 
static int format_is_supported (enum AVPixelFormat fmt)
 
static av_cold int init_processing_chain (AVFilterContext *ctx, int width, int height)
 
static av_cold int cudacolorspace_load_functions (AVFilterContext *ctx)
 
static av_cold int cudacolorspace_config_props (AVFilterLink *outlink)
 
static int conv_cuda_convert (AVFilterContext *ctx, AVFrame *out, AVFrame *in)
 
static int cudacolorspace_conv (AVFilterContext *ctx, AVFrame *out, AVFrame *in)
 
static int cudacolorspace_filter_frame (AVFilterLink *link, AVFrame *in)
 

Variables

static enum AVPixelFormat supported_formats []
 
static const AVOption options []
 
static const AVClass cudacolorspace_class
 
static const AVFilterPad cudacolorspace_inputs []
 
static const AVFilterPad cudacolorspace_outputs []
 
const AVFilter ff_vf_colorspace_cuda
 

Macro Definition Documentation

◆ DIV_UP

#define DIV_UP (   a,
  b 
)    (((a) + (b)-1) / (b))

Definition at line 48 of file vf_colorspace_cuda.c.

◆ BLOCKX

#define BLOCKX   32

Definition at line 49 of file vf_colorspace_cuda.c.

◆ BLOCKY

#define BLOCKY   16

Definition at line 50 of file vf_colorspace_cuda.c.

◆ CHECK_CU

#define CHECK_CU (   x)    FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)

Definition at line 52 of file vf_colorspace_cuda.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(CUDAColorspaceContext, x)

Definition at line 386 of file vf_colorspace_cuda.c.

◆ FLAGS

Definition at line 387 of file vf_colorspace_cuda.c.

Function Documentation

◆ cudacolorspace_init()

static av_cold int cudacolorspace_init ( AVFilterContext ctx)
static

Definition at line 73 of file vf_colorspace_cuda.c.

◆ cudacolorspace_uninit()

static av_cold void cudacolorspace_uninit ( AVFilterContext ctx)
static

Definition at line 88 of file vf_colorspace_cuda.c.

◆ init_hwframe_ctx()

static av_cold int init_hwframe_ctx ( CUDAColorspaceContext s,
AVBufferRef device_ctx,
int  width,
int  height 
)
static

Definition at line 107 of file vf_colorspace_cuda.c.

Referenced by init_processing_chain().

◆ format_is_supported()

static int format_is_supported ( enum AVPixelFormat  fmt)
static

Definition at line 146 of file vf_colorspace_cuda.c.

Referenced by init_processing_chain().

◆ init_processing_chain()

static av_cold int init_processing_chain ( AVFilterContext ctx,
int  width,
int  height 
)
static

Definition at line 155 of file vf_colorspace_cuda.c.

Referenced by cudacolorspace_config_props().

◆ cudacolorspace_load_functions()

static av_cold int cudacolorspace_load_functions ( AVFilterContext ctx)
static

Definition at line 195 of file vf_colorspace_cuda.c.

Referenced by cudacolorspace_config_props().

◆ cudacolorspace_config_props()

static av_cold int cudacolorspace_config_props ( AVFilterLink outlink)
static

Definition at line 228 of file vf_colorspace_cuda.c.

◆ conv_cuda_convert()

static int conv_cuda_convert ( AVFilterContext ctx,
AVFrame out,
AVFrame in 
)
static

Definition at line 263 of file vf_colorspace_cuda.c.

Referenced by cudacolorspace_conv().

◆ cudacolorspace_conv()

static int cudacolorspace_conv ( AVFilterContext ctx,
AVFrame out,
AVFrame in 
)
static

Definition at line 317 of file vf_colorspace_cuda.c.

Referenced by cudacolorspace_filter_frame().

◆ cudacolorspace_filter_frame()

static int cudacolorspace_filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 346 of file vf_colorspace_cuda.c.

Variable Documentation

◆ supported_formats

enum AVPixelFormat supported_formats[]
static
Initial value:

Definition at line 42 of file vf_colorspace_cuda.c.

Referenced by format_is_supported().

◆ options

const AVOption options[]
static
Initial value:
= {
{"range", "Output video range", OFFSET(range), AV_OPT_TYPE_INT, { .i64 = AVCOL_RANGE_UNSPECIFIED }, AVCOL_RANGE_UNSPECIFIED, AVCOL_RANGE_NB - 1, FLAGS, "range"},
{"tv", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, "range"},
{"mpeg", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, "range"},
{"pc", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, "range"},
{"jpeg", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, "range"},
{NULL},
}

Definition at line 388 of file vf_colorspace_cuda.c.

◆ cudacolorspace_class

const AVClass cudacolorspace_class
static
Initial value:
= {
.class_name = "colorspace_cuda",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 397 of file vf_colorspace_cuda.c.

◆ cudacolorspace_inputs

const AVFilterPad cudacolorspace_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = cudacolorspace_filter_frame,
},
}

Definition at line 404 of file vf_colorspace_cuda.c.

◆ cudacolorspace_outputs

const AVFilterPad cudacolorspace_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = cudacolorspace_config_props,
},
}

Definition at line 412 of file vf_colorspace_cuda.c.

◆ ff_vf_colorspace_cuda

const AVFilter ff_vf_colorspace_cuda
Initial value:
= {
.name = "colorspace_cuda",
.description = NULL_IF_CONFIG_SMALL("CUDA accelerated video color converter"),
.priv_size = sizeof(CUDAColorspaceContext),
.priv_class = &cudacolorspace_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}

Definition at line 420 of file vf_colorspace_cuda.c.

AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:253
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: internal.h:374
cudacolorspace_config_props
static av_cold int cudacolorspace_config_props(AVFilterLink *outlink)
Definition: vf_colorspace_cuda.c:228
cudacolorspace_uninit
static av_cold void cudacolorspace_uninit(AVFilterContext *ctx)
Definition: vf_colorspace_cuda.c:88
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:661
OFFSET
#define OFFSET(x)
Definition: vf_colorspace_cuda.c:386
FLAGS
#define FLAGS
Definition: vf_colorspace_cuda.c:387
AVCOL_RANGE_NB
@ AVCOL_RANGE_NB
Not part of ABI.
Definition: pixfmt.h:662
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:194
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
CUDAColorspaceContext
Definition: vf_colorspace_cuda.c:54
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:627
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:115
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:184
cudacolorspace_inputs
static const AVFilterPad cudacolorspace_inputs[]
Definition: vf_colorspace_cuda.c:404
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:644
AV_PIX_FMT_NV12
@ 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:89
cudacolorspace_init
static av_cold int cudacolorspace_init(AVFilterContext *ctx)
Definition: vf_colorspace_cuda.c:73
cudacolorspace_filter_frame
static int cudacolorspace_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_colorspace_cuda.c:346
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:195
cudacolorspace_class
static const AVClass cudacolorspace_class
Definition: vf_colorspace_cuda.c:397
cudacolorspace_outputs
static const AVFilterPad cudacolorspace_outputs[]
Definition: vf_colorspace_cuda.c:412
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
options
static const AVOption options[]
Definition: vf_colorspace_cuda.c:388