FFmpeg
Data Structures | Macros | Functions | Variables
vf_nnedi.c File Reference
#include <float.h>
#include "libavutil/common.h"
#include "libavutil/float_dsp.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  FrameData
 
struct  NNEDIContext
 

Macros

#define OFFSET(x)   offsetof(NNEDIContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define NUM_NSIZE   7
 
#define NUM_NNS   5
 

Functions

 AVFILTER_DEFINE_CLASS (nnedi)
 
static int config_input (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static int query_formats (AVFilterContext *ctx)
 
static void copy_pad (const AVFrame *src, FrameData *frame_data, NNEDIContext *s, int fn)
 
static void elliott (float *data, const int n)
 
static void dot_prod (NNEDIContext *s, const float *data, const float *weights, float *vals, const int n, const int len, const float *scale)
 
static void dot_prods (NNEDIContext *s, const float *dataf, const float *weightsf, float *vals, const int n, const int len, const float *scale)
 
static void compute_network0 (NNEDIContext *s, const float *input, const float *weights, uint8_t *d)
 
static void compute_network0_i16 (NNEDIContext *s, const float *inputf, const float *weightsf, uint8_t *d)
 
static void pixel2float48 (const uint8_t *t8, const int pitch, float *p)
 
static void byte2word48 (const uint8_t *t, const int pitch, float *pf)
 
static int32_t process_line0 (const uint8_t *tempu, int width, uint8_t *dstp8, const uint8_t *src3p8, const int src_pitch, const int max_value, const int chroma)
 
static void byte2word64 (const uint8_t *t, const int pitch, float *p)
 
static void compute_network0new (NNEDIContext *s, const float *datai, const float *weights, uint8_t *d)
 
static void evalfunc_0 (NNEDIContext *s, FrameData *frame_data)
 
static void extract_m8 (const uint8_t *srcp8, const int stride, const int xdia, const int ydia, float *mstd, float *input)
 
static void extract_m8_i16 (const uint8_t *srcp, const int stride, const int xdia, const int ydia, float *mstd, float *inputf)
 
static void e2_m16 (float *s, const int n)
 
static void weighted_avg_elliott_mul5_m16 (const float *w, const int n, float *mstd)
 
static void evalfunc_1 (NNEDIContext *s, FrameData *frame_data)
 
static int roundds (const double f)
 
static void select_functions (NNEDIContext *s)
 
static int modnpf (const int m, const int n)
 
static int get_frame (AVFilterContext *ctx, int is_second)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *src)
 
static int request_frame (AVFilterLink *link)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption nnedi_options []
 
static const float exp_lo = -80.0f
 
static const float exp_hi = +80.0f
 
const float min_weight_sum = 1e-10f
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
AVFilter ff_vf_nnedi
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 104 of file vf_nnedi.c.

◆ FLAGS

Definition at line 105 of file vf_nnedi.c.

◆ NUM_NSIZE

#define NUM_NSIZE   7

Definition at line 635 of file vf_nnedi.c.

◆ NUM_NNS

#define NUM_NNS   5

Definition at line 636 of file vf_nnedi.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( nnedi  )

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 150 of file vf_nnedi.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 167 of file vf_nnedi.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 184 of file vf_nnedi.c.

◆ copy_pad()

static void copy_pad ( const AVFrame src,
FrameData frame_data,
NNEDIContext s,
int  fn 
)
static

Definition at line 204 of file vf_nnedi.c.

Referenced by select_functions().

◆ elliott()

static void elliott ( float *  data,
const int  n 
)
static

Definition at line 260 of file vf_nnedi.c.

Referenced by compute_network0(), and compute_network0_i16().

◆ dot_prod()

static void dot_prod ( NNEDIContext s,
const float *  data,
const float *  weights,
float *  vals,
const int  n,
const int  len,
const float *  scale 
)
static

Definition at line 268 of file vf_nnedi.c.

Referenced by compute_network0(), compute_network0_i16(), and select_functions().

◆ dot_prods()

static void dot_prods ( NNEDIContext s,
const float *  dataf,
const float *  weightsf,
float *  vals,
const int  n,
const int  len,
const float *  scale 
)
static

Definition at line 281 of file vf_nnedi.c.

Referenced by compute_network0_i16(), and select_functions().

◆ compute_network0()

static void compute_network0 ( NNEDIContext s,
const float *  input,
const float *  weights,
uint8_t d 
)
static

Definition at line 297 of file vf_nnedi.c.

Referenced by select_functions().

◆ compute_network0_i16()

static void compute_network0_i16 ( NNEDIContext s,
const float *  inputf,
const float *  weightsf,
uint8_t d 
)
static

Definition at line 314 of file vf_nnedi.c.

Referenced by select_functions().

◆ pixel2float48()

static void pixel2float48 ( const uint8_t t8,
const int  pitch,
float *  p 
)
static

Definition at line 332 of file vf_nnedi.c.

Referenced by select_functions().

◆ byte2word48()

