23 static const int8_t
sqr1[8][2] = {{ 0,-1}, { 0, 1}, {-1, 0}, { 1, 0}, {-1,-1}, {-1, 1}, { 1,-1}, { 1, 1}};
24 static const int8_t
dia1[4][2] = {{-1, 0}, { 0,-1}, { 1, 0}, { 0, 1}};
25 static const int8_t
dia2[8][2] = {{-2, 0}, {-1,-1}, { 0,-2}, { 1,-1}, { 2, 0}, { 1, 1}, { 0, 2}, {-1, 1}};
26 static const int8_t
hex2[6][2] = {{-2, 0}, {-1,-2}, {-1, 2}, { 1,-2}, { 1, 2}, { 2, 0}};
27 static const int8_t
hex4[16][2] = {{-4,-2}, {-4,-1}, {-4, 0}, {-4, 1}, {-4, 2},
28 { 4,-2}, { 4,-1}, { 4, 0}, { 4, 1}, { 4, 2},
29 {-2, 3}, { 0, 4}, { 2, 3}, {-2,-3}, { 0,-4}, { 2,-3}};
31 #define COST_MV(x, y)\ 33 cost = me_ctx->get_cost(me_ctx, x_mb, y_mb, x, y);\ 34 if (cost < cost_min) {\ 41 #define COST_P_MV(x, y)\ 42 if (x >= x_min && x <= x_max && y >= y_min && y <= y_max)\ 46 int width,
int height,
int x_min,
int x_max,
int y_min,
int y_max)
53 me_ctx->
x_min = x_min;
54 me_ctx->
x_max = x_max;
55 me_ctx->
y_min = y_min;
56 me_ctx->
y_max = y_max;
61 const int linesize = me_ctx->
linesize;
67 data_ref += y_mv * linesize;
68 data_cur += y_mb * linesize;
70 for (j = 0; j < me_ctx->
mb_size; j++)
71 for (i = 0; i < me_ctx->
mb_size; i++)
72 sad +=
FFABS(data_ref[x_mv + i + j * linesize] - data_cur[x_mb + i + j * linesize]);
84 uint64_t cost, cost_min;
86 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
89 for (y = y_min; y <= y_max; y++)
90 for (x = x_min; x <= x_max; x++)
103 uint64_t cost, cost_min;
110 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
117 for (i = 0; i < 8; i++)
134 uint64_t cost, cost_min;
141 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
148 for (i = 0; i < 4; i++)
151 if (x == mv[0] && y == mv[1])
166 uint64_t cost, cost_min;
174 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
181 for (i = 0; i < 8; i++)
187 for (i = 0; i < 8; i++)
190 if (x == mv[0] && y == mv[1])
193 if (
FFABS(x - mv[0]) <= 1 &&
FFABS(y - mv[1]) <= 1) {
197 for (i = 0; i < 8; i++)
219 uint64_t cost, cost_min;
226 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
233 for (i = 0; i < 8; i++)
236 if (x == mv[0] && y == mv[1])
251 uint64_t cost, cost_min;
255 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
266 for (i = 0; i < 8; i++)
272 if (dir_x <= 0 && dir_y <= 0)
276 if (dir_x >= 0 && dir_y <= 0)
280 if (dir_x >= 0 && dir_y >= 0)
284 if (dir_x <= 0 && dir_y >= 0)
291 }
while (x != mv[0] || y != mv[1]);
293 for (i = 0; i < 4; i++)
306 uint64_t cost, cost_min;
309 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
316 for (i = 0; i < 6; i++)
319 }
while (x != mv[0] || y != mv[1]);
321 for (i = 0; i < 4; i++)
339 uint64_t cost, cost_min;
344 cost_min = UINT64_MAX;
348 for (i = 0; i < preds[0].
nb; i++)
349 COST_P_MV(x_mb + preds[0].mvs[i][0], y_mb + preds[0].mvs[i][1]);
351 for (i = 0; i < preds[1].
nb; i++)
352 COST_P_MV(x_mb + preds[1].mvs[i][0], y_mb + preds[1].mvs[i][1]);
358 for (i = 0; i < 4; i++)
361 }
while (x != mv[0] || y != mv[1]);
380 uint64_t cost, cost_min;
386 cost_min = UINT64_MAX;
390 for (i = 0; i < pred->
nb; i++)
399 if (d <= me_ctx->search_param / 2) {
406 end_x =
FFMIN(mv[0] + 2, x_max);
407 end_y =
FFMIN(mv[1] + 2, y_max);
408 for (y =
FFMAX(y_min, mv[1] - 2); y <= end_y; y++)
409 for (x =
FFMAX(x_min, mv[0] - 2); x <= end_x; x++)
415 for (i = 1; i < 16; i++)
423 for (i = 0; i < 6; i++)
426 }
while (x != mv[0] || y != mv[1]);
428 for (i = 0; i < 4; i++)
uint64_t ff_me_search_hexbs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
int pred_y
median predictor y
uint64_t(* get_cost)(struct AVMotionEstContext *me_ctx, int x_mb, int y_mb, int mv_x, int mv_y)
AVMotionEstPredictor preds[2]
uint64_t ff_me_search_fss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
static const int8_t hex4[16][2]
static const int8_t sqr1[8][2]
Copyright (c) 2016 Davinder Singh (DSM_) <ds.mudhar<.com>
int pred_x
median predictor x
uint64_t ff_me_search_ds(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
uint64_t ff_me_search_umh(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
#define ROUNDED_DIV(a, b)
uint64_t ff_me_search_epzs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
uint64_t ff_me_search_tdls(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
static const int8_t dia1[4][2]
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
uint64_t ff_me_search_ntss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
static const int8_t dia2[8][2]
static const int8_t hex2[6][2]
static const float pred[4]
static const int8_t mv[256][2]
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)
uint64_t ff_me_cmp_sad(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int x_mv, int y_mv)
uint64_t ff_me_search_esa(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
uint64_t ff_me_search_tss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)