vf_scale_cuda.c 19 KB

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