FFmpeg
Data Structures | Macros | Functions | Variables
vf_siti.c File Reference
#include <math.h>
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "filters.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  SiTiContext
 

Macros

#define CONVOLVE(bps)
 
#define CALCULATE(bps)
 
#define OFFSET(x)   offsetof(SiTiContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int is_full_range (AVFrame *frame)
 
static uint16_t convert_full_range (int factor, uint16_t y)
 
static void convolve_sobel (SiTiContext *s, const uint8_t *src, float *dst, int linesize)
 
static void calculate_motion (SiTiContext *s, const uint8_t *curr, float *motion_matrix, int linesize)
 
static float std_deviation (float *img_metrics, int width, int height)
 
static void set_meta (AVDictionary **metadata, const char *key, float d)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
 AVFILTER_DEFINE_CLASS (siti)
 

Variables

static const int X_FILTER [9]
 
static const int Y_FILTER [9]
 
static enum AVPixelFormat pix_fmts []
 
static const AVOption siti_options []
 
static const AVFilterPad avfilter_vf_siti_inputs []
 
const AVFilter ff_vf_siti
 

Detailed Description

Calculate Spatial Info (SI) and Temporal Info (TI) scores

Definition in file vf_siti.c.

Macro Definition Documentation

◆ CONVOLVE

#define CONVOLVE (   bps)
Value:
{ \
uint##bps##_t *vsrc = (uint##bps##_t*)src; \
for (int j = 1; j < s->height - 1; j++) { \
for (int i = 1; i < s->width - 1; i++) { \
x_conv_sum = 0.0; \
y_conv_sum = 0.0; \
for (int k = 0; k < filter_size; k++) { \
ki = k % filter_width - 1; \
kj = floor(k / filter_width) - 1; \
index = (j + kj) * stride + (i + ki); \
data = s->full_range ? vsrc[index] : convert_full_range(factor, vsrc[index]); \
x_conv_sum += data * X_FILTER[k]; \
y_conv_sum += data * Y_FILTER[k]; \
} \
gradient = sqrt(x_conv_sum * x_conv_sum + y_conv_sum * y_conv_sum); \
dst[(j - 1) * (s->width - 2) + (i - 1)] = gradient; \
} \
} \
}

◆ CALCULATE

#define CALCULATE (   bps)
Value:
{ \
uint##bps##_t *vsrc = (uint##bps##_t*)curr; \
uint##bps##_t *vdst = (uint##bps##_t*)s->prev_frame; \
for (int j = 0; j < s->height; j++) { \
for (int i = 0; i < s->width; i++) { \
motion = 0; \
curr_index = j * stride + i; \
prev_index = j * s->width + i; \
curr_data = s->full_range ? vsrc[curr_index] : convert_full_range(factor, vsrc[curr_index]); \
if (s->nb_frames > 1) \
motion = curr_data - vdst[prev_index]; \
vdst[prev_index] = curr_data; \
motion_matrix[j * s->width + i] = motion; \
} \
} \
}

◆ OFFSET

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

Definition at line 312 of file vf_siti.c.

◆ FLAGS

Definition at line 313 of file vf_siti.c.

Function Documentation

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 75 of file vf_siti.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 84 of file vf_siti.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 104 of file vf_siti.c.

◆ is_full_range()

static int is_full_range ( AVFrame frame)
static

Definition at line 145 of file vf_siti.c.

Referenced by filter_frame().

◆ convert_full_range()

static uint16_t convert_full_range ( int  factor,
uint16_t  y 
)
static

Definition at line 154 of file vf_siti.c.

◆ convolve_sobel()

static void convolve_sobel ( SiTiContext s,
const uint8_t *  src,
float dst,
int  linesize 
)
static

Definition at line 170 of file vf_siti.c.

Referenced by filter_frame().

◆ calculate_motion()

static void calculate_motion ( SiTiContext s,
const uint8_t *  curr,
float motion_matrix,
int  linesize 
)
static

Definition at line 215 of file vf_siti.c.

Referenced by filter_frame().

◆ std_deviation()

static float std_deviation ( float img_metrics,
int  width,
int  height 
)
static

Definition at line 252 of file vf_siti.c.

Referenced by filter_frame().

◆ set_meta()

static void set_meta ( AVDictionary **  metadata,
const char *  key,
float  d 
)
static

Definition at line 274 of file vf_siti.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 281 of file vf_siti.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( siti  )

Variable Documentation

◆ X_FILTER

const int X_FILTER[9]
static
Initial value:
= {
1, 0, -1,
2, 0, -2,
1, 0, -1
}

Definition at line 38 of file vf_siti.c.

◆ Y_FILTER

const int Y_FILTER[9]
static
Initial value:
= {
1, 2, 1,
0, 0, 0,
-1, -2, -1
}

Definition at line 44 of file vf_siti.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ siti_options

const AVOption siti_options[]
static
Initial value:
= {
{ "print_summary", "Print summary showing average values", OFFSET(print_summary), AV_OPT_TYPE_BOOL, { .i64=0 }, 0, 1, FLAGS },
{ NULL }
}

Definition at line 315 of file vf_siti.c.

◆ avfilter_vf_siti_inputs

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

Definition at line 322 of file vf_siti.c.

◆ ff_vf_siti

const AVFilter ff_vf_siti
Initial value:
= {
.name = "siti",
.description = NULL_IF_CONFIG_SMALL("Calculate spatial information (SI) and temporal information (TI)."),
.priv_size = sizeof(SiTiContext),
.priv_class = &siti_class,
.init = init,
}

Definition at line 331 of file vf_siti.c.

avfilter_vf_siti_inputs
static const AVFilterPad avfilter_vf_siti_inputs[]
Definition: vf_siti.c:322
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
X_FILTER
static const int X_FILTER[9]
Definition: vf_siti.c:38
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
data
const char data[16]
Definition: mxf.c:148
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:478
convert_full_range
static uint16_t convert_full_range(int factor, uint16_t y)
Definition: vf_siti.c:154
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_siti.c:104
ff_video_default_filterpad
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition: video.c:37
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:86
SiTiContext
Definition: vf_siti.c:50
s
#define s(width, name)
Definition: cbs_vp9.c:198
floor
static __device__ float floor(float a)
Definition: cuda_runtime.h:173
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_siti.c:68
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_siti.c:84
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
Y_FILTER
static const int Y_FILTER[9]
Definition: vf_siti.c:44
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:85
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:479
OFFSET
#define OFFSET(x)
Definition: vf_siti.c:312
index
int index
Definition: gxfenc.c:90
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
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_siti.c:281
bps
unsigned bps
Definition: movenc.c:1877
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_siti.c:75
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
stride
#define stride
Definition: h264pred_template.c:537
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AVFILTER_FLAG_METADATA_ONLY
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
Definition: avfilter.h:168
factor
static const int factor[16]
Definition: vf_pp7.c:80
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
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
FLAGS
#define FLAGS
Definition: vf_siti.c:313
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:482
src
#define src
Definition: vp8dsp.c:248