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 "internal.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_DEFINE_CLASS (dnn_processing)
 
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 44 of file vf_dnn_processing.c.

◆ FLAGS

Definition at line 45 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 78 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 63 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 85 of file vf_dnn_processing.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

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

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 202 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 221 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 252 of file vf_dnn_processing.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext filter_ctx)
static

Definition at line 283 of file vf_dnn_processing.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 348 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 46 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 356 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 364 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 372 of file vf_dnn_processing.c.

uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_dnn_processing.c:348
OFFSET
#define OFFSET(x)
Definition: vf_dnn_processing.c:44
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
DnnProcessingContext
Definition: vf_dnn_processing.c:37
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_dnn_processing.c:142
DNN_TF
@ DNN_TF
Definition: dnn_interface.h:35
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_dnn_processing.c:69
ctx
AVFormatContext * ctx
Definition: movenc.c:48
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
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:511
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
NULL
#define NULL
Definition: coverity.c:32
init
static av_cold int init(AVFilterContext *context)
Definition: vf_dnn_processing.c:63
dnn_processing_inputs
static const AVFilterPad dnn_processing_inputs[]
Definition: vf_dnn_processing.c:356
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
DNN_COMMON_OPTIONS
#define DNN_COMMON_OPTIONS
Definition: dnn_filter_common.h:43
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:106
activate
static int activate(AVFilterContext *filter_ctx)
Definition: vf_dnn_processing.c:283
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
Definition: opt.h:235
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:147
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
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:45
dnn_processing_outputs
static const AVFilterPad dnn_processing_outputs[]
Definition: vf_dnn_processing.c:364
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:2882
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_dnn_processing.c:202