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, s->force_divisible_by, w_adj);
702 
703  if (((int64_t)h * inlink->w) > INT_MAX ||
704  ((int64_t)w * inlink->h) > INT_MAX)
705  av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
706 
707  outlink->w = w;
708  outlink->h = h;
709 
711  if (ret < 0)
712  return ret;
713 
714  frames_ctx = (AVHWFramesContext*)inl->hw_frames_ctx->data;
715  device_hwctx = frames_ctx->device_ctx->hwctx;
716 
717  s->hwctx = device_hwctx;
718  s->cu_stream = s->hwctx->stream;
719 
720  if (s->reset_sar)
721  outlink->sample_aspect_ratio = (AVRational){1, 1};
722  else if (inlink->sample_aspect_ratio.num) {
723  outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h*inlink->w,
724  outlink->w*inlink->h},
725  inlink->sample_aspect_ratio);
726  } else {
727  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
728  }
729 
730  av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s -> w:%d h:%d fmt:%s%s\n",
731  inlink->w, inlink->h, av_get_pix_fmt_name(s->in_fmt),
732  outlink->w, outlink->h, av_get_pix_fmt_name(s->out_fmt),
733  s->passthrough ? " (passthrough)" : "");
734 
735  if (s->use_filters) {
737  if (ret < 0)
738  return ret;
739  }
740 
742  if (ret < 0)
743  return ret;
744 
745  return 0;
746 
747 fail:
748  return ret;
749 }
750 
751 /* if depths/channels are NULL, only maps pointers without creating textures */
753  const int depths[4], const int channels[4],
754  CUDATex *tex)
755 {
756  CUDAScaleContext *s = ctx->priv;
757  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
758 
759  const AVHWFramesContext *fctx = (const AVHWFramesContext*)frame->hw_frames_ctx->data;
761  const int planes = av_pix_fmt_count_planes(fctx->sw_format);
762 
763  *tex = (CUDATex) {
764  .width = frame->width,
765  .height = frame->height,
766  .crop_left = frame->crop_left,
767  .crop_top = frame->crop_top,
768  .crop_width = (frame->width - frame->crop_right) - frame->crop_left,
769  .crop_height = (frame->height - frame->crop_bottom) - frame->crop_top,
770  .color_range = frame->color_range,
771  .log2_chroma_w = desc->log2_chroma_w,
772  .log2_chroma_h = desc->log2_chroma_h,
773  .external_data = 1,
774  };
775 
776  for (int i = 0; i < planes; i++) {
777  tex->data[i] = (CUdeviceptr)frame->data[i];
778  tex->linesize[i] = frame->linesize[i];
779  if (!depths || !channels)
780  continue;
781 
782  CUDA_TEXTURE_DESC tex_desc = {
783  .filterMode = s->interp_use_linear ?
784  CU_TR_FILTER_MODE_LINEAR :
785  CU_TR_FILTER_MODE_POINT,
786  .flags = s->interp_as_integer ? CU_TRSF_READ_AS_INTEGER : 0,
787  };
788 
789  const int is_chroma = i == 1 || i == 2;
790  const int sub_x = is_chroma ? desc->log2_chroma_w : 0;
791  const int sub_y = is_chroma ? desc->log2_chroma_h : 0;
792  CUDA_RESOURCE_DESC res_desc = {
793  .resType = CU_RESOURCE_TYPE_PITCH2D,
794  .res.pitch2D.format = depths[i] <= 8 ?
795  CU_AD_FORMAT_UNSIGNED_INT8 :
796  CU_AD_FORMAT_UNSIGNED_INT16,
797  .res.pitch2D.numChannels = channels[i],
798  .res.pitch2D.pitchInBytes = tex->linesize[i],
799  .res.pitch2D.devPtr = tex->data[i],
800  .res.pitch2D.width = AV_CEIL_RSHIFT(frame->width, sub_x),
801  .res.pitch2D.height = AV_CEIL_RSHIFT(frame->height, sub_y),
802  };
803 
804  int ret = CHECK_CU(cu->cuTexObjectCreate(&tex->tex[i], &res_desc, &tex_desc, NULL));
805  if (ret < 0) {
806  cuda_tex_uninit(cu, tex);
807  return ret;
808  }
809  }
810 
811  return 0;
812 }
813 
814 static int call_resize_kernel(AVFilterContext *ctx, CUfunction func,
815  const CUtexObject src_tex[4],
816  int src_left, int src_top, int src_width, int src_height,
817  const CUdeviceptr out_data[4],
818  int dst_width, int dst_height, int dst_pitch, int mpeg_range,
819  const CUDAScaleFilter *filter)
820 {
821  CUDAScaleContext *s = ctx->priv;
822  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
823 
824  CUDAScaleKernelParams params = {
825  .src_tex = {src_tex[0], src_tex[1], src_tex[2], src_tex[3]},
826  .dst = {
827  out_data[0],
828  out_data[1],
829  out_data[2],
830  out_data[3]
831  },
832  .dst_width = dst_width,
833  .dst_height = dst_height,
834  .dst_pitch = dst_pitch,
835  .src_left = src_left,
836  .src_top = src_top,
837  .src_width = src_width,
838  .src_height = src_height,
839  .param = s->param,
840  .mpeg_range = mpeg_range,
841  };
842 
843  if (filter) {
844  params.weights = filter->weights;
845  params.offsets = filter->offsets;
846  params.filter_size = filter->filter_size;
847  }
848 
849  void *args[] = { &params };
850 
851  return CHECK_CU(cu->cuLaunchKernel(func,
852  DIV_UP(dst_width, BLOCKX), DIV_UP(dst_height, BLOCKY), 1,
853  BLOCKX, BLOCKY, 1, 0, s->cu_stream, args, NULL));
854 }
855 
856 static int scalecuda_resize(AVFilterContext *ctx, int pass,
857  const CUDATex *out, const CUDATex *in)
858 {
859  CUDAScaleContext *s = ctx->priv;
860  int mpeg_range = in->color_range != AVCOL_RANGE_JPEG;
861  int ret;
862 
863  int out_planes = s->out_planes;
864  if (pass == FILTER_TMP)
865  out_planes = s->in_planes;
866 
867  // scale primary plane(s). Usually Y (and A), or single plane of RGB frames.
868  ret = call_resize_kernel(ctx, s->cu_func[pass],
869  in->tex, in->crop_left, in->crop_top,
870  in->crop_width, in->crop_height,
871  out->data, out->width, out->height,
872  out->linesize[0], mpeg_range,
873  &s->filters[pass]);
874  if (ret < 0)
875  return ret;
876 
877  if (out_planes > 1) {
878  // scale UV plane. Scale function sets both U and V plane, or singular interleaved plane.
879  ret = call_resize_kernel(ctx, s->cu_func_uv[pass], in->tex,
884  out->data,
885  AV_CEIL_RSHIFT(out->width, out->log2_chroma_w),
886  AV_CEIL_RSHIFT(out->height, out->log2_chroma_h),
887  out->linesize[1], mpeg_range,
888  &s->filters_uv[pass]);
889  if (ret < 0)
890  return ret;
891  }
892 
893  return 0;
894 }
895 
897 {
898  CUDAScaleContext *s = ctx->priv;
899  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
900  AVFilterLink *outlink = ctx->outputs[0];
901  int ret = 0;
902 
903  CUDATex in_tex = {0}, out_tex = {0};
904  ret = cuda_tex_map_frame(ctx, in, s->in_plane_depths, s->in_plane_channels, &in_tex);
905  if (ret < 0)
906  goto fail;
907 
908  ret = cuda_tex_map_frame(ctx, s->frame, NULL, NULL, &out_tex);
909  if (ret < 0)
910  goto fail;
911 
912  const CUDATex *src = &in_tex;
913  if (s->use_filters) {
914  /* Handle first pass separately */
915  s->inter_tex.color_range = in->color_range;
916  ret = scalecuda_resize(ctx, FILTER_TMP, &s->inter_tex, src);
917  if (ret < 0)
918  goto fail;
919  src = &s->inter_tex;
920  }
921 
922  ret = scalecuda_resize(ctx, FILTER_OUT, &out_tex, src);
923  if (ret < 0)
924  goto fail;
925 
926  ret = av_hwframe_get_buffer(s->frame->hw_frames_ctx, s->tmp_frame, 0);
927  if (ret < 0)
928  goto fail;
929 
930  av_frame_move_ref(out, s->frame);
931  av_frame_move_ref(s->frame, s->tmp_frame);
932 
933  s->frame->width = outlink->w;
934  s->frame->height = outlink->h;
935 
936  ret = av_frame_copy_props(out, in);
937  if (ret < 0)
938  goto fail;
939 
940  if (out->width != in->width || out->height != in->height) {
941  av_frame_side_data_remove_by_props(&out->side_data, &out->nb_side_data,
943  }
944 
945 fail:
946  cuda_tex_uninit(cu, &in_tex);
947  cuda_tex_uninit(cu, &out_tex);
948  return ret;
949 }
950 
952 {
953  AVFilterContext *ctx = link->dst;
954  CUDAScaleContext *s = ctx->priv;
955  AVFilterLink *outlink = ctx->outputs[0];
956  CudaFunctions *cu = s->hwctx->internal->cuda_dl;
957 
958  AVFrame *out = NULL;
959  CUcontext dummy;
960  int ret = 0;
961 
962  if (s->passthrough)
963  return ff_filter_frame(outlink, in);
964 
965  out = av_frame_alloc();
966  if (!out) {
967  ret = AVERROR(ENOMEM);
968  goto fail;
969  }
970 
971  ret = CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx));
972  if (ret < 0)
973  goto fail;
974 
975  ret = cudascale_scale(ctx, out, in);
976 
977  CHECK_CU(cu->cuCtxPopCurrent(&dummy));
978  if (ret < 0)
979  goto fail;
980 
981  if (s->reset_sar) {
982  out->sample_aspect_ratio = (AVRational){1, 1};
983  } else {
984  av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
985  (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
986  (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
987  INT_MAX);
988  }
989 
990  av_frame_free(&in);
991  return ff_filter_frame(outlink, out);
992 fail:
993  av_frame_free(&in);
994  av_frame_free(&out);
995  return ret;
996 }
997 
999 {
1000  CUDAScaleContext *s = inlink->dst->priv;
1001 
1002  return s->passthrough ?
1005 }
1006 
1007 #define OFFSET(x) offsetof(CUDAScaleContext, x)
1008 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
1009 static const AVOption options[] = {
1010  { "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS },
1011  { "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS },
1012  { "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" },
1013  { "nearest", "nearest neighbour", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_NEAREST }, 0, 0, FLAGS, .unit = "interp_algo" },
1014  { "bilinear", "bilinear", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_BILINEAR }, 0, 0, FLAGS, .unit = "interp_algo" },
1015  { "bicubic", "bicubic", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_BICUBIC }, 0, 0, FLAGS, .unit = "interp_algo" },
1016  { "lanczos", "lanczos", 0, AV_OPT_TYPE_CONST, { .i64 = INTERP_ALGO_LANCZOS }, 0, 0, FLAGS, .unit = "interp_algo" },
1017  { "format", "Output video pixel format", OFFSET(format), AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_NONE }, INT_MIN, INT_MAX, .flags=FLAGS },
1018  { "passthrough", "Do not process frames at all if parameters match", OFFSET(passthrough), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS },
1019  { "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" },
1020  { "auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, FLAGS, .unit = "use_filters" },
1021  { "param", "Algorithm-Specific parameter", OFFSET(param), AV_OPT_TYPE_FLOAT, { .dbl = SCALE_CUDA_PARAM_DEFAULT }, -FLT_MAX, FLT_MAX, FLAGS },
1022  { "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" },
1023  { "disable", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DISABLE }, 0, 0, FLAGS, .unit = "force_oar" },
1024  { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_DECREASE }, 0, 0, FLAGS, .unit = "force_oar" },
1025  { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = SCALE_FORCE_OAR_INCREASE }, 0, 0, FLAGS, .unit = "force_oar" },
1026  { "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 },
1027  { "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 },
1028  { NULL },
1029 };
1030 
1031 static const AVClass cudascale_class = {
1032  .class_name = "cudascale",
1033  .item_name = av_default_item_name,
1034  .option = options,
1035  .version = LIBAVUTIL_VERSION_INT,
1036 };
1037 
1038 static const AVFilterPad cudascale_inputs[] = {
1039  {
1040  .name = "default",
1041  .type = AVMEDIA_TYPE_VIDEO,
1042  .filter_frame = cudascale_filter_frame,
1043  .get_buffer.video = cudascale_get_video_buffer,
1044  },
1045 };
1046 
1047 static const AVFilterPad cudascale_outputs[] = {
1048  {
1049  .name = "default",
1050  .type = AVMEDIA_TYPE_VIDEO,
1051  .config_props = cudascale_config_props,
1052  },
1053 };
1054 
1056  .p.name = "scale_cuda",
1057  .p.description = NULL_IF_CONFIG_SMALL("GPU accelerated video resizer"),
1058 
1059  .p.priv_class = &cudascale_class,
1060 
1061  .init = cudascale_init,
1062  .uninit = cudascale_uninit,
1063 
1064  .priv_size = sizeof(CUDAScaleContext),
1065 
1068 
1070 
1071  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
1072 };
options
static const AVOption options[]
Definition: vf_scale_cuda.c:1009
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: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
INTERP_ALGO_DEFAULT
@ INTERP_ALGO_DEFAULT
Definition: vf_scale_cuda.c:83
format_entry::format
enum AVPixelFormat format
Definition: vf_scale_cuda.c:48
SCALE_FORCE_OAR_DISABLE
@ SCALE_FORCE_OAR_DISABLE
Definition: scale_eval.h:25
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
SCALE_FORCE_OAR_INCREASE
@ SCALE_FORCE_OAR_INCREASE
Definition: scale_eval.h:27
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: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:34
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:427
pixdesc.h
AVFrame::width
int width
Definition: frame.h:499
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:101
CUDAScaleFilter::filter_size
int filter_size
Definition: vf_scale_cuda.c:102
AVOption
AVOption.
Definition: opt.h:429
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:1008
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
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:61
CUDAScaleKernelParams::weights
CUdeviceptr weights
Definition: vf_scale_cuda.h:50
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:337
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:220
video.h
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:185
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:113
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3496
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:56
vf_scale_cuda.h
fail
#define fail()
Definition: checkasm.h:219
CHECK_CU
#define CHECK_CU(x)
Definition: vf_scale_cuda.c:80
CUDAScaleContext::in_planes
int in_planes
Definition: vf_scale_cuda.c:124
dummy
int dummy
Definition: motion.c:64
CUDAScaleContext::in_plane_channels
int in_plane_channels[4]
Definition: vf_scale_cuda.c:126
SWS_SCALE_LANCZOS
@ SWS_SCALE_LANCZOS
3-tap sinc/sinc
Definition: filters.h:34
FILTER_TMP
@ FILTER_TMP
Definition: vf_scale_cuda.c:95
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:309
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
cudascale_class
static const AVClass cudascale_class
Definition: vf_scale_cuda.c:1031
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
av_cold
#define av_cold
Definition: attributes.h:111
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
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:60
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:1055
CUDATex::external_data
int external_data
Definition: vf_scale_cuda.c:114
CUDAScaleContext::cu_stream
CUstream cu_stream
Definition: vf_scale_cuda.c:150
SWS_FILTER_SIZE_MAX
@ SWS_FILTER_SIZE_MAX
Definition: filters.h:57
FILTER_OUT
@ FILTER_OUT
Definition: vf_scale_cuda.c:94
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
INTERP_ALGO_NEAREST
@ INTERP_ALGO_NEAREST
Definition: vf_scale_cuda.c:85
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
SWS_PARAM_DEFAULT
#define SWS_PARAM_DEFAULT
Definition: filters.h:42
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
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:1007
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:282
CUDATex::height
int height
Definition: vf_scale_cuda.c:110
SWS_SCALE_BILINEAR
@ SWS_SCALE_BILINEAR
bilinear filtering
Definition: filters.h:28
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:242
options
Definition: swscale.c:43
planes
static const struct @562 planes[]
double
double
Definition: af_crystalizer.c:132
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:540
FILTER_NB
@ FILTER_NB
Definition: vf_scale_cuda.c:96
cudascale_inputs
static const AVFilterPad cudascale_inputs[]
Definition: vf_scale_cuda.c:1038
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:94
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
INTERP_ALGO_COUNT
@ INTERP_ALGO_COUNT
Definition: vf_scale_cuda.c:90
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
CUDATex::crop_left
int crop_left
Definition: vf_scale_cuda.c:112
INTERP_ALGO_BICUBIC
@ INTERP_ALGO_BICUBIC
Definition: vf_scale_cuda.c:87
AV_PIX_FMT_P216
#define AV_PIX_FMT_P216
Definition: pixfmt.h:620
SCALE_FORCE_OAR_DECREASE
@ SCALE_FORCE_OAR_DECREASE
Definition: scale_eval.h:26
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
SWS_SCALE_BICUBIC
@ SWS_SCALE_BICUBIC
2-tap cubic BC-spline
Definition: filters.h:29
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:271
internal.h
INTERP_ALGO_BILINEAR
@ INTERP_ALGO_BILINEAR
Definition: vf_scale_cuda.c:86
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:66
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
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:524
CUDAScaleContext::filters_uv
CUDAScaleFilter filters_uv[FILTER_NB]
Definition: vf_scale_cuda.c:157
CUDATex::width
int width
Definition: vf_scale_cuda.c:110
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:998
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:259
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:814
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
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:1047
desc
const char * desc
Definition: libsvtav1.c:82
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:896
cudascale_filter_frame
static int cudascale_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_scale_cuda.c:951
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
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:327
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:34
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
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:752
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
SCALE_FORCE_OAR_NB
@ SCALE_FORCE_OAR_NB
Definition: scale_eval.h:28
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:51
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
SwsFilterParams::scaler
SwsScaler scaler
The filter kernel and parameters to use.
Definition: filters.h:65
snprintf
#define snprintf
Definition: snprintf.h:34
INTERP_ALGO_LANCZOS
@ INTERP_ALGO_LANCZOS
Definition: vf_scale_cuda.c:88
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:122
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:52
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:856