FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_scale_npp.c File Reference
#include <nppi.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/cuda_check.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "scale.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  NPPScaleStageContext
 
struct  NPPScaleContext
 

Macros

#define CHECK_CU(x)   FF_CUDA_CHECK_DL(ctx, device_hwctx->internal->cuda_dl, x)
 
#define OFFSET(x)   offsetof(NPPScaleContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
 

Enumerations

enum  ScaleStage { STAGE_DEINTERLEAVE, STAGE_RESIZE, STAGE_INTERLEAVE, STAGE_NB }
 

Functions

static int nppscale_init (AVFilterContext *ctx)
 
static void nppscale_uninit (AVFilterContext *ctx)
 
static int nppscale_query_formats (AVFilterContext *ctx)
 
static int init_stage (NPPScaleStageContext *stage, AVBufferRef *device_ctx)
 
static int format_is_supported (enum AVPixelFormat fmt)
 
static enum AVPixelFormat get_deinterleaved_format (enum AVPixelFormat fmt)
 
static int init_processing_chain (AVFilterContext *ctx, int in_width, int in_height, int out_width, int out_height)
 
static int nppscale_config_props (AVFilterLink *outlink)
 
static int nppscale_deinterleave (AVFilterContext *ctx, NPPScaleStageContext *stage, AVFrame *out, AVFrame *in)
 
static int nppscale_resize (AVFilterContext *ctx, NPPScaleStageContext *stage, AVFrame *out, AVFrame *in)
 
static int nppscale_interleave (AVFilterContext *ctx, NPPScaleStageContext *stage, AVFrame *out, AVFrame *in)
 
static int nppscale_scale (AVFilterContext *ctx, AVFrame *out, AVFrame *in)
 
static int nppscale_filter_frame (AVFilterLink *link, AVFrame *in)
 

Variables

static enum AVPixelFormat supported_formats []
 
static enum AVPixelFormat deinterleaved_formats [][2]
 
static int(*const nppscale_process [])(AVFilterContext *ctx, NPPScaleStageContext *stage, AVFrame *out, AVFrame *in)
 
static const AVOption options []
 
static const AVClass nppscale_class
 
static const AVFilterPad nppscale_inputs []
 
static const AVFilterPad nppscale_outputs []
 
AVFilter ff_vf_scale_npp
 

Detailed Description

scale video filter

Definition in file vf_scale_npp.c.

Macro Definition Documentation

◆ CHECK_CU

#define CHECK_CU (   x)    FF_CUDA_CHECK_DL(ctx, device_hwctx->internal->cuda_dl, x)

Definition at line 43 of file vf_scale_npp.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(NPPScaleContext, x)

Definition at line 542 of file vf_scale_npp.c.

◆ FLAGS

Definition at line 543 of file vf_scale_npp.c.

Enumeration Type Documentation

◆ ScaleStage

enum ScaleStage
Enumerator
STAGE_DEINTERLEAVE 
STAGE_RESIZE 
STAGE_INTERLEAVE 
STAGE_NB 

Definition at line 55 of file vf_scale_npp.c.

Function Documentation

◆ nppscale_init()

static int nppscale_init ( AVFilterContext ctx)
static

Definition at line 104 of file vf_scale_npp.c.

◆ nppscale_uninit()

static void nppscale_uninit ( AVFilterContext ctx)
static

Definition at line 131 of file vf_scale_npp.c.

◆ nppscale_query_formats()

static int nppscale_query_formats ( AVFilterContext ctx)
static

Definition at line 143 of file vf_scale_npp.c.

◆ init_stage()

static int init_stage ( NPPScaleStageContext stage,
AVBufferRef device_ctx 
)
static

Definition at line 153 of file vf_scale_npp.c.

Referenced by init_processing_chain().

◆ format_is_supported()

static int format_is_supported ( enum AVPixelFormat  fmt)
static

Definition at line 205 of file vf_scale_npp.c.

Referenced by init_processing_chain().

◆ get_deinterleaved_format()

static enum AVPixelFormat get_deinterleaved_format ( enum AVPixelFormat  fmt)
static

Definition at line 215 of file vf_scale_npp.c.

Referenced by init_processing_chain().

◆ init_processing_chain()

static int init_processing_chain ( AVFilterContext ctx,
int  in_width,
int  in_height,
int  out_width,
int  out_height 
)
static

Definition at line 229 of file vf_scale_npp.c.

Referenced by nppscale_config_props().

◆ nppscale_config_props()

static int nppscale_config_props ( AVFilterLink outlink)
static

Definition at line 336 of file vf_scale_npp.c.

◆ nppscale_deinterleave()

static int nppscale_deinterleave ( AVFilterContext ctx,
NPPScaleStageContext stage,
AVFrame out,
AVFrame in 
)
static

Definition at line 377 of file vf_scale_npp.c.

◆ nppscale_resize()

static int nppscale_resize ( AVFilterContext ctx,
NPPScaleStageContext stage,
AVFrame out,
AVFrame in 
)
static

Definition at line 401 of file vf_scale_npp.c.

◆ nppscale_interleave()

static int nppscale_interleave ( AVFilterContext ctx,
NPPScaleStageContext stage,
AVFrame out,
AVFrame in 
)
static

Definition at line 429 of file vf_scale_npp.c.

◆ nppscale_scale()

static int nppscale_scale ( AVFilterContext ctx,
AVFrame out,
AVFrame in 
)
static

Definition at line 461 of file vf_scale_npp.c.

Referenced by nppscale_filter_frame().

◆ nppscale_filter_frame()

static int nppscale_filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 498 of file vf_scale_npp.c.

Variable Documentation

◆ supported_formats

enum AVPixelFormat supported_formats[]
static
Initial value:

Definition at line 45 of file vf_scale_npp.c.

Referenced by format_is_supported().

◆ deinterleaved_formats

enum AVPixelFormat deinterleaved_formats[][2]
static
Initial value:

Definition at line 51 of file vf_scale_npp.c.

Referenced by get_deinterleaved_format().

◆ nppscale_process

int(*const nppscale_process[])(AVFilterContext *ctx, NPPScaleStageContext *stage, AVFrame *out, AVFrame *in)
static

◆ options

const AVOption options[]
static
Initial value:
= {
{ "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS },
{ "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS },
{ "format", "Output pixel format", OFFSET(format_str), AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
{ "interp_algo", "Interpolation algorithm used for resizing", OFFSET(interp_algo), AV_OPT_TYPE_INT, { .i64 = NPPI_INTER_CUBIC }, 0, INT_MAX, FLAGS, "interp_algo" },
{ "nn", "nearest neighbour", 0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_NN }, 0, 0, FLAGS, "interp_algo" },
{ "linear", "linear", 0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_LINEAR }, 0, 0, FLAGS, "interp_algo" },
{ "cubic", "cubic", 0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_CUBIC }, 0, 0, FLAGS, "interp_algo" },
{ "cubic2p_bspline", "2-parameter cubic (B=1, C=0)", 0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_CUBIC2P_BSPLINE }, 0, 0, FLAGS, "interp_algo" },
{ "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" },
{ "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" },
{ "super", "supersampling", 0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_SUPER }, 0, 0, FLAGS, "interp_algo" },
{ "lanczos", "Lanczos", 0, AV_OPT_TYPE_CONST, { .i64 = NPPI_INTER_LANCZOS }, 0, 0, FLAGS, "interp_algo" },
{ NULL },
}

Definition at line 544 of file vf_scale_npp.c.

◆ nppscale_class

const AVClass nppscale_class
static
Initial value:
= {
.class_name = "nppscale",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 561 of file vf_scale_npp.c.

◆ nppscale_inputs

const AVFilterPad nppscale_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = nppscale_filter_frame,
},
{ NULL }
}

Definition at line 568 of file vf_scale_npp.c.

◆ nppscale_outputs

const AVFilterPad nppscale_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = nppscale_config_props,
},
{ NULL }
}

Definition at line 577 of file vf_scale_npp.c.

◆ ff_vf_scale_npp

AVFilter ff_vf_scale_npp
Initial value:
= {
.name = "scale_npp",
.description = NULL_IF_CONFIG_SMALL("NVIDIA Performance Primitives video "
"scaling and format conversion"),
.init = nppscale_init,
.uninit = nppscale_uninit,
.query_formats = nppscale_query_formats,
.priv_size = sizeof(NPPScaleContext),
.priv_class = &nppscale_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}

Definition at line 586 of file vf_scale_npp.c.

nppscale_inputs
static const AVFilterPad nppscale_inputs[]
Definition: vf_scale_npp.c:568
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: internal.h:385
nppscale_class
static const AVClass nppscale_class
Definition: vf_scale_npp.c:561
STAGE_RESIZE
@ STAGE_RESIZE
Definition: vf_scale_npp.c:57
nppscale_uninit
static void nppscale_uninit(AVFilterContext *ctx)
Definition: vf_scale_npp.c:131
nppscale_query_formats
static int nppscale_query_formats(AVFilterContext *ctx)
Definition: vf_scale_npp.c:143
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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:66
NPPScaleContext
Definition: vf_scale_npp.c:76
FLAGS
#define FLAGS
Definition: vf_scale_npp.c:543
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
nppscale_interleave
static int nppscale_interleave(AVFilterContext *ctx, NPPScaleStageContext *stage, AVFrame *out, AVFrame *in)
Definition: vf_scale_npp.c:429
NULL
#define NULL
Definition: coverity.c:32
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
inputs
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 inputs
Definition: filter_design.txt:243
nppscale_init
static int nppscale_init(AVFilterContext *ctx)
Definition: vf_scale_npp.c:104
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:188
OFFSET
#define OFFSET(x)
Definition: vf_scale_npp.c:542
nppscale_filter_frame
static int nppscale_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_scale_npp.c:498
nppscale_config_props
static int nppscale_config_props(AVFilterLink *outlink)
Definition: vf_scale_npp.c:336
nppscale_resize
static int nppscale_resize(AVFilterContext *ctx, NPPScaleStageContext *stage, AVFrame *out, AVFrame *in)
Definition: vf_scale_npp.c:401
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:89
STAGE_INTERLEAVE
@ STAGE_INTERLEAVE
Definition: vf_scale_npp.c:58
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
nppscale_outputs
static const AVFilterPad nppscale_outputs[]
Definition: vf_scale_npp.c:577
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:71
STAGE_DEINTERLEAVE
@ STAGE_DEINTERLEAVE
Definition: vf_scale_npp.c:56
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
options
static const AVOption options[]
Definition: vf_scale_npp.c:544
nppscale_deinterleave
static int nppscale_deinterleave(AVFilterContext *ctx, NPPScaleStageContext *stage, AVFrame *out, AVFrame *in)
Definition: vf_scale_npp.c:377
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:227
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232