38 #define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, ctx->hwctx->internal->cuda_dl, x) 39 #define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) ) 86 if (formats[
i] == fmt)
112 uint8_t* main_data,
int main_linesize,
113 int main_width,
int main_height,
114 uint8_t* overlay_data,
int overlay_linesize,
115 int overlay_width,
int overlay_height,
116 uint8_t* alpha_data,
int alpha_linesize,
117 int alpha_adj_x,
int alpha_adj_y) {
121 void* kernel_args[] = {
123 &main_data, &main_linesize,
124 &overlay_data, &overlay_linesize,
125 &overlay_width, &overlay_height,
126 &alpha_data, &alpha_linesize,
127 &alpha_adj_x, &alpha_adj_y,
151 AVFrame *input_main, *input_overlay;
160 if (!input_main || !input_overlay)
171 ret =
CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
185 input_overlay->
data[3], input_overlay->
linesize[3], 1, 1);
206 input_overlay->
width / 2, input_overlay->
height / 2,
207 input_overlay->
data[3], input_overlay->
linesize[3], 2, 2);
214 input_overlay->
width / 2, input_overlay->
height / 2,
215 input_overlay->
data[3], input_overlay->
linesize[3], 2, 2);
220 CHECK_CU(cu->cuCtxPopCurrent(&dummy));
224 CHECK_CU(cu->cuCtxPopCurrent(&dummy));
254 CHECK_CU(cu->cuCtxPopCurrent(&dummy));
288 extern char vf_overlay_cuda_ptx[];
300 CUcontext
dummy, cuda_ctx;
319 if (!frames_ctx_overlay) {
353 err =
CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
360 CHECK_CU(cu->cuCtxPopCurrent(&dummy));
366 CHECK_CU(cu->cuCtxPopCurrent(&dummy));
370 CHECK_CU(cu->cuCtxPopCurrent(&dummy));
383 #define OFFSET(x) offsetof(OverlayCUDAContext, x) 384 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM) 387 {
"x",
"Overlay x position",
389 {
"y",
"Overlay y position",
391 {
"eof_action",
"Action to take when encountering EOF from secondary input ",
426 .
name =
"overlay_cuda",
429 .priv_class = &overlay_cuda_class,
434 .
inputs = overlay_cuda_inputs,
435 .
outputs = overlay_cuda_outputs,
436 .preinit = overlay_cuda_framesync_preinit,
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
FRAMESYNC_DEFINE_CLASS(overlay_cuda, OverlayCUDAContext, fs)
This structure describes decoded (raw) audio or video data.
Main libavfilter public API header.
Memory handling functions.
static av_cold int init(AVCodecContext *avctx)
AVCUDADeviceContextInternal * internal
static enum AVPixelFormat supported_overlay_formats[]
int ff_framesync_configure(FFFrameSync *fs)
Configure a frame sync structure.
const char * name
Pad name.
AVFilterContext * parent
Parent filter context.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static int overlay_cuda_call_kernel(OverlayCUDAContext *ctx, int x_position, int y_position, uint8_t *main_data, int main_linesize, int main_width, int main_height, uint8_t *overlay_data, int overlay_linesize, int overlay_width, int overlay_height, uint8_t *alpha_data, int alpha_linesize, int alpha_adj_x, int alpha_adj_y)
Call overlay kernell for a plane.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static av_cold int uninit(AVCodecContext *avctx)
int ff_framesync_init_dualinput(FFFrameSync *fs, AVFilterContext *parent)
Initialize a frame sync structure for dualinput.
filter_frame For filters that do not use the activate() callback
int ff_framesync_dualinput_get(FFFrameSync *fs, AVFrame **f0, AVFrame **f1)
static const AVFilterPad overlay_cuda_inputs[]
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
A filter pad used for either input or output.
static int format_is_supported(const enum AVPixelFormat formats[], enum AVPixelFormat fmt)
Helper to find out if provided format is supported by filter.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void ff_framesync_uninit(FFFrameSync *fs)
Free all memory currently allocated.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
int ff_framesync_activate(FFFrameSync *fs)
Examine the frames in the filter's input and try to produce output.
int(* on_event)(struct FFFrameSync *fs)
Callback called when a frame event is ready.
static const AVOption overlay_cuda_options[]
enum AVPixelFormat in_format_main
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames...
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
AVRational time_base
Time base for the output events.
FFmpeg internal API for CUDA.
AVFilterContext * src
source filter
HW acceleration through CUDA.
static av_cold int overlay_cuda_init(AVFilterContext *avctx)
Initialize overlay_cuda.
static const AVFilterPad outputs[]
static int overlay_cuda_activate(AVFilterContext *avctx)
Activate overlay_cuda.
enum AVPixelFormat in_format_overlay
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
uint8_t * data
The data buffer.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
static av_cold void overlay_cuda_uninit(AVFilterContext *avctx)
Uninitialize overlay_cuda.
This struct is allocated as AVHWDeviceContext.hwctx.
Describe the class of an AVClass context structure.
This struct describes a set or pool of "hardware" frames (i.e.
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
static enum AVPixelFormat pix_fmts[]
int av_frame_make_writable(AVFrame *frame)
Ensure that the frame data is writable, avoiding data copy if possible.
static const AVFilterPad overlay_cuda_outputs[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int query_formats(AVFilterContext *ctx)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static int overlay_cuda_blend(FFFrameSync *fs)
Perform blend overlay picture over main picture.
static int formats_match(const enum AVPixelFormat format_main, const enum AVPixelFormat format_overlay)
Helper checks if we can process main and overlay pixel formats.
static int overlay_cuda_config_output(AVFilterLink *outlink)
Configure output.
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.
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
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
AVPixelFormat
Pixel format.
AVFilter ff_vf_overlay_cuda
static int overlay_cuda_query_formats(AVFilterContext *avctx)
Query formats.
static enum AVPixelFormat supported_main_formats[]