FFmpeg
Loading...
Searching...
No Matches
vf_colorspace_cuda.c File Reference
#include <string.h>
#include "libavutil/attributes.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 "filters.h"
#include "cuda/load_helper.h"

Go to the source code of this file.

Data Structures

struct  CUDAColorspaceContext
 

Macros

#define DIV_UP(a, b)
 
#define BLOCKX   32
 
#define BLOCKY   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 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 FFFilter ff_vf_colorspace_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 45 of file vf_colorspace_cuda.c.

Referenced by conv_cuda_convert().

◆ BLOCKX

#define BLOCKX   32

Definition at line 46 of file vf_colorspace_cuda.c.

◆ BLOCKY

#define BLOCKY   16

Definition at line 47 of file vf_colorspace_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 49 of file vf_colorspace_cuda.c.

Referenced by conv_cuda_convert(), cudacolorspace_filter_frame(), cudacolorspace_load_functions(), and cudacolorspace_uninit().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 389 of file vf_colorspace_cuda.c.

◆ FLAGS

Definition at line 390 of file vf_colorspace_cuda.c.

Function Documentation

◆ cudacolorspace_init()

static av_cold int cudacolorspace_init ( AVFilterContext * ctx)
static

Definition at line 71 of file vf_colorspace_cuda.c.

◆ cudacolorspace_uninit()

static av_cold void cudacolorspace_uninit ( AVFilterContext * ctx)
static

Definition at line 86 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 105 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 144 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 153 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 266 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 320 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 349 of file vf_colorspace_cuda.c.

Variable Documentation

◆ supported_formats

enum AVPixelFormat supported_formats[]
static
Initial value:
= {
}
@ 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_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78

Definition at line 39 of file vf_colorspace_cuda.c.

◆ 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, .unit = "range"},
{"tv", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, .unit = "range"},
{"mpeg", "Limited range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_MPEG }, 0, 0, FLAGS, .unit = "range"},
{"pc", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, .unit = "range"},
{"jpeg", "Full range", 0, AV_OPT_TYPE_CONST, { .i64 = AVCOL_RANGE_JPEG }, 0, 0, FLAGS, .unit = "range"},
{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
enum AVColorRange range
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:766
@ AVCOL_RANGE_UNSPECIFIED
Definition pixfmt.h:749
@ AVCOL_RANGE_NB
Not part of ABI.
Definition pixfmt.h:784
@ AVCOL_RANGE_JPEG
Full range content.
Definition pixfmt.h:783

Definition at line 391 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,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 400 of file vf_colorspace_cuda.c.

◆ cudacolorspace_inputs

const AVFilterPad cudacolorspace_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = cudacolorspace_filter_frame,
},
}
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static int cudacolorspace_filter_frame(AVFilterLink *link, AVFrame *in)

Definition at line 407 of file vf_colorspace_cuda.c.

◆ cudacolorspace_outputs

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

Definition at line 415 of file vf_colorspace_cuda.c.

◆ ff_vf_colorspace_cuda

const FFFilter ff_vf_colorspace_cuda
Initial value:
= {
.p.name = "colorspace_cuda",
.p.description = NULL_IF_CONFIG_SMALL("CUDA accelerated video color converter"),
.p.priv_class = &cudacolorspace_class,
.priv_size = sizeof(CUDAColorspaceContext),
.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 const AVFilterPad cudacolorspace_inputs[]
static const AVClass cudacolorspace_class
static const AVFilterPad cudacolorspace_outputs[]
static av_cold int cudacolorspace_init(AVFilterContext *ctx)
static av_cold void cudacolorspace_uninit(AVFilterContext *ctx)

Definition at line 423 of file vf_colorspace_cuda.c.