45#define DIV_UP(a, b) (((a) + (b)-1) / (b))
49#define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
90 if (
s->hwctx &&
s->cu_module) {
91 CudaFunctions* cu =
s->hwctx->internal->cuda_dl;
94 CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
95 CHECK_CU(cu->cuModuleUnload(
s->cu_module));
132 s->own_frame->width =
width;
136 s->frames_ctx = out_ref;
198 CUcontext
dummy, cuda_ctx =
s->hwctx->cuda_ctx;
199 CudaFunctions* cu =
s->hwctx->internal->cuda_dl;
202 extern const unsigned char ff_vf_colorspace_cuda_ptx_data[];
203 extern const unsigned int ff_vf_colorspace_cuda_ptx_len;
205 ret =
CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
210 ff_vf_colorspace_cuda_ptx_data,
211 ff_vf_colorspace_cuda_ptx_len);
238 outlink->
w = inlink->
w;
239 outlink->
h = inlink->
h;
248 s->hwctx = device_hwctx;
249 s->cu_stream =
s->hwctx->stream;
269 CudaFunctions* cu =
s->hwctx->internal->cuda_dl;
270 CUcontext
dummy, cuda_ctx =
s->hwctx->cuda_ctx;
273 ret =
CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
277 out->color_range =
s->range;
279 for (
int i = 0;
i <
s->num_planes;
i++) {
282 switch (
s->pix_fmt) {
297 if (!
s->cu_convert[
out->color_range]) {
339 s->own_frame->width = outlink->
w;
340 s->own_frame->height = outlink->
h;
354 CudaFunctions* cu =
s->hwctx->internal->cuda_dl;
366 ret =
CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
376 av_reduce(&
out->sample_aspect_ratio.num, &
out->sample_aspect_ratio.den,
389#define OFFSET(x) offsetof(CUDAColorspaceContext, x)
390#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
401 .class_name =
"colorspace_cuda",
424 .p.name =
"colorspace_cuda",
const FFFilter ff_vf_colorspace_cuda
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
common internal and external API header
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
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.
const char * av_default_item_name(void *ptr)
Return the context name.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define LIBAVUTIL_VERSION_INT
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags)
Copy data to or from a hw surface.
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
FFmpeg internal API for CUDA.
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
static FilterLink * ff_filter_link(AVFilterLink *link)
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Macro definitions for various function/variable attributes.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
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.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_NB
Not part of ABI.
@ AVCOL_RANGE_JPEG
Full range content.
AVPixelFormat
Pixel format.
@ 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...
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
uint8_t * data
The data buffer.
This struct is allocated as AVHWDeviceContext.hwctx.
Describe the class of an AVClass context structure.
AVFilterLink ** inputs
array of pointers to input links
A link between two filters.
int w
agreed upon image width
int h
agreed upon image height
AVFilterContext * src
source filter
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
This struct describes a set or pool of "hardware" frames (i.e.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
int width
The allocated dimensions of the frames in this pool.
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Rational number (pair of numerator and denominator).
AVCUDADeviceContext * hwctx
enum AVPixelFormat pix_fmt
CUfunction cu_convert[AVCOL_RANGE_NB]
Link properties exposed to filter code, but not external callers.
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
static AVFormatContext * ctx
static enum AVPixelFormat supported_formats[]
static int conv_cuda_convert(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
static av_cold int init_hwframe_ctx(CUDAColorspaceContext *s, AVBufferRef *device_ctx, int width, int height)
static av_cold int cudacolorspace_config_props(AVFilterLink *outlink)
static const AVFilterPad cudacolorspace_inputs[]
static const AVClass cudacolorspace_class
static av_cold int cudacolorspace_load_functions(AVFilterContext *ctx)
static const AVFilterPad cudacolorspace_outputs[]
static int format_is_supported(enum AVPixelFormat fmt)
static av_cold int cudacolorspace_init(AVFilterContext *ctx)
static av_cold void cudacolorspace_uninit(AVFilterContext *ctx)
static int cudacolorspace_filter_frame(AVFilterLink *link, AVFrame *in)
static int cudacolorspace_conv(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
static av_cold int init_processing_chain(AVFilterContext *ctx, int width, int height)