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 #include <string.h>
26 
27 #include "libavutil/common.h"
28 #include "libavutil/hwcontext.h"
30 #include "libavutil/cuda_check.h"
31 #include "libavutil/internal.h"
32 #include "libavutil/mem.h"
33 #include "libavutil/opt.h"
34 #include "libavutil/pixdesc.h"
35 #include "libavutil/refstruct.h"
36 
37 #include "libswscale/filters.h"
38 
39 #include "avfilter.h"
40 #include "filters.h"
41 #include "scale_eval.h"
42 #include "video.h"
43 
44 #include "cuda/load_helper.h"
45 #include "vf_scale_cuda.h"
46 
47 struct format_entry {
49  char name[13];
50 };
51 
52 static const struct format_entry supported_formats[] = {
53  {AV_PIX_FMT_YUV420P, "planar8"},
54  {AV_PIX_FMT_YUV422P, "planar8"},
55  {AV_PIX_FMT_YUV444P, "planar8"},
56  {AV_PIX_FMT_YUV420P10,"planar10"},
57  {AV_PIX_FMT_YUV422P10,"planar10"},
58  {AV_PIX_FMT_YUV444P10,"planar10"},
59  {AV_PIX_FMT_YUV444P10MSB,"planar16"},
60  {AV_PIX_FMT_YUV444P12MSB,"planar16"},
61  {AV_PIX_FMT_YUV444P16,"planar16"},
62  {AV_PIX_FMT_NV12, "semiplanar8"},
63  {AV_PIX_FMT_NV16, "semiplanar8"},
64  {AV_PIX_FMT_P010, "semiplanar10"},
65  {AV_PIX_FMT_P210, "semiplanar10"},
66  {AV_PIX_FMT_P012, "semiplanar16"},
67  {AV_PIX_FMT_P212, "semiplanar16"},
68  {AV_PIX_FMT_P016, "semiplanar16"},
69  {AV_PIX_FMT_P216, "semiplanar16"},
70  {AV_PIX_FMT_0RGB32, "bgr0"},
71  {AV_PIX_FMT_0BGR32, "rgb0"},
72  {AV_PIX_FMT_RGB32, "bgra"},
73  {AV_PIX_FMT_BGR32, "rgba"},
74 };
75 
76 #define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
77 #define BLOCKX 32
78 #define BLOCKY 16
79 
80 #define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
81 
82 enum {
84 
89 
91 };
92 
93 enum {
97 };
98 
99 typedef struct CUDAScaleFilter {
100  CUdeviceptr weights; ///< float[dst_size][filter_size]
101  CUdeviceptr offsets; ///< int[dst_size]
103  int dst_size;
105 
106 typedef struct CUDATex {
107  CUtexObject tex[4];
108  CUdeviceptr data[4];
109  int linesize[4];
110  int width, height;
115 } CUDATex;
116 
117 typedef struct CUDAScaleContext {
118  const AVClass *class;
119 
121 
122  enum AVPixelFormat in_fmt, out_fmt;
127 
130 
133 
134  /**
135  * Output sw format. AV_PIX_FMT_NONE for no conversion.
136  */
138 
139  char *w_expr; ///< width expression string
140  char *h_expr; ///< height expression string
141 
145 
146  CUcontext cu_ctx;
147  CUmodule cu_module;
148  CUfunction cu_func[FILTER_NB];
149  CUfunction cu_func_uv[FILTER_NB];
150  CUstream cu_stream;
151 
155 
159  int use_filters; /* -1 for auto */
160 
161  float param;
163 
165 {
166  CUDAScaleContext *s = ctx->priv;
167 
168  s->frame = av_frame_alloc();
169  if (!s->frame)
170  return AVERROR(ENOMEM);
171 
172  s->tmp_frame = av_frame_alloc();
173  if (!s->tmp_frame)
174  return AVERROR(ENOMEM);
175 
176  return 0;
177 }
178 
179 static void filter_uninit(CudaFunctions *cu, CUDAScaleFilter *filter)
180 {
181  if (filter->weights)
182  cu->cuMemFree(filter->weights);
183  if (filter->offsets)
184  cu->cuMemFree(filter->offsets);
185  memset(filter, 0, sizeof(*filter));
186 }
187 
188 static void cuda_tex_uninit(CudaFunctions *cu, CUDATex *t)
189 {
190  for (int i = 0; i < FF_ARRAY_ELEMS(t->tex); i++) {
191  if (t->tex[i])
192  cu->cuTexObjectDestroy(t->tex[i]);
193  if (t->data[i] && !t->external_data)
194  cu->cuMemFree(t->data[i]);
195  }
196 
197  memset(t, 0, sizeof(*t));
198 }
199 
201 {
202  CUDAScaleContext *s = ctx->priv;
203 
204  if (s->hwctx) {
205  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
206  CUcontext dummy;
207 
208  CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx));
209 
210  cuda_tex_uninit(cu, &s->inter_tex);
211  for (int i = 0; i < FF_ARRAY_ELEMS(s->filters); i++) {
212  filter_uninit(cu, &s->filters[i]);
213  filter_uninit(cu, &s->filters_uv[i]);
214  }
215 
216  if (s->cu_module) {
217  CHECK_CU(cu->cuModuleUnload(s->cu_module));
218  s->cu_module = NULL;
219  }
220 
221  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
222  }
223 
224  av_frame_free(&s->frame);
225  av_buffer_unref(&s->frames_ctx);
226  av_frame_free(&s->tmp_frame);
227 }
228 
229 static av_cold int init_hwframe_ctx(CUDAScaleContext *s, AVBufferRef *device_ctx, int width, int height)
230 {
231  AVBufferRef *out_ref = NULL;
232  AVHWFramesContext *out_ctx;
233  int ret;
234 
235  out_ref = av_hwframe_ctx_alloc(device_ctx);
236  if (!out_ref)
237  return AVERROR(ENOMEM);
238  out_ctx = (AVHWFramesContext*)out_ref->data;
239 
240  out_ctx->format = AV_PIX_FMT_CUDA;
241  out_ctx->sw_format = s->out_fmt;
242  out_ctx->width = FFALIGN(width, 32);
243  out_ctx->height = FFALIGN(height, 32);
244 
245  ret = av_hwframe_ctx_init(out_ref);
246  if (ret < 0)
247  goto fail;
248 
249  av_frame_unref(s->frame);
250  ret = av_hwframe_get_buffer(out_ref, s->frame, 0);
251  if (ret < 0)
252  goto fail;
253 
254  s->frame->width = width;
255  s->frame->height = height;
256 
257  av_buffer_unref(&s->frames_ctx);
258  s->frames_ctx = out_ref;
259 
260  return 0;
261 fail:
262  av_buffer_unref(&out_ref);
263  return ret;
264 }
265 
266 static av_cold int inter_buf_init(AVFilterContext *ctx, int out_width, int in_height)
267 {
268  CUDAScaleContext *s = ctx->priv;
269  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
270  int ret = 0;
271 
272  cuda_tex_uninit(cu, &s->inter_tex);
273  s->inter_tex = (CUDATex) {
274  .width = out_width,
275  .height = in_height,
276  .crop_width = out_width,
277  .crop_height = in_height,
278  .log2_chroma_w = s->out_desc->log2_chroma_w,
279  .log2_chroma_h = s->in_desc->log2_chroma_h,
280  };
281 
282  for (int i = 0; i < s->in_planes; i++) {
283  const int is_chroma = i == 1 || i == 2;
284  const int sub_x = is_chroma ? s->inter_tex.log2_chroma_w : 0;
285  const int sub_y = is_chroma ? s->inter_tex.log2_chroma_h : 0;
286  const int plane_w = AV_CEIL_RSHIFT(out_width, sub_x);
287  const int plane_h = AV_CEIL_RSHIFT(in_height, sub_y);
288  const int sizeof_pixel = (s->in_plane_depths[i] <= 8 ? 1 : 2) *
289  s->in_plane_channels[i];
290 
291  size_t pitch;
292  ret = CHECK_CU(cu->cuMemAllocPitch(&s->inter_tex.data[i], &pitch,
293  (size_t) plane_w * sizeof_pixel,
294  plane_h, 16));
295  if (ret < 0)
296  goto fail;
297  s->inter_tex.linesize[i] = pitch;
298 
299  CUDA_TEXTURE_DESC tex_desc = {
300  /* inter tex is always read as float */
301  .filterMode = CU_TR_FILTER_MODE_POINT,
302  };
303 
304  CUDA_RESOURCE_DESC res_desc = {
305  .resType = CU_RESOURCE_TYPE_PITCH2D,
306  .res.pitch2D.format = s->in_plane_depths[i] <= 8 ?
307  CU_AD_FORMAT_UNSIGNED_INT8 :
308  CU_AD_FORMAT_UNSIGNED_INT16,
309  .res.pitch2D.numChannels = s->in_plane_channels[i],
310  .res.pitch2D.devPtr = s->inter_tex.data[i],
311  .res.pitch2D.pitchInBytes = pitch,
312  .res.pitch2D.width = plane_w,
313  .res.pitch2D.height = plane_h,
314  };
315 
316  ret = CHECK_CU(cu->cuTexObjectCreate(&s->inter_tex.tex[i], &res_desc,
317  &tex_desc, NULL));
318  if (ret < 0)
319  goto fail;
320  }
321 
322  return 0;
323 
324 fail:
325  cuda_tex_uninit(cu, &s->inter_tex);
326  return ret;
327 }
328 
329 static int format_is_supported(enum AVPixelFormat fmt)
330 {
331  for (int i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
332  if (supported_formats[i].format == fmt)
333  return 1;
334  return 0;
335 }
336 
337 static const char* get_format_name(enum AVPixelFormat fmt)
338 {
339  for (int i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
340  if (supported_formats[i].format == fmt)
341  return supported_formats[i].name;
342  return NULL;
343 }
344 
345 static av_cold void set_format_info(AVFilterContext *ctx, enum AVPixelFormat in_format, enum AVPixelFormat out_format)
346 {
347  CUDAScaleContext *s = ctx->priv;
348  int i, p, d;
349 
350  s->in_fmt = in_format;
351  s->out_fmt = out_format;
352 
353  s->in_desc = av_pix_fmt_desc_get(s->in_fmt);
354  s->out_desc = av_pix_fmt_desc_get(s->out_fmt);
355  s->in_planes = av_pix_fmt_count_planes(s->in_fmt);
356  s->out_planes = av_pix_fmt_count_planes(s->out_fmt);
357 
358  // find maximum step of each component of each plane
359  // For our subset of formats, this should accurately tell us how many channels CUDA needs
360  // i.e. 1 for Y plane, 2 for UV plane of NV12, 4 for single plane of RGB0 formats
361 
362  for (i = 0; i < s->in_desc->nb_components; i++) {
363  d = (s->in_desc->comp[i].depth + 7) / 8;
364  p = s->in_desc->comp[i].plane;
365  s->in_plane_channels[p] = FFMAX(s->in_plane_channels[p], s->in_desc->comp[i].step / d);
366 
367  s->in_plane_depths[p] = s->in_desc->comp[i].depth;
368  }
369 }
370 
371 static av_cold int init_processing_chain(AVFilterContext *ctx, int in_width, int in_height,
372  int out_width, int out_height)
373 {
374  CUDAScaleContext *s = ctx->priv;
375  FilterLink *inl = ff_filter_link(ctx->inputs[0]);
376  FilterLink *outl = ff_filter_link(ctx->outputs[0]);
377 
378  AVHWFramesContext *in_frames_ctx;
379 
380  enum AVPixelFormat in_format;
381  enum AVPixelFormat out_format;
382  int ret;
383 
384  /* check that we have a hw context */
385  if (!inl->hw_frames_ctx) {
386  av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n");
387  return AVERROR(EINVAL);
388  }
389  in_frames_ctx = (AVHWFramesContext*)inl->hw_frames_ctx->data;
390  in_format = in_frames_ctx->sw_format;
391  out_format = (s->format == AV_PIX_FMT_NONE) ? in_format : s->format;
392 
393  if (!format_is_supported(in_format)) {
394  av_log(ctx, AV_LOG_ERROR, "Unsupported input format: %s\n",
395  av_get_pix_fmt_name(in_format));
396  return AVERROR(ENOSYS);
397  }
398  if (!format_is_supported(out_format)) {
399  av_log(ctx, AV_LOG_ERROR, "Unsupported output format: %s\n",
400  av_get_pix_fmt_name(out_format));
401  return AVERROR(ENOSYS);
402  }
403 
404  set_format_info(ctx, in_format, out_format);
405 
406  if (s->passthrough && in_width == out_width && in_height == out_height && in_format == out_format) {
407  s->frames_ctx = av_buffer_ref(inl->hw_frames_ctx);
408  if (!s->frames_ctx)
409  return AVERROR(ENOMEM);
410  } else {
411  s->passthrough = 0;
412 
413  ret = init_hwframe_ctx(s, in_frames_ctx->device_ref, out_width, out_height);
414  if (ret < 0)
415  return ret;
416 
417  if (in_width == out_width && in_height == out_height &&
418  in_format == out_format && s->interp_algo == INTERP_ALGO_DEFAULT)
419  s->interp_algo = INTERP_ALGO_NEAREST;
420 
421  if (s->interp_algo == INTERP_ALGO_NEAREST) {
422  s->use_filters = 0;
423  } else if (s->use_filters < 0 && (out_width < in_width || out_height < in_height))
424  s->use_filters = 1; /* downscaling; needed for anti-aliasing */
425  }
426 
427  outl->hw_frames_ctx = av_buffer_ref(s->frames_ctx);
428  if (!outl->hw_frames_ctx)
429  return AVERROR(ENOMEM);
430 
431  return 0;
432 }
433 
435 {
436  CUDAScaleContext *s = ctx->priv;
437  CUcontext dummy, cuda_ctx = s->hwctx->cuda_ctx;
438  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
439  char buf[128];
440  int ret;
441 
442  const char *in_fmt_name = get_format_name(s->in_fmt);
443  const char *out_fmt_name = get_format_name(s->out_fmt);
444 
445  const char *function_infix = "";
446 
447  extern const unsigned char ff_vf_scale_cuda_ptx_data[];
448  extern const unsigned int ff_vf_scale_cuda_ptx_len;
449 
450  if (s->use_filters) {
451  /* Final pass is always vertical unless not vertically scaling */
452  AVFilterLink *inlink = ctx->inputs[0];
453  AVFilterLink *outlink = ctx->outputs[0];
454  function_infix = inlink->h == outlink->h ? "Generic_h" : "Generic_v";
455  s->interp_use_linear = 0;
456  s->interp_as_integer = 0;
457  } else {
458  switch(s->interp_algo) {
459  case INTERP_ALGO_NEAREST:
460  function_infix = "Nearest";
461  s->interp_use_linear = 0;
462  s->interp_as_integer = 1;
463  break;
465  function_infix = "Bilinear";
466  s->interp_use_linear = 1;
467  s->interp_as_integer = 1;
468  break;
469  case INTERP_ALGO_DEFAULT:
470  case INTERP_ALGO_BICUBIC:
471  function_infix = "Bicubic";
472  s->interp_use_linear = 0;
473  s->interp_as_integer = 0;
474  break;
475  case INTERP_ALGO_LANCZOS:
476  function_infix = "Lanczos";
477  s->interp_use_linear = 0;
478  s->interp_as_integer = 0;
479  break;
480  default:
481  av_log(ctx, AV_LOG_ERROR, "Unknown interpolation algorithm\n");
482  return AVERROR_BUG;
483  }
484  }
485 
486  ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
487  if (ret < 0)
488  return ret;
489 
490  ret = ff_cuda_load_module(ctx, s->hwctx, &s->cu_module,
491  ff_vf_scale_cuda_ptx_data, ff_vf_scale_cuda_ptx_len);
492  if (ret < 0)
493  goto fail;
494 
495  snprintf(buf, sizeof(buf), "Subsample_%s_%s_%s", function_infix, in_fmt_name, out_fmt_name);
496  ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func[FILTER_OUT], s->cu_module, buf));
497  if (ret < 0) {
498  av_log(ctx, AV_LOG_FATAL, "Unsupported conversion: %s -> %s\n", in_fmt_name, out_fmt_name);
499  ret = AVERROR(ENOSYS);
500  goto fail;
501  }
502  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));
503 
504  snprintf(buf, sizeof(buf), "Subsample_%s_%s_%s_uv", function_infix, in_fmt_name, out_fmt_name);
505  ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func_uv[FILTER_OUT], s->cu_module, buf));
506  if (ret < 0)
507  goto fail;
508  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));
509 
510  if (s->use_filters) {
511  /* Intermediate pass is always horizontal */
512  snprintf(buf, sizeof(buf), "Subsample_Generic_h_%s_%s", in_fmt_name, in_fmt_name);
513  ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func[FILTER_TMP], s->cu_module, buf));
514  if (ret < 0)
515  goto fail;
516 
517  snprintf(buf, sizeof(buf), "Subsample_Generic_h_%s_%s_uv", in_fmt_name, in_fmt_name);
518  ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func_uv[FILTER_TMP], s->cu_module, buf));
519  if (ret < 0)
520  goto fail;
521  }
522 
523 fail:
524  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
525 
526  return ret;
527 }
528 
531  int src_size, int dst_size,
532  double virtual_size)
533 {
534  CUDAScaleContext *s = ctx->priv;
535  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
536 
537  SwsFilterParams params = {
539  .src_size = src_size,
540  .dst_size = dst_size,
541  .virtual_size = virtual_size,
542  };
543 
544  switch (s->interp_algo) {
545  case INTERP_ALGO_NEAREST: return 0; /* no weights needed */
546  case INTERP_ALGO_BILINEAR: params.scaler = SWS_SCALE_BILINEAR; break;
547  case INTERP_ALGO_LANCZOS: params.scaler = SWS_SCALE_LANCZOS; break;
548  case INTERP_ALGO_DEFAULT:
549  case INTERP_ALGO_BICUBIC:
550  params.scaler = SWS_SCALE_BICUBIC;
551  params.scaler_params[0] = params.scaler_params[1] = 0.0;
552  if (s->param != SCALE_CUDA_PARAM_DEFAULT)
553  params.scaler_params[1] = s->param;
554  break;
555  }
556 
558  int ret = ff_sws_filter_generate(ctx, &params, &weights);
559  if (ret < 0) {
560  if (ret == AVERROR(ENOTSUP)) {
561  av_log(ctx, AV_LOG_ERROR, "Filter size exceeds the maximum "
562  "currently supported by the CUDA scaler (%d).\n",
564  }
565  return ret;
566  }
567 
568  float *tmp = av_malloc_array(weights->num_weights, sizeof(*tmp));
569  if (!tmp) {
570  ret = AVERROR(ENOMEM);
571  goto fail;
572  }
573  for (size_t i = 0; i < weights->num_weights; i++)
574  tmp[i] = weights->weights[i] / (float) SWS_FILTER_SCALE;
575 
576  f->filter_size = weights->filter_size;
577  f->dst_size = dst_size;
578 
579  const size_t weights_size = weights->num_weights * sizeof(*tmp);
580  ret = CHECK_CU(cu->cuMemAlloc(&f->weights, weights_size));
581  if (ret < 0)
582  goto fail;
583  ret = CHECK_CU(cu->cuMemcpyHtoD(f->weights, tmp, weights_size));
584  if (ret < 0)
585  goto fail;
586 
587  const size_t offsets_size = dst_size * sizeof(*weights->offsets);
588  ret = CHECK_CU(cu->cuMemAlloc(&f->offsets, offsets_size));
589  if (ret < 0)
590  goto fail;
591  ret = CHECK_CU(cu->cuMemcpyHtoD(f->offsets, weights->offsets, offsets_size));
592  if (ret < 0)
593  goto fail;
594 
595  av_log(ctx, AV_LOG_VERBOSE, " using %d tap '%s' filter: %d -> %d\n",
596  f->filter_size, weights->name, src_size, dst_size);
597 
598  ret = 0;
599 
600 fail:
601  av_free(tmp);
603  return ret;
604 }
605 
607 {
608  CUDAScaleContext *s = ctx->priv;
609  AVFilterLink *inlink = ctx->inputs[0];
610  AVFilterLink *outlink = ctx->outputs[0];
611  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
612  CUcontext dummy;
613  int ret;
614 
615  const int in_sub_x = s->in_desc->log2_chroma_w;
616  const int in_sub_y = s->in_desc->log2_chroma_h;
617  const int out_sub_x = s->out_desc->log2_chroma_w;
618  const int out_sub_y = s->out_desc->log2_chroma_h;
619 
620  ret = CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx));
621  if (ret < 0)
622  return ret;
623 
624  int pass_x = -1, pass_y = -1;
625  if (inlink->w != outlink->w && inlink->h != outlink->h) {
626  /* Always perform the horizontal scaling pass first */
627  pass_x = FILTER_TMP;
628  pass_y = FILTER_OUT;
629  } else if (inlink->w != outlink->w) {
630  pass_x = FILTER_OUT;
631  } else if (inlink->h != outlink->h) {
632  pass_y = FILTER_OUT;
633  }
634 
635  if (pass_x >= 0) {
636  ret = cudascale_filter_init(ctx, &s->filters[pass_x],
637  inlink->w, outlink->w, 0.0);
638  if (ret < 0)
639  goto fail;
640  if (s->in_planes > 1) {
641  const int src_size = AV_CEIL_RSHIFT(inlink->w, in_sub_x);
642  const int dst_size = AV_CEIL_RSHIFT(outlink->w, out_sub_x);
643  const double virtual_size = (double) outlink->w / (1 << out_sub_x);
644  ret = cudascale_filter_init(ctx, &s->filters_uv[pass_x],
645  src_size, dst_size, virtual_size);
646  if (ret < 0)
647  goto fail;
648  }
649  }
650 
651  if (pass_y >= 0) {
652  ret = cudascale_filter_init(ctx, &s->filters[pass_y],
653  inlink->h, outlink->h, 0.0);
654  if (ret < 0)
655  goto fail;
656  if (s->in_planes > 1) {
657  const int src_size = AV_CEIL_RSHIFT(inlink->h, in_sub_y);
658  const int dst_size = AV_CEIL_RSHIFT(outlink->h, out_sub_y);
659  const double virtual_size = (double) outlink->h / (1 << out_sub_y);
660  ret = cudascale_filter_init(ctx, &s->filters_uv[pass_y],
661  src_size, dst_size, virtual_size);
662  if (ret < 0)
663  goto fail;
664  }
665  }
666 
667  ret = inter_buf_init(ctx, outlink->w, inlink->h);
668  if (ret < 0)
669  goto fail;
670 
671  ret = 0;
672 
673 fail:
674  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
675  return ret;
676 }
677 
679 {
680  AVFilterContext *ctx = outlink->src;
681  AVFilterLink *inlink = outlink->src->inputs[0];
683  CUDAScaleContext *s = ctx->priv;
684  AVHWFramesContext *frames_ctx;
685  AVCUDADeviceContext *device_hwctx;
686  int w, h;
687  double w_adj = 1.0;
688  int ret;
689 
691  s->w_expr, s->h_expr,
692  inlink, outlink,
693  &w, &h)) < 0)
694  goto fail;
695 
696  if (s->reset_sar)
697  w_adj = inlink->sample_aspect_ratio.num ?
698  (double)inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
699 
701  s->force_original_aspect_ratio,
702  s->force_divisible_by, w_adj);
703  if (ret < 0)
704  goto fail;
705 
706  if (((int64_t)h * inlink->w) > INT_MAX ||
707  ((int64_t)w * inlink->h) > INT_MAX)
708  av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
709 
710  outlink->w = w;
711  outlink->h = h;
712 
714  if (ret < 0)
715  return ret;
716 
717  frames_ctx = (AVHWFramesContext*)inl->hw_frames_ctx->data;
718  device_hwctx = frames_ctx->device_ctx->hwctx;
719 
720  s->hwctx = device_hwctx;
721  s->cu_stream = s->hwctx->stream;
722 
723  if (s->reset_sar)
724  outlink->sample_aspect_ratio = (AVRational){1, 1};
725  else if (inlink->sample_aspect_ratio.num) {
726  outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h*inlink->w,
727  outlink->w*inlink->h},
728  inlink->sample_aspect_ratio);
729  } else {
730  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
731  }
732 
733  av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s -> w:%d h:%d fmt:%s%s\n",
734  inlink->w, inlink->h, av_get_pix_fmt_name(s->in_fmt),
735  outlink->w, outlink->h, av_get_pix_fmt_name(s->out_fmt),
736  s->passthrough ? " (passthrough)" : "");
737 
738  if (s->use_filters) {
740  if (ret < 0)
741  return ret;
742  }
743 
745  if (ret < 0)
746  return ret;
747 
748  return 0;
749 
750 fail:
751  return ret;
752 }
753 
754 /* if depths/channels are NULL, only maps pointers without creating textures */
756  const int depths[4], const int channels[4],
757  CUDATex *tex)
758 {
759  CUDAScaleContext *s = ctx->priv;
760  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
761 
762  const AVHWFramesContext *fctx = (const AVHWFramesContext*)frame->hw_frames_ctx->data;
764  const int planes = av_pix_fmt_count_planes(fctx->sw_format);
765 
766  *tex = (CUDATex) {
767  .width = frame->width,
768  .height = frame->height,
769  .crop_left = frame->crop_left,
770  .crop_top = frame->crop_top,
771  .crop_width = (frame->width - frame->crop_right) - frame->crop_left,
772  .crop_height = (frame->height - frame->crop_bottom) - frame->crop_top,
773  .color_range = frame->color_range,
774  .log2_chroma_w = desc->log2_chroma_w,
775  .log2_chroma_h = desc->log2_chroma_h,
776  .external_data = 1,
777  };
778 
779  for (int i = 0; i < planes; i++) {
780  tex->data[i] = (CUdeviceptr)frame->data[i];
781  tex->linesize[i] = frame->linesize[i];
782  if (!depths || !channels)
783  continue;
784 
785  CUDA_TEXTURE_DESC tex_desc = {
786  .filterMode = s->interp_use_linear ?
787  CU_TR_FILTER_MODE_LINEAR :
788  CU_TR_FILTER_MODE_POINT,
789  .flags = s->interp_as_integer ? CU_TRSF_READ_AS_INTEGER : 0,
790  };
791 
792  const int is_chroma = i == 1 || i == 2;
793  const int sub_x = is_chroma ? desc->log2_chroma_w : 0;
794  const int sub_y = is_chroma ? desc->log2_chroma_h : 0;
795  CUDA_RESOURCE_DESC res_desc = {
796  .resType = CU_RESOURCE_TYPE_PITCH2D,
797  .res.pitch2D.format = depths[i] <= 8 ?
798  CU_AD_FORMAT_UNSIGNED_INT8 :
799  CU_AD_FORMAT_UNSIGNED_INT16,
800  .res.pitch2D.numChannels = channels[i],
801  .res.pitch2D.pitchInBytes = tex->linesize[i],
802  .res.pitch2D.devPtr = tex->data[i],
803  .res.pitch2D.width = AV_CEIL_RSHIFT(frame->width, sub_x),
804  .res.pitch2D.height = AV_CEIL_RSHIFT(frame->height, sub_y),
805  };
806 
807  int ret = CHECK_CU(cu->cuTexObjectCreate(&tex->tex[i], &res_desc, &tex_desc, NULL));
808  if (ret < 0) {
809  cuda_tex_uninit(cu, tex);
810  return ret;
811  }
812  }
813 
814  return 0;
815 }
816 
817 static int call_resize_kernel(AVFilterContext *ctx, CUfunction func,
818  const CUtexObject src_tex[4],
819  int src_left, int src_top, int src_width, int src_height,
820  const CUdeviceptr out_data[4],
821  int dst_width, int dst_height, int dst_pitch, int mpeg_range,
822  const CUDAScaleFilter *filter)
823 {
824  CUDAScaleContext *s = ctx->priv;
825  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
826 
827  CUDAScaleKernelParams params = {
828  .src_tex = {src_tex[0], src_tex[1], src_tex[2], src_tex[3]},
829  .dst = {
830  out_data[0],
831  out_data[1],
832  out_data[2],
833  out_data[3]
834  },
835  .dst_width = dst_width,
836  .dst_height = dst_height,
837  .dst_pitch = dst_pitch,
838  .src_left = src_left,
839  .src_top = src_top,
840  .src_width = src_width,
841  .src_height = src_height,
842  .param = s->param,
843  .mpeg_range = mpeg_range,
844  };
845 
846  if (filter) {
847  params.weights = filter->weights;
848  params.offsets = filter->offsets;
849  params.filter_size = filter->filter_size;
850  }
851 
852  void *args[] = { &params };
853 
854  return CHECK_CU(cu->cuLaunchKernel(func,
855  DIV_UP(dst_width, BLOCKX), DIV_UP(dst_height, BLOCKY), 1,
856  BLOCKX, BLOCKY, 1, 0, s->cu_stream, args, NULL));
857 }
858 
859 static int scalecuda_resize(AVFilterContext *ctx, int pass,
860  const CUDATex *out, const CUDATex *in)
861 {
862  CUDAScaleContext *s = ctx->priv;
863  int mpeg_range = in->color_range != AVCOL_RANGE_JPEG;
864  int ret;
865 
866  int out_planes = s->out_planes;
867  if (pass == FILTER_TMP)
868  out_planes = s->in_planes;
869 
870  // scale primary plane(s). Usually Y (and A), or single plane of RGB frames.
871  ret = call_resize_kernel(ctx, s->cu_func[pass],
872  in->tex, in->crop_left, in->crop_top,
873  in->crop_width, in->crop_height,
874  out->data, out->width, out->height,
875  out->linesize[0], mpeg_range,
876  &s->filters[pass]);
877  if (ret < 0)
878  return ret;
879 
880  if (out_planes > 1) {
881  // scale UV plane. Scale function sets both U and V plane, or singular interleaved plane.
882  ret = call_resize_kernel(ctx, s->cu_func_uv[pass], in->tex,
887  out->data,
888  AV_CEIL_RSHIFT(out->width, out->log2_chroma_w),
889  AV_CEIL_RSHIFT(out->height, out->log2_chroma_h),
890  out->linesize[1], mpeg_range,
891  &s->filters_uv[pass]);
892  if (ret < 0)
893  return ret;
894  }
895 
896  return 0;
897 }
898 
900 {
901  CUDAScaleContext *s = ctx->priv;
902  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
903  AVFilterLink *outlink = ctx->outputs[0];
904  int ret = 0;
905 
906  CUDATex in_tex = {0}, out_tex = {0};
907  ret = cuda_tex_map_frame(ctx, in, s->in_plane_depths, s->in_plane_channels, &in_tex);
908  if (ret < 0)
909  goto fail;
910 
911  ret = cuda_tex_map_frame(ctx, s->frame, NULL, NULL, &out_tex);
912  if (ret < 0)
913  goto fail;
914 
915  const CUDATex *src = &in_tex;
916  if (s->use_filters) {
917  /* Handle first pass separately */
918  s->inter_tex.color_range = in->color_range;
919  ret = scalecuda_resize(ctx, FILTER_TMP, &s->inter_tex, src);
920  if (ret < 0)
921  goto fail;
922  src = &s->inter_tex;
923  }
924 
925  ret = scalecuda_resize(ctx, FILTER_OUT, &out_tex, src);
926  if (ret < 0)
927  goto fail;
928 
929  ret = av_hwframe_get_buffer(s->frame->hw_frames_ctx, s->tmp_frame, 0);
930  if (ret < 0)
931  goto fail;
932 
933  av_frame_move_ref(out, s->frame);
934  av_frame_move_ref(s->frame, s->tmp_frame);
935 
936  s->frame->width = outlink->w;
937  s->frame->height = outlink->h;
938 
939  ret = av_frame_copy_props(out, in);
940  if (ret < 0)
941  goto fail;
942 
943  if (out->width != in->width || out->height != in->height) {
944  av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
946  }
947 
948 fail:
949  cuda_tex_uninit(cu, &in_tex);
950  cuda_tex_uninit(cu, &out_tex);
951  return ret;
952 }
953 
955 {
956  AVFilterContext *ctx = link->dst;
957  CUDAScaleContext *s = ctx->priv;
958  AVFilterLink *outlink = ctx->outputs[0];
959  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
960 
961  AVFrame *out = NULL;
962  CUcontext dummy;
963  int ret = 0;
964 
965  if (s->passthrough)
966  return ff_filter_frame(outlink, in);
967 
968  out = av_frame_alloc();
969  if (!out) {
970  ret = AVERROR(ENOMEM);
971  goto fail;
972  }
973 
974  ret = CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx));
975  if (ret < 0)
976  goto fail;
977 
978  ret = cudascale_scale(ctx, out, in);
979 
980  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
981  if (ret < 0)
982  goto fail;
983 
984  if (s->reset_sar) {
985  out->sample_aspect_ratio = (AVRational){1, 1};
986  } else {
987  av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
988  (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
989  (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
990  INT_MAX);
991  }
992 
993  av_frame_free(&in);
994  return ff_filter_frame(outlink, out);
995 fail:
996  av_frame_free(&in);
997  av_frame_free(&out);
998  return ret;
999 }
1000 
1002 {
1003  CUDAScaleContext *s = inlink->dst->priv;
1004 
1005  return s->passthrough ?
1008 }
1009 
1010 #define OFFSET(x) offsetof(CUDAScaleContext, x)
1011 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
1012 static const AVOption options[] = {
1013  { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS },
1014  { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS },
1015  { "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" },
1016  { "nearest", "nearest neighbour", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_NEAREST }, 0, 0, FLAGS, .unit = "interp_algo" },
1017  { "bilinear", "bilinear", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_BILINEAR }, 0, 0, FLAGS, .unit = "interp_algo" },
1018  { "bicubic", "bicubic", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_BICUBIC }, 0, 0, FLAGS, .unit = "interp_algo" },
1019  { "lanczos", "lanczos", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_LANCZOS }, 0, 0, FLAGS, .unit = "interp_algo" },
1020  { "format", "Output video pixel format", OFFSET(format), AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_NONE }, INT_MIN, INT_MAX, .flags=FLAGS },
1021  { "passthrough", "Do not process frames at all if parameters match", OFFSET(passthrough), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
1022  { "use_filters", "Use generic filters instead of fixed function kernels", OFFSET(use_filters), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, FLAGS, .unit = "use_filters" },
1023  { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "use_filters" },
1024  { "param", "Algorithm-Specific parameter", OFFSET(param), AV_OPT_TYPE_FLOAT, { .dbl = SCALE_CUDA_PARAM_DEFAULT }, -FLT_MAX, FLT_MAX, FLAGS },
1025  { "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" },
1026  { "disable", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DISABLE }, 0, 0, FLAGS, .unit = "force_oar" },
1027  { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DECREASE }, 0, 0, FLAGS, .unit = "force_oar" },
1028  { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_INCREASE }, 0, 0, FLAGS, .unit = "force_oar" },
1029  { "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 },
1030  { "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 },
1031  { NULL },
1032 };
1033 
1034 static const AVClass cudascale_class = {
1035  .class_name = "cudascale",
1036  .item_name = av_default_item_name,
1037  .option = options,
1038  .version = LIBAVUTIL_VERSION_INT,
1039 };
1040 
1041 static const AVFilterPad cudascale_inputs[] = {
1042  {
1043  .name = "default",
1044  .type = AVMEDIA_TYPE_VIDEO,
1045  .filter_frame = cudascale_filter_frame,
1046  .get_buffer.video = cudascale_get_video_buffer,
1047  },
1048 };
1049 
1050 static const AVFilterPad cudascale_outputs[] = {
1051  {
1052  .name = "default",
1053  .type = AVMEDIA_TYPE_VIDEO,
1054  .config_props = cudascale_config_props,
1055  },
1056 };
1057 
1059  .p.name = "scale_cuda",
1060  .p.description = NULL_IF_CONFIG_SMALL("GPU accelerated video resizer"),
1061 
1062  .p.priv_class = &cudascale_class,
1063 
1064  .init = cudascale_init,
1065  .uninit = cudascale_uninit,
1066 
1067  .priv_size = sizeof(CUDAScaleContext),
1068 
1071 
1073 
1074  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
1075 };
SCALE_FORCE_OAR_DISABLE
@ SCALE_FORCE_OAR_DISABLE
Definition: scale_eval.h:25
options
static const AVOption options[]
Definition: vf_scale_cuda.c:1012
func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:66
CUDAScaleFilter
Definition: vf_scale_cuda.c:99
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:88
CUDATex::crop_top
int crop_top
Definition: vf_scale_cuda.c:112
AVFrame::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: frame.h:717
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:48
CUDAScaleKernelParams::src_tex
CUtexObject src_tex[4]
Definition: vf_scale_cuda.h:36
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:128
hwcontext_cuda_internal.h
cudascale_init
static av_cold int cudascale_init(AVFilterContext *ctx)
Definition: vf_scale_cuda.c:164
out
static FILE * out
Definition: movenc.c:55
supported_formats
static const struct format_entry supported_formats[]
Definition: vf_scale_cuda.c:52
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:1068
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
SWS_SCALE_BILINEAR
@ SWS_SCALE_BILINEAR
bilinear filtering
Definition: swscale.h:98
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:34
av_cold
#define av_cold
Definition: attributes.h:119
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:131
AV_PIX_FMT_YUV444P10MSB
#define AV_PIX_FMT_YUV444P10MSB
Definition: pixfmt.h:554
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:208
CUDAScaleContext::passthrough
int passthrough
Definition: vf_scale_cuda.c:132
cudascale_uninit
static av_cold void cudascale_uninit(AVFilterContext *ctx)
Definition: vf_scale_cuda.c:200
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
CUDAScaleContext::w_expr
char * w_expr
width expression string
Definition: vf_scale_cuda.c:139
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:466
pixdesc.h
AVFrame::width
int width
Definition: frame.h:538
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
SwsFilterWeights
Represents a computed filter kernel.
Definition: filters.h:85
CUDAScaleFilter::filter_size
int filter_size
Definition: vf_scale_cuda.c:102
AVOption
AVOption.
Definition: opt.h:428
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:254
init_hwframe_ctx
static av_cold int init_hwframe_ctx(CUDAScaleContext *s, AVBufferRef *device_ctx, int width, int height)
Definition: vf_scale_cuda.c:229
filters.h
CUDAScaleContext::interp_use_linear
int interp_use_linear
Definition: vf_scale_cuda.c:153
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:539
FLAGS
#define FLAGS
Definition: vf_scale_cuda.c:1011
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:58
float.h
filter
void(* filter)(uint8_t *src, int stride, int qscale)
Definition: h263dsp.c:29
DIV_UP
#define DIV_UP(a, b)
Definition: vf_scale_cuda.c:76
SwsFilterParams
Definition: filters.h:45
CUDAScaleKernelParams::weights
CUdeviceptr weights
Definition: vf_scale_cuda.h:49
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
CUDAScaleKernelParams
Definition: vf_scale_cuda.h:35
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:219
INTERP_ALGO_DEFAULT
@ INTERP_ALGO_DEFAULT
Definition: vf_scale_cuda.c:83
get_format_name
static const char * get_format_name(enum AVPixelFormat fmt)
Definition: vf_scale_cuda.c:337
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:220
video.h
dummy
static int dummy
Definition: ffplay.c:3751
CUDATex::log2_chroma_w
int log2_chroma_w
Definition: vf_scale_cuda.c:111
AV_PIX_FMT_P212
#define AV_PIX_FMT_P212
Definition: pixfmt.h:618
AV_PIX_FMT_YUV444P12MSB
#define AV_PIX_FMT_YUV444P12MSB
Definition: pixfmt.h:555
ff_sws_filter_generate
int ff_sws_filter_generate(void *log, const SwsFilterParams *params, SwsFilterWeights **out)
Generate a filter kernel for the given parameters.
Definition: filters.c:187
CUDAScaleContext::frame
AVFrame * frame
Definition: vf_scale_cuda.c:129
ff_default_get_video_buffer
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:84
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3496
vf_scale_cuda.h
INTERP_ALGO_LANCZOS
@ INTERP_ALGO_LANCZOS
Definition: vf_scale_cuda.c:88
CHECK_CU
#define CHECK_CU(x)
Definition: vf_scale_cuda.c:80
CUDAScaleContext::in_planes
int in_planes
Definition: vf_scale_cuda.c:124
CUDAScaleContext::in_plane_channels
int in_plane_channels[4]
Definition: vf_scale_cuda.c:126
CUDAScaleContext::reset_sar
int reset_sar
Definition: vf_scale_cuda.c:144
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
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:434
refstruct.h
AV_SIDE_DATA_PROP_SIZE_DEPENDENT
@ AV_SIDE_DATA_PROP_SIZE_DEPENDENT
Side data depends on the video dimensions.
Definition: frame.h:348
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:40
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
CUDATex::tex
CUtexObject tex[4]
Definition: vf_scale_cuda.c:107
SWS_SCALE_BICUBIC
@ SWS_SCALE_BICUBIC
2-tap cubic BC-spline
Definition: swscale.h:99
cudascale_class
static const AVClass cudascale_class
Definition: vf_scale_cuda.c:1034
cudascale_config_props
static av_cold int cudascale_config_props(AVFilterLink *outlink)
Definition: vf_scale_cuda.c:678
CUDAScaleContext::hwctx
AVCUDADeviceContext * hwctx
Definition: vf_scale_cuda.c:120
cudascale_setup_filters
static av_cold int cudascale_setup_filters(AVFilterContext *ctx)
Definition: vf_scale_cuda.c:606
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:345
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
inter_buf_init
static av_cold int inter_buf_init(AVFilterContext *ctx, int out_width, int in_height)
Definition: vf_scale_cuda.c:266
AVHWFramesContext::height
int height
Definition: hwcontext.h:220
FFFilter
Definition: filters.h:267
CUDAScaleContext::interp_as_integer
int interp_as_integer
Definition: vf_scale_cuda.c:154
s
#define s(width, name)
Definition: cbs_vp9.c:198
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:265
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:552
SWS_SCALE_LANCZOS
@ SWS_SCALE_LANCZOS
3-tap sinc/sinc
Definition: swscale.h:104
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
SWS_FILTER_SCALE
@ SWS_FILTER_SCALE
14-bit coefficients are picked to fit comfortably within int16_t for efficient SIMD processing (e....
Definition: filters.h:40
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:199
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:1058
CUDATex::external_data
int external_data
Definition: vf_scale_cuda.c:114
CUDAScaleContext::cu_stream
CUstream cu_stream
Definition: vf_scale_cuda.c:150
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
ctx
static AVFormatContext * ctx
Definition: movenc.c:49
channels
channels
Definition: aptx.h:31
load_helper.h
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
format_is_supported
static int format_is_supported(enum AVPixelFormat fmt)
Definition: vf_scale_cuda.c:329
tmp
static uint8_t tmp[40]
Definition: aes_ctr.c:52
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
CUDAScaleContext::param
float param
Definition: vf_scale_cuda.c:161
if
if(ret)
Definition: filter_design.txt:179
CUDAScaleContext::force_divisible_by
int force_divisible_by
Definition: vf_scale_cuda.c:143
fail
#define fail
Definition: test.h:478
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
CUDAScaleContext::interp_algo
int interp_algo
Definition: vf_scale_cuda.c:152
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
OFFSET
#define OFFSET(x)
Definition: vf_scale_cuda.c:1010
NULL
#define NULL
Definition: coverity.c:32
filters.h
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:123
CUDAScaleContext::h_expr
char * h_expr
height expression string
Definition: vf_scale_cuda.c:140
BLOCKY
#define BLOCKY
Definition: vf_scale_cuda.c:78
CUDATex::color_range
int color_range
Definition: vf_scale_cuda.c:113
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
CUDATex::data
CUdeviceptr data[4]
Definition: vf_scale_cuda.c:108
AVHWFramesContext::device_ref
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition: hwcontext.h:129
CUDATex::linesize
int linesize[4]
Definition: vf_scale_cuda.c:109
CUDAScaleFilter::dst_size
int dst_size
Definition: vf_scale_cuda.c:103
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:281
CUDATex::height
int height
Definition: vf_scale_cuda.c:110
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:242
options
Definition: swscale.c:50
double
double
Definition: af_crystalizer.c:132
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:540
cudascale_inputs
static const AVFilterPad cudascale_inputs[]
Definition: vf_scale_cuda.c:1041
SWS_PARAM_DEFAULT
#define SWS_PARAM_DEFAULT
Definition: swscale.h:458
f
f
Definition: af_crystalizer.c:122
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:88
height
#define height
Definition: dsp.h:89
AV_PIX_FMT_P012
#define AV_PIX_FMT_P012
Definition: pixfmt.h:603
CUDAScaleContext::cu_func
CUfunction cu_func[FILTER_NB]
Definition: vf_scale_cuda.c:148
CUDAScaleContext::inter_tex
CUDATex inter_tex
Definition: vf_scale_cuda.c:158
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
cuda_tex_uninit
static void cuda_tex_uninit(CudaFunctions *cu, CUDATex *t)
Definition: vf_scale_cuda.c:188
CUDAScaleContext::use_filters
int use_filters
Definition: vf_scale_cuda.c:159
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
cudascale_filter_init
static av_cold int cudascale_filter_init(AVFilterContext *ctx, CUDAScaleFilter *f, int src_size, int dst_size, double virtual_size)
Definition: vf_scale_cuda.c:529
AV_PIX_FMT_RGB32
#define AV_PIX_FMT_RGB32
Definition: pixfmt.h:511
CUDAScaleContext::filters
CUDAScaleFilter filters[FILTER_NB]
Definition: vf_scale_cuda.c:156
FILTER_TMP
@ FILTER_TMP
Definition: vf_scale_cuda.c:95
CUDATex::crop_left
int crop_left
Definition: vf_scale_cuda.c:112
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:122
CUDAScaleContext::cu_module
CUmodule cu_module
Definition: vf_scale_cuda.c:147
ff_null_get_video_buffer
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:44
CUDAScaleContext::cu_func_uv
CUfunction cu_func_uv[FILTER_NB]
Definition: vf_scale_cuda.c:149
CUDAScaleContext
Definition: vf_scale_cuda.c:117
av_refstruct_unref
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
Definition: refstruct.c:120
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:270
SCALE_FORCE_OAR_NB
@ SCALE_FORCE_OAR_NB
Definition: scale_eval.h:28
SCALE_FORCE_OAR_INCREASE
@ SCALE_FORCE_OAR_INCREASE
Definition: scale_eval.h:27
internal.h
planes
static const struct @596 planes[]
av_malloc_array
#define av_malloc_array(a, b)
Definition: tableprint_vlc.h:32
weights
static const int weights[]
Definition: hevc_pel.c:32
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
SwsFilterParams::scaler_params
double scaler_params[SWS_NUM_SCALER_PARAMS]
Definition: filters.h:50
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:46
filter_uninit
static void filter_uninit(CudaFunctions *cu, CUDAScaleFilter *filter)
Definition: vf_scale_cuda.c:179
AV_PIX_FMT_P016
#define AV_PIX_FMT_P016
Definition: pixfmt.h:604
CUDAScaleFilter::offsets
CUdeviceptr offsets
int[dst_size]
Definition: vf_scale_cuda.c:101
CUDAScaleContext::in_plane_depths
int in_plane_depths[4]
Definition: vf_scale_cuda.c:125
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:77
CUDAScaleContext::out_fmt
enum AVPixelFormat in_fmt out_fmt
Definition: vf_scale_cuda.c:122
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
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
frame
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:265
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:47
INTERP_ALGO_BICUBIC
@ INTERP_ALGO_BICUBIC
Definition: vf_scale_cuda.c:87
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:264
AVFrame::sample_aspect_ratio
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition: frame.h:563
CUDAScaleContext::filters_uv
CUDAScaleFilter filters_uv[FILTER_NB]
Definition: vf_scale_cuda.c:157
INTERP_ALGO_BILINEAR
@ INTERP_ALGO_BILINEAR
Definition: vf_scale_cuda.c:86
CUDATex::width
int width
Definition: vf_scale_cuda.c:110
AVFrame::height
int height
Definition: frame.h:538
INTERP_ALGO_COUNT
@ INTERP_ALGO_COUNT
Definition: vf_scale_cuda.c:90
SCALE_FORCE_OAR_DECREASE
@ SCALE_FORCE_OAR_DECREASE
Definition: scale_eval.h:26
cudascale_get_video_buffer
static AVFrame * cudascale_get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: vf_scale_cuda.c:1001
FILTER_OUT
@ FILTER_OUT
Definition: vf_scale_cuda.c:94
AVRational::den
int den
Denominator.
Definition: rational.h:60
format_entry::name
char name[13]
Definition: vf_scale_cuda.c:49
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:258
FILTER_NB
@ FILTER_NB
Definition: vf_scale_cuda.c:96
avfilter.h
call_resize_kernel
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)
Definition: vf_scale_cuda.c:817
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:306
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
AVFilterContext
An instance of a filter.
Definition: avfilter.h:273
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:1050
desc
const char * desc
Definition: libsvtav1.c:83
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FFFilter::p
AVFilter p
The public AVFilter.
Definition: filters.h:271
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
mem.h
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:899
cudascale_filter_frame
static int cudascale_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_scale_cuda.c:954
CUDATex::crop_height
int crop_height
Definition: vf_scale_cuda.c:112
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
w
uint8_t w
Definition: llvidencdsp.c:39
CUDAScaleContext::force_original_aspect_ratio
int force_original_aspect_ratio
Definition: vf_scale_cuda.c:142
CUDAScaleContext::format
enum AVPixelFormat format
Output sw format.
Definition: vf_scale_cuda.c:137
SWS_FILTER_SIZE_MAX
@ SWS_FILTER_SIZE_MAX
Definition: filters.h:41
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
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:326
CUDATex::crop_width
int crop_width
Definition: vf_scale_cuda.c:112
SCALE_CUDA_PARAM_DEFAULT
#define SCALE_CUDA_PARAM_DEFAULT
Definition: vf_scale_cuda.h:33
CUDATex
Definition: vf_scale_cuda.c:106
CUDAScaleContext::in_desc
const AVPixFmtDescriptor * in_desc
Definition: vf_scale_cuda.c:123
CUDAScaleFilter::weights
CUdeviceptr weights
float[dst_size][filter_size]
Definition: vf_scale_cuda.c:100
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:371
hwcontext.h
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
INTERP_ALGO_NEAREST
@ INTERP_ALGO_NEAREST
Definition: vf_scale_cuda.c:85
h
h
Definition: vp9dsp_template.c:2070
cuda_tex_map_frame
static int cuda_tex_map_frame(AVFilterContext *ctx, const AVFrame *frame, const int depths[4], const int channels[4], CUDATex *tex)
Definition: vf_scale_cuda.c:755
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:275
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
CUDAScaleKernelParams::offsets
CUdeviceptr offsets
Definition: vf_scale_cuda.h:50
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:298
SwsFilterParams::scaler
SwsScaler scaler
The filter kernel and parameters to use.
Definition: filters.h:49
snprintf
#define snprintf
Definition: snprintf.h:34
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:123
CUDATex::log2_chroma_h
int log2_chroma_h
Definition: vf_scale_cuda.c:111
src
#define src
Definition: vp8dsp.c:248
CUDAScaleKernelParams::filter_size
int filter_size
Definition: vf_scale_cuda.h:51
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:124
CUDAScaleContext::cu_ctx
CUcontext cu_ctx
Definition: vf_scale_cuda.c:146
scalecuda_resize
static int scalecuda_resize(AVFilterContext *ctx, int pass, const CUDATex *out, const CUDATex *in)
Definition: vf_scale_cuda.c:859