static void byte2word48 ( const uint8_t t,
const int  pitch,
float *  pf 
)
static

Definition at line 342 of file vf_nnedi.c.

Referenced by select_functions().

◆ process_line0()

static int32_t process_line0 ( const uint8_t tempu,
int  width,
uint8_t dstp8,
const uint8_t src3p8,
const int  src_pitch,
const int  max_value,
const int  chroma 
)
static

Definition at line 352 of file vf_nnedi.c.

Referenced by select_functions().

◆ byte2word64()

static void byte2word64 ( const uint8_t t,
const int  pitch,
float *  p 
)
static

Definition at line 373 of file vf_nnedi.c.

Referenced by select_functions().

◆ compute_network0new()

static void compute_network0new ( NNEDIContext s,
const float *  datai,
const float *  weights,
uint8_t d 
)
static

Definition at line 383 of file vf_nnedi.c.

Referenced by select_functions().

◆ evalfunc_0()

static void evalfunc_0 ( NNEDIContext s,
FrameData frame_data 
)
static

Definition at line 418 of file vf_nnedi.c.

Referenced by select_functions().

◆ extract_m8()

static void extract_m8 ( const uint8_t srcp8,
const int  stride,
const int  xdia,
const int  ydia,
float *  mstd,
float *  input 
)
static

Definition at line 487 of file vf_nnedi.c.

Referenced by select_functions().

◆ extract_m8_i16()

static void extract_m8_i16 ( const uint8_t srcp,
const int  stride,
const int  xdia,
const int  ydia,
float *  mstd,
float *  inputf 
)
static

Definition at line 520 of file vf_nnedi.c.

Referenced by select_functions().

◆ e2_m16()

static void e2_m16 ( float *  s,
const int  n 
)
static

Definition at line 552 of file vf_nnedi.c.

Referenced by select_functions().

◆ weighted_avg_elliott_mul5_m16()

static void weighted_avg_elliott_mul5_m16 ( const float *  w,
const int  n,
float *  mstd 
)
static

Definition at line 562 of file vf_nnedi.c.

Referenced by select_functions().

◆ evalfunc_1()

static void evalfunc_1 ( NNEDIContext s,
FrameData frame_data 
)
static

Definition at line 578 of file vf_nnedi.c.

Referenced by select_functions().

◆ roundds()

static int roundds ( const double  f)
static

Definition at line 638 of file vf_nnedi.c.

Referenced by init().

◆ select_functions()

static void select_functions ( NNEDIContext s)
static

Definition at line 645 of file vf_nnedi.c.

Referenced by init().

◆ modnpf()

static int modnpf ( const int  m,
const int  n 
)
static

Definition at line 682 of file vf_nnedi.c.

Referenced by get_frame().

◆ get_frame()

static int get_frame ( AVFilterContext ctx,
int  is_second 
)
static

Definition at line 689 of file vf_nnedi.c.

Referenced by filter_frame(), and vtenc_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame src 
)
static

Definition at line 794 of file vf_nnedi.c.

Referenced by request_frame().

◆ request_frame()

static int request_frame ( AVFilterLink link)
static

Definition at line 879 of file vf_nnedi.c.

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 907 of file vf_nnedi.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1159 of file vf_nnedi.c.

Variable Documentation

◆ nnedi_options

const AVOption nnedi_options[]
static

Definition at line 107 of file vf_nnedi.c.

◆ exp_lo

const float exp_lo = -80.0f
static

Definition at line 549 of file vf_nnedi.c.

Referenced by e2_m16().

◆ exp_hi

const float exp_hi = +80.0f
static

Definition at line 550 of file vf_nnedi.c.

Referenced by e2_m16().

◆ min_weight_sum

const float min_weight_sum = 1e-10f

Definition at line 560 of file vf_nnedi.c.

Referenced by weighted_avg_elliott_mul5_m16().

◆ inputs

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

Definition at line 1180 of file vf_nnedi.c.

◆ outputs

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

Definition at line 1190 of file vf_nnedi.c.

◆ ff_vf_nnedi

AVFilter ff_vf_nnedi
Initial value:
= {
.name = "nnedi",
.description = NULL_IF_CONFIG_SMALL("Apply neural network edge directed interpolation intra-only deinterlacer."),
.priv_size = sizeof(NNEDIContext),
.priv_class = &nnedi_class,
.init = init,
}

Definition at line 1200 of file vf_nnedi.c.

NNEDIContext
Definition: vf_nnedi.c:50
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_nnedi.c:1159
inputs
static const AVFilterPad inputs[]
Definition: vf_nnedi.c:1180
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_nnedi.c:879
NULL
#define NULL
Definition: coverity.c:32
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_nnedi.c:184
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:188
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *src)
Definition: vf_nnedi.c:794
outputs
static const AVFilterPad outputs[]
Definition: vf_nnedi.c:1190
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_nnedi.c:907
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_nnedi.c:150
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
Definition: avfilter.h:133
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_nnedi.c:167