FFmpeg
vf_mestimate.c
Go to the documentation of this file.
1 /**
2  * Copyright (c) 2016 Davinder Singh (DSM_) <ds.mudhar<@gmail.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "motion_estimation.h"
22 #include "libavcodec/mathops.h"
23 #include "libavutil/common.h"
24 #include "libavutil/imgutils.h"
25 #include "libavutil/opt.h"
26 #include "libavutil/pixdesc.h"
28 #include "avfilter.h"
29 #include "formats.h"
30 #include "internal.h"
31 #include "video.h"
32 
33 typedef struct MEContext {
34  const AVClass *class;
36  int method; ///< motion estimation method
37 
38  int mb_size; ///< macroblock size
39  int search_param; ///< search parameter
42 
44 
45  int (*mv_table[3])[2][2]; ///< motion vectors of current & prev 2 frames
46 } MEContext;
47 
48 #define OFFSET(x) offsetof(MEContext, x)
49 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
50 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
51 
52 static const AVOption mestimate_options[] = {
53  { "method", "motion estimation method", OFFSET(method), AV_OPT_TYPE_INT, {.i64 = AV_ME_METHOD_ESA}, AV_ME_METHOD_ESA, AV_ME_METHOD_UMH, FLAGS, "method" },
54  CONST("esa", "exhaustive search", AV_ME_METHOD_ESA, "method"),
55  CONST("tss", "three step search", AV_ME_METHOD_TSS, "method"),
56  CONST("tdls", "two dimensional logarithmic search", AV_ME_METHOD_TDLS, "method"),
57  CONST("ntss", "new three step search", AV_ME_METHOD_NTSS, "method"),
58  CONST("fss", "four step search", AV_ME_METHOD_FSS, "method"),
59  CONST("ds", "diamond search", AV_ME_METHOD_DS, "method"),
60  CONST("hexbs", "hexagon-based search", AV_ME_METHOD_HEXBS, "method"),
61  CONST("epzs", "enhanced predictive zonal search", AV_ME_METHOD_EPZS, "method"),
62  CONST("umh", "uneven multi-hexagon search", AV_ME_METHOD_UMH, "method"),
63  { "mb_size", "macroblock size", OFFSET(mb_size), AV_OPT_TYPE_INT, {.i64 = 16}, 8, INT_MAX, FLAGS },
64  { "search_param", "search parameter", OFFSET(search_param), AV_OPT_TYPE_INT, {.i64 = 7}, 4, INT_MAX, FLAGS },
65  { NULL }
66 };
67 
68 AVFILTER_DEFINE_CLASS(mestimate);
69 
71 {
72  static const enum AVPixelFormat pix_fmts[] = {
82  };
83 
85  if (!fmts_list)
86  return AVERROR(ENOMEM);
87  return ff_set_common_formats(ctx, fmts_list);
88 }
89 
91 {
92  MEContext *s = inlink->dst->priv;
93  int i;
94 
95  s->log2_mb_size = av_ceil_log2_c(s->mb_size);
96  s->mb_size = 1 << s->log2_mb_size;
97 
98  s->b_width = inlink->w >> s->log2_mb_size;
99  s->b_height = inlink->h >> s->log2_mb_size;
100  s->b_count = s->b_width * s->b_height;
101 
102  if (s->b_count == 0)
103  return AVERROR(EINVAL);
104 
105  for (i = 0; i < 3; i++) {
106  s->mv_table[i] = av_mallocz_array(s->b_count, sizeof(*s->mv_table[0]));
107  if (!s->mv_table[i])
108  return AVERROR(ENOMEM);
109  }
110 
111  ff_me_init_context(&s->me_ctx, s->mb_size, s->search_param, inlink->w, inlink->h, 0, (s->b_width - 1) << s->log2_mb_size, 0, (s->b_height - 1) << s->log2_mb_size);
112 
113  return 0;
114 }
115 
116 static void add_mv_data(AVMotionVector *mv, int mb_size,
117  int x, int y, int x_mv, int y_mv, int dir)
118 {
119  mv->w = mb_size;
120  mv->h = mb_size;
121  mv->dst_x = x + (mb_size >> 1);
122  mv->dst_y = y + (mb_size >> 1);
123  mv->src_x = x_mv + (mb_size >> 1);
124  mv->src_y = y_mv + (mb_size >> 1);
125  mv->source = dir ? 1 : -1;
126  mv->flags = 0;
127 }
128 
129 #define SEARCH_MV(method)\
130  do {\
131  for (mb_y = 0; mb_y < s->b_height; mb_y++)\
132  for (mb_x = 0; mb_x < s->b_width; mb_x++) {\
133  const int x_mb = mb_x << s->log2_mb_size;\
134  const int y_mb = mb_y << s->log2_mb_size;\
135  int mv[2] = {x_mb, y_mb};\
136  ff_me_search_##method(me_ctx, x_mb, y_mb, mv);\
137  add_mv_data(((AVMotionVector *) sd->data) + mv_count++, me_ctx->mb_size, x_mb, y_mb, mv[0], mv[1], dir);\
138  }\
139  } while (0)
140 
141 #define ADD_PRED(preds, px, py)\
142  do {\
143  preds.mvs[preds.nb][0] = px;\
144  preds.mvs[preds.nb][1] = py;\
145  preds.nb++;\
146  } while(0)
147 
149 {
150  AVFilterContext *ctx = inlink->dst;
151  MEContext *s = ctx->priv;
152  AVMotionEstContext *me_ctx = &s->me_ctx;
153  AVFrameSideData *sd;
154  AVFrame *out;
155  int mb_x, mb_y, dir;
156  int32_t mv_count = 0;
157  int ret;
158 
159  if (frame->pts == AV_NOPTS_VALUE) {
160  ret = ff_filter_frame(ctx->outputs[0], frame);
161  return ret;
162  }
163 
164  av_frame_free(&s->prev);
165  s->prev = s->cur;
166  s->cur = s->next;
167  s->next = frame;
168 
169  s->mv_table[2] = memcpy(s->mv_table[2], s->mv_table[1], sizeof(*s->mv_table[1]) * s->b_count);
170  s->mv_table[1] = memcpy(s->mv_table[1], s->mv_table[0], sizeof(*s->mv_table[0]) * s->b_count);
171 
172  if (!s->cur) {
173  s->cur = av_frame_clone(frame);
174  if (!s->cur)
175  return AVERROR(ENOMEM);
176  }
177 
178  if (!s->prev)
179  return 0;
180 
181  out = av_frame_clone(s->cur);
182  if (!out)
183  return AVERROR(ENOMEM);
184 
186  if (!sd) {
187  av_frame_free(&out);
188  return AVERROR(ENOMEM);
189  }
190 
191  me_ctx->data_cur = s->cur->data[0];
192  me_ctx->linesize = s->cur->linesize[0];
193 
194  for (dir = 0; dir < 2; dir++) {
195  me_ctx->data_ref = (dir ? s->next : s->prev)->data[0];
196 
197  if (s->method == AV_ME_METHOD_DS)
198  SEARCH_MV(ds);
199  else if (s->method == AV_ME_METHOD_ESA)
200  SEARCH_MV(esa);
201  else if (s->method == AV_ME_METHOD_FSS)
202  SEARCH_MV(fss);
203  else if (s->method == AV_ME_METHOD_NTSS)
204  SEARCH_MV(ntss);
205  else if (s->method == AV_ME_METHOD_TDLS)
206  SEARCH_MV(tdls);
207  else if (s->method == AV_ME_METHOD_TSS)
208  SEARCH_MV(tss);
209  else if (s->method == AV_ME_METHOD_HEXBS)
210  SEARCH_MV(hexbs);
211  else if (s->method == AV_ME_METHOD_UMH) {
212  for (mb_y = 0; mb_y < s->b_height; mb_y++)
213  for (mb_x = 0; mb_x < s->b_width; mb_x++) {
214  const int mb_i = mb_x + mb_y * s->b_width;
215  const int x_mb = mb_x << s->log2_mb_size;
216  const int y_mb = mb_y << s->log2_mb_size;
217  int mv[2] = {x_mb, y_mb};
218 
219  AVMotionEstPredictor *preds = me_ctx->preds;
220  preds[0].nb = 0;
221 
222  ADD_PRED(preds[0], 0, 0);
223 
224  //left mb in current frame
225  if (mb_x > 0)
226  ADD_PRED(preds[0], s->mv_table[0][mb_i - 1][dir][0], s->mv_table[0][mb_i - 1][dir][1]);
227 
228  if (mb_y > 0) {
229  //top mb in current frame
230  ADD_PRED(preds[0], s->mv_table[0][mb_i - s->b_width][dir][0], s->mv_table[0][mb_i - s->b_width][dir][1]);
231 
232  //top-right mb in current frame
233  if (mb_x + 1 < s->b_width)
234  ADD_PRED(preds[0], s->mv_table[0][mb_i - s->b_width + 1][dir][0], s->mv_table[0][mb_i - s->b_width + 1][dir][1]);
235  //top-left mb in current frame
236  else if (mb_x > 0)
237  ADD_PRED(preds[0], s->mv_table[0][mb_i - s->b_width - 1][dir][0], s->mv_table[0][mb_i - s->b_width - 1][dir][1]);
238  }
239 
240  //median predictor
241  if (preds[0].nb == 4) {
242  me_ctx->pred_x = mid_pred(preds[0].mvs[1][0], preds[0].mvs[2][0], preds[0].mvs[3][0]);
243  me_ctx->pred_y = mid_pred(preds[0].mvs[1][1], preds[0].mvs[2][1], preds[0].mvs[3][1]);
244  } else if (preds[0].nb == 3) {
245  me_ctx->pred_x = mid_pred(0, preds[0].mvs[1][0], preds[0].mvs[2][0]);
246  me_ctx->pred_y = mid_pred(0, preds[0].mvs[1][1], preds[0].mvs[2][1]);
247  } else if (preds[0].nb == 2) {
248  me_ctx->pred_x = preds[0].mvs[1][0];
249  me_ctx->pred_y = preds[0].mvs[1][1];
250  } else {
251  me_ctx->pred_x = 0;
252  me_ctx->pred_y = 0;
253  }
254 
255  ff_me_search_umh(me_ctx, x_mb, y_mb, mv);
256 
257  s->mv_table[0][mb_i][dir][0] = mv[0] - x_mb;
258  s->mv_table[0][mb_i][dir][1] = mv[1] - y_mb;
259  add_mv_data(((AVMotionVector *) sd->data) + mv_count++, me_ctx->mb_size, x_mb, y_mb, mv[0], mv[1], dir);
260  }
261 
262  } else if (s->method == AV_ME_METHOD_EPZS) {
263 
264  for (mb_y = 0; mb_y < s->b_height; mb_y++)
265  for (mb_x = 0; mb_x < s->b_width; mb_x++) {
266  const int mb_i = mb_x + mb_y * s->b_width;
267  const int x_mb = mb_x << s->log2_mb_size;
268  const int y_mb = mb_y << s->log2_mb_size;
269  int mv[2] = {x_mb, y_mb};
270 
271  AVMotionEstPredictor *preds = me_ctx->preds;
272  preds[0].nb = 0;
273  preds[1].nb = 0;
274 
275  ADD_PRED(preds[0], 0, 0);
276 
277  //left mb in current frame
278  if (mb_x > 0)
279  ADD_PRED(preds[0], s->mv_table[0][mb_i - 1][dir][0], s->mv_table[0][mb_i - 1][dir][1]);
280 
281  //top mb in current frame
282  if (mb_y > 0)
283  ADD_PRED(preds[0], s->mv_table[0][mb_i - s->b_width][dir][0], s->mv_table[0][mb_i - s->b_width][dir][1]);
284 
285  //top-right mb in current frame
286  if (mb_y > 0 && mb_x + 1 < s->b_width)
287  ADD_PRED(preds[0], s->mv_table[0][mb_i - s->b_width + 1][dir][0], s->mv_table[0][mb_i - s->b_width + 1][dir][1]);
288 
289  //median predictor
290  if (preds[0].nb == 4) {
291  me_ctx->pred_x = mid_pred(preds[0].mvs[1][0], preds[0].mvs[2][0], preds[0].mvs[3][0]);
292  me_ctx->pred_y = mid_pred(preds[0].mvs[1][1], preds[0].mvs[2][1], preds[0].mvs[3][1]);
293  } else if (preds[0].nb == 3) {
294  me_ctx->pred_x = mid_pred(0, preds[0].mvs[1][0], preds[0].mvs[2][0]);
295  me_ctx->pred_y = mid_pred(0, preds[0].mvs[1][1], preds[0].mvs[2][1]);
296  } else if (preds[0].nb == 2) {
297  me_ctx->pred_x = preds[0].mvs[1][0];
298  me_ctx->pred_y = preds[0].mvs[1][1];
299  } else {
300  me_ctx->pred_x = 0;
301  me_ctx->pred_y = 0;
302  }
303 
304  //collocated mb in prev frame
305  ADD_PRED(preds[0], s->mv_table[1][mb_i][dir][0], s->mv_table[1][mb_i][dir][1]);
306 
307  //accelerator motion vector of collocated block in prev frame
308  ADD_PRED(preds[1], s->mv_table[1][mb_i][dir][0] + (s->mv_table[1][mb_i][dir][0] - s->mv_table[2][mb_i][dir][0]),
309  s->mv_table[1][mb_i][dir][1] + (s->mv_table[1][mb_i][dir][1] - s->mv_table[2][mb_i][dir][1]));
310 
311  //left mb in prev frame
312  if (mb_x > 0)
313  ADD_PRED(preds[1], s->mv_table[1][mb_i - 1][dir][0], s->mv_table[1][mb_i - 1][dir][1]);
314 
315  //top mb in prev frame
316  if (mb_y > 0)
317  ADD_PRED(preds[1], s->mv_table[1][mb_i - s->b_width][dir][0], s->mv_table[1][mb_i - s->b_width][dir][1]);
318 
319  //right mb in prev frame
320  if (mb_x + 1 < s->b_width)
321  ADD_PRED(preds[1], s->mv_table[1][mb_i + 1][dir][0], s->mv_table[1][mb_i + 1][dir][1]);
322 
323  //bottom mb in prev frame
324  if (mb_y + 1 < s->b_height)
325  ADD_PRED(preds[1], s->mv_table[1][mb_i + s->b_width][dir][0], s->mv_table[1][mb_i + s->b_width][dir][1]);
326 
327  ff_me_search_epzs(me_ctx, x_mb, y_mb, mv);
328 
329  s->mv_table[0][mb_i][dir][0] = mv[0] - x_mb;
330  s->mv_table[0][mb_i][dir][1] = mv[1] - y_mb;
331  add_mv_data(((AVMotionVector *) sd->data) + mv_count++, s->mb_size, x_mb, y_mb, mv[0], mv[1], dir);
332  }
333  }
334  }
335 
336  return ff_filter_frame(ctx->outputs[0], out);
337 }
338 
340 {
341  MEContext *s = ctx->priv;
342  int i;
343 
344  av_frame_free(&s->prev);
345  av_frame_free(&s->cur);
346  av_frame_free(&s->next);
347 
348  for (i = 0; i < 3; i++)
349  av_freep(&s->mv_table[i]);
350 }
351 
352 static const AVFilterPad mestimate_inputs[] = {
353  {
354  .name = "default",
355  .type = AVMEDIA_TYPE_VIDEO,
356  .filter_frame = filter_frame,
357  .config_props = config_input,
358  },
359  { NULL }
360 };
361 
362 static const AVFilterPad mestimate_outputs[] = {
363  {
364  .name = "default",
365  .type = AVMEDIA_TYPE_VIDEO,
366  },
367  { NULL }
368 };
369 
371  .name = "mestimate",
372  .description = NULL_IF_CONFIG_SMALL("Generate motion vectors."),
373  .priv_size = sizeof(MEContext),
374  .priv_class = &mestimate_class,
375  .uninit = uninit,
379 };
AVMotionEstPredictor::nb
int nb
Definition: motion_estimation.h:38
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_mestimate.c:70
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
AVMotionEstContext::data_ref
uint8_t * data_ref
Definition: motion_estimation.h:42
AVERROR
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
opt.h
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
AVMotionEstPredictor
Definition: motion_estimation.h:36
out
FILE * out
Definition: movenc.c:54
av_frame_new_side_data
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size)
Add a new side data to a frame.
Definition: frame.c:605
AVMotionVector
Definition: motion_vector.h:24
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:978
MEContext::mv_table
int(*[3] mv_table)[2][2]
motion vectors of current & prev 2 frames
Definition: vf_mestimate.c:45
mv
static const int8_t mv[256][2]
Definition: 4xm.c:79
inlink
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
Definition: filter_design.txt:212
MEContext::b_height
int b_height
Definition: vf_mestimate.c:40
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:112
mestimate_outputs
static const AVFilterPad mestimate_outputs[]
Definition: vf_mestimate.c:362
AVMotionEstContext::data_cur
uint8_t * data_cur
Definition: motion_estimation.h:42
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
pixdesc.h
AVOption
AVOption.
Definition: opt.h:247
MEContext::next
AVFrame * next
Definition: vf_mestimate.c:43
data
const char data[16]
Definition: mxf.c:143
MEContext::prev
AVFrame * prev
Definition: vf_mestimate.c:43
av_mallocz_array
void * av_mallocz_array(size_t nmemb, size_t size)
Definition: mem.c:196
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:149
add_mv_data
static void add_mv_data(AVMotionVector *mv, int mb_size, int x, int y, int x_mv, int y_mv, int dir)
Definition: vf_mestimate.c:116
MEContext::me_ctx
AVMotionEstContext me_ctx
Definition: vf_mestimate.c:35
MEContext::method
int method
motion estimation method
Definition: vf_mestimate.c:36
video.h
MEContext
Copyright (c) 2016 Davinder Singh (DSM_) <ds.mudhar<@gmail.com>
Definition: vf_mestimate.c:33
AV_ME_METHOD_FSS
#define AV_ME_METHOD_FSS
Definition: motion_estimation.h:30
AVMotionEstContext::pred_x
int pred_x
median predictor x
Definition: motion_estimation.h:56
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
SEARCH_MV
#define SEARCH_MV(method)
Definition: vf_mestimate.c:129
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_mestimate.c:90
AV_ME_METHOD_ESA
#define AV_ME_METHOD_ESA
Copyright (c) 2016 Davinder Singh (DSM_) <ds.mudhar<@gmail.com>
Definition: motion_estimation.h:26
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:248
av_cold
#define av_cold
Definition: attributes.h:90
inputs
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
Definition: filter_design.txt:243
ff_set_common_formats
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:580
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:79
motion_vector.h
AV_ME_METHOD_TSS
#define AV_ME_METHOD_TSS
Definition: motion_estimation.h:27
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(mestimate)
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:290
ctx
AVFormatContext * ctx
Definition: movenc.c:48
av_frame_clone
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
Definition: frame.c:424
CONST
#define CONST(name, help, val, unit)
Definition: vf_mestimate.c:50
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:66
AVMotionEstContext
Definition: motion_estimation.h:41
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
mestimate_inputs
static const AVFilterPad mestimate_inputs[]
Definition: vf_mestimate.c:352
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
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:78
ADD_PRED
#define ADD_PRED(preds, px, py)
Definition: vf_mestimate.c:141
motion_estimation.h
mathops.h
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
OFFSET
#define OFFSET(x)
Definition: vf_mestimate.c:48
ff_vf_mestimate
const AVFilter ff_vf_mestimate
Definition: vf_mestimate.c:370
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:116
ff_me_search_epzs
uint64_t ff_me_search_epzs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
Definition: motion_estimation.c:332
MEContext::log2_mb_size
int log2_mb_size
Definition: vf_mestimate.c:41
mestimate_options
static const AVOption mestimate_options[]
Definition: vf_mestimate.c:52
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AVFrameSideData::data
uint8_t * data
Definition: frame.h:211
MEContext::b_width
int b_width
Definition: vf_mestimate.c:40
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:167
AV_ME_METHOD_EPZS
#define AV_ME_METHOD_EPZS
Definition: motion_estimation.h:33
internal.h
MEContext::cur
AVFrame * cur
Definition: vf_mestimate.c:43
AV_ME_METHOD_DS
#define AV_ME_METHOD_DS
Definition: motion_estimation.h:31
i
int i
Definition: input.c:406
AV_ME_METHOD_HEXBS
#define AV_ME_METHOD_HEXBS
Definition: motion_estimation.h:32
common.h
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AVFilter
Filter definition.
Definition: avfilter.h:145
mid_pred
#define mid_pred
Definition: mathops.h:97
ret
ret
Definition: filter_design.txt:187
frame
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
Definition: filter_design.txt:264
FLAGS
#define FLAGS
Definition: vf_mestimate.c:49
ff_me_init_context
void ff_me_init_context(AVMotionEstContext *me_ctx, int mb_size, int search_param, int width, int height, int x_min, int x_max, int y_min, int y_max)
Definition: motion_estimation.c:45
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_mestimate.c:339
MEContext::search_param
int search_param
search parameter
Definition: vf_mestimate.c:39
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
avfilter.h
MEContext::b_count
int b_count
Definition: vf_mestimate.c:40
AV_ME_METHOD_UMH
#define AV_ME_METHOD_UMH
Definition: motion_estimation.h:34
MEContext::mb_size
int mb_size
macroblock size
Definition: vf_mestimate.c:38
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AVFilterContext
An instance of a filter.
Definition: avfilter.h:333
AVMotionEstContext::pred_y
int pred_y
median predictor y
Definition: motion_estimation.h:57
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:70
AV_ME_METHOD_NTSS
#define AV_ME_METHOD_NTSS
Definition: motion_estimation.h:29
AVMotionEstContext::linesize
int linesize
Definition: motion_estimation.h:43
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:209
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
int32_t
int32_t
Definition: audioconvert.c:56
imgutils.h
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
AV_FRAME_DATA_MOTION_VECTORS
@ AV_FRAME_DATA_MOTION_VECTORS
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
Definition: frame.h:96
ff_me_search_umh
uint64_t ff_me_search_umh(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
Definition: motion_estimation.c:373
AVMotionEstPredictor::mvs
int mvs[10][2]
Definition: motion_estimation.h:37
AV_ME_METHOD_TDLS
#define AV_ME_METHOD_TDLS
Definition: motion_estimation.h:28
int
int
Definition: ffmpeg_filter.c:156
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_mestimate.c:148
AVMotionEstContext::preds
AVMotionEstPredictor preds[2]
Definition: motion_estimation.h:58
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
AVMotionEstContext::mb_size
int mb_size
Definition: motion_estimation.h:45
av_ceil_log2_c
static av_always_inline av_const int av_ceil_log2_c(int x)
Compute ceil(log2(x)).
Definition: common.h:444