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 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 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 77 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.

◆ check_modelinput_inlink()

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

Definition at line 84 of file vf_dnn_processing.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

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

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 193 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 212 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 243 of file vf_dnn_processing.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext filter_ctx)
static

Definition at line 274 of file vf_dnn_processing.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 339 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.

◆ 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 347 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 355 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 363 of file vf_dnn_processing.c.

uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_dnn_processing.c:339
OFFSET
#define OFFSET(x)
Definition: vf_dnn_processing.c:45
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:170
DnnProcessingContext
Definition: vf_dnn_processing.c:38
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_dnn_processing.c:133
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:68
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:66
AV_PIX_FMT_GRAYF32
#define AV_PIX_FMT_GRAYF32
Definition: pixfmt.h:438
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
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:347
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
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:68
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:274
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:89
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
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:71
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:70
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
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:73
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:72
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
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:355
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:2582
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_dnn_processing.c:193