FFmpeg
Data Structures | Macros | Functions | Variables
vf_nnedi.c File Reference
#include <float.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/float_dsp.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem_internal.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  PrescreenerCoefficients
 
struct  PredictorCoefficients
 
struct  NNEDIContext
 

Macros

#define OFFSET(x)   offsetof(NNEDIContext, x)
 
#define RFLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (nnedi)
 
static int config_output (AVFilterLink *outlink)
 
static int query_formats (AVFilterContext *ctx)
 
static float dot_dsp (const NNEDIContext *const s, const float *kernel, const float *input, int n, float scale, float bias)
 
static float elliott (float x)
 
static void transform_elliott (float *input, int size)
 
static void process_old (AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, uint8_t *prescreen, int N, const PrescreenerCoefficients *const m_data)
 
static void process_new (AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, uint8_t *prescreen, int N, const PrescreenerCoefficients *const m_data)
 
static int filter_offset (int nn, const PredictorCoefficients *const model)
 
static const float * softmax_q1_filter (int nn, const PredictorCoefficients *const model)
 
static const float * elliott_q1_filter (int nn, const PredictorCoefficients *const model)
 
static const float * softmax_q2_filter (int nn, const PredictorCoefficients *const model)
 
static const float * elliott_q2_filter (int nn, const PredictorCoefficients *const model)
 
static void gather_input (const float *src, ptrdiff_t src_stride, float *buf, float mstd[4], const PredictorCoefficients *const model)
 
static float softmax_exp (float x)
 
static void transform_softmax_exp (float *input, int size)
 
static void wae5 (const float *softmax, const float *el, int n, float mstd[4])
 
static void predictor (AVFilterContext *ctx, const void *src, ptrdiff_t src_stride, void *dst, const uint8_t *prescreen, int N, const PredictorCoefficients *const model, int use_q2)
 
static void read_bytes (const uint8_t *src, float *dst, int src_stride, int dst_stride, int width, int height, float scale)
 
static void read_words (const uint8_t *srcp, float *dst, int src_stride, int dst_stride, int width, int height, float scale)
 
static void write_bytes (const float *src, uint8_t *dst, int src_stride, int dst_stride, int width, int height, int depth, float scale)
 
static void write_words (const float *src, uint8_t *dstp, int src_stride, int dst_stride, int width, int height, int depth, float scale)
 
static void interpolation (const void *src, ptrdiff_t src_stride, void *dst, const uint8_t *prescreen, int n)
 
static int filter_slice (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int get_frame (AVFilterContext *ctx, int is_second)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int request_frame (AVFilterLink *link)
 
static void copy_weights (float *dst, int n, const float **data)
 
static float * allocate (float **ptr, int size)
 
static int allocate_model (PredictorCoefficients *coeffs, int xdim, int ydim, int nns)
 
static int read_weights (AVFilterContext *ctx, const float *bdata)
 
static float mean (const float *input, int size)
 
static void transform (float *input, int size, float mean, float half)
 
static void subtract_mean_old (PrescreenerCoefficients *coeffs, float half)
 
static void subtract_mean_new (PrescreenerCoefficients *coeffs, float half)
 
static void subtract_mean_predictor (PredictorCoefficients *model)
 
static av_cold int init (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const size_t NNEDI_WEIGHTS_SIZE = 13574928
 
static const uint8_t NNEDI_XDIM [] = { 8, 16, 32, 48, 8, 16, 32 }
 
static const uint8_t NNEDI_YDIM [] = { 6, 6, 6, 6, 4, 4, 4 }
 
static const uint16_t NNEDI_NNS [] = { 16, 32, 64, 128, 256 }
 
static const AVOption nnedi_options []
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
AVFilter ff_vf_nnedi
 

Macro Definition Documentation

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

Definition at line 117 of file vf_nnedi.c.

Definition at line 118 of file vf_nnedi.c.

Definition at line 119 of file vf_nnedi.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( nnedi  )
static int config_output ( AVFilterLink outlink)
static

Definition at line 167 of file vf_nnedi.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 182 of file vf_nnedi.c.

static float dot_dsp ( const NNEDIContext *const  s,
const float *  kernel,
const float *  input,
int  n,
float  scale,
float  bias 
)
static

Definition at line 216 of file vf_nnedi.c.

Referenced by predictor(), process_new(), and process_old().

static float elliott ( float  x)
static

Definition at line 228 of file vf_nnedi.c.

Referenced by transform_elliott(), and wae5().

static void transform_elliott ( float *  input,
int  size 
)
static

Definition at line 233 of file vf_nnedi.c.

Referenced by process_new(), and process_old().

static void process_old ( AVFilterContext ctx,
const void src,
ptrdiff_t  src_stride,
uint8_t prescreen,
int  N,
const PrescreenerCoefficients *const  m_data 
)
static

Definition at line 239 of file vf_nnedi.c.

Referenced by config_input().

static void process_new ( AVFilterContext ctx,
const void src,
ptrdiff_t  src_stride,
uint8_t prescreen,
int  N,
const PrescreenerCoefficients *const  m_data 
)
static

Definition at line 275 of file vf_nnedi.c.

Referenced by config_input().

static int filter_offset ( int  nn,
const PredictorCoefficients *const  model 
)
static
static const float* softmax_q1_filter ( int  nn,
const PredictorCoefficients *const  model 
)
static

Definition at line 310 of file vf_nnedi.c.

Referenced by predictor().

static const float* elliott_q1_filter ( int  nn,
const PredictorCoefficients *const  model 
)
static

Definition at line 316 of file vf_nnedi.c.

Referenced by predictor().

static const float* softmax_q2_filter ( int  nn,
const PredictorCoefficients *const  model 
)
static

Definition at line 322 of file vf_nnedi.c.

Referenced by predictor().

static const float* elliott_q2_filter ( int  nn,
const PredictorCoefficients *const  model 
)
static

Definition at line 328 of file vf_nnedi.c.

Referenced by predictor().

static void gather_input ( const float *  src,
ptrdiff_t  src_stride,
float *  buf,
float  mstd[4],
const PredictorCoefficients *const  model 
)
static

Definition at line 334 of file vf_nnedi.c.

Referenced by predictor().

static float softmax_exp ( float  x)
static

Definition at line 370 of file vf_nnedi.c.

Referenced by transform_softmax_exp().

static void transform_softmax_exp ( float *  input,
int  size 
)
static

Definition at line 375 of file vf_nnedi.c.

Referenced by predictor().

static void wae5 ( const float *  softmax,
const float *  el,
int  n,
float  mstd[4] 
)
static

Definition at line 381 of file vf_nnedi.c.

Referenced by predictor().

static void predictor ( AVFilterContext ctx,
const void src,
ptrdiff_t  src_stride,
void dst,
const uint8_t prescreen,
int  N,
const PredictorCoefficients *const  model,
int  use_q2 
)
static

Definition at line 397 of file vf_nnedi.c.

Referenced by filter_slice().

static void read_bytes ( const uint8_t src,
float *  dst,
int  src_stride,
int  dst_stride,
int  width,
int  height,
float  scale 
)
static

Definition at line 447 of file vf_nnedi.c.

Referenced by config_input().

static void read_words ( const uint8_t srcp,
float *  dst,
int  src_stride,
int  dst_stride,
int  width,
int  height,
float  scale 
)
static

Definition at line 466 of file vf_nnedi.c.

Referenced by config_input().

static void write_bytes ( const float *  src,
uint8_t dst,
int  src_stride,
int  dst_stride,
int  width,
int  height,
int  depth,
float  scale 
)
static

Definition at line 489 of file vf_nnedi.c.

Referenced by config_input().

static void write_words ( const float *  src,
uint8_t dstp,
int  src_stride,
int  dst_stride,
int  width,
int  height,
int  depth,
float  scale 
)
static

Definition at line 503 of file vf_nnedi.c.

Referenced by config_input().

static void interpolation ( const void src,
ptrdiff_t  src_stride,
void dst,
const uint8_t prescreen,
int  n 
)
static

Definition at line 521 of file vf_nnedi.c.

Referenced by filter_slice().

static int filter_slice ( AVFilterContext ctx,
void arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 543 of file vf_nnedi.c.

Referenced by get_frame().

static int get_frame ( AVFilterContext ctx,
int  is_second 
)
static

Definition at line 666 of file vf_nnedi.c.

Referenced by filter_frame(), and vtenc_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 687 of file vf_nnedi.c.

Referenced by request_frame().

static int request_frame ( AVFilterLink link)
static

Definition at line 720 of file vf_nnedi.c.

static void copy_weights ( float *  dst,
int  n,
const float **  data 
)
static

Definition at line 749 of file vf_nnedi.c.

Referenced by read_weights().

static float* allocate ( float **  ptr,
int  size 
)
static

Definition at line 755 of file vf_nnedi.c.

Referenced by allocate_model().

static int allocate_model ( PredictorCoefficients coeffs,
int  xdim,
int  ydim,
int  nns 
)
static

Definition at line 764 of file vf_nnedi.c.

Referenced by read_weights().

static int read_weights ( AVFilterContext ctx,
const float *  bdata 
)
static

Definition at line 793 of file vf_nnedi.c.

Referenced by init().

static float mean ( const float *  input,
int  size 
)
static
static void transform ( float *  input,
int  size,
float  mean,
float  half 
)
static

Definition at line 874 of file vf_nnedi.c.

Referenced by subtract_mean_new(), and subtract_mean_old().

static void subtract_mean_old ( PrescreenerCoefficients coeffs,
float  half 
)
static

Definition at line 880 of file vf_nnedi.c.

Referenced by config_input().

static void subtract_mean_new ( PrescreenerCoefficients coeffs,
float  half 
)
static

Definition at line 889 of file vf_nnedi.c.

Referenced by config_input().

static void subtract_mean_predictor ( PredictorCoefficients model)
static

Definition at line 898 of file vf_nnedi.c.

Referenced by config_input().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 958 of file vf_nnedi.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 1028 of file vf_nnedi.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1110 of file vf_nnedi.c.

Variable Documentation

const size_t NNEDI_WEIGHTS_SIZE = 13574928
static

Definition at line 36 of file vf_nnedi.c.

Referenced by init().

const uint8_t NNEDI_XDIM[] = { 8, 16, 32, 48, 8, 16, 32 }
static

Definition at line 37 of file vf_nnedi.c.

Referenced by read_weights().

const uint8_t NNEDI_YDIM[] = { 6, 6, 6, 6, 4, 4, 4 }
static

Definition at line 38 of file vf_nnedi.c.

Referenced by read_weights().

const uint16_t NNEDI_NNS[] = { 16, 32, 64, 128, 256 }
static

Definition at line 39 of file vf_nnedi.c.

Referenced by read_weights().

const AVOption nnedi_options[]
static

Definition at line 121 of file vf_nnedi.c.

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)
Definition: vf_nnedi.c:1028
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_nnedi.c:687

Definition at line 1141 of file vf_nnedi.c.

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
.request_frame = request_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int request_frame(AVFilterLink *link)
Definition: vf_nnedi.c:720
static int config_output(AVFilterLink *outlink)
Definition: vf_nnedi.c:167

Definition at line 1151 of file vf_nnedi.c.

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,
}
static const AVFilterPad outputs[]
Definition: vf_nnedi.c:1151
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_nnedi.c:1110
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:115
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options...
Definition: avfilter.c:881
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
static int query_formats(AVFilterContext *ctx)
Definition: vf_nnedi.c:182
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_acrusher.c:336
static const AVFilterPad inputs[]
Definition: vf_nnedi.c:1141
#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:134
#define flags(name, subs,...)
Definition: cbs_av1.c:561
static av_cold int init(AVFilterContext *ctx)
Definition: vf_nnedi.c:958

Definition at line 1161 of file vf_nnedi.c.