24static const int8_t
sqr1[8][2] = {{ 0,-1}, { 0, 1}, {-1, 0}, { 1, 0}, {-1,-1}, {-1, 1}, { 1,-1}, { 1, 1}};
25static const int8_t
dia1[4][2] = {{-1, 0}, { 0,-1}, { 1, 0}, { 0, 1}};
26static const int8_t
dia2[8][2] = {{-2, 0}, {-1,-1}, { 0,-2}, { 1,-1}, { 2, 0}, { 1, 1}, { 0, 2}, {-1, 1}};
27static const int8_t
hex2[6][2] = {{-2, 0}, {-1,-2}, {-1, 2}, { 1,-2}, { 1, 2}, { 2, 0}};
28static const int8_t
hex4[16][2] = {{-4,-2}, {-4,-1}, {-4, 0}, {-4, 1}, {-4, 2},
29 { 4,-2}, { 4,-1}, { 4, 0}, { 4, 1}, { 4, 2},
30 {-2, 3}, { 0, 4}, { 2, 3}, {-2,-3}, { 0,-4}, { 2,-3}};
34 cost = me_ctx->get_cost(me_ctx, x_mb, y_mb, x, y);\
35 if (cost < cost_min) {\
42#define COST_P_MV(x, y)\
43if (x >= x_min && x <= x_max && y >= y_min && y <= y_max)\
47 int width,
int height,
int x_min,
int x_max,
int y_min,
int y_max)
54 me_ctx->
x_min = x_min;
55 me_ctx->
x_max = x_max;
56 me_ctx->
y_min = y_min;
57 me_ctx->
y_max = y_max;
64 uint8_t *data_ref = me_ctx->
data_ref;
65 uint8_t *data_cur = me_ctx->
data_cur;
69 data_ref += y_mv * linesize_ref;
70 data_cur += y_mb * linesize_cur;
72 for (j = 0; j < me_ctx->
mb_size; j++)
74 sad +=
FFABS(data_ref[x_mv +
i + j * linesize_ref] - data_cur[x_mb +
i + j * linesize_cur]);
86 uint64_t cost, cost_min;
88 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
91 for (y = y_min; y <= y_max; y++)
92 for (x = x_min; x <= x_max; x++)
105 uint64_t cost, cost_min;
112 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
119 for (
i = 0;
i < 8;
i++)
136 uint64_t cost, cost_min;
143 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
150 for (
i = 0;
i < 4;
i++)
153 if (x ==
mv[0] && y ==
mv[1])
168 uint64_t cost, cost_min;
176 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
183 for (
i = 0;
i < 8;
i++)
189 for (
i = 0;
i < 8;
i++)
192 if (x ==
mv[0] && y ==
mv[1])
199 for (
i = 0;
i < 8;
i++)
221 uint64_t cost, cost_min;
228 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
235 for (
i = 0;
i < 8;
i++)
238 if (x ==
mv[0] && y ==
mv[1])
253 uint64_t cost, cost_min;
257 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
268 for (
i = 0;
i < 8;
i++)
274 if (dir_x <= 0 && dir_y <= 0)
278 if (dir_x >= 0 && dir_y <= 0)
282 if (dir_x >= 0 && dir_y >= 0)
286 if (dir_x <= 0 && dir_y >= 0)
293 }
while (x !=
mv[0] || y !=
mv[1]);
295 for (
i = 0;
i < 4;
i++)
308 uint64_t cost, cost_min;
311 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
318 for (
i = 0;
i < 6;
i++)
321 }
while (x !=
mv[0] || y !=
mv[1]);
323 for (
i = 0;
i < 4;
i++)
341 uint64_t cost, cost_min;
346 cost_min = UINT64_MAX;
350 for (
i = 0;
i < preds[0].
nb;
i++)
351 COST_P_MV(x_mb + preds[0].mvs[
i][0], y_mb + preds[0].mvs[
i][1]);
353 for (
i = 0;
i < preds[1].
nb;
i++)
354 COST_P_MV(x_mb + preds[1].mvs[
i][0], y_mb + preds[1].mvs[
i][1]);
360 for (
i = 0;
i < 4;
i++)
363 }
while (x !=
mv[0] || y !=
mv[1]);
382 uint64_t cost, cost_min;
388 cost_min = UINT64_MAX;
401 if (d <= me_ctx->search_param / 2) {
408 end_x =
FFMIN(
mv[0] + 2, x_max);
409 end_y =
FFMIN(
mv[1] + 2, y_max);
410 for (y =
FFMAX(y_min,
mv[1] - 2); y <= end_y; y++)
411 for (x =
FFMAX(x_min,
mv[0] - 2); x <= end_x; x++)
417 for (
i = 1;
i < 16;
i++)
425 for (
i = 0;
i < 6;
i++)
428 }
while (x !=
mv[0] || y !=
mv[1]);
430 for (
i = 0;
i < 4;
i++)
#define i(width, name, range_min, range_max)
common internal and external API header
#define ROUNDED_DIV(a, b)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const int8_t mv[256][2]
static const int8_t dia1[4][2]
uint64_t ff_me_search_epzs(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
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_search_ntss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *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)
uint64_t ff_me_search_hexbs(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)
uint64_t ff_me_cmp_sad(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int x_mv, int y_mv)
static const int8_t hex2[6][2]
uint64_t ff_me_search_fss(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
uint64_t ff_me_search_ds(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
static const int8_t sqr1[8][2]
Copyright (c) 2016 Davinder Singh (DSM_) <ds.mudhar<@gmail.com>
static const int8_t dia2[8][2]
uint64_t ff_me_search_tdls(AVMotionEstContext *me_ctx, int x_mb, int y_mb, int *mv)
static const int8_t hex4[16][2]
static const float pred[4]
uint64_t(* get_cost)(struct AVMotionEstContext *me_ctx, int x_mb, int y_mb, int mv_x, int mv_y)
AVMotionEstPredictor preds[2]
int pred_y
median predictor y
int pred_x
median predictor x