Go to the documentation of this file.
44 #define DIV_UP(a, b) (((a) + (b)-1) / (b))
48 #define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
88 if (
s->hwctx &&
s->cu_module) {
89 CudaFunctions* cu =
s->hwctx->internal->cuda_dl;
92 CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
93 CHECK_CU(cu->cuModuleUnload(
s->cu_module));
130 s->own_frame->width =
width;
134 s->frames_ctx = out_ref;
196 CUcontext
dummy, cuda_ctx =
s->hwctx->cuda_ctx;
197 CudaFunctions* cu =
s->hwctx->internal->cuda_dl;
200 extern const unsigned char ff_vf_colorspace_cuda_ptx_data[];
201 extern const unsigned int ff_vf_colorspace_cuda_ptx_len;
208 ff_vf_colorspace_cuda_ptx_data,
209 ff_vf_colorspace_cuda_ptx_len);
246 s->hwctx = device_hwctx;
247 s->cu_stream =
s->hwctx->stream;
249 if (
inlink->sample_aspect_ratio.num) {
252 inlink->sample_aspect_ratio);
267 CudaFunctions* cu =
s->hwctx->internal->cuda_dl;
268 CUcontext
dummy, cuda_ctx =
s->hwctx->cuda_ctx;
275 out->color_range =
s->range;
277 for (
int i = 0;
i <
s->num_planes;
i++) {
280 switch (
s->pix_fmt) {
295 if (!
s->cu_convert[
out->color_range]) {
337 s->own_frame->width = outlink->
w;
338 s->own_frame->height = outlink->
h;
352 CudaFunctions* cu =
s->hwctx->internal->cuda_dl;
364 ret =
CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
374 av_reduce(&
out->sample_aspect_ratio.num, &
out->sample_aspect_ratio.den,
387 #define OFFSET(x) offsetof(CUDAColorspaceContext, x)
388 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
422 .
name =
"colorspace_cuda",
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
uint8_t * data
The data buffer.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
static av_cold int cudacolorspace_config_props(AVFilterLink *outlink)
int ff_cuda_load_module(void *avctx, AVCUDADeviceContext *hwctx, CUmodule *cu_module, const unsigned char *data, const unsigned int length)
Loads a CUDA module and applies any decompression, if necessary.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold void cudacolorspace_uninit(AVFilterContext *ctx)
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
#define FILTER_INPUTS(array)
This structure describes decoded (raw) audio or video data.
@ AVCOL_RANGE_JPEG
Full range content.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
const char * name
Filter name.
CUfunction cu_convert[AVCOL_RANGE_NB]
int width
The allocated dimensions of the frames in this pool.
A link between two filters.
enum AVPixelFormat pix_fmt
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Link properties exposed to filter code, but not external callers.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
static int format_is_supported(enum AVPixelFormat fmt)
@ AVCOL_RANGE_NB
Not part of ABI.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
A filter pad used for either input or output.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_OUTPUTS(array)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a link
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Rational number (pair of numerator and denominator).
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
AVFilterLink ** inputs
array of pointers to input links
const char * av_default_item_name(void *ptr)
Return the context name.
static int cudacolorspace_conv(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
@ AVCOL_RANGE_UNSPECIFIED
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat supported_formats[]
AVFilterContext * src
source filter
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
#define i(width, name, range_min, range_max)
static const AVFilterPad cudacolorspace_inputs[]
int w
agreed upon image width
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
static av_cold int init_hwframe_ctx(CUDAColorspaceContext *s, AVBufferRef *device_ctx, int width, int height)
const char * name
Pad name.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
const AVFilter ff_vf_colorspace_cuda
This struct describes a set or pool of "hardware" frames (i.e.
This struct is allocated as AVHWDeviceContext.hwctx.
@ 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...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static av_cold int cudacolorspace_init(AVFilterContext *ctx)
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
static av_cold int init_processing_chain(AVFilterContext *ctx, int width, int height)
int h
agreed upon image height
static int cudacolorspace_filter_frame(AVFilterLink *link, AVFrame *in)
@ AV_OPT_TYPE_INT
Underlying C type is int.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
A reference to a data buffer.
static int conv_cuda_convert(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
static const AVClass cudacolorspace_class
static const AVFilterPad cudacolorspace_outputs[]
static av_cold int cudacolorspace_load_functions(AVFilterContext *ctx)
AVColorRange
Visual content value range.
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
AVCUDADeviceContext * hwctx
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
static const AVOption options[]