]> git.sesse.net Git - ffmpeg/blob - libavfilter/vf_scale_npp.c
Merge commit '5d01bd181bb77e6740462095d7be4e0733a59420'
[ffmpeg] / libavfilter / vf_scale_npp.c
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 /**
20  * @file
21  * scale video filter
22  */
23
24 #include <nppi.h>
25 #include <stdio.h>
26 #include <string.h>
27
28 #include "libavutil/avstring.h"
29 #include "libavutil/common.h"
30 #include "libavutil/hwcontext.h"
31 #include "libavutil/hwcontext_cuda_internal.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 };
47
48 static const enum AVPixelFormat deinterleaved_formats[][2] = {
49     { AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P },
50 };
51
52 enum ScaleStage {
53     STAGE_DEINTERLEAVE,
54     STAGE_RESIZE,
55     STAGE_INTERLEAVE,
56     STAGE_NB,
57 };
58
59 typedef struct NPPScaleStageContext {
60     int stage_needed;
61     enum AVPixelFormat in_fmt;
62     enum AVPixelFormat out_fmt;
63
64     struct {
65         int width;
66         int height;
67     } planes_in[3], planes_out[3];
68
69     AVBufferRef *frames_ctx;
70     AVFrame     *frame;
71 } NPPScaleStageContext;
72
73 typedef struct NPPScaleContext {
74     const AVClass *class;
75
76     NPPScaleStageContext stages[STAGE_NB];
77     AVFrame *tmp_frame;
78     int passthrough;
79
80     int shift_width, shift_height;
81
82     /**
83      * New dimensions. Special values are:
84      *   0 = original width/height
85      *  -1 = keep original aspect
86      */
87     int w, h;
88
89     /**
90      * Output sw format. AV_PIX_FMT_NONE for no conversion.
91      */
92     enum AVPixelFormat format;
93
94     char *w_expr;               ///< width  expression string
95     char *h_expr;               ///< height expression string
96     char *format_str;
97
98     int interp_algo;
99 } NPPScaleContext;
100
101 static int nppscale_init(AVFilterContext *ctx)
102 {
103     NPPScaleContext *s = ctx->priv;
104     int i;
105
106     if (!strcmp(s->format_str, "same")) {
107         s->format = AV_PIX_FMT_NONE;
108     } else {
109         s->format = av_get_pix_fmt(s->format_str);
110         if (s->format == AV_PIX_FMT_NONE) {
111             av_log(ctx, AV_LOG_ERROR, "Unrecognized pixel format: %s\n", s->format_str);
112             return AVERROR(EINVAL);
113         }
114     }
115
116     for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
117         s->stages[i].frame = av_frame_alloc();
118         if (!s->stages[i].frame)
119             return AVERROR(ENOMEM);
120     }
121     s->tmp_frame = av_frame_alloc();
122     if (!s->tmp_frame)
123         return AVERROR(ENOMEM);
124
125     return 0;
126 }
127
128 static void nppscale_uninit(AVFilterContext *ctx)
129 {
130     NPPScaleContext *s = ctx->priv;
131     int i;
132
133     for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
134         av_frame_free(&s->stages[i].frame);
135         av_buffer_unref(&s->stages[i].frames_ctx);
136     }
137     av_frame_free(&s->tmp_frame);
138 }
139
140 static int nppscale_query_formats(AVFilterContext *ctx)
141 {
142     static const enum AVPixelFormat pixel_formats[] = {
143         AV_PIX_FMT_CUDA, AV_PIX_FMT_NONE,
144     };
145     AVFilterFormats *pix_fmts = ff_make_format_list(pixel_formats);
146
147     return ff_set_common_formats(ctx, pix_fmts);
148 }
149
150 static int init_stage(NPPScaleStageContext *stage, AVBufferRef *device_ctx)
151 {
152     AVBufferRef *out_ref = NULL;
153     AVHWFramesContext *out_ctx;
154     int in_sw, in_sh, out_sw, out_sh;
155     int ret, i;
156
157     av_pix_fmt_get_chroma_sub_sample(stage->in_fmt,  &in_sw,  &in_sh);
158     av_pix_fmt_get_chroma_sub_sample(stage->out_fmt, &out_sw, &out_sh);
159     if (!stage->planes_out[0].width) {
160         stage->planes_out[0].width  = stage->planes_in[0].width;
161         stage->planes_out[0].height = stage->planes_in[0].height;
162     }
163
164     for (i = 1; i < FF_ARRAY_ELEMS(stage->planes_in); i++) {
165         stage->planes_in[i].width   = stage->planes_in[0].width   >> in_sw;
166         stage->planes_in[i].height  = stage->planes_in[0].height  >> in_sh;
167         stage->planes_out[i].width  = stage->planes_out[0].width  >> out_sw;
168         stage->planes_out[i].height = stage->planes_out[0].height >> out_sh;
169     }
170
171     out_ref = av_hwframe_ctx_alloc(device_ctx);
172     if (!out_ref)
173         return AVERROR(ENOMEM);
174     out_ctx = (AVHWFramesContext*)out_ref->data;
175
176     out_ctx->format    = AV_PIX_FMT_CUDA;
177     out_ctx->sw_format = stage->out_fmt;
178     out_ctx->width     = FFALIGN(stage->planes_out[0].width,  32);
179     out_ctx->height    = FFALIGN(stage->planes_out[0].height, 32);
180
181     ret = av_hwframe_ctx_init(out_ref);
182     if (ret < 0)
183         goto fail;
184
185     av_frame_unref(stage->frame);
186     ret = av_hwframe_get_buffer(out_ref, stage->frame, 0);
187     if (ret < 0)
188         goto fail;
189
190     stage->frame->width  = stage->planes_out[0].width;
191     stage->frame->height = stage->planes_out[0].height;
192
193     av_buffer_unref(&stage->frames_ctx);
194     stage->frames_ctx = out_ref;
195
196     return 0;
197 fail:
198     av_buffer_unref(&out_ref);
199     return ret;
200 }
201
202 static int format_is_supported(enum AVPixelFormat fmt)
203 {
204     int i;
205
206     for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
207         if (supported_formats[i] == fmt)
208             return 1;
209     return 0;
210 }
211
212 static enum AVPixelFormat get_deinterleaved_format(enum AVPixelFormat fmt)
213 {
214     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
215     int i, planes;
216
217     planes = av_pix_fmt_count_planes(fmt);
218     if (planes == desc->nb_components)
219         return fmt;
220     for (i = 0; i < FF_ARRAY_ELEMS(deinterleaved_formats); i++)
221         if (deinterleaved_formats[i][0] == fmt)
222             return deinterleaved_formats[i][1];
223     return AV_PIX_FMT_NONE;
224 }
225
226 static int init_processing_chain(AVFilterContext *ctx, int in_width, int in_height,
227                                  int out_width, int out_height)
228 {
229     NPPScaleContext *s = ctx->priv;
230
231     AVHWFramesContext *in_frames_ctx;
232
233     enum AVPixelFormat in_format;
234     enum AVPixelFormat out_format;
235     enum AVPixelFormat in_deinterleaved_format;
236     enum AVPixelFormat out_deinterleaved_format;
237
238     int i, ret, last_stage = -1;
239
240     /* check that we have a hw context */
241     if (!ctx->inputs[0]->hw_frames_ctx) {
242         av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n");
243         return AVERROR(EINVAL);
244     }
245     in_frames_ctx = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data;
246     in_format     = in_frames_ctx->sw_format;
247     out_format    = (s->format == AV_PIX_FMT_NONE) ? in_format : s->format;
248
249     if (!format_is_supported(in_format)) {
250         av_log(ctx, AV_LOG_ERROR, "Unsupported input format: %s\n",
251                av_get_pix_fmt_name(in_format));
252         return AVERROR(ENOSYS);
253     }
254     if (!format_is_supported(out_format)) {
255         av_log(ctx, AV_LOG_ERROR, "Unsupported output format: %s\n",
256                av_get_pix_fmt_name(out_format));
257         return AVERROR(ENOSYS);
258     }
259
260     in_deinterleaved_format  = get_deinterleaved_format(in_format);
261     out_deinterleaved_format = get_deinterleaved_format(out_format);
262     if (in_deinterleaved_format  == AV_PIX_FMT_NONE ||
263         out_deinterleaved_format == AV_PIX_FMT_NONE)
264         return AVERROR_BUG;
265
266     /* figure out which stages need to be done */
267     if (in_width != out_width || in_height != out_height ||
268         in_deinterleaved_format != out_deinterleaved_format) {
269         s->stages[STAGE_RESIZE].stage_needed = 1;
270
271         if (s->interp_algo == NPPI_INTER_SUPER &&
272             (out_width > in_width && out_height > in_height)) {
273             s->interp_algo = NPPI_INTER_LANCZOS;
274             av_log(ctx, AV_LOG_WARNING, "super-sampling not supported for output dimensions, using lanczos instead.\n");
275         }
276         if (s->interp_algo == NPPI_INTER_SUPER &&
277             !(out_width < in_width && out_height < in_height)) {
278             s->interp_algo = NPPI_INTER_CUBIC;
279             av_log(ctx, AV_LOG_WARNING, "super-sampling not supported for output dimensions, using cubic instead.\n");
280         }
281     }
282
283     if (!s->stages[STAGE_RESIZE].stage_needed && in_format == out_format)
284         s->passthrough = 1;
285
286     if (!s->passthrough) {
287         if (in_format != in_deinterleaved_format)
288             s->stages[STAGE_DEINTERLEAVE].stage_needed = 1;
289         if (out_format != out_deinterleaved_format)
290             s->stages[STAGE_INTERLEAVE].stage_needed = 1;
291     }
292
293     s->stages[STAGE_DEINTERLEAVE].in_fmt              = in_format;
294     s->stages[STAGE_DEINTERLEAVE].out_fmt             = in_deinterleaved_format;
295     s->stages[STAGE_DEINTERLEAVE].planes_in[0].width  = in_width;
296     s->stages[STAGE_DEINTERLEAVE].planes_in[0].height = in_height;
297
298     s->stages[STAGE_RESIZE].in_fmt               = in_deinterleaved_format;
299     s->stages[STAGE_RESIZE].out_fmt              = out_deinterleaved_format;
300     s->stages[STAGE_RESIZE].planes_in[0].width   = in_width;
301     s->stages[STAGE_RESIZE].planes_in[0].height  = in_height;
302     s->stages[STAGE_RESIZE].planes_out[0].width  = out_width;
303     s->stages[STAGE_RESIZE].planes_out[0].height = out_height;
304
305     s->stages[STAGE_INTERLEAVE].in_fmt              = out_deinterleaved_format;
306     s->stages[STAGE_INTERLEAVE].out_fmt             = out_format;
307     s->stages[STAGE_INTERLEAVE].planes_in[0].width  = out_width;
308     s->stages[STAGE_INTERLEAVE].planes_in[0].height = out_height;
309
310     /* init the hardware contexts */
311     for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
312         if (!s->stages[i].stage_needed)
313             continue;
314
315         ret = init_stage(&s->stages[i], in_frames_ctx->device_ref);
316         if (ret < 0)
317             return ret;
318
319         last_stage = i;
320     }
321
322     if (last_stage >= 0)
323         ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->stages[last_stage].frames_ctx);
324     else
325         ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(ctx->inputs[0]->hw_frames_ctx);
326
327     if (!ctx->outputs[0]->hw_frames_ctx)
328         return AVERROR(ENOMEM);
329
330     return 0;
331 }
332
333 static int nppscale_config_props(AVFilterLink *outlink)
334 {
335     AVFilterContext *ctx = outlink->src;
336     AVFilterLink *inlink = outlink->src->inputs[0];
337     NPPScaleContext *s = ctx->priv;
338     int w, h;
339     int ret;
340
341     if ((ret = ff_scale_eval_dimensions(s,
342                                         s->w_expr, s->h_expr,
343                                         inlink, outlink,
344                                         &w, &h)) < 0)
345         goto fail;
346
347     if (((int64_t)h * inlink->w) > INT_MAX  ||
348         ((int64_t)w * inlink->h) > INT_MAX)
349         av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
350
351     outlink->w = w;
352     outlink->h = h;
353
354     ret = init_processing_chain(ctx, inlink->w, inlink->h, w, h);
355     if (ret < 0)
356         return ret;
357
358     av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d -> w:%d h:%d\n",
359            inlink->w, inlink->h, outlink->w, outlink->h);
360
361     if (inlink->sample_aspect_ratio.num)
362         outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h*inlink->w,
363                                                              outlink->w*inlink->h},
364                                                 inlink->sample_aspect_ratio);
365     else
366         outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
367
368     return 0;
369
370 fail:
371     return ret;
372 }
373
374 static int nppscale_deinterleave(AVFilterContext *ctx, NPPScaleStageContext *stage,
375                                  AVFrame *out, AVFrame *in)
376 {
377     AVHWFramesContext *in_frames_ctx = (AVHWFramesContext*)in->hw_frames_ctx->data;
378     NppStatus err;
379
380     switch (in_frames_ctx->sw_format) {
381     case AV_PIX_FMT_NV12:
382         err = nppiYCbCr420_8u_P2P3R(in->data[0], in->linesize[0],
383                                     in->data[1], in->linesize[1],
384                                     out->data, out->linesize,
385                                     (NppiSize){ in->width, in->height });
386         break;
387     default:
388         return AVERROR_BUG;
389     }
390     if (err != NPP_SUCCESS) {
391         av_log(ctx, AV_LOG_ERROR, "NPP deinterleave error: %d\n", err);
392         return AVERROR_UNKNOWN;
393     }
394
395     return 0;
396 }
397
398 static int nppscale_resize(AVFilterContext *ctx, NPPScaleStageContext *stage,
399                            AVFrame *out, AVFrame *in)
400 {
401     NPPScaleContext *s = ctx->priv;
402     NppStatus err;
403     int i;
404
405     for (i = 0; i < FF_ARRAY_ELEMS(stage->planes_in) && i < FF_ARRAY_ELEMS(in->data) && in->data[i]; i++) {
406         int iw = stage->planes_in[i].width;
407         int ih = stage->planes_in[i].height;
408         int ow = stage->planes_out[i].width;
409         int oh = stage->planes_out[i].height;
410
411         err = nppiResizeSqrPixel_8u_C1R(in->data[i], (NppiSize){ iw, ih },
412                                         in->linesize[i], (NppiRect){ 0, 0, iw, ih },
413                                         out->data[i], out->linesize[i],
414                                         (NppiRect){ 0, 0, ow, oh },
415                                         (double)ow / iw, (double)oh / ih,
416                                         0.0, 0.0, s->interp_algo);
417         if (err != NPP_SUCCESS) {
418             av_log(ctx, AV_LOG_ERROR, "NPP resize error: %d\n", err);
419             return AVERROR_UNKNOWN;
420         }
421     }
422
423     return 0;
424 }
425
426 static int nppscale_interleave(AVFilterContext *ctx, NPPScaleStageContext *stage,
427                                AVFrame *out, AVFrame *in)
428 {
429     AVHWFramesContext *out_frames_ctx = (AVHWFramesContext*)out->hw_frames_ctx->data;
430     NppStatus err;
431
432     switch (out_frames_ctx->sw_format) {
433     case AV_PIX_FMT_NV12:
434         err = nppiYCbCr420_8u_P3P2R((const uint8_t**)in->data,
435                                     in->linesize,
436                                     out->data[0], out->linesize[0],
437                                     out->data[1], out->linesize[1],
438                                     (NppiSize){ in->width, in->height });
439         break;
440     default:
441         return AVERROR_BUG;
442     }
443     if (err != NPP_SUCCESS) {
444         av_log(ctx, AV_LOG_ERROR, "NPP deinterleave error: %d\n", err);
445         return AVERROR_UNKNOWN;
446     }
447
448     return 0;
449 }
450
451 static int (*const nppscale_process[])(AVFilterContext *ctx, NPPScaleStageContext *stage,
452                                        AVFrame *out, AVFrame *in) = {
453     [STAGE_DEINTERLEAVE] = nppscale_deinterleave,
454     [STAGE_RESIZE]       = nppscale_resize,
455     [STAGE_INTERLEAVE]   = nppscale_interleave,
456 };
457
458 static int nppscale_scale(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
459 {
460     NPPScaleContext *s = ctx->priv;
461     AVFrame *src = in;
462     int i, ret, last_stage = -1;
463
464     for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
465         if (!s->stages[i].stage_needed)
466             continue;
467
468         ret = nppscale_process[i](ctx, &s->stages[i], s->stages[i].frame, src);
469         if (ret < 0)
470             return ret;
471
472         src        = s->stages[i].frame;
473         last_stage = i;
474     }
475
476     if (last_stage < 0)
477         return AVERROR_BUG;
478     ret = av_hwframe_get_buffer(src->hw_frames_ctx, s->tmp_frame, 0);
479     if (ret < 0)
480         return ret;
481
482     av_frame_move_ref(out, src);
483     av_frame_move_ref(src, s->tmp_frame);
484
485     ret = av_frame_copy_props(out, in);
486     if (ret < 0)
487         return ret;
488
489     return 0;
490 }
491
492 static int nppscale_filter_frame(AVFilterLink *link, AVFrame *in)
493 {
494     AVFilterContext              *ctx = link->dst;
495     NPPScaleContext                *s = ctx->priv;
496     AVFilterLink             *outlink = ctx->outputs[0];
497     AVHWFramesContext     *frames_ctx = (AVHWFramesContext*)outlink->hw_frames_ctx->data;
498     AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
499
500     AVFrame *out = NULL;
501     CUresult err;
502     CUcontext dummy;
503     int ret = 0;
504
505     if (s->passthrough)
506         return ff_filter_frame(outlink, in);
507
508     out = av_frame_alloc();
509     if (!out) {
510         ret = AVERROR(ENOMEM);
511         goto fail;
512     }
513
514     err = device_hwctx->internal->cuda_dl->cuCtxPushCurrent(device_hwctx->cuda_ctx);
515     if (err != CUDA_SUCCESS) {
516         ret = AVERROR_UNKNOWN;
517         goto fail;
518     }
519
520     ret = nppscale_scale(ctx, out, in);
521
522     device_hwctx->internal->cuda_dl->cuCtxPopCurrent(&dummy);
523     if (ret < 0)
524         goto fail;
525
526     av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
527               (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
528               (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
529               INT_MAX);
530
531     av_frame_free(&in);
532     return ff_filter_frame(outlink, out);
533 fail:
534     av_frame_free(&in);
535     av_frame_free(&out);
536     return ret;
537 }
538
539 #define OFFSET(x) offsetof(NPPScaleContext, x)
540 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
541 static const AVOption options[] = {
542     { "w",      "Output video width",  OFFSET(w_expr),     AV_OPT_TYPE_STRING, { .str = "iw"   }, .flags = FLAGS },
543     { "h",      "Output video height", OFFSET(h_expr),     AV_OPT_TYPE_STRING, { .str = "ih"   }, .flags = FLAGS },
544     { "format", "Output pixel format", OFFSET(format_str), AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
545
546     { "interp_algo", "Interpolation algorithm used for resizing", OFFSET(interp_algo), AV_OPT_TYPE_INT, { .i64 = NPPI_INTER_CUBIC }, 0, INT_MAX, FLAGS, "interp_algo" },
547         { "nn",                 "nearest neighbour",                 0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_NN                 }, 0, 0, FLAGS, "interp_algo" },
548         { "linear",             "linear",                            0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_LINEAR             }, 0, 0, FLAGS, "interp_algo" },
549         { "cubic",              "cubic",                             0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_CUBIC              }, 0, 0, FLAGS, "interp_algo" },
550         { "cubic2p_bspline",    "2-parameter cubic (B=1, C=0)",      0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_CUBIC2P_BSPLINE    }, 0, 0, FLAGS, "interp_algo" },
551         { "cubic2p_catmullrom", "2-parameter cubic (B=0, C=1/2)",    0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_CUBIC2P_CATMULLROM }, 0, 0, FLAGS, "interp_algo" },
552         { "cubic2p_b05c03",     "2-parameter cubic (B=1/2, C=3/10)", 0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_CUBIC2P_B05C03     }, 0, 0, FLAGS, "interp_algo" },
553         { "super",              "supersampling",                     0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_SUPER              }, 0, 0, FLAGS, "interp_algo" },
554         { "lanczos",            "Lanczos",                           0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_LANCZOS            }, 0, 0, FLAGS, "interp_algo" },
555     { NULL },
556 };
557
558 static const AVClass nppscale_class = {
559     .class_name = "nppscale",
560     .item_name  = av_default_item_name,
561     .option     = options,
562     .version    = LIBAVUTIL_VERSION_INT,
563 };
564
565 static const AVFilterPad nppscale_inputs[] = {
566     {
567         .name        = "default",
568         .type        = AVMEDIA_TYPE_VIDEO,
569         .filter_frame = nppscale_filter_frame,
570     },
571     { NULL }
572 };
573
574 static const AVFilterPad nppscale_outputs[] = {
575     {
576         .name         = "default",
577         .type         = AVMEDIA_TYPE_VIDEO,
578         .config_props = nppscale_config_props,
579     },
580     { NULL }
581 };
582
583 AVFilter ff_vf_scale_npp = {
584     .name      = "scale_npp",
585     .description = NULL_IF_CONFIG_SMALL("NVIDIA Performance Primitives video "
586                                         "scaling and format conversion"),
587
588     .init          = nppscale_init,
589     .uninit        = nppscale_uninit,
590     .query_formats = nppscale_query_formats,
591
592     .priv_size = sizeof(NPPScaleContext),
593     .priv_class = &nppscale_class,
594
595     .inputs    = nppscale_inputs,
596     .outputs   = nppscale_outputs,
597
598     .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
599 };