FFmpeg
Data Structures | Macros | Functions | Variables
vf_dnn_processing.c File Reference
#include "libavformat/avio.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "filters.h"
#include "dnn_filter_common.h"
#include "formats.h"
#include "internal.h"
#include "libswscale/swscale.h"
#include "libavutil/time.h"

Go to the source code of this file.

Data Structures

struct  DnnProcessingContext
 

Macros

#define OFFSET(x)   offsetof(DnnProcessingContext, dnnctx.x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 
#define LOG_FORMAT_CHANNEL_MISMATCH()
 

Functions

 AVFILTER_DEFINE_CLASS (dnn_processing)
 
static av_cold int init (AVFilterContext *context)
 
static int query_formats (AVFilterContext *context)
 
static int check_modelinput_inlink (const DNNData *model_input, const AVFilterLink *inlink)
 
static int config_input (AVFilterLink *inlink)
 
static av_always_inline int isPlanarYUV (enum AVPixelFormat pix_fmt)
 
static int prepare_uv_scale (AVFilterLink *outlink)
 
static int config_output (AVFilterLink *outlink)
 
static int copy_uv_planes (DnnProcessingContext *ctx, AVFrame *out, const AVFrame *in)
 
static int flush_frame (AVFilterLink *outlink, int64_t pts, int64_t *out_pts)
 
static int activate (AVFilterContext *filter_ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption dnn_processing_options []
 
static const AVFilterPad dnn_processing_inputs []
 
static const AVFilterPad dnn_processing_outputs []
 
const AVFilter ff_vf_dnn_processing
 

Detailed Description

implementing a generic image processing filter using deep learning networks.

Definition in file vf_dnn_processing.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET (   x)    offsetof(DnnProcessingContext, dnnctx.x)

Definition at line 45 of file vf_dnn_processing.c.

◆ FLAGS

Definition at line 46 of file vf_dnn_processing.c.

◆ LOG_FORMAT_CHANNEL_MISMATCH

#define LOG_FORMAT_CHANNEL_MISMATCH ( )
Value:
"the frame's format %s does not match " \
"the model input channel %d\n", \
model_input->channels);

Definition at line 81 of file vf_dnn_processing.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( dnn_processing  )

◆ init()

static av_cold int init ( AVFilterContext context)
static

Definition at line 62 of file vf_dnn_processing.c.

◆ query_formats()

static int query_formats ( AVFilterContext context)
static

Definition at line 68 of file vf_dnn_processing.c.

◆ check_modelinput_inlink()

static int check_modelinput_inlink ( const DNNData model_input,
const AVFilterLink inlink 
)
static

Definition at line 88 of file vf_dnn_processing.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 137 of file vf_dnn_processing.c.

◆ isPlanarYUV()

static av_always_inline int isPlanarYUV ( enum AVPixelFormat  pix_fmt)
static

◆ prepare_uv_scale()

static int prepare_uv_scale ( AVFilterLink outlink)
static

Definition at line 166 of file vf_dnn_processing.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 197 of file vf_dnn_processing.c.

◆ copy_uv_planes()

static int copy_uv_planes ( DnnProcessingContext ctx,
AVFrame out,
const AVFrame in 
)
static

Definition at line 216 of file vf_dnn_processing.c.

Referenced by activate(), and flush_frame().

◆ flush_frame()

static int flush_frame ( AVFilterLink outlink,
int64_t  pts,
int64_t *  out_pts 
)
static

Definition at line 247 of file vf_dnn_processing.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext filter_ctx)
static

Definition at line 278 of file vf_dnn_processing.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 343 of file vf_dnn_processing.c.

Variable Documentation

◆ dnn_processing_options

const AVOption dnn_processing_options[]
static
Initial value:
= {
{ "dnn_backend", "DNN backend", OFFSET(backend_type), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, "backend" },
{ "native", "native backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "backend" },
{ NULL }
}

Definition at line 47 of file vf_dnn_processing.c.

◆ dnn_processing_inputs

const AVFilterPad dnn_processing_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}

Definition at line 351 of file vf_dnn_processing.c.

◆ dnn_processing_outputs

const AVFilterPad dnn_processing_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}

Definition at line 359 of file vf_dnn_processing.c.

◆ ff_vf_dnn_processing

const AVFilter ff_vf_dnn_processing
Initial value:
= {
.name = "dnn_processing",
.description = NULL_IF_CONFIG_SMALL("Apply DNN processing filter to the input."),
.priv_size = sizeof(DnnProcessingContext),
.init = init,
.priv_class = &dnn_processing_class,
.activate = activate,
}

Definition at line 367 of file vf_dnn_processing.c.

uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_dnn_processing.c:343
OFFSET
#define OFFSET(x)
Definition: vf_dnn_processing.c:45
DnnProcessingContext
Definition: vf_dnn_processing.c:38
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_dnn_processing.c:137
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
ctx
AVFormatContext * ctx
Definition: movenc.c:48
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:152
NULL
#define NULL
Definition: coverity.c:32
init
static av_cold int init(AVFilterContext *context)
Definition: vf_dnn_processing.c:62
dnn_processing_inputs
static const AVFilterPad dnn_processing_inputs[]
Definition: vf_dnn_processing.c:351
query_formats
static int query_formats(AVFilterContext *context)
Definition: vf_dnn_processing.c:68
DNN_COMMON_OPTIONS
#define DNN_COMMON_OPTIONS
Definition: dnn_filter_common.h:43
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:117
activate
static int activate(AVFilterContext *filter_ctx)
Definition: vf_dnn_processing.c:278
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:153
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
FLAGS
#define FLAGS
Definition: vf_dnn_processing.c:46
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
dnn_processing_outputs
static const AVFilterPad dnn_processing_outputs[]
Definition: vf_dnn_processing.c:359
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:2460
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_dnn_processing.c:197