Go to the documentation of this file.
88 if (
s->print_summary) {
89 float avg_si =
s->sum_si /
s->nb_frames;
90 float avg_ti =
s->sum_ti /
s->nb_frames;
92 "SITI Summary:\nTotal frames: %"PRId64
"\n\n"
93 "Spatial Information:\nAverage: %f\nMax: %f\nMin: %f\n\n"
94 "Temporal Information:\nAverage: %f\nMax: %f\nMin: %f\n",
95 s->nb_frames, avg_si,
s->max_si,
s->min_si, avg_ti,
s->max_ti,
s->min_ti
123 s->pixel_depth = max_pixsteps[0];
126 pixel_sz =
s->pixel_depth == 1 ?
sizeof(uint8_t) :
sizeof(uint16_t);
127 data_sz =
s->width * pixel_sz *
s->height;
131 gradient_sz = (
s->width - 2) *
sizeof(
float) * (
s->height - 2);
134 motion_sz =
s->width *
sizeof(
float) *
s->height;
137 if (!
s->prev_frame || !
s->gradient_matrix || !
s->motion_matrix) {
164 full_upper = 256 *
factor - 1;
166 return (full_upper * limit_y / limit_upper);
179 int filter_width = 3;
180 int filter_size = filter_width * filter_width;
181 int stride = linesize /
s->pixel_depth;
183 int factor =
s->pixel_depth == 1 ? 1 : 4;
186 #define CONVOLVE(bps) \
188 uint##bps##_t *vsrc = (uint##bps##_t*)src; \
189 for (int j = 1; j < s->height - 1; j++) { \
190 for (int i = 1; i < s->width - 1; i++) { \
193 for (int k = 0; k < filter_size; k++) { \
194 ki = k % filter_width - 1; \
195 kj = floor(k / filter_width) - 1; \
196 index = (j + kj) * stride + (i + ki); \
197 data = s->full_range ? vsrc[index] : convert_full_range(factor, vsrc[index]); \
198 x_conv_sum += data * X_FILTER[k]; \
199 y_conv_sum += data * Y_FILTER[k]; \
201 gradient = sqrt(x_conv_sum * x_conv_sum + y_conv_sum * y_conv_sum); \
202 dst[(j - 1) * (s->width - 2) + (i - 1)] = gradient; \
207 if (
s->pixel_depth == 2) {
216 float *motion_matrix,
int linesize)
218 int stride = linesize /
s->pixel_depth;
224 int factor =
s->pixel_depth == 1 ? 1 : 4;
227 #define CALCULATE(bps) \
229 uint##bps##_t *vsrc = (uint##bps##_t*)curr; \
230 uint##bps##_t *vdst = (uint##bps##_t*)s->prev_frame; \
231 for (int j = 0; j < s->height; j++) { \
232 for (int i = 0; i < s->width; i++) { \
234 curr_index = j * stride + i; \
235 prev_index = j * s->width + i; \
236 curr_data = s->full_range ? vsrc[curr_index] : convert_full_range(factor, vsrc[curr_index]); \
237 if (s->nb_frames > 1) \
238 motion = curr_data - vdst[prev_index]; \
239 vdst[prev_index] = curr_data; \
240 motion_matrix[j * s->width + i] = motion; \
245 if (
s->pixel_depth == 2) {
258 for (
int j = 0; j <
height; j++)
264 for (
int j = 0; j <
height; j++) {
266 float mean_diff = img_metrics[j *
width +
i] -
mean;
267 sqr_diff += (mean_diff * mean_diff);
270 sqr_diff = sqr_diff /
size;
271 return sqrt(sqr_diff);
298 s->max_si =
fmaxf(si,
s->max_si);
299 s->max_ti =
fmaxf(ti,
s->max_ti);
302 s->min_si =
s->nb_frames == 1 ? si :
fminf(si,
s->min_si);
303 s->min_ti =
s->nb_frames == 1 ? ti :
fminf(ti,
s->min_ti);
312 #define OFFSET(x) offsetof(SiTiContext, x)
313 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
333 .description =
NULL_IF_CONFIG_SMALL(
"Calculate spatial information (SI) and temporal information (TI)."),
335 .priv_class = &siti_class,
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
#define FILTER_PIXFMTS_ARRAY(array)
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)
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]
#define FILTER_INPUTS(array)
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.
@ 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_OUTPUTS(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)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
float fmaxf(float, float)
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.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
AVFILTER_DEFINE_CLASS(siti)
#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...
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
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[]
static void convolve_sobel(SiTiContext *s, const uint8_t *src, float *dst, int linesize)