FFmpeg
vf_scale_cuda.c
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 */
22 
23 #include <float.h>
24 #include <stdio.h>
25 
26 #include "libavutil/common.h"
27 #include "libavutil/hwcontext.h"
29 #include "libavutil/cuda_check.h"
30 #include "libavutil/internal.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/pixdesc.h"
33 
34 #include "avfilter.h"
35 #include "filters.h"
36 #include "scale_eval.h"
37 #include "video.h"
38 
39 #include "cuda/load_helper.h"
40 #include "vf_scale_cuda.h"
41 
42 struct format_entry {
44  char name[13];
45 };
46 
47 static const struct format_entry supported_formats[] = {
48  {AV_PIX_FMT_YUV420P, "planar8"},
49  {AV_PIX_FMT_YUV422P, "planar8"},
50  {AV_PIX_FMT_YUV444P, "planar8"},
51  {AV_PIX_FMT_YUV420P10,"planar10"},
52  {AV_PIX_FMT_YUV422P10,"planar10"},
53  {AV_PIX_FMT_YUV444P10,"planar10"},
54  {AV_PIX_FMT_YUV444P16,"planar16"},
55  {AV_PIX_FMT_NV12, "semiplanar8"},
56  {AV_PIX_FMT_NV16, "semiplanar8"},
57  {AV_PIX_FMT_P010, "semiplanar10"},
58  {AV_PIX_FMT_P210, "semiplanar10"},
59  {AV_PIX_FMT_P016, "semiplanar16"},
60  {AV_PIX_FMT_P216, "semiplanar16"},
61  {AV_PIX_FMT_0RGB32, "bgr0"},
62  {AV_PIX_FMT_0BGR32, "rgb0"},
63  {AV_PIX_FMT_RGB32, "bgra"},
64  {AV_PIX_FMT_BGR32, "rgba"},
65 };
66 
67 #define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
68 #define BLOCKX 32
69 #define BLOCKY 16
70 
71 #define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
72 
73 enum {
75 
80 
82 };
83 
84 typedef struct CUDAScaleContext {
85  const AVClass *class;
86 
88 
89  enum AVPixelFormat in_fmt, out_fmt;
94 
97 
100 
101  /**
102  * Output sw format. AV_PIX_FMT_NONE for no conversion.
103  */
105 
106  char *w_expr; ///< width expression string
107  char *h_expr; ///< height expression string
108 
112 
113  CUcontext cu_ctx;
114  CUmodule cu_module;
115  CUfunction cu_func;
116  CUfunction cu_func_uv;
117  CUstream cu_stream;
118 
122 
123  float param;
125 
127 {
128  CUDAScaleContext *s = ctx->priv;
129 
130  s->frame = av_frame_alloc();
131  if (!s->frame)
132  return AVERROR(ENOMEM);
133 
134  s->tmp_frame = av_frame_alloc();
135  if (!s->tmp_frame)
136  return AVERROR(ENOMEM);
137 
138  return 0;
139 }
140 
142 {
143  CUDAScaleContext *s = ctx->priv;
144 
145  if (s->hwctx && s->cu_module) {
146  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
147  CUcontext dummy;
148 
149  CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx));
150  CHECK_CU(cu->cuModuleUnload(s->cu_module));
151  s->cu_module = NULL;
152  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
153  }
154 
155  av_frame_free(&s->frame);
156  av_buffer_unref(&s->frames_ctx);
157  av_frame_free(&s->tmp_frame);
158 }
159 
160 static av_cold int init_hwframe_ctx(CUDAScaleContext *s, AVBufferRef *device_ctx, int width, int height)
161 {
162  AVBufferRef *out_ref = NULL;
163  AVHWFramesContext *out_ctx;
164  int ret;
165 
166  out_ref = av_hwframe_ctx_alloc(device_ctx);
167  if (!out_ref)
168  return AVERROR(ENOMEM);
169  out_ctx = (AVHWFramesContext*)out_ref->data;
170 
171  out_ctx->format = AV_PIX_FMT_CUDA;
172  out_ctx->sw_format = s->out_fmt;
173  out_ctx->width = FFALIGN(width, 32);
174  out_ctx->height = FFALIGN(height, 32);
175 
176  ret = av_hwframe_ctx_init(out_ref);
177  if (ret < 0)
178  goto fail;
179 
180  av_frame_unref(s->frame);
181  ret = av_hwframe_get_buffer(out_ref, s->frame, 0);
182  if (ret < 0)
183  goto fail;
184 
185  s->frame->width = width;
186  s->frame->height = height;
187 
188  av_buffer_unref(&s->frames_ctx);
189  s->frames_ctx = out_ref;
190 
191  return 0;
192 fail:
193  av_buffer_unref(&out_ref);
194  return ret;
195 }
196 
197 static int format_is_supported(enum AVPixelFormat fmt)
198 {
199  for (int i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
200  if (supported_formats[i].format == fmt)
201  return 1;
202  return 0;
203 }
204 
205 static const char* get_format_name(enum AVPixelFormat fmt)
206 {
207  for (int i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
208  if (supported_formats[i].format == fmt)
209  return supported_formats[i].name;
210  return NULL;
211 }
212 
213 static av_cold void set_format_info(AVFilterContext *ctx, enum AVPixelFormat in_format, enum AVPixelFormat out_format)
214 {
215  CUDAScaleContext *s = ctx->priv;
216  int i, p, d;
217 
218  s->in_fmt = in_format;
219  s->out_fmt = out_format;
220 
221  s->in_desc = av_pix_fmt_desc_get(s->in_fmt);
222  s->out_desc = av_pix_fmt_desc_get(s->out_fmt);
223  s->in_planes = av_pix_fmt_count_planes(s->in_fmt);
224  s->out_planes = av_pix_fmt_count_planes(s->out_fmt);
225 
226  // find maximum step of each component of each plane
227  // For our subset of formats, this should accurately tell us how many channels CUDA needs
228  // i.e. 1 for Y plane, 2 for UV plane of NV12, 4 for single plane of RGB0 formats
229 
230  for (i = 0; i < s->in_desc->nb_components; i++) {
231  d = (s->in_desc->comp[i].depth + 7) / 8;
232  p = s->in_desc->comp[i].plane;
233  s->in_plane_channels[p] = FFMAX(s->in_plane_channels[p], s->in_desc->comp[i].step / d);
234 
235  s->in_plane_depths[p] = s->in_desc->comp[i].depth;
236  }
237 }
238 
239 static av_cold int init_processing_chain(AVFilterContext *ctx, int in_width, int in_height,
240  int out_width, int out_height)
241 {
242  CUDAScaleContext *s = ctx->priv;
243  FilterLink *inl = ff_filter_link(ctx->inputs[0]);
244  FilterLink *outl = ff_filter_link(ctx->outputs[0]);
245 
246  AVHWFramesContext *in_frames_ctx;
247 
248  enum AVPixelFormat in_format;
249  enum AVPixelFormat out_format;
250  int ret;
251 
252  /* check that we have a hw context */
253  if (!inl->hw_frames_ctx) {
254  av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n");
255  return AVERROR(EINVAL);
256  }
257  in_frames_ctx = (AVHWFramesContext*)inl->hw_frames_ctx->data;
258  in_format = in_frames_ctx->sw_format;
259  out_format = (s->format == AV_PIX_FMT_NONE) ? in_format : s->format;
260 
261  if (!format_is_supported(in_format)) {
262  av_log(ctx, AV_LOG_ERROR, "Unsupported input format: %s\n",
263  av_get_pix_fmt_name(in_format));
264  return AVERROR(ENOSYS);
265  }
266  if (!format_is_supported(out_format)) {
267  av_log(ctx, AV_LOG_ERROR, "Unsupported output format: %s\n",
268  av_get_pix_fmt_name(out_format));
269  return AVERROR(ENOSYS);
270  }
271 
272  set_format_info(ctx, in_format, out_format);
273 
274  if (s->passthrough && in_width == out_width && in_height == out_height && in_format == out_format) {
275  s->frames_ctx = av_buffer_ref(inl->hw_frames_ctx);
276  if (!s->frames_ctx)
277  return AVERROR(ENOMEM);
278  } else {
279  s->passthrough = 0;
280 
281  ret = init_hwframe_ctx(s, in_frames_ctx->device_ref, out_width, out_height);
282  if (ret < 0)
283  return ret;
284 
285  if (in_width == out_width && in_height == out_height &&
286  in_format == out_format && s->interp_algo == INTERP_ALGO_DEFAULT)
287  s->interp_algo = INTERP_ALGO_NEAREST;
288  }
289 
290  outl->hw_frames_ctx = av_buffer_ref(s->frames_ctx);
291  if (!outl->hw_frames_ctx)
292  return AVERROR(ENOMEM);
293 
294  return 0;
295 }
296 
298 {
299  CUDAScaleContext *s = ctx->priv;
300  CUcontext dummy, cuda_ctx = s->hwctx->cuda_ctx;
301  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
302  char buf[128];
303  int ret;
304 
305  const char *in_fmt_name = get_format_name(s->in_fmt);
306  const char *out_fmt_name = get_format_name(s->out_fmt);
307 
308  const char *function_infix = "";
309 
310  extern const unsigned char ff_vf_scale_cuda_ptx_data[];
311  extern const unsigned int ff_vf_scale_cuda_ptx_len;
312 
313  switch(s->interp_algo) {
314  case INTERP_ALGO_NEAREST:
315  function_infix = "Nearest";
316  s->interp_use_linear = 0;
317  s->interp_as_integer = 1;
318  break;
320  function_infix = "Bilinear";
321  s->interp_use_linear = 1;
322  s->interp_as_integer = 1;
323  break;
324  case INTERP_ALGO_DEFAULT:
325  case INTERP_ALGO_BICUBIC:
326  function_infix = "Bicubic";
327  s->interp_use_linear = 0;
328  s->interp_as_integer = 0;
329  break;
330  case INTERP_ALGO_LANCZOS:
331  function_infix = "Lanczos";
332  s->interp_use_linear = 0;
333  s->interp_as_integer = 0;
334  break;
335  default:
336  av_log(ctx, AV_LOG_ERROR, "Unknown interpolation algorithm\n");
337  return AVERROR_BUG;
338  }
339 
340  ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
341  if (ret < 0)
342  return ret;
343 
344  ret = ff_cuda_load_module(ctx, s->hwctx, &s->cu_module,
345  ff_vf_scale_cuda_ptx_data, ff_vf_scale_cuda_ptx_len);
346  if (ret < 0)
347  goto fail;
348 
349  snprintf(buf, sizeof(buf), "Subsample_%s_%s_%s", function_infix, in_fmt_name, out_fmt_name);
350  ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func, s->cu_module, buf));
351  if (ret < 0) {
352  av_log(ctx, AV_LOG_FATAL, "Unsupported conversion: %s -> %s\n", in_fmt_name, out_fmt_name);
353  ret = AVERROR(ENOSYS);
354  goto fail;
355  }
356  av_log(ctx, AV_LOG_DEBUG, "Luma filter: %s (%s -> %s)\n", buf, av_get_pix_fmt_name(s->in_fmt), av_get_pix_fmt_name(s->out_fmt));
357 
358  snprintf(buf, sizeof(buf), "Subsample_%s_%s_%s_uv", function_infix, in_fmt_name, out_fmt_name);
359  ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func_uv, s->cu_module, buf));
360  if (ret < 0)
361  goto fail;
362  av_log(ctx, AV_LOG_DEBUG, "Chroma filter: %s (%s -> %s)\n", buf, av_get_pix_fmt_name(s->in_fmt), av_get_pix_fmt_name(s->out_fmt));
363 
364 fail:
365  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
366 
367  return ret;
368 }
369 
371 {
372  AVFilterContext *ctx = outlink->src;
373  AVFilterLink *inlink = outlink->src->inputs[0];
375  CUDAScaleContext *s = ctx->priv;
376  AVHWFramesContext *frames_ctx;
377  AVCUDADeviceContext *device_hwctx;
378  int w, h;
379  double w_adj = 1.0;
380  int ret;
381 
383  s->w_expr, s->h_expr,
384  inlink, outlink,
385  &w, &h)) < 0)
386  goto fail;
387 
388  if (s->reset_sar)
389  w_adj = inlink->sample_aspect_ratio.num ?
390  (double)inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
391 
393  s->force_original_aspect_ratio, s->force_divisible_by, w_adj);
394 
395  if (((int64_t)h * inlink->w) > INT_MAX ||
396  ((int64_t)w * inlink->h) > INT_MAX)
397  av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
398 
399  outlink->w = w;
400  outlink->h = h;
401 
403  if (ret < 0)
404  return ret;
405 
406  frames_ctx = (AVHWFramesContext*)inl->hw_frames_ctx->data;
407  device_hwctx = frames_ctx->device_ctx->hwctx;
408 
409  s->hwctx = device_hwctx;
410  s->cu_stream = s->hwctx->stream;
411 
412  if (s->reset_sar)
413  outlink->sample_aspect_ratio = (AVRational){1, 1};
414  else if (inlink->sample_aspect_ratio.num) {
415  outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h*inlink->w,
416  outlink->w*inlink->h},
417  inlink->sample_aspect_ratio);
418  } else {
419  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
420  }
421 
422  av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s -> w:%d h:%d fmt:%s%s\n",
423  inlink->w, inlink->h, av_get_pix_fmt_name(s->in_fmt),
424  outlink->w, outlink->h, av_get_pix_fmt_name(s->out_fmt),
425  s->passthrough ? " (passthrough)" : "");
426 
428  if (ret < 0)
429  return ret;
430 
431  return 0;
432 
433 fail:
434  return ret;
435 }
436 
437 static int call_resize_kernel(AVFilterContext *ctx, CUfunction func,
438  CUtexObject src_tex[4], int src_left, int src_top, int src_width, int src_height,
439  AVFrame *out_frame, int dst_width, int dst_height, int dst_pitch, int mpeg_range)
440 {
441  CUDAScaleContext *s = ctx->priv;
442  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
443 
444  CUDAScaleKernelParams params = {
445  .src_tex = {src_tex[0], src_tex[1], src_tex[2], src_tex[3]},
446  .dst = {
447  (CUdeviceptr)out_frame->data[0],
448  (CUdeviceptr)out_frame->data[1],
449  (CUdeviceptr)out_frame->data[2],
450  (CUdeviceptr)out_frame->data[3]
451  },
452  .dst_width = dst_width,
453  .dst_height = dst_height,
454  .dst_pitch = dst_pitch,
455  .src_left = src_left,
456  .src_top = src_top,
457  .src_width = src_width,
458  .src_height = src_height,
459  .param = s->param,
460  .mpeg_range = mpeg_range
461  };
462 
463  void *args[] = { &params };
464 
465  return CHECK_CU(cu->cuLaunchKernel(func,
466  DIV_UP(dst_width, BLOCKX), DIV_UP(dst_height, BLOCKY), 1,
467  BLOCKX, BLOCKY, 1, 0, s->cu_stream, args, NULL));
468 }
469 
471  AVFrame *out, AVFrame *in)
472 {
473  CUDAScaleContext *s = ctx->priv;
474  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
475  CUcontext dummy, cuda_ctx = s->hwctx->cuda_ctx;
476  int i, ret;
477  int mpeg_range = in->color_range != AVCOL_RANGE_JPEG;
478 
479  CUtexObject tex[4] = { 0, 0, 0, 0 };
480 
481  int crop_width = (in->width - in->crop_right) - in->crop_left;
482  int crop_height = (in->height - in->crop_bottom) - in->crop_top;
483 
484  ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
485  if (ret < 0)
486  return ret;
487 
488  for (i = 0; i < s->in_planes; i++) {
489  CUDA_TEXTURE_DESC tex_desc = {
490  .filterMode = s->interp_use_linear ?
491  CU_TR_FILTER_MODE_LINEAR :
492  CU_TR_FILTER_MODE_POINT,
493  .flags = s->interp_as_integer ? CU_TRSF_READ_AS_INTEGER : 0,
494  };
495 
496  CUDA_RESOURCE_DESC res_desc = {
497  .resType = CU_RESOURCE_TYPE_PITCH2D,
498  .res.pitch2D.format = s->in_plane_depths[i] <= 8 ?
499  CU_AD_FORMAT_UNSIGNED_INT8 :
500  CU_AD_FORMAT_UNSIGNED_INT16,
501  .res.pitch2D.numChannels = s->in_plane_channels[i],
502  .res.pitch2D.pitchInBytes = in->linesize[i],
503  .res.pitch2D.devPtr = (CUdeviceptr)in->data[i],
504  };
505 
506  if (i == 1 || i == 2) {
507  res_desc.res.pitch2D.width = AV_CEIL_RSHIFT(in->width, s->in_desc->log2_chroma_w);
508  res_desc.res.pitch2D.height = AV_CEIL_RSHIFT(in->height, s->in_desc->log2_chroma_h);
509  } else {
510  res_desc.res.pitch2D.width = in->width;
511  res_desc.res.pitch2D.height = in->height;
512  }
513 
514  ret = CHECK_CU(cu->cuTexObjectCreate(&tex[i], &res_desc, &tex_desc, NULL));
515  if (ret < 0)
516  goto exit;
517  }
518 
519  // scale primary plane(s). Usually Y (and A), or single plane of RGB frames.
520  ret = call_resize_kernel(ctx, s->cu_func,
521  tex, in->crop_left, in->crop_top, crop_width, crop_height,
522  out, out->width, out->height, out->linesize[0], mpeg_range);
523  if (ret < 0)
524  goto exit;
525 
526  if (s->out_planes > 1) {
527  // scale UV plane. Scale function sets both U and V plane, or singular interleaved plane.
528  ret = call_resize_kernel(ctx, s->cu_func_uv, tex,
529  AV_CEIL_RSHIFT(in->crop_left, s->in_desc->log2_chroma_w),
530  AV_CEIL_RSHIFT(in->crop_top, s->in_desc->log2_chroma_h),
531  AV_CEIL_RSHIFT(crop_width, s->in_desc->log2_chroma_w),
532  AV_CEIL_RSHIFT(crop_height, s->in_desc->log2_chroma_h),
533  out,
534  AV_CEIL_RSHIFT(out->width, s->out_desc->log2_chroma_w),
535  AV_CEIL_RSHIFT(out->height, s->out_desc->log2_chroma_h),
536  out->linesize[1], mpeg_range);
537  if (ret < 0)
538  goto exit;
539  }
540 
541 exit:
542  for (i = 0; i < s->in_planes; i++)
543  if (tex[i])
544  CHECK_CU(cu->cuTexObjectDestroy(tex[i]));
545 
546  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
547 
548  return ret;
549 }
550 
552 {
553  CUDAScaleContext *s = ctx->priv;
554  AVFilterLink *outlink = ctx->outputs[0];
555  AVFrame *src = in;
556  int ret;
557 
558  ret = scalecuda_resize(ctx, s->frame, src);
559  if (ret < 0)
560  return ret;
561 
562  src = s->frame;
563  ret = av_hwframe_get_buffer(src->hw_frames_ctx, s->tmp_frame, 0);
564  if (ret < 0)
565  return ret;
566 
567  av_frame_move_ref(out, s->frame);
568  av_frame_move_ref(s->frame, s->tmp_frame);
569 
570  s->frame->width = outlink->w;
571  s->frame->height = outlink->h;
572 
573  ret = av_frame_copy_props(out, in);
574  if (ret < 0)
575  return ret;
576 
577  if (out->width != in->width || out->height != in->height) {
578  av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
580  }
581 
582  return 0;
583 }
584 
586 {
587  AVFilterContext *ctx = link->dst;
588  CUDAScaleContext *s = ctx->priv;
589  AVFilterLink *outlink = ctx->outputs[0];
590  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
591 
592  AVFrame *out = NULL;
593  CUcontext dummy;
594  int ret = 0;
595 
596  if (s->passthrough)
597  return ff_filter_frame(outlink, in);
598 
599  out = av_frame_alloc();
600  if (!out) {
601  ret = AVERROR(ENOMEM);
602  goto fail;
603  }
604 
605  ret = CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx));
606  if (ret < 0)
607  goto fail;
608 
609  ret = cudascale_scale(ctx, out, in);
610 
611  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
612  if (ret < 0)
613  goto fail;
614 
615  if (s->reset_sar) {
616  out->sample_aspect_ratio = (AVRational){1, 1};
617  } else {
618  av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
619  (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
620  (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
621  INT_MAX);
622  }
623 
624  av_frame_free(&in);
625  return ff_filter_frame(outlink, out);
626 fail:
627  av_frame_free(&in);
628  av_frame_free(&out);
629  return ret;
630 }
631 
633 {
634  CUDAScaleContext *s = inlink->dst->priv;
635 
636  return s->passthrough ?
639 }
640 
641 #define OFFSET(x) offsetof(CUDAScaleContext, x)
642 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
643 static const AVOption options[] = {
644  { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS },
645  { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS },
646  { "interp_algo", "Interpolation algorithm used for resizing", OFFSET(interp_algo), AV_OPT_TYPE_INT, { .i64 = INTERP_ALGO_DEFAULT }, 0, INTERP_ALGO_COUNT - 1, FLAGS, .unit = "interp_algo" },
647  { "nearest", "nearest neighbour", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_NEAREST }, 0, 0, FLAGS, .unit = "interp_algo" },
648  { "bilinear", "bilinear", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_BILINEAR }, 0, 0, FLAGS, .unit = "interp_algo" },
649  { "bicubic", "bicubic", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_BICUBIC }, 0, 0, FLAGS, .unit = "interp_algo" },
650  { "lanczos", "lanczos", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_LANCZOS }, 0, 0, FLAGS, .unit = "interp_algo" },
651  { "format", "Output video pixel format", OFFSET(format), AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_NONE }, INT_MIN, INT_MAX, .flags=FLAGS },
652  { "passthrough", "Do not process frames at all if parameters match", OFFSET(passthrough), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
653  { "param", "Algorithm-Specific parameter", OFFSET(param), AV_OPT_TYPE_FLOAT, { .dbl = SCALE_CUDA_PARAM_DEFAULT }, -FLT_MAX, FLT_MAX, FLAGS },
654  { "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" },
655  { "disable", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DISABLE }, 0, 0, FLAGS, .unit = "force_oar" },
656  { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DECREASE }, 0, 0, FLAGS, .unit = "force_oar" },
657  { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_INCREASE }, 0, 0, FLAGS, .unit = "force_oar" },
658  { "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 },
659  { "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 },
660  { NULL },
661 };
662 
663 static const AVClass cudascale_class = {
664  .class_name = "cudascale",
665  .item_name = av_default_item_name,
666  .option = options,
667  .version = LIBAVUTIL_VERSION_INT,
668 };
669 
670 static const AVFilterPad cudascale_inputs[] = {
671  {
672  .name = "default",
673  .type = AVMEDIA_TYPE_VIDEO,
674  .filter_frame = cudascale_filter_frame,
675  .get_buffer.video = cudascale_get_video_buffer,
676  },
677 };
678 
679 static const AVFilterPad cudascale_outputs[] = {
680  {
681  .name = "default",
682  .type = AVMEDIA_TYPE_VIDEO,
683  .config_props = cudascale_config_props,
684  },
685 };
686 
688  .p.name = "scale_cuda",
689  .p.description = NULL_IF_CONFIG_SMALL("GPU accelerated video resizer"),
690 
691  .p.priv_class = &cudascale_class,
692 
693  .init = cudascale_init,
694  .uninit = cudascale_uninit,
695 
696  .priv_size = sizeof(CUDAScaleContext),
697 
700 
702 
703  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
704 };
options
static const AVOption options[]
Definition: vf_scale_cuda.c:643
func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:66
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:88
AVFrame::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:678
AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:260
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
format_entry::format
enum AVPixelFormat format
Definition: vf_scale_cuda.c:43
CUDAScaleKernelParams::src_tex
CUtexObject src_tex[4]
Definition: vf_scale_cuda.h:37
AVERROR
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
opt.h
CUDAScaleContext::frames_ctx
AVBufferRef * frames_ctx
Definition: vf_scale_cuda.c:95
hwcontext_cuda_internal.h
cudascale_init
static av_cold int cudascale_init(AVFilterContext *ctx)
Definition: vf_scale_cuda.c:126
out
FILE * out
Definition: movenc.c:55
supported_formats
static const struct format_entry supported_formats[]
Definition: vf_scale_cuda.c:47
AV_PIX_FMT_BGR32
#define AV_PIX_FMT_BGR32
Definition: pixfmt.h:513
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1067
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3456
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:200
ff_cuda_load_module
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.
Definition: load_helper.c:35
int64_t
long long int64_t
Definition: coverity.c:34
inlink
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
Definition: filter_design.txt:212
CUDAScaleContext::tmp_frame
AVFrame * tmp_frame
Definition: vf_scale_cuda.c:98
CUDAScaleContext::passthrough
int passthrough
Definition: vf_scale_cuda.c:99
cudascale_uninit
static av_cold void cudascale_uninit(AVFilterContext *ctx)
Definition: vf_scale_cuda.c:141
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:64
av_hwframe_ctx_init
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:337
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:263
CUDAScaleContext::w_expr
char * w_expr
width expression string
Definition: vf_scale_cuda.c:106
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
pixdesc.h
AVFrame::width
int width
Definition: frame.h:499
w
uint8_t w
Definition: llviddspenc.c:38
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:777
av_hwframe_ctx_alloc
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:263
AVOption
AVOption.
Definition: opt.h:429
init_hwframe_ctx
static av_cold int init_hwframe_ctx(CUDAScaleContext *s, AVBufferRef *device_ctx, int width, int height)
Definition: vf_scale_cuda.c:160
CUDAScaleContext::interp_use_linear
int interp_use_linear
Definition: vf_scale_cuda.c:120
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:539
FLAGS
#define FLAGS
Definition: vf_scale_cuda.c:642
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:226
ff_scale_eval_dimensions
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.
Definition: scale_eval.c:57
float.h
DIV_UP
#define DIV_UP(a, b)
Definition: vf_scale_cuda.c:67
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
CUDAScaleKernelParams
Definition: vf_scale_cuda.h:36
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:220
get_format_name
static const char * get_format_name(enum AVPixelFormat fmt)
Definition: vf_scale_cuda.c:205
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:220
video.h
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:448
CUDAScaleContext::frame
AVFrame * frame
Definition: vf_scale_cuda.c:96
ff_default_get_video_buffer
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:112
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3496
CUDAScaleContext::cu_func_uv
CUfunction cu_func_uv
Definition: vf_scale_cuda.c:116
vf_scale_cuda.h
fail
#define fail()
Definition: checkasm.h:208
CHECK_CU
#define CHECK_CU(x)
Definition: vf_scale_cuda.c:71
CUDAScaleContext::in_planes
int in_planes
Definition: vf_scale_cuda.c:91
dummy
int dummy
Definition: motion.c:64
scalecuda_resize
static int scalecuda_resize(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
Definition: vf_scale_cuda.c:470
CUDAScaleContext::in_plane_channels
int in_plane_channels[4]
Definition: vf_scale_cuda.c:93
CUDAScaleContext::reset_sar
int reset_sar
Definition: vf_scale_cuda.c:111
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
INTERP_ALGO_COUNT
@ INTERP_ALGO_COUNT
Definition: vf_scale_cuda.c:81
AVRational::num
int num
Numerator.
Definition: rational.h:59
cudascale_load_functions
static av_cold int cudascale_load_functions(AVFilterContext *ctx)
Definition: vf_scale_cuda.c:297
AV_SIDE_DATA_PROP_SIZE_DEPENDENT
@ AV_SIDE_DATA_PROP_SIZE_DEPENDENT
Side data depends on the video dimensions.
Definition: frame.h:309
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:39
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:52
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:542
cudascale_class
static const AVClass cudascale_class
Definition: vf_scale_cuda.c:663
cudascale_config_props
static av_cold int cudascale_config_props(AVFilterLink *outlink)
Definition: vf_scale_cuda.c:370
CUDAScaleContext::hwctx
AVCUDADeviceContext * hwctx
Definition: vf_scale_cuda.c:87
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
set_format_info
static av_cold void set_format_info(AVFilterContext *ctx, enum AVPixelFormat in_format, enum AVPixelFormat out_format)
Definition: vf_scale_cuda.c:213
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:106
AVHWFramesContext::height
int height
Definition: hwcontext.h:220
FFFilter
Definition: filters.h:266
SCALE_FORCE_OAR_NB
@ SCALE_FORCE_OAR_NB
Definition: scale_eval.h:28
CUDAScaleContext::interp_as_integer
int interp_as_integer
Definition: vf_scale_cuda.c:121
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:552
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
AV_PIX_FMT_0BGR32
#define AV_PIX_FMT_0BGR32
Definition: pixfmt.h:516
ff_vf_scale_cuda
const FFFilter ff_vf_scale_cuda
Definition: vf_scale_cuda.c:687
CUDAScaleContext::cu_stream
CUstream cu_stream
Definition: vf_scale_cuda.c:117
filters.h
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
ctx
AVFormatContext * ctx
Definition: movenc.c:49
load_helper.h
AVFrame::crop_right
size_t crop_right
Definition: frame.h:753
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:264
format_is_supported
static int format_is_supported(enum AVPixelFormat fmt)
Definition: vf_scale_cuda.c:197
link
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
Definition: filter_design.txt:23
call_resize_kernel
static int call_resize_kernel(AVFilterContext *ctx, CUfunction func, CUtexObject src_tex[4], int src_left, int src_top, int src_width, int src_height, AVFrame *out_frame, int dst_width, int dst_height, int dst_pitch, int mpeg_range)
Definition: vf_scale_cuda.c:437
CUDAScaleContext::param
float param
Definition: vf_scale_cuda.c:123
if
if(ret)
Definition: filter_design.txt:179
CUDAScaleContext::force_divisible_by
int force_divisible_by
Definition: vf_scale_cuda.c:110
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
CUDAScaleContext::interp_algo
int interp_algo
Definition: vf_scale_cuda.c:119
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
OFFSET
#define OFFSET(x)
Definition: vf_scale_cuda.c:641
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:213
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:599
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
CUDAScaleContext::out_desc
const AVPixFmtDescriptor * out_desc
Definition: vf_scale_cuda.c:90
CUDAScaleContext::h_expr
char * h_expr
height expression string
Definition: vf_scale_cuda.c:107
BLOCKY
#define BLOCKY
Definition: vf_scale_cuda.c:69
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVHWFramesContext::device_ref
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition: hwcontext.h:129
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:282
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:241
options
Definition: swscale.c:43
double
double
Definition: af_crystalizer.c:132
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:540
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:198
AVFrame::crop_bottom
size_t crop_bottom
Definition: frame.h:751
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: filters.h:207
cudascale_inputs
static const AVFilterPad cudascale_inputs[]
Definition: vf_scale_cuda.c:670
AVFrame::crop_left
size_t crop_left
Definition: frame.h:752
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
height
#define height
Definition: dsp.h:89
CUDAScaleContext::cu_func
CUfunction cu_func
Definition: vf_scale_cuda.c:115
scale_eval.h
AV_PIX_FMT_NV16
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:198
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:511
AV_PIX_FMT_P216
#define AV_PIX_FMT_P216
Definition: pixfmt.h:620
AV_PIX_FMT_P210
#define AV_PIX_FMT_P210
Definition: pixfmt.h:616
av_frame_side_data_remove_by_props
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.
Definition: side_data.c:117
CUDAScaleContext::cu_module
CUmodule cu_module
Definition: vf_scale_cuda.c:114
ff_null_get_video_buffer
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:44
CUDAScaleContext
Definition: vf_scale_cuda.c:84
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
SCALE_FORCE_OAR_DISABLE
@ SCALE_FORCE_OAR_DISABLE
Definition: scale_eval.h:25
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
internal.h
common.h
av_frame_move_ref
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition: frame.c:523
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:496
SCALE_FORCE_OAR_DECREASE
@ SCALE_FORCE_OAR_DECREASE
Definition: scale_eval.h:26
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:45
AV_PIX_FMT_P016
#define AV_PIX_FMT_P016
Definition: pixfmt.h:604
CUDAScaleContext::in_plane_depths
int in_plane_depths[4]
Definition: vf_scale_cuda.c:92
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:118
AVCUDADeviceContext
This struct is allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_cuda.h:42
BLOCKX
#define BLOCKX
Definition: vf_scale_cuda.c:68
CUDAScaleContext::out_fmt
enum AVPixelFormat in_fmt out_fmt
Definition: vf_scale_cuda.c:89
ret
ret
Definition: filter_design.txt:187
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:204
INTERP_ALGO_BILINEAR
@ INTERP_ALGO_BILINEAR
Definition: vf_scale_cuda.c:77
AV_PIX_FMT_NV12
@ 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...
Definition: pixfmt.h:96
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:81
AV_PIX_FMT_0RGB32
#define AV_PIX_FMT_0RGB32
Definition: pixfmt.h:515
AVHWFramesContext::device_ctx
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Definition: hwcontext.h:137
cuda_check.h
format_entry
Definition: vf_scale_cuda.c:42
AVFrame::sample_aspect_ratio
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:524
INTERP_ALGO_NEAREST
@ INTERP_ALGO_NEAREST
Definition: vf_scale_cuda.c:76
AVFrame::height
int height
Definition: frame.h:499
cudascale_get_video_buffer
static AVFrame * cudascale_get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: vf_scale_cuda.c:632
AVRational::den
int den
Denominator.
Definition: rational.h:60
format_entry::name
char name[13]
Definition: vf_scale_cuda.c:44
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
INTERP_ALGO_LANCZOS
@ INTERP_ALGO_LANCZOS
Definition: vf_scale_cuda.c:79
Windows::Graphics::DirectX::Direct3D11::p
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
Definition: vsrc_gfxcapture_winrt.hpp:53
AV_OPT_TYPE_PIXEL_FMT
@ AV_OPT_TYPE_PIXEL_FMT
Underlying C type is enum AVPixelFormat.
Definition: opt.h:307
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
INTERP_ALGO_BICUBIC
@ INTERP_ALGO_BICUBIC
Definition: vf_scale_cuda.c:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:274
AV_PIX_FMT_P010
#define AV_PIX_FMT_P010
Definition: pixfmt.h:602
cudascale_outputs
static const AVFilterPad cudascale_outputs[]
Definition: vf_scale_cuda.c:679
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FFFilter::p
AVFilter p
The public AVFilter.
Definition: filters.h:270
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
cudascale_scale
static int cudascale_scale(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
Definition: vf_scale_cuda.c:551
cudascale_filter_frame
static int cudascale_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_scale_cuda.c:585
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
CUDAScaleContext::force_original_aspect_ratio
int force_original_aspect_ratio
Definition: vf_scale_cuda.c:109
CUDAScaleContext::format
enum AVPixelFormat format
Output sw format.
Definition: vf_scale_cuda.c:104
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AVFrame::crop_top
size_t crop_top
Definition: frame.h:750
SCALE_CUDA_PARAM_DEFAULT
#define SCALE_CUDA_PARAM_DEFAULT
Definition: vf_scale_cuda.h:34
CUDAScaleContext::in_desc
const AVPixFmtDescriptor * in_desc
Definition: vf_scale_cuda.c:90
init_processing_chain
static av_cold int init_processing_chain(AVFilterContext *ctx, int in_width, int in_height, int out_width, int out_height)
Definition: vf_scale_cuda.c:239
hwcontext.h
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:472
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
h
h
Definition: vp9dsp_template.c:2070
AV_OPT_TYPE_STRING
@ 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...
Definition: opt.h:276
width
#define width
Definition: dsp.h:89
av_hwframe_get_buffer
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
Definition: hwcontext.c:506
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:253
snprintf
#define snprintf
Definition: snprintf.h:34
INTERP_ALGO_DEFAULT
@ INTERP_ALGO_DEFAULT
Definition: vf_scale_cuda.c:74
ff_scale_adjust_dimensions
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 ...
Definition: scale_eval.c:113
src
#define src
Definition: vp8dsp.c:248
SCALE_FORCE_OAR_INCREASE
@ SCALE_FORCE_OAR_INCREASE
Definition: scale_eval.h:27
av_get_pix_fmt_name
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.
Definition: pixdesc.c:3376
CUDAScaleContext::out_planes
int out_planes
Definition: vf_scale_cuda.c:91
CUDAScaleContext::cu_ctx
CUcontext cu_ctx
Definition: vf_scale_cuda.c:113