]> git.sesse.net Git - ffmpeg/blob - libavfilter/vf_scale_cuda.c
Merge commit '90b15f60bf4919deaed66d868e18107eba371da7'
[ffmpeg] / libavfilter / vf_scale_cuda.c
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 <cuda.h>
24 #include <stdio.h>
25 #include <string.h>
26
27 #include "libavutil/avstring.h"
28 #include "libavutil/common.h"
29 #include "libavutil/hwcontext.h"
30 #include "libavutil/hwcontext_cuda.h"
31 #include "libavutil/cuda_check.h"
32 #include "libavutil/internal.h"
33 #include "libavutil/opt.h"
34 #include "libavutil/pixdesc.h"
35
36 #include "avfilter.h"
37 #include "formats.h"
38 #include "internal.h"
39 #include "scale.h"
40 #include "video.h"
41
42 static const enum AVPixelFormat supported_formats[] = {
43     AV_PIX_FMT_YUV420P,
44     AV_PIX_FMT_NV12,
45     AV_PIX_FMT_YUV444P,
46     AV_PIX_FMT_P010,
47     AV_PIX_FMT_P016
48 };
49
50 #define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
51 #define ALIGN_UP(a, b) (((a) + (b) - 1) & ~((b) - 1))
52 #define NUM_BUFFERS 2
53 #define BLOCKX 32
54 #define BLOCKY 16
55
56 #define CHECK_CU(x) FF_CUDA_CHECK(ctx, x)
57
58 typedef struct CUDAScaleContext {
59     const AVClass *class;
60     enum AVPixelFormat in_fmt;
61     enum AVPixelFormat out_fmt;
62
63     struct {
64         int width;
65         int height;
66     } planes_in[3], planes_out[3];
67
68     AVBufferRef *frames_ctx;
69     AVFrame     *frame;
70
71     AVFrame *tmp_frame;
72     int passthrough;
73
74     /**
75      * Output sw format. AV_PIX_FMT_NONE for no conversion.
76      */
77     enum AVPixelFormat format;
78
79     char *w_expr;               ///< width  expression string
80     char *h_expr;               ///< height expression string
81
82     CUcontext   cu_ctx;
83     CUevent     cu_event;
84     CUmodule    cu_module;
85     CUfunction  cu_func_uchar;
86     CUfunction  cu_func_uchar2;
87     CUfunction  cu_func_uchar4;
88     CUfunction  cu_func_ushort;
89     CUfunction  cu_func_ushort2;
90     CUfunction  cu_func_ushort4;
91     CUtexref    cu_tex_uchar;
92     CUtexref    cu_tex_uchar2;
93     CUtexref    cu_tex_uchar4;
94     CUtexref    cu_tex_ushort;
95     CUtexref    cu_tex_ushort2;
96     CUtexref    cu_tex_ushort4;
97
98     CUdeviceptr srcBuffer;
99     CUdeviceptr dstBuffer;
100     int         tex_alignment;
101 } CUDAScaleContext;
102
103 static av_cold int cudascale_init(AVFilterContext *ctx)
104 {
105     CUDAScaleContext *s = ctx->priv;
106
107     s->format = AV_PIX_FMT_NONE;
108     s->frame = av_frame_alloc();
109     if (!s->frame)
110         return AVERROR(ENOMEM);
111
112     s->tmp_frame = av_frame_alloc();
113     if (!s->tmp_frame)
114         return AVERROR(ENOMEM);
115
116     return 0;
117 }
118
119 static av_cold void cudascale_uninit(AVFilterContext *ctx)
120 {
121     CUDAScaleContext *s = ctx->priv;
122
123     av_frame_free(&s->frame);
124     av_buffer_unref(&s->frames_ctx);
125     av_frame_free(&s->tmp_frame);
126 }
127
128 static int cudascale_query_formats(AVFilterContext *ctx)
129 {
130     static const enum AVPixelFormat pixel_formats[] = {
131         AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,
132     };
133     AVFilterFormats *pix_fmts = ff_make_format_list(pixel_formats);
134
135     return ff_set_common_formats(ctx, pix_fmts);
136 }
137
138 static av_cold int init_stage(CUDAScaleContext *s, AVBufferRef *device_ctx)
139 {
140     AVBufferRef *out_ref = NULL;
141     AVHWFramesContext *out_ctx;
142     int in_sw, in_sh, out_sw, out_sh;
143     int ret, i;
144
145     av_pix_fmt_get_chroma_sub_sample(s->in_fmt,  &in_sw,  &in_sh);
146     av_pix_fmt_get_chroma_sub_sample(s->out_fmt, &out_sw, &out_sh);
147     if (!s->planes_out[0].width) {
148         s->planes_out[0].width  = s->planes_in[0].width;
149         s->planes_out[0].height = s->planes_in[0].height;
150     }
151
152     for (i = 1; i < FF_ARRAY_ELEMS(s->planes_in); i++) {
153         s->planes_in[i].width   = s->planes_in[0].width   >> in_sw;
154         s->planes_in[i].height  = s->planes_in[0].height  >> in_sh;
155         s->planes_out[i].width  = s->planes_out[0].width  >> out_sw;
156         s->planes_out[i].height = s->planes_out[0].height >> out_sh;
157     }
158
159     out_ref = av_hwframe_ctx_alloc(device_ctx);
160     if (!out_ref)
161         return AVERROR(ENOMEM);
162     out_ctx = (AVHWFramesContext*)out_ref->data;
163
164     out_ctx->format    = AV_PIX_FMT_CUDA;
165     out_ctx->sw_format = s->out_fmt;
166     out_ctx->width     = FFALIGN(s->planes_out[0].width,  32);
167     out_ctx->height    = FFALIGN(s->planes_out[0].height, 32);
168
169     ret = av_hwframe_ctx_init(out_ref);
170     if (ret < 0)
171         goto fail;
172
173     av_frame_unref(s->frame);
174     ret = av_hwframe_get_buffer(out_ref, s->frame, 0);
175     if (ret < 0)
176         goto fail;
177
178     s->frame->width  = s->planes_out[0].width;
179     s->frame->height = s->planes_out[0].height;
180
181     av_buffer_unref(&s->frames_ctx);
182     s->frames_ctx = out_ref;
183
184     return 0;
185 fail:
186     av_buffer_unref(&out_ref);
187     return ret;
188 }
189
190 static int format_is_supported(enum AVPixelFormat fmt)
191 {
192     int i;
193
194     for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
195         if (supported_formats[i] == fmt)
196             return 1;
197     return 0;
198 }
199
200 static av_cold int init_processing_chain(AVFilterContext *ctx, int in_width, int in_height,
201                                          int out_width, int out_height)
202 {
203     CUDAScaleContext *s = ctx->priv;
204
205     AVHWFramesContext *in_frames_ctx;
206
207     enum AVPixelFormat in_format;
208     enum AVPixelFormat out_format;
209     int ret;
210
211     /* check that we have a hw context */
212     if (!ctx->inputs[0]->hw_frames_ctx) {
213         av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n");
214         return AVERROR(EINVAL);
215     }
216     in_frames_ctx = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data;
217     in_format     = in_frames_ctx->sw_format;
218     out_format    = (s->format == AV_PIX_FMT_NONE) ? in_format : s->format;
219
220     if (!format_is_supported(in_format)) {
221         av_log(ctx, AV_LOG_ERROR, "Unsupported input format: %s\n",
222                av_get_pix_fmt_name(in_format));
223         return AVERROR(ENOSYS);
224     }
225     if (!format_is_supported(out_format)) {
226         av_log(ctx, AV_LOG_ERROR, "Unsupported output format: %s\n",
227                av_get_pix_fmt_name(out_format));
228         return AVERROR(ENOSYS);
229     }
230
231     if (in_width == out_width && in_height == out_height)
232         s->passthrough = 1;
233
234     s->in_fmt = in_format;
235     s->out_fmt = out_format;
236
237     s->planes_in[0].width   = in_width;
238     s->planes_in[0].height  = in_height;
239     s->planes_out[0].width  = out_width;
240     s->planes_out[0].height = out_height;
241
242     ret = init_stage(s, in_frames_ctx->device_ref);
243     if (ret < 0)
244         return ret;
245
246     ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->frames_ctx);
247     if (!ctx->outputs[0]->hw_frames_ctx)
248         return AVERROR(ENOMEM);
249
250     return 0;
251 }
252
253 static av_cold int cudascale_config_props(AVFilterLink *outlink)
254 {
255     AVFilterContext *ctx = outlink->src;
256     AVFilterLink *inlink = outlink->src->inputs[0];
257     CUDAScaleContext *s  = ctx->priv;
258     AVHWFramesContext     *frames_ctx = (AVHWFramesContext*)inlink->hw_frames_ctx->data;
259     AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
260     CUcontext dummy, cuda_ctx = device_hwctx->cuda_ctx;
261     int w, h;
262     int ret;
263
264     extern char vf_scale_cuda_ptx[];
265
266     ret = CHECK_CU(cuCtxPushCurrent(cuda_ctx));
267     if (ret < 0)
268         goto fail;
269
270     ret = CHECK_CU(cuModuleLoadData(&s->cu_module, vf_scale_cuda_ptx));
271     if (ret < 0)
272         goto fail;
273
274     CHECK_CU(cuModuleGetFunction(&s->cu_func_uchar, s->cu_module, "Subsample_Bilinear_uchar"));
275     CHECK_CU(cuModuleGetFunction(&s->cu_func_uchar2, s->cu_module, "Subsample_Bilinear_uchar2"));
276     CHECK_CU(cuModuleGetFunction(&s->cu_func_uchar4, s->cu_module, "Subsample_Bilinear_uchar4"));
277     CHECK_CU(cuModuleGetFunction(&s->cu_func_ushort, s->cu_module, "Subsample_Bilinear_ushort"));
278     CHECK_CU(cuModuleGetFunction(&s->cu_func_ushort2, s->cu_module, "Subsample_Bilinear_ushort2"));
279     CHECK_CU(cuModuleGetFunction(&s->cu_func_ushort4, s->cu_module, "Subsample_Bilinear_ushort4"));
280
281     CHECK_CU(cuModuleGetTexRef(&s->cu_tex_uchar, s->cu_module, "uchar_tex"));
282     CHECK_CU(cuModuleGetTexRef(&s->cu_tex_uchar2, s->cu_module, "uchar2_tex"));
283     CHECK_CU(cuModuleGetTexRef(&s->cu_tex_uchar4, s->cu_module, "uchar4_tex"));
284     CHECK_CU(cuModuleGetTexRef(&s->cu_tex_ushort, s->cu_module, "ushort_tex"));
285     CHECK_CU(cuModuleGetTexRef(&s->cu_tex_ushort2, s->cu_module, "ushort2_tex"));
286     CHECK_CU(cuModuleGetTexRef(&s->cu_tex_ushort4, s->cu_module, "ushort4_tex"));
287
288     CHECK_CU(cuTexRefSetFlags(s->cu_tex_uchar, CU_TRSF_READ_AS_INTEGER));
289     CHECK_CU(cuTexRefSetFlags(s->cu_tex_uchar2, CU_TRSF_READ_AS_INTEGER));
290     CHECK_CU(cuTexRefSetFlags(s->cu_tex_uchar4, CU_TRSF_READ_AS_INTEGER));
291     CHECK_CU(cuTexRefSetFlags(s->cu_tex_ushort, CU_TRSF_READ_AS_INTEGER));
292     CHECK_CU(cuTexRefSetFlags(s->cu_tex_ushort2, CU_TRSF_READ_AS_INTEGER));
293     CHECK_CU(cuTexRefSetFlags(s->cu_tex_ushort4, CU_TRSF_READ_AS_INTEGER));
294
295     CHECK_CU(cuTexRefSetFilterMode(s->cu_tex_uchar, CU_TR_FILTER_MODE_LINEAR));
296     CHECK_CU(cuTexRefSetFilterMode(s->cu_tex_uchar2, CU_TR_FILTER_MODE_LINEAR));
297     CHECK_CU(cuTexRefSetFilterMode(s->cu_tex_uchar4, CU_TR_FILTER_MODE_LINEAR));
298     CHECK_CU(cuTexRefSetFilterMode(s->cu_tex_ushort, CU_TR_FILTER_MODE_LINEAR));
299     CHECK_CU(cuTexRefSetFilterMode(s->cu_tex_ushort2, CU_TR_FILTER_MODE_LINEAR));
300     CHECK_CU(cuTexRefSetFilterMode(s->cu_tex_ushort4, CU_TR_FILTER_MODE_LINEAR));
301
302     CHECK_CU(cuCtxPopCurrent(&dummy));
303
304     if ((ret = ff_scale_eval_dimensions(s,
305                                         s->w_expr, s->h_expr,
306                                         inlink, outlink,
307                                         &w, &h)) < 0)
308         goto fail;
309
310     if (((int64_t)h * inlink->w) > INT_MAX  ||
311         ((int64_t)w * inlink->h) > INT_MAX)
312         av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
313
314     outlink->w = w;
315     outlink->h = h;
316
317     ret = init_processing_chain(ctx, inlink->w, inlink->h, w, h);
318     if (ret < 0)
319         return ret;
320
321     av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d -> w:%d h:%d\n",
322            inlink->w, inlink->h, outlink->w, outlink->h);
323
324     if (inlink->sample_aspect_ratio.num) {
325         outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h*inlink->w,
326                                                              outlink->w*inlink->h},
327                                                 inlink->sample_aspect_ratio);
328     } else {
329         outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
330     }
331
332     return 0;
333
334 fail:
335     return ret;
336 }
337
338 static int call_resize_kernel(CUDAScaleContext *ctx, CUfunction func, CUtexref tex, int channels,
339                               uint8_t *src_dptr, int src_width, int src_height, int src_pitch,
340                               uint8_t *dst_dptr, int dst_width, int dst_height, int dst_pitch,
341                               int pixel_size)
342 {
343     CUdeviceptr src_devptr = (CUdeviceptr)src_dptr;
344     CUdeviceptr dst_devptr = (CUdeviceptr)dst_dptr;
345     void *args_uchar[] = { &dst_devptr, &dst_width, &dst_height, &dst_pitch, &src_width, &src_height };
346     CUDA_ARRAY_DESCRIPTOR desc;
347
348     desc.Width  = src_width;
349     desc.Height = src_height;
350     desc.NumChannels = channels;
351     if (pixel_size == 1) {
352         desc.Format = CU_AD_FORMAT_UNSIGNED_INT8;
353     } else {
354         desc.Format = CU_AD_FORMAT_UNSIGNED_INT16;
355     }
356
357     CHECK_CU(cuTexRefSetAddress2D_v3(tex, &desc, src_devptr, src_pitch * pixel_size));
358     CHECK_CU(cuLaunchKernel(func, DIV_UP(dst_width, BLOCKX), DIV_UP(dst_height, BLOCKY), 1,
359                             BLOCKX, BLOCKY, 1, 0, 0, args_uchar, NULL));
360
361     return 0;
362 }
363
364 static int scalecuda_resize(AVFilterContext *ctx,
365                             AVFrame *out, AVFrame *in)
366 {
367     AVHWFramesContext *in_frames_ctx = (AVHWFramesContext*)in->hw_frames_ctx->data;
368     CUDAScaleContext *s = ctx->priv;
369
370     switch (in_frames_ctx->sw_format) {
371     case AV_PIX_FMT_YUV420P:
372         call_resize_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
373                            in->data[0], in->width, in->height, in->linesize[0],
374                            out->data[0], out->width, out->height, out->linesize[0],
375                            1);
376         call_resize_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
377                            in->data[0]+in->linesize[0]*in->height, in->width/2, in->height/2, in->linesize[0]/2,
378                            out->data[0]+out->linesize[0]*out->height, out->width/2, out->height/2, out->linesize[0]/2,
379                            1);
380         call_resize_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
381                            in->data[0]+ ALIGN_UP((in->linesize[0]*in->height*5)/4, s->tex_alignment), in->width/2, in->height/2, in->linesize[0]/2,
382                            out->data[0]+(out->linesize[0]*out->height*5)/4, out->width/2, out->height/2, out->linesize[0]/2,
383                            1);
384         break;
385     case AV_PIX_FMT_YUV444P:
386         call_resize_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
387                            in->data[0], in->width, in->height, in->linesize[0],
388                            out->data[0], out->width, out->height, out->linesize[0],
389                            1);
390         call_resize_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
391                            in->data[0]+in->linesize[0]*in->height, in->width, in->height, in->linesize[0],
392                            out->data[0]+out->linesize[0]*out->height, out->width, out->height, out->linesize[0],
393                            1);
394         call_resize_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
395                            in->data[0]+in->linesize[0]*in->height*2, in->width, in->height, in->linesize[0],
396                            out->data[0]+out->linesize[0]*out->height*2, out->width, out->height, out->linesize[0],
397                            1);
398         break;
399     case AV_PIX_FMT_NV12:
400         call_resize_kernel(s, s->cu_func_uchar, s->cu_tex_uchar, 1,
401                            in->data[0], in->width, in->height, in->linesize[0],
402                            out->data[0], out->width, out->height, out->linesize[0],
403                            1);
404         call_resize_kernel(s, s->cu_func_uchar2, s->cu_tex_uchar2, 2,
405                            in->data[1], in->width/2, in->height/2, in->linesize[1],
406                            out->data[0] + out->linesize[0] * ((out->height + 31) & ~0x1f), out->width/2, out->height/2, out->linesize[1]/2,
407                            1);
408         break;
409     case AV_PIX_FMT_P010LE:
410         call_resize_kernel(s, s->cu_func_ushort, s->cu_tex_ushort, 1,
411                            in->data[0], in->width, in->height, in->linesize[0]/2,
412                            out->data[0], out->width, out->height, out->linesize[0]/2,
413                            2);
414         call_resize_kernel(s, s->cu_func_ushort2, s->cu_tex_ushort2, 2,
415                            in->data[1], in->width / 2, in->height / 2, in->linesize[1]/2,
416                            out->data[0] + out->linesize[0] * ((out->height + 31) & ~0x1f), out->width / 2, out->height / 2, out->linesize[1] / 4,
417                            2);
418         break;
419     case AV_PIX_FMT_P016LE:
420         call_resize_kernel(s, s->cu_func_ushort, s->cu_tex_ushort, 1,
421                            in->data[0], in->width, in->height, in->linesize[0] / 2,
422                            out->data[0], out->width, out->height, out->linesize[0] / 2,
423                            2);
424         call_resize_kernel(s, s->cu_func_ushort2, s->cu_tex_ushort2, 2,
425                            in->data[1], in->width / 2, in->height / 2, in->linesize[1] / 2,
426                            out->data[0] + out->linesize[0] * ((out->height + 31) & ~0x1f), out->width / 2, out->height / 2, out->linesize[1] / 4,
427                            2);
428         break;
429     default:
430         return AVERROR_BUG;
431     }
432
433     return 0;
434 }
435
436 static int cudascale_scale(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
437 {
438     CUDAScaleContext *s = ctx->priv;
439     AVFrame *src = in;
440     int ret;
441
442     ret = scalecuda_resize(ctx, s->frame, src);
443     if (ret < 0)
444         return ret;
445
446     src = s->frame;
447     ret = av_hwframe_get_buffer(src->hw_frames_ctx, s->tmp_frame, 0);
448     if (ret < 0)
449         return ret;
450
451     av_frame_move_ref(out, s->frame);
452     av_frame_move_ref(s->frame, s->tmp_frame);
453
454     ret = av_frame_copy_props(out, in);
455     if (ret < 0)
456         return ret;
457
458     return 0;
459 }
460
461 static int cudascale_filter_frame(AVFilterLink *link, AVFrame *in)
462 {
463     AVFilterContext              *ctx = link->dst;
464     CUDAScaleContext               *s = ctx->priv;
465     AVFilterLink             *outlink = ctx->outputs[0];
466     AVHWFramesContext     *frames_ctx = (AVHWFramesContext*)s->frames_ctx->data;
467     AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
468
469     AVFrame *out = NULL;
470     CUcontext dummy;
471     int ret = 0;
472
473     out = av_frame_alloc();
474     if (!out) {
475         ret = AVERROR(ENOMEM);
476         goto fail;
477     }
478
479     ret = CHECK_CU(cuCtxPushCurrent(device_hwctx->cuda_ctx));
480     if (ret < 0)
481         goto fail;
482
483     ret = cudascale_scale(ctx, out, in);
484
485     CHECK_CU(cuCtxPopCurrent(&dummy));
486     if (ret < 0)
487         goto fail;
488
489     av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
490               (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
491               (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
492               INT_MAX);
493
494     av_frame_free(&in);
495     return ff_filter_frame(outlink, out);
496 fail:
497     av_frame_free(&in);
498     av_frame_free(&out);
499     return ret;
500 }
501
502 #define OFFSET(x) offsetof(CUDAScaleContext, x)
503 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
504 static const AVOption options[] = {
505     { "w",      "Output video width",  OFFSET(w_expr),     AV_OPT_TYPE_STRING, { .str = "iw"   }, .flags = FLAGS },
506     { "h",      "Output video height", OFFSET(h_expr),     AV_OPT_TYPE_STRING, { .str = "ih"   }, .flags = FLAGS },
507     { NULL },
508 };
509
510 static const AVClass cudascale_class = {
511     .class_name = "cudascale",
512     .item_name  = av_default_item_name,
513     .option     = options,
514     .version    = LIBAVUTIL_VERSION_INT,
515 };
516
517 static const AVFilterPad cudascale_inputs[] = {
518     {
519         .name        = "default",
520         .type        = AVMEDIA_TYPE_VIDEO,
521         .filter_frame = cudascale_filter_frame,
522     },
523     { NULL }
524 };
525
526 static const AVFilterPad cudascale_outputs[] = {
527     {
528         .name         = "default",
529         .type         = AVMEDIA_TYPE_VIDEO,
530         .config_props = cudascale_config_props,
531     },
532     { NULL }
533 };
534
535 AVFilter ff_vf_scale_cuda = {
536     .name      = "scale_cuda",
537     .description = NULL_IF_CONFIG_SMALL("GPU accelerated video resizer"),
538
539     .init          = cudascale_init,
540     .uninit        = cudascale_uninit,
541     .query_formats = cudascale_query_formats,
542
543     .priv_size = sizeof(CUDAScaleContext),
544     .priv_class = &cudascale_class,
545
546     .inputs    = cudascale_inputs,
547     .outputs   = cudascale_outputs,
548
549     .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
550 };