Go to the documentation of this file.
51 #define OFFSET(x) offsetof(VMAFMotionContext, x)
52 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
62 int h, ptrdiff_t _img1_stride, ptrdiff_t _img2_stride)
64 ptrdiff_t img1_stride = _img1_stride /
sizeof(*img1);
65 ptrdiff_t img2_stride = _img2_stride /
sizeof(*img2);
69 for (
i = 0;
i <
h;
i++) {
70 for (j = 0; j <
w; j++) {
81 uint16_t *dst,
int w,
int h, ptrdiff_t _src_stride,
82 ptrdiff_t _dst_stride)
84 ptrdiff_t src_stride = _src_stride /
sizeof(*src);
85 ptrdiff_t dst_stride = _dst_stride /
sizeof(*dst);
86 int radius = filt_w / 2;
87 int borders_left = radius;
88 int borders_right =
w - (filt_w - radius);
92 for (
i = 0;
i <
h;
i++) {
93 for (j = 0; j < borders_left; j++) {
95 for (k = 0; k < filt_w; k++) {
96 int j_tap =
FFABS(j - radius + k);
98 j_tap =
w - (j_tap -
w + 1);
100 sum +=
filter[k] *
src[
i * src_stride + j_tap];
105 for (j = borders_left; j < borders_right; j++) {
107 for (k = 0; k < filt_w; k++) {
108 sum +=
filter[k] *
src[
i * src_stride + j - radius + k];
113 for (j = borders_right; j <
w; j++) {
115 for (k = 0; k < filt_w; k++) {
116 int j_tap =
FFABS(j - radius + k);
118 j_tap =
w - (j_tap -
w + 1);
120 sum +=
filter[k] *
src[
i * src_stride + j_tap];
127 #define conv_y_fn(type, bits) \
128 static void convolution_y_##bits##bit(const uint16_t *filter, int filt_w, \
129 const uint8_t *_src, uint16_t *dst, \
130 int w, int h, ptrdiff_t _src_stride, \
131 ptrdiff_t _dst_stride) \
133 const type *src = (const type *) _src; \
134 ptrdiff_t src_stride = _src_stride / sizeof(*src); \
135 ptrdiff_t dst_stride = _dst_stride / sizeof(*dst); \
136 int radius = filt_w / 2; \
137 int borders_top = radius; \
138 int borders_bottom = h - (filt_w - radius); \
142 for (i = 0; i < borders_top; i++) { \
143 for (j = 0; j < w; j++) { \
145 for (k = 0; k < filt_w; k++) { \
146 int i_tap = FFABS(i - radius + k); \
148 i_tap = h - (i_tap - h + 1); \
150 sum += filter[k] * src[i_tap * src_stride + j]; \
152 dst[i * dst_stride + j] = sum >> bits; \
155 for (i = borders_top; i < borders_bottom; i++) { \
156 for (j = 0; j < w; j++) { \
158 for (k = 0; k < filt_w; k++) { \
159 sum += filter[k] * src[(i - radius + k) * src_stride + j]; \
161 dst[i * dst_stride + j] = sum >> bits; \
164 for (i = borders_bottom; i < h; i++) { \
165 for (j = 0; j < w; j++) { \
167 for (k = 0; k < filt_w; k++) { \
168 int i_tap = FFABS(i - radius + k); \
170 i_tap = h - (i_tap - h + 1); \
172 sum += filter[k] * src[i_tap * src_stride + j]; \
174 dst[i * dst_stride + j] = sum >> bits; \
184 dsp->convolution_y = bpp == 10 ? convolution_y_10bit : convolution_y_8bit;
192 s->vmafdsp.convolution_y(
s->filter, 5,
ref->data[0],
s->temp_data,
193 s->width,
s->height,
ref->linesize[0],
s->stride);
194 s->vmafdsp.convolution_x(
s->filter, 5,
s->temp_data,
s->blur_data[0],
195 s->width,
s->height,
s->stride,
s->stride);
200 uint64_t sad =
s->vmafdsp.sad(
s->blur_data[1],
s->blur_data[0],
201 s->width,
s->height,
s->stride,
s->stride);
203 score = (double) (sad * 1.0 / (
s->width *
s->height << (
BIT_SHIFT - 8)));
206 FFSWAP(uint16_t *,
s->blur_data[0],
s->blur_data[1]);
208 s->motion_sum += score;
226 set_meta(&
ref->metadata,
"lavfi.vmafmotion.score", score);
228 fprintf(
s->stats_file,
229 "n:%"PRId64
" motion:%0.2lf\n",
s->data.nb_frames, score);
243 s->stride =
FFALIGN(
w *
sizeof(uint16_t), 32);
245 data_sz = (size_t)
s->stride *
h;
252 for (
i = 0;
i < 5;
i++) {
256 vmafmotiondsp_init(&
s->vmafdsp,
desc->comp[0].depth);
271 (
desc->comp[0].depth == 8 ||
desc->comp[0].depth == 10) &&
285 ctx->inputs[0]->h,
ctx->inputs[0]->format);
294 return s->nb_frames > 0 ?
s->motion_sum /
s->nb_frames : 0.0;
308 if (
s->stats_file_str) {
309 if (!strcmp(
s->stats_file_str,
"-")) {
310 s->stats_file = stdout;
312 s->stats_file = fopen(
s->stats_file_str,
"w");
313 if (!
s->stats_file) {
318 s->stats_file_str, buf);
332 if (
s->data.nb_frames > 0) {
336 if (
s->stats_file &&
s->stats_file != stdout)
337 fclose(
s->stats_file);
359 .
name =
"vmafmotion",
365 .priv_class = &vmafmotion_class,
AVPixelFormat
Pixel format.
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 FFSWAP(type, a, b)
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
This structure describes decoded (raw) audio or video data.
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
const char * name
Filter name.
A link between two filters.
double ff_vmafmotion_process(VMAFMotionData *s, AVFrame *ref)
static int filter_frame(AVFilterLink *inlink, AVFrame *ref)
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
static void convolution_x(const uint16_t *filter, int filt_w, const uint16_t *src, uint16_t *dst, int w, int h, ptrdiff_t _src_stride, ptrdiff_t _dst_stride)
static int config_input_ref(AVFilterLink *inlink)
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
int ff_vmafmotion_init(VMAFMotionData *s, int w, int h, enum AVPixelFormat fmt)
static const AVFilterPad outputs[]
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Describe the class of an AVClass context structure.
AVFILTER_DEFINE_CLASS(vmafmotion)
static const AVFilterPad vmafmotion_outputs[]
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 inputs
static uint8_t img1[WIDTH *HEIGHT]
double ff_vmafmotion_uninit(VMAFMotionData *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
static uint8_t img2[WIDTH *HEIGHT]
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
static av_cold int init(AVFilterContext *ctx)
#define AV_LOG_INFO
Standard information.
static uint64_t image_sad(const uint16_t *img1, const uint16_t *img2, int w, int h, ptrdiff_t _img1_stride, ptrdiff_t _img2_stride)
#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
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
const char * name
Pad name.
AVFilter ff_vf_vmafmotion
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo ug o o w
static int query_formats(AVFilterContext *ctx)
static const float FILTER_5[5]
static int ref[MAX_W *MAX_W]
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
static void do_vmafmotion(AVFilterContext *ctx, AVFrame *ref)
static const AVFilterPad vmafmotion_inputs[]
#define conv_y_fn(type, bits)
static const AVOption vmafmotion_options[]
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static av_cold void uninit(AVFilterContext *ctx)
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
static void set_meta(AVDictionary **metadata, const char *key, float d)