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 filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int activate_sync (AVFilterContext *filter_ctx)
 
static int flush_frame (AVFilterLink *outlink, int64_t pts, int64_t *out_pts)
 
static int activate_async (AVFilterContext *filter_ctx)
 
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 []
 
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 82 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 89 of file vf_dnn_processing.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 138 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 167 of file vf_dnn_processing.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 198 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 217 of file vf_dnn_processing.c.

Referenced by activate_async(), filter_frame(), and flush_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 245 of file vf_dnn_processing.c.

Referenced by activate_sync().

◆ activate_sync()

static int activate_sync ( AVFilterContext filter_ctx)
static

Definition at line 275 of file vf_dnn_processing.c.

Referenced by activate().

◆ flush_frame()

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

Definition at line 315 of file vf_dnn_processing.c.

Referenced by activate_async().

◆ activate_async()

static int activate_async ( AVFilterContext filter_ctx)
static

Definition at line 346 of file vf_dnn_processing.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext filter_ctx)
static

Definition at line 411 of file vf_dnn_processing.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 421 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,
},
{ NULL }
}

Definition at line 429 of file vf_dnn_processing.c.

◆ dnn_processing_outputs

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

Definition at line 438 of file vf_dnn_processing.c.

◆ ff_vf_dnn_processing

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,
}

Definition at line 447 of file vf_dnn_processing.c.

uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_dnn_processing.c:421
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:138
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
ctx
AVFormatContext * ctx
Definition: movenc.c:48
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:429
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
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:41
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:411
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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:234
dnn_processing_outputs
static const AVFilterPad dnn_processing_outputs[]
Definition: vf_dnn_processing.c:438
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:2489
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_dnn_processing.c:198