77#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
81#define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
203 int in_sub,
int out_sub)
206 (
int64_t)in_size * (1 << out_sub);
210 int in_sub,
int out_sub)
213 (
int64_t)in_size * (1 << out_sub);
218 int in_sub,
int out_sub)
221 (1 << in_sub) / (1 << out_sub);
225 int in_width,
int in_height,
226 int out_width,
int out_height,
227 int in_sub_x,
int in_sub_y,
228 int out_sub_x,
int out_sub_y,
231 unsigned int x_planes = 0;
232 unsigned int y_planes = 0;
245 in_sub_x, out_sub_x))
248 in_sub_y, out_sub_y))
255 if (x_planes && y_planes) {
258 }
else if (x_planes) {
260 }
else if (y_planes) {
283 cu->cuMemFree(
filter->weights);
285 cu->cuMemFree(
filter->offsets);
293 cu->cuTexObjectDestroy(t->
tex[
i]);
295 cu->cuMemFree(t->
data[
i]);
298 memset(t, 0,
sizeof(*t));
308 memset(
set, 0,
sizeof(*
set));
316 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
319 CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
324 CHECK_CU(cu->cuModuleUnload(
s->cu_module));
365 s->frames_ctx = out_ref;
374 int out_width,
int in_height,
375 int use_float,
unsigned int planes)
378 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
384 .crop_width = out_width,
385 .crop_height = in_height,
386 .log2_chroma_w =
s->out_desc->log2_chroma_w,
387 .log2_chroma_h =
s->in_desc->log2_chroma_h,
390 for (
int i = 0;
i <
s->in_planes;
i++) {
391 const int is_chroma =
i == 1 ||
i == 2;
398 const int sizeof_pixel = (use_float ?
sizeof(
float) :
399 s->in_plane_depths[
i] <= 8 ? 1 : 2) *
400 s->in_plane_channels[
i];
407 (
size_t) plane_w * sizeof_pixel,
413 CUDA_TEXTURE_DESC tex_desc = {
415 .filterMode = CU_TR_FILTER_MODE_POINT,
418 CUDA_RESOURCE_DESC res_desc = {
419 .resType = CU_RESOURCE_TYPE_PITCH2D,
420 .res.pitch2D.format = use_float ? CU_AD_FORMAT_FLOAT :
421 s->in_plane_depths[
i] <= 8 ?
422 CU_AD_FORMAT_UNSIGNED_INT8 :
423 CU_AD_FORMAT_UNSIGNED_INT16,
424 .res.pitch2D.numChannels =
s->in_plane_channels[
i],
425 .res.pitch2D.devPtr = tex->
data[
i],
426 .res.pitch2D.pitchInBytes = pitch,
427 .res.pitch2D.width = plane_w,
428 .res.pitch2D.height = plane_h,
431 ret =
CHECK_CU(cu->cuTexObjectCreate(&tex->
tex[
i], &res_desc,
465 s->in_fmt = in_format;
466 s->out_fmt = out_format;
477 for (
i = 0;
i <
s->in_desc->nb_components;
i++) {
478 d = (
s->in_desc->comp[
i].depth + 7) / 8;
479 p =
s->in_desc->comp[
i].plane;
480 s->in_plane_channels[p] =
FFMAX(
s->in_plane_channels[p],
s->in_desc->comp[
i].step / d);
482 s->in_plane_depths[p] =
s->in_desc->comp[
i].depth;
487 int out_width,
int out_height)
520 if (
s->passthrough && in_width == out_width && in_height == out_height && in_format == out_format) {
533 if (in_width == out_width && in_height == out_height &&
535 s->use_filters_opt != 1)
540 }
else if (
s->use_filters_opt >= 0) {
541 s->use_filters =
s->use_filters_opt;
551 (
s->in_planes > 1 &&
s->out_planes > 1 &&
554 s->in_desc->log2_chroma_w,
555 s->out_desc->log2_chroma_w) ||
557 in_height, out_height,
558 s->in_desc->log2_chroma_h,
559 s->out_desc->log2_chroma_h)));
573 CUcontext
dummy, cuda_ctx =
s->hwctx->cuda_ctx;
574 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
581 const char *fixed_infix;
582 int fixed_use_linear;
583 int fixed_as_integer;
585 extern const unsigned char ff_vf_scale_cuda_ptx_data[];
586 extern const unsigned int ff_vf_scale_cuda_ptx_len;
588 switch (
s->interp_algo) {
590 fixed_infix =
"Nearest";
591 fixed_use_linear = 0;
592 fixed_as_integer = 1;
595 fixed_infix =
"Bilinear";
596 fixed_use_linear = 1;
597 fixed_as_integer = 1;
601 fixed_infix =
"Bicubic";
602 fixed_use_linear = 0;
603 fixed_as_integer = 0;
606 fixed_infix =
"Lanczos";
607 fixed_use_linear = 0;
608 fixed_as_integer = 0;
615 ret =
CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
620 ff_vf_scale_cuda_ptx_data, ff_vf_scale_cuda_ptx_len);
624 if (
s->use_filters) {
625 static const char *
const infix[] = {
"Generic_h",
"Generic_v" };
627 "Generic_float_h" :
"Generic_h";
629 s->interp_use_linear = 0;
630 s->interp_as_integer = 0;
633 snprintf(buf,
sizeof(buf),
"Subsample_%s_%s_%s",
634 infix[dir], in_fmt_name, out_fmt_name);
635 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_out[dir],
640 snprintf(buf,
sizeof(buf),
"Subsample_%s_%s_%s_uv",
641 infix[dir], in_fmt_name, out_fmt_name);
642 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_out_uv[dir],
648 snprintf(buf,
sizeof(buf),
"Subsample_%s_%s_%s", tmp_infix,
649 in_fmt_name, in_fmt_name);
650 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_tmp,
655 if (
s->in_planes > 1) {
656 snprintf(buf,
sizeof(buf),
"Subsample_%s_%s_%s_uv", tmp_infix,
657 in_fmt_name, in_fmt_name);
658 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_tmp_uv,
664 s->interp_use_linear = fixed_use_linear;
665 s->interp_as_integer = fixed_as_integer;
667 snprintf(buf,
sizeof(buf),
"Subsample_%s_%s_%s", fixed_infix,
668 in_fmt_name, out_fmt_name);
669 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_fixed,
674 snprintf(buf,
sizeof(buf),
"Subsample_%s_%s_%s_uv", fixed_infix,
675 in_fmt_name, out_fmt_name);
676 ret =
CHECK_CU(cu->cuModuleGetFunction(&
s->cu_func_fixed_uv,
686 in_fmt_name, out_fmt_name);
697 int src_size,
int dst_size,
698 double virtual_size,
int needs_scale)
701 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
705 .src_size = src_size,
706 .dst_size = dst_size,
707 .virtual_size = virtual_size,
712 params.virtual_size = 0.0;
714 switch (
s->interp_algo) {
720 params.scaler_params[0] =
s->param;
725 params.scaler_params[0] =
params.scaler_params[1] = 0.0;
727 params.scaler_params[1] =
s->param;
737 "currently supported by the CUDA scaler (%d).\n",
748 for (
size_t i = 0;
i <
weights->num_weights;
i++)
751 f->filter_size =
weights->filter_size;
752 f->dst_size = dst_size;
754 const size_t weights_size =
weights->num_weights *
sizeof(*tmp);
755 ret =
CHECK_CU(cu->cuMemAlloc(&
f->weights, weights_size));
758 ret =
CHECK_CU(cu->cuMemcpyHtoD(
f->weights,
tmp, weights_size));
762 const size_t offsets_size = dst_size *
sizeof(*
weights->offsets);
763 ret =
CHECK_CU(cu->cuMemAlloc(&
f->offsets, offsets_size));
766 ret =
CHECK_CU(cu->cuMemcpyHtoD(
f->offsets,
weights->offsets, offsets_size));
771 f->filter_size,
weights->name, src_size, dst_size);
783 int in_width,
int in_height,
790 const int in_sub_x =
s->in_desc->log2_chroma_w;
791 const int in_sub_y =
s->in_desc->log2_chroma_h;
792 const int out_sub_x =
s->out_desc->log2_chroma_w;
793 const int out_sub_y =
s->out_desc->log2_chroma_h;
795 const int has_chroma =
s->in_planes > 1 &&
s->out_planes > 1;
800 set->in_width = in_width;
801 set->in_height = in_height;
802 set->normalize_crop = normalize_crop;
805 in_width, in_height, outlink->
w, outlink->
h,
806 in_sub_x, in_sub_y, out_sub_x, out_sub_y,
823 (normalize_crop ? all_planes :
824 set->pass_plan.x_planes) :
832 in_width, outlink->
w, 0.0,
833 !!(
set->pass_plan.x_planes &
842 src_size, in_width, outlink->
w, in_sub_x, out_sub_x);
844 src_size, dst_size, virtual_size,
845 !!(
set->pass_plan.x_planes &
854 in_height, outlink->
h, 0.0,
855 !!(
set->pass_plan.y_planes &
863 src_size, in_height, outlink->
h, in_sub_y, out_sub_y);
865 src_size, dst_size, virtual_size,
866 !!(
set->pass_plan.y_planes &
875 outlink->
w, in_height,
889 int in_width,
int in_height,
893 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
898 if (
s->filter_set.in_width == in_width &&
899 s->filter_set.in_height == in_height &&
900 s->filter_set.normalize_crop == normalize_crop)
908 if (
s->filter_set.in_width) {
910 ret =
CHECK_CU(cu->cuStreamSynchronize(
s->cu_stream));
916 s->filter_set = next;
917 memset(&next, 0,
sizeof(next));
921 "Prepared generic filters for visible input %dx%d%s\n",
922 in_width, in_height, normalize_crop ?
" (cropped)" :
"");
931 int in_width,
int in_height)
934 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
938 ret =
CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
961 s->w_expr,
s->h_expr,
971 s->force_original_aspect_ratio,
972 s->force_divisible_by, w_adj);
976 if (((
int64_t)
h * inlink->
w) > INT_MAX ||
990 s->hwctx = device_hwctx;
991 s->cu_stream =
s->hwctx->stream;
997 outlink->
w*inlink->
h},
1006 s->passthrough ?
" (passthrough)" :
"");
1008 if (
s->use_filters) {
1026 int *normalize_crop)
1029 size_t frame_width, frame_height;
1031 if (
frame->width <= 0 ||
frame->height <= 0) {
1036 frame_width =
frame->width;
1037 frame_height =
frame->height;
1038 if (
frame->crop_left >= frame_width ||
1039 frame->crop_right >= frame_width -
frame->crop_left ||
1040 frame->crop_top >= frame_height ||
1041 frame->crop_bottom >= frame_height -
frame->crop_top) {
1048 *normalize_crop =
frame->crop_left ||
frame->crop_top ||
1056 const int depths[4],
const int channels[4],
1057 CUDATex *tex,
int use_linear,
int as_integer)
1060 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
1067 .width =
frame->width,
1068 .height =
frame->height,
1069 .crop_left =
frame->crop_left,
1070 .crop_top =
frame->crop_top,
1072 .crop_height = (
frame->height -
frame->crop_bottom) -
frame->crop_top,
1073 .color_range =
frame->color_range,
1074 .log2_chroma_w =
desc->log2_chroma_w,
1075 .log2_chroma_h =
desc->log2_chroma_h,
1085 CUDA_TEXTURE_DESC tex_desc = {
1086 .filterMode = use_linear ?
1087 CU_TR_FILTER_MODE_LINEAR :
1088 CU_TR_FILTER_MODE_POINT,
1089 .flags = as_integer ? CU_TRSF_READ_AS_INTEGER : 0,
1092 const int is_chroma =
i == 1 ||
i == 2;
1093 const int sub_x = is_chroma ?
desc->log2_chroma_w : 0;
1094 const int sub_y = is_chroma ?
desc->log2_chroma_h : 0;
1095 CUDA_RESOURCE_DESC res_desc = {
1096 .resType = CU_RESOURCE_TYPE_PITCH2D,
1097 .res.pitch2D.format = depths[
i] <= 8 ?
1098 CU_AD_FORMAT_UNSIGNED_INT8 :
1099 CU_AD_FORMAT_UNSIGNED_INT16,
1101 .res.pitch2D.pitchInBytes = tex->
linesize[
i],
1102 .res.pitch2D.devPtr = tex->
data[
i],
1107 int ret =
CHECK_CU(cu->cuTexObjectCreate(&tex->
tex[
i], &res_desc, &tex_desc,
NULL));
1118 const CUtexObject src_tex[4],
1119 int src_left,
int src_top,
int src_width,
int src_height,
1120 const CUdeviceptr out_data[4],
1121 int dst_width,
int dst_height,
int dst_pitch,
int mpeg_range,
1125 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
1128 .src_tex = {src_tex[0], src_tex[1], src_tex[2], src_tex[3]},
1135 .dst_width = dst_width,
1136 .dst_height = dst_height,
1137 .dst_pitch = dst_pitch,
1138 .src_left = src_left,
1140 .src_width = src_width,
1141 .src_height = src_height,
1143 .mpeg_range = mpeg_range,
1146 .src_depth =
s->in_desc->comp[0].depth,
1147 .src_storage_max = ((1U <<
s->in_desc->comp[0].depth) - 1) <<
1148 s->in_desc->comp[0].shift,
1157 void *args[] = { &
params };
1171 CUfunction
func, func_uv;
1175 int out_planes =
s->out_planes;
1177 out_planes =
s->in_planes;
1178 func =
s->cu_func_tmp;
1179 func_uv =
s->cu_func_tmp_uv;
1180 }
else if (
s->use_filters) {
1184 func =
s->cu_func_out[dir];
1185 func_uv =
s->cu_func_out_uv[dir];
1187 func =
s->cu_func_fixed;
1188 func_uv =
s->cu_func_fixed_uv;
1191 if (
s->use_filters) {
1193 filter_uv = &
set->filters_uv[pass];
1208 if (out_planes > 1 &&
1222 out->linesize[1], mpeg_range, filter_uv);
1231 int in_width,
int in_height,
int normalize_crop)
1234 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
1238 if (
s->use_filters) {
1245 CUDATex in_tex = {0}, out_tex = {0};
1247 s->in_plane_channels, &in_tex,
1248 s->interp_use_linear,
s->interp_as_integer);
1258 if (
s->use_filters &&
1262 inter_tex =
s->filter_set.inter_tex;
1264 for (
int i = 0;
i <
s->in_planes;
i++) {
1265 if (!inter_tex.
tex[
i])
1269 &
s->filter_set.inter_tex,
src);
1286 s->frame->width = outlink->
w;
1287 s->frame->height = outlink->
h;
1294 out->crop_bottom = 0;
1296 out->crop_right = 0;
1300 out->width != in_width ||
out->height != in_height) {
1316 CudaFunctions *cu =
s->hwctx->internal->cuda_dl;
1320 int in_width, in_height, normalize_crop;
1337 ret =
CHECK_CU(cu->cuCtxPushCurrent(
s->hwctx->cuda_ctx));
1351 av_reduce(&
out->sample_aspect_ratio.num, &
out->sample_aspect_ratio.den,
1369 return s->passthrough ?
1374#define OFFSET(x) offsetof(CUDAScaleContext, x)
1375#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
1385 {
"passthrough",
"Do not process frames at all if parameters match",
OFFSET(passthrough),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
FLAGS },
1386 {
"use_filters",
"Use generic filters instead of fixed function kernels",
OFFSET(use_filters_opt),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1,
FLAGS, .unit =
"use_filters" },
1389 {
"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,
SCALE_FORCE_OAR_NB-1,
FLAGS, .unit =
"force_oar" },
1393 {
"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 },
1394 {
"reset_sar",
"reset SAR to 1 and scale to square pixels if scaling proportionally",
OFFSET(reset_sar),
AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1,
FLAGS },
1399 .class_name =
"cudascale",
1423 .p.name =
"scale_cuda",
SwsAArch64OpImplParams params
static const char *const format[]
const FFFilter ff_vf_scale_cuda
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
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
#define AV_CEIL_RSHIFT(a, b)
int ff_sws_filter_generate(void *log, const SwsFilterParams *params, SwsFilterWeights **out)
Generate a filter kernel for the given parameters.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
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.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
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_side_data_remove_by_props(AVFrameSideData ***sd, int *nb_sd, int props)
Remove and free all side data instances that match any of the given side data properties.
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.
@ AV_SIDE_DATA_PROP_SIZE_DEPENDENT
Side data depends on the video dimensions.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
#define AV_LOG_VERBOSE
Detailed information.
#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
#define SWS_PARAM_DEFAULT
@ SWS_SCALE_POINT
nearest neighbor (point sampling)
@ SWS_SCALE_LANCZOS
3-tap sinc/sinc
@ SWS_SCALE_BILINEAR
bilinear filtering
@ SWS_SCALE_BICUBIC
2-tap cubic BC-spline
static const int weights[]
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_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
FFmpeg internal API for CUDA.
static int unsupported(AVCodecContext *avctx)
int(* func)(AVBPrint *dst, const char *in, const char *arg)
#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_)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
@ SWS_FILTER_SCALE
14-bit coefficients are picked to fit comfortably within int16_t for efficient SIMD processing (e....
static const struct @257111027162314367033347246032313251342043035002 planes[]
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.
Memory handling functions.
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.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_0RGB32
#define AV_PIX_FMT_YUV420P10
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12MSB
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_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P10MSB
#define AV_PIX_FMT_0BGR32
#define AV_PIX_FMT_YUV444P10
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
int ff_scale_adjust_dimensions(AVFilterLink *inlink, int *ret_w, int *ret_h, int force_original_aspect_ratio, int force_divisible_by, double w_adj)
Transform evaluated width and height obtained from ff_scale_eval_dimensions into actual target width ...
int ff_scale_eval_dimensions(void *log_ctx, const char *w_expr, const char *h_expr, AVFilterLink *inlink, AVFilterLink *outlink, int *ret_w, int *ret_h)
Parse and evaluate string expressions for width and height.
@ SCALE_FORCE_OAR_DISABLE
@ SCALE_FORCE_OAR_INCREASE
@ SCALE_FORCE_OAR_DECREASE
#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
void * priv
private data for use by the filter
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.
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.
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.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Rational number (pair of numerator and denominator).
enum AVPixelFormat format
Output sw format.
int force_original_aspect_ratio
CUfunction cu_func_tmp_uv
const AVPixFmtDescriptor * in_desc
enum AVPixelFormat in_fmt out_fmt
AVCUDADeviceContext * hwctx
CUDAScaleFilterSet filter_set
char * w_expr
width expression string
const AVPixFmtDescriptor * out_desc
CUfunction cu_func_fixed_uv
char * h_expr
height expression string
CUfunction cu_func_out[2]
CUfunction cu_func_out_uv[2]
CUDAScaleFilter filters_uv[FILTER_NB]
CUDAScalePassPlan pass_plan
CUDAScaleFilter filters[FILTER_NB]
CUdeviceptr weights
float[dst_size][filter_size]
CUdeviceptr offsets
int[dst_size]
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.
Represents a computed filter kernel.
enum AVPixelFormat format
#define av_malloc_array(a, b)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v)
static enum AVPixelFormat supported_formats[]
static int cudascale_filter_set_init(AVFilterContext *ctx, CUDAScaleFilterSet *set, int in_width, int in_height, int normalize_crop)
static double cudascale_plane_virtual_size(int src_size, int in_size, int out_size, int in_sub, int out_sub)
@ CUDA_SCALE_PLANE_PRIMARY
@ CUDA_SCALE_PLANE_CHROMA
static int cudascale_plane_needs_scale(int in_size, int out_size, int in_sub, int out_sub)
static av_cold int cudascale_setup_filters(AVFilterContext *ctx, int in_width, int in_height)
static int cudascale_filter_init(AVFilterContext *ctx, CUDAScaleFilter *f, int src_size, int dst_size, double virtual_size, int needs_scale)
static int cudascale_plane_is_downscaled(int in_size, int out_size, int in_sub, int out_sub)
static av_cold int init_hwframe_ctx(CUDAScaleContext *s, AVBufferRef *device_ctx, int width, int height)
static av_cold void cudascale_uninit(AVFilterContext *ctx)
static int cudascale_frame_geometry(AVFilterContext *ctx, const AVFrame *frame, int *width, int *height, int *normalize_crop)
static int cudascale_scale(AVFilterContext *ctx, AVFrame *out, AVFrame *in, int in_width, int in_height, int normalize_crop)
static av_cold int cudascale_config_props(AVFilterLink *outlink)
static int scalecuda_resize(AVFilterContext *ctx, const CUDAScaleFilterSet *set, int pass, const CUDATex *out, const CUDATex *in)
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_init(AVFilterContext *ctx)
static const AVClass cudascale_class
static av_cold int cudascale_load_functions(AVFilterContext *ctx)
static const char * get_format_name(enum AVPixelFormat fmt)
static void filter_set_uninit(CudaFunctions *cu, CUDAScaleFilterSet *set)
static int call_resize_kernel(AVFilterContext *ctx, CUfunction func, const CUtexObject src_tex[4], int src_left, int src_top, int src_width, int src_height, const CUdeviceptr out_data[4], int dst_width, int dst_height, int dst_pitch, int mpeg_range, const CUDAScaleFilter *filter)
static void cuda_tex_uninit(CudaFunctions *cu, CUDATex *t)
static int format_is_supported(enum AVPixelFormat fmt)
static av_cold void set_format_info(AVFilterContext *ctx, enum AVPixelFormat in_format, enum AVPixelFormat out_format)
static AVFrame * cudascale_get_video_buffer(AVFilterLink *inlink, int w, int h)
static void cudascale_plan_passes(CUDAScalePassPlan *plan, int in_width, int in_height, int out_width, int out_height, int in_sub_x, int in_sub_y, int out_sub_x, int out_sub_y, int has_chroma)
static int cudascale_prepare_filter_set(AVFilterContext *ctx, int in_width, int in_height, int normalize_crop)
static int cuda_tex_map_frame(AVFilterContext *ctx, const AVFrame *frame, const int depths[4], const int channels[4], CUDATex *tex, int use_linear, int as_integer)
static void filter_uninit(CudaFunctions *cu, CUDAScaleFilter *filter)
static int cudascale_filter_frame(AVFilterLink *link, AVFrame *in)
static const AVFilterPad cudascale_outputs[]
static int inter_buf_init(AVFilterContext *ctx, CUDATex *tex, int out_width, int in_height, int use_float, unsigned int planes)
static const AVFilterPad cudascale_inputs[]
#define SCALE_CUDA_PARAM_DEFAULT
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)