FFmpeg
Data Structures | Macros | Functions | Variables
vf_dnn_processing.c File Reference

implementing a generic image processing filter using deep learning networks. More...

#include "libavformat/avio.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "avfilter.h"
#include "dnn_interface.h"
#include "formats.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  DnnProcessingContext
 

Macros

#define OFFSET(x)   offsetof(DnnProcessingContext, 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 int config_output (AVFilterLink *outlink)
 
static int copy_from_frame_to_dnn (DNNData *dnn_input, const AVFrame *frame)
 
static int copy_from_dnn_to_frame (AVFrame *frame, const DNNData *dnn_output)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
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 []
 
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

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

Definition at line 52 of file vf_dnn_processing.c.

Definition at line 53 of file vf_dnn_processing.c.

#define LOG_FORMAT_CHANNEL_MISMATCH ( )
Value:
"the frame's format %s does not match " \
"the model input channel %d\n", \
model_input->channels);
const char * fmt
Definition: avisynth_c.h:861
#define av_log(a,...)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
AVFormatContext * ctx
Definition: movenc.c:48
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:2438

Definition at line 115 of file vf_dnn_processing.c.

Referenced by check_modelinput_inlink().

Function Documentation

AVFILTER_DEFINE_CLASS ( dnn_processing  )
static av_cold int init ( AVFilterContext context)
static

Definition at line 68 of file vf_dnn_processing.c.

static int query_formats ( AVFilterContext context)
static

Definition at line 104 of file vf_dnn_processing.c.

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

Definition at line 122 of file vf_dnn_processing.c.

Referenced by config_input().

static int config_input ( AVFilterLink inlink)
static

Definition at line 179 of file vf_dnn_processing.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 214 of file vf_dnn_processing.c.

static int copy_from_frame_to_dnn ( DNNData dnn_input,
const AVFrame frame 
)
static

Definition at line 233 of file vf_dnn_processing.c.

Referenced by filter_frame().

static int copy_from_dnn_to_frame ( AVFrame frame,
const DNNData dnn_output 
)
static

Definition at line 269 of file vf_dnn_processing.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 313 of file vf_dnn_processing.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 342 of file vf_dnn_processing.c.

Variable Documentation

const AVOption dnn_processing_options[]
static
Initial value:
= {
{ "dnn_backend", "DNN backend", OFFSET(backend_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "backend" },
{ "native", "native backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "backend" },
{ "model", "path to model file", OFFSET(model_filename), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
{ "input", "input name of the model", OFFSET(model_inputname), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
{ "output", "output name of the model", OFFSET(model_outputname), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, FLAGS },
{ NULL }
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
#define FLAGS

Definition at line 54 of file vf_dnn_processing.c.

const AVFilterPad dnn_processing_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)

Definition at line 352 of file vf_dnn_processing.c.

const AVFilterPad dnn_processing_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_output(AVFilterLink *outlink)

Definition at line 362 of file vf_dnn_processing.c.

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,
}
static const AVFilterPad dnn_processing_outputs[]
static av_cold void uninit(AVFilterContext *ctx)
static av_cold int init(AVFilterContext *context)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static const AVFilterPad dnn_processing_inputs[]
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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
static int query_formats(AVFilterContext *context)

Definition at line 371 of file vf_dnn_processing.c.