libvmaf
Loading...
Searching...
No Matches
vif_tools.h
Go to the documentation of this file.
1
18
19#pragma once
20
21#ifndef VIF_TOOLS_H_
22#define VIF_TOOLS_H_
23
24#include <stdbool.h>
25
32
33# define NUM_KERNELSCALES 21
34
35static const float valid_kernelscales[NUM_KERNELSCALES] = {
36 1.0,
37 1.0f / 2.0f,
38 3.0f / 2.0f,
39 2.0f,
40 2.0f / 3.0f,
41 24.0f / 10.0f,
42 360.0f / 97.0f,
43 4.0f / 3.0f,
44 3.5f / 3.0f,
45 3.75f / 3.0f,
46 4.25f / 3.0f,
47 5.0f / 3.0f,
48 3.0f,
49 1.0f / 2.25f,
50 1.4746f,
51 1.54f,
52 1.6f,
53 1.06667f,
54 0.711111f,
55 0.740740f,
56 1.111111f,
57};
58
59/* s single precision, d double precision */
60
61void vif_dec2_s(const float *src, float *dst, int src_w, int src_h, int src_stride, int dst_stride); // stride >= width, multiple of 16 or 32 typically
62
63void vif_dec16_s(const float *src, float *dst, int src_w, int src_h, int src_stride, int dst_stride); // stride >= width, multiple of 16 or 32 typically
64
65float vif_sum_s(const float *x, int w, int h, int stride);
66
67void vif_statistic_s(const float *mu1_sq, const float *mu2_sq, const float *xx_filt, const float *yy_filt, const float *xy_filt, float *num, float *den,
68 int w, int h, int mu1_sq_stride, int mu2_sq_stride, int xx_filt_stride, int yy_filt_stride, int xy_filt_stride, double vif_enhn_gain_limit, double vif_sigma_nsq);
69
70void vif_filter1d_s(const float *f, const float *src, float *dst, float *tmpbuf, int w, int h, int src_stride, int dst_stride, int fwidth);
71
72void vif_filter1d_sq_s(const float *f, const float *src, float *dst, float *tmpbuf, int w, int h, int src_stride, int dst_stride, int fwidth);
73
74void vif_filter1d_xy_s(const float *f, const float *src1, const float *src2, float *dst, float *tmpbuf, int w, int h, int src1_stride, int src2_stride, int dst_stride, int fwidth);
75
76int vif_get_scaling_method(char *scaling_method_str, enum vif_scaling_method *scale_method);
77
78// Bilinear scaling (vif_scale_frame_s with vif_scale_bilinear, and
79// vif_scale_frame_bilinear_precompute_columns_s/_precomputed_s) builds its
80// column tables on the stack and does not support dst_w beyond this. Callers
81// with a fixed prescale factor must check their dst_w against this limit at
82// init time and fail rather than call into the scaler with a wider output.
83#define VIF_BILINEAR_MAX_WIDTH 7680 // covers up to 8K frame width
84
85void vif_scale_frame_s(enum vif_scaling_method scale_method, const float *src, float *dst, int src_w, int src_h, int src_stride, int dst_w, int dst_h, int dst_stride);
86
87// Precomputes the per-output-column source indices/weight used by bilinear
88// scaling. x1a, x2a and dxa must each have room for dst_w elements. The
89// table only depends on src_w/dst_w, so callers that scale many frames at a
90// fixed resolution (e.g. a feature extractor with a fixed prescale) can
91// compute it once and reuse it via vif_scale_frame_bilinear_precomputed_s.
92void vif_scale_frame_bilinear_precompute_columns_s(int src_w, int dst_w, int *x1a, int *x2a, float *dxa);
93
94// Same as vif_scale_frame_s(vif_scale_bilinear, ...), but using a column
95// table already filled in by vif_scale_frame_bilinear_precompute_columns_s
96// for this src_w/dst_w instead of recomputing it.
97void vif_scale_frame_bilinear_precomputed_s(const float *src, float *dst, int src_w, int src_h, int src_stride, int dst_w, int dst_h, int dst_stride, const int *x1a, const int *x2a, const float *dxa);
98
99int vif_get_filter_size(int scale, float kernelscale);
100
101void vif_get_filter(float *out, int scale, float kernelscale);
102
103void speed_get_antialias_filter(float *out, int scale, float kernelscale);
104
105bool vif_validate_kernelscale(float kernelscale);
106
107#endif /* VIF_TOOLS_H_ */
#define NUM_KERNELSCALES
Definition vif_tools.h:33
void vif_scale_frame_bilinear_precomputed_s(const float *src, float *dst, int src_w, int src_h, int src_stride, int dst_w, int dst_h, int dst_stride, const int *x1a, const int *x2a, const float *dxa)
void vif_scale_frame_bilinear_precompute_columns_s(int src_w, int dst_w, int *x1a, int *x2a, float *dxa)
vif_scaling_method
Definition vif_tools.h:26
@ vif_scale_nearest
Definition vif_tools.h:27
@ vif_scale_bilinear
Definition vif_tools.h:30
@ vif_scale_lanczos4
Definition vif_tools.h:29
@ vif_scale_bicubic
Definition vif_tools.h:28
int vif_get_scaling_method(char *scaling_method_str, enum vif_scaling_method *scale_method)
bool vif_validate_kernelscale(float kernelscale)
void vif_filter1d_sq_s(const float *f, const float *src, float *dst, float *tmpbuf, int w, int h, int src_stride, int dst_stride, int fwidth)
void vif_filter1d_xy_s(const float *f, const float *src1, const float *src2, float *dst, float *tmpbuf, int w, int h, int src1_stride, int src2_stride, int dst_stride, int fwidth)
float vif_sum_s(const float *x, int w, int h, int stride)
void vif_filter1d_s(const float *f, const float *src, float *dst, float *tmpbuf, int w, int h, int src_stride, int dst_stride, int fwidth)
void vif_dec16_s(const float *src, float *dst, int src_w, int src_h, int src_stride, int dst_stride)
void vif_statistic_s(const float *mu1_sq, const float *mu2_sq, const float *xx_filt, const float *yy_filt, const float *xy_filt, float *num, float *den, int w, int h, int mu1_sq_stride, int mu2_sq_stride, int xx_filt_stride, int yy_filt_stride, int xy_filt_stride, double vif_enhn_gain_limit, double vif_sigma_nsq)
int vif_get_filter_size(int scale, float kernelscale)
void vif_scale_frame_s(enum vif_scaling_method scale_method, const float *src, float *dst, int src_w, int src_h, int src_stride, int dst_w, int dst_h, int dst_stride)
void speed_get_antialias_filter(float *out, int scale, float kernelscale)
void vif_get_filter(float *out, int scale, float kernelscale)
void vif_dec2_s(const float *src, float *dst, int src_w, int src_h, int src_stride, int dst_stride)