FFmpeg
Data Structures | Macros | Functions | Variables
vf_dnn_processing.c File Reference
#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 "video.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_DNN_DEFINE_CLASS (dnn_processing, DNN_TF|DNN_OV|DNN_TH)
 
static av_cold int init (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 enum AVPixelFormat pix_fmts []
 
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 43 of file vf_dnn_processing.c.

◆ FLAGS

Definition at line 44 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->dims[dnn_get_channel_idx_by_layout(model_input->layout)]);

Definition at line 76 of file vf_dnn_processing.c.

Function Documentation

◆ AVFILTER_DNN_DEFINE_CLASS()

AVFILTER_DNN_DEFINE_CLASS ( dnn_processing  ,
DNN_TF|DNN_OV DNN_TH 
)

◆ init()

static av_cold int init ( AVFilterContext context)
static

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

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

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

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 200 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 219 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 250 of file vf_dnn_processing.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext filter_ctx)
static

Definition at line 281 of file vf_dnn_processing.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 346 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 = DNN_TF }, INT_MIN, INT_MAX, FLAGS, .unit = "backend" },
{ NULL }
}

Definition at line 45 of file vf_dnn_processing.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ dnn_processing_inputs

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

Definition at line 354 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 362 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 370 of file vf_dnn_processing.c.

uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_dnn_processing.c:346
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
OFFSET
#define OFFSET(x)
Definition: vf_dnn_processing.c:43
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
DnnProcessingContext
Definition: vf_dnn_processing.c:36
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
preinit
static av_cold int preinit(AVFilterContext *ctx)
Definition: af_aresample.c:48
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_dnn_processing.c:140
ff_dnn_filter_init_child_class
int ff_dnn_filter_init_child_class(AVFilterContext *filter)
Definition: dnn_filter_common.c:61
DNN_TF
@ DNN_TF
Definition: dnn_interface.h:36
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_dnn_processing.c:67
ctx
AVFormatContext * ctx
Definition: movenc.c:49
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:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:535
NULL
#define NULL
Definition: coverity.c:32
init
static av_cold int init(AVFilterContext *context)
Definition: vf_dnn_processing.c:61
dnn_processing_inputs
static const AVFilterPad dnn_processing_inputs[]
Definition: vf_dnn_processing.c:354
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
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:94
activate
static int activate(AVFilterContext *filter_ctx)
Definition: vf_dnn_processing.c:281
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:96
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
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:78
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
dnn_get_channel_idx_by_layout
static int dnn_get_channel_idx_by_layout(DNNLayout layout)
Definition: dnn_interface.h:207
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
FLAGS
#define FLAGS
Definition: vf_dnn_processing.c:44
dnn_processing_outputs
static const AVFilterPad dnn_processing_outputs[]
Definition: vf_dnn_processing.c:362
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:3090
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_dnn_processing.c:200