Go to the documentation of this file.
87 if (
s->print_summary) {
88 float avg_si =
s->sum_si /
s->nb_frames;
89 float avg_ti =
s->sum_ti /
s->nb_frames;
91 "SITI Summary:\nTotal frames: %"PRId64
"\n\n"
92 "Spatial Information:\nAverage: %f\nMax: %f\nMin: %f\n\n"
93 "Temporal Information:\nAverage: %f\nMax: %f\nMin: %f\n",
94 s->nb_frames, avg_si,
s->max_si,
s->min_si, avg_ti,
s->max_ti,
s->min_ti
122 s->pixel_depth = max_pixsteps[0];
125 pixel_sz =
s->pixel_depth == 1 ?
sizeof(uint8_t) :
sizeof(uint16_t);
126 data_sz =
s->width * pixel_sz *
s->height;
130 gradient_sz = (
s->width - 2) *
sizeof(
float) * (
s->height - 2);
133 motion_sz =
s->width *
sizeof(
float) *
s->height;
136 if (!
s->prev_frame || !
s->gradient_matrix || !
s->motion_matrix) {
163 full_upper = 256 *
factor - 1;
165 return (full_upper * limit_y / limit_upper);
178 int filter_width = 3;
179 int filter_size = filter_width * filter_width;
180 int stride = linesize /
s->pixel_depth;
182 int factor =
s->pixel_depth == 1 ? 1 : 4;
185 #define CONVOLVE(bps) \
187 uint##bps##_t *vsrc = (uint##bps##_t*)src; \
188 for (int j = 1; j < s->height - 1; j++) { \
189 for (int i = 1; i < s->width - 1; i++) { \
192 for (int k = 0; k < filter_size; k++) { \
193 ki = k % filter_width - 1; \
194 kj = floor(k / filter_width) - 1; \
195 index = (j + kj) * stride + (i + ki); \
196 data = s->full_range ? vsrc[index] : convert_full_range(factor, vsrc[index]); \
197 x_conv_sum += data * X_FILTER[k]; \
198 y_conv_sum += data * Y_FILTER[k]; \
200 gradient = sqrt(x_conv_sum * x_conv_sum + y_conv_sum * y_conv_sum); \
201 dst[(j - 1) * (s->width - 2) + (i - 1)] = gradient; \
206 if (
s->pixel_depth == 2) {
215 float *motion_matrix,
int linesize)
217 int stride = linesize /
s->pixel_depth;
223 int factor =
s->pixel_depth == 1 ? 1 : 4;
226 #define CALCULATE(bps) \
228 uint##bps##_t *vsrc = (uint##bps##_t*)curr; \
229 uint##bps##_t *vdst = (uint##bps##_t*)s->prev_frame; \
230 for (int j = 0; j < s->height; j++) { \
231 for (int i = 0; i < s->width; i++) { \
233 curr_index = j * stride + i; \
234 prev_index = j * s->width + i; \
235 curr_data = s->full_range ? vsrc[curr_index] : convert_full_range(factor, vsrc[curr_index]); \
236 if (s->nb_frames > 1) \
237 motion = curr_data - vdst[prev_index]; \
238 vdst[prev_index] = curr_data; \
239 motion_matrix[j * s->width + i] = motion; \
244 if (
s->pixel_depth == 2) {
257 for (
int j = 0; j <
height; j++)
263 for (
int j = 0; j <
height; j++) {
265 float mean_diff = img_metrics[j *
width +
i] -
mean;
266 sqr_diff += (mean_diff * mean_diff);
269 sqr_diff = sqr_diff /
size;
270 return sqrt(sqr_diff);
297 s->max_si =
fmaxf(si,
s->max_si);
298 s->max_ti =
fmaxf(ti,
s->max_ti);
301 s->min_si =
s->nb_frames == 1 ? si :
fminf(si,
s->min_si);
302 s->min_ti =
s->nb_frames == 1 ? ti :
fminf(ti,
s->min_ti);
311 #define OFFSET(x) offsetof(SiTiContext, x)
312 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
332 .description =
NULL_IF_CONFIG_SMALL(
"Calculate spatial information (SI) and temporal information (TI)."),
334 .priv_class = &siti_class,
enum AVColorRange color_range
MPEG vs JPEG YUV range.
AVPixelFormat
Pixel format.
static const AVFilterPad avfilter_vf_siti_inputs[]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define FILTER_PIXFMTS_ARRAY(array)
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
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 const int X_FILTER[9]
This structure describes decoded (raw) audio or video data.
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUV420P10
static uint16_t convert_full_range(int factor, uint16_t y)
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
@ AVCOL_RANGE_NB
Not part of ABI.
static int config_input(AVFilterLink *inlink)
A filter pad used for either input or output.
static int is_full_range(AVFrame *frame)
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
static enum AVPixelFormat pix_fmts[]
float fminf(float, float)
static av_cold void uninit(AVFilterContext *ctx)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FILTER_INPUTS(array)
static const int Y_FILTER[9]
Describe the class of an AVClass context structure.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define AV_PIX_FMT_YUV422P10
@ AVCOL_RANGE_UNSPECIFIED
static void set_meta(AVDictionary **metadata, const char *key, float d)
const AVFilter ff_vf_siti
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int shift(int a, int b)
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
float fmaxf(float, float)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
static av_cold int init(AVFilterContext *ctx)
#define AV_LOG_INFO
Standard information.
#define i(width, name, range_min, range_max)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
const char * name
Pad name.
AVFILTER_DEFINE_CLASS(siti)
AVDictionary * metadata
metadata.
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
static float mean(const float *input, int size)
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
static const int factor[16]
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FILTER_OUTPUTS(array)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define flags(name, subs,...)
static const AVOption siti_options[]
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
static void convolve_sobel(SiTiContext *s, const uint8_t *src, float *dst, int linesize)