FFmpeg
Data Structures | Macros | Functions | Variables
vf_scale_cuda.c File Reference
#include <stdio.h>
#include <string.h>
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/cuda_check.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"

Go to the source code of this file.

Data Structures

struct  CUDAScaleContext
 

Macros

#define DIV_UP(a, b)   ( ((a) + (b) - 1) / (b) )
 
#define ALIGN_UP(a, b)   (((a) + (b) - 1) & ~((b) - 1))
 
#define NUM_BUFFERS   2
 
#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(CUDAScaleContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
 

Functions

static av_cold int cudascale_init (AVFilterContext *ctx)
 
static av_cold void cudascale_uninit (AVFilterContext *ctx)
 
static int cudascale_query_formats (AVFilterContext *ctx)
 
static av_cold int init_stage (CUDAScaleContext *s, AVBufferRef *device_ctx)
 
static int format_is_supported (enum AVPixelFormat fmt)
 
static av_cold int init_processing_chain (AVFilterContext *ctx, int in_width, int in_height, int out_width, int out_height)
 
static av_cold int cudascale_config_props (AVFilterLink *outlink)
 
static int call_resize_kernel (AVFilterContext *ctx, CUfunction func, int channels, uint8_t *src_dptr, int src_width, int src_height, int src_pitch, uint8_t *dst_dptr, int dst_width, int dst_height, int dst_pitch, int pixel_size)
 
static int scalecuda_resize (AVFilterContext *ctx, AVFrame *out, AVFrame *in)
 
static int cudascale_scale (AVFilterContext *ctx, AVFrame *out, AVFrame *in)
 
static int cudascale_filter_frame (AVFilterLink *link, AVFrame *in)
 

Variables

static enum AVPixelFormat supported_formats []
 
static const AVOption options []
 
static const AVClass cudascale_class
 
static const AVFilterPad cudascale_inputs []
 
static const AVFilterPad cudascale_outputs []
 
AVFilter ff_vf_scale_cuda
 

Macro Definition Documentation

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

Definition at line 50 of file vf_scale_cuda.c.

Referenced by call_resize_kernel().

#define ALIGN_UP (   a,
  b 
)    (((a) + (b) - 1) & ~((b) - 1))

Definition at line 51 of file vf_scale_cuda.c.

#define NUM_BUFFERS   2

Definition at line 52 of file vf_scale_cuda.c.

#define BLOCKX   32

Definition at line 53 of file vf_scale_cuda.c.

Referenced by call_resize_kernel().

#define BLOCKY   16

Definition at line 54 of file vf_scale_cuda.c.

Referenced by call_resize_kernel().

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

Definition at line 540 of file vf_scale_cuda.c.

Definition at line 541 of file vf_scale_cuda.c.

Function Documentation

static av_cold int cudascale_init ( AVFilterContext ctx)
static

Definition at line 103 of file vf_scale_cuda.c.

static av_cold void cudascale_uninit ( AVFilterContext ctx)
static

Definition at line 119 of file vf_scale_cuda.c.

static int cudascale_query_formats ( AVFilterContext ctx)
static

Definition at line 128 of file vf_scale_cuda.c.

static av_cold int init_stage ( CUDAScaleContext s,
AVBufferRef device_ctx 
)
static

Definition at line 138 of file vf_scale_cuda.c.

Referenced by init_processing_chain().

static int format_is_supported ( enum AVPixelFormat  fmt)
static

Definition at line 190 of file vf_scale_cuda.c.

Referenced by init_processing_chain().

static av_cold int init_processing_chain ( AVFilterContext ctx,
int  in_width,
int  in_height,
int  out_width,
int  out_height 
)
static

Definition at line 200 of file vf_scale_cuda.c.

Referenced by cudascale_config_props().

static av_cold int cudascale_config_props ( AVFilterLink outlink)
static

Definition at line 253 of file vf_scale_cuda.c.

static int call_resize_kernel ( AVFilterContext ctx,
CUfunction  func,
int  channels,
uint8_t src_dptr,
int  src_width,
int  src_height,
int  src_pitch,
uint8_t dst_dptr,
int  dst_width,
int  dst_height,
int  dst_pitch,
int  pixel_size 
)
static

Definition at line 342 of file vf_scale_cuda.c.

Referenced by scalecuda_resize().

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

Definition at line 386 of file vf_scale_cuda.c.

Referenced by cudascale_scale().

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

Definition at line 472 of file vf_scale_cuda.c.

Referenced by cudascale_filter_frame().

static int cudascale_filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 500 of file vf_scale_cuda.c.

Variable Documentation

enum AVPixelFormat supported_formats[]
static
Initial value:
= {
}
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
#define AV_PIX_FMT_P016
Definition: pixfmt.h:437
#define AV_PIX_FMT_P010
Definition: pixfmt.h:436
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:400
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
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66

Definition at line 41 of file vf_scale_cuda.c.

Referenced by format_is_supported().

const AVOption options[]
static
Initial value:
= {
{ "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS },
{ "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS },
{ "force_original_aspect_ratio", "decrease or increase w/h if necessary to keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { .i64 = 0}, 0, 2, FLAGS, "force_oar" },
{ "disable", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, "force_oar" },
{ "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, "force_oar" },
{ "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, FLAGS, "force_oar" },
{ "force_divisible_by", "enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used", OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1}, 1, 256, FLAGS },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define FLAGS
#define OFFSET(x)

Definition at line 542 of file vf_scale_cuda.c.

const AVClass cudascale_class
static
Initial value:
= {
.class_name = "cudascale",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
static const AVOption options[]

Definition at line 553 of file vf_scale_cuda.c.

const AVFilterPad cudascale_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = cudascale_filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int cudascale_filter_frame(AVFilterLink *link, AVFrame *in)

Definition at line 560 of file vf_scale_cuda.c.

const AVFilterPad cudascale_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = cudascale_config_props,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static av_cold int cudascale_config_props(AVFilterLink *outlink)

Definition at line 569 of file vf_scale_cuda.c.

AVFilter ff_vf_scale_cuda
Initial value:
= {
.name = "scale_cuda",
.description = NULL_IF_CONFIG_SMALL("GPU accelerated video resizer"),
.init = cudascale_init,
.uninit = cudascale_uninit,
.query_formats = cudascale_query_formats,
.priv_size = sizeof(CUDAScaleContext),
.priv_class = &cudascale_class,
.flags_internal = 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:385
static const AVFilterPad cudascale_outputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static const AVClass cudascale_class
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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
static av_cold void cudascale_uninit(AVFilterContext *ctx)
static const AVFilterPad cudascale_inputs[]
static av_cold int cudascale_init(AVFilterContext *ctx)
static int cudascale_query_formats(AVFilterContext *ctx)

Definition at line 578 of file vf_scale_cuda.c.