24 static const int8_t
sqr1[8][2] = {{ 0,-1}, { 0, 1}, {-1, 0}, { 1, 0}, {-1,-1}, {-1, 1}, { 1,-1}, { 1, 1}};
25 static const int8_t
dia1[4][2] = {{-1, 0}, { 0,-1}, { 1, 0}, { 0, 1}};
26 static const int8_t
dia2[8][2] = {{-2, 0}, {-1,-1}, { 0,-2}, { 1,-1}, { 2, 0}, { 1, 1}, { 0, 2}, {-1, 1}};
27 static const int8_t
hex2[6][2] = {{-2, 0}, {-1,-2}, {-1, 2}, { 1,-2}, { 1, 2}, { 2, 0}};
28 static 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}};
32 #define COST_MV(x, y)\
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)\
43 if (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;
62 const int linesize = me_ctx->
linesize;
63 uint8_t *data_ref = me_ctx->
data_ref;
64 uint8_t *data_cur = me_ctx->
data_cur;
68 data_ref += y_mv * linesize;
69 data_cur += y_mb * linesize;
71 for (j = 0; j < me_ctx->
mb_size; j++)
73 sad +=
FFABS(data_ref[x_mv +
i + j * linesize] - data_cur[x_mb +
i + j * linesize]);
85 uint64_t cost, cost_min;
87 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
90 for (y = y_min; y <= y_max; y++)
91 for (x = x_min; x <= x_max; x++)
104 uint64_t cost, cost_min;
111 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
118 for (
i = 0;
i < 8;
i++)
135 uint64_t cost, cost_min;
142 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
149 for (
i = 0;
i < 4;
i++)
152 if (x ==
mv[0] && y ==
mv[1])
167 uint64_t cost, cost_min;
175 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
182 for (
i = 0;
i < 8;
i++)
188 for (
i = 0;
i < 8;
i++)
191 if (x ==
mv[0] && y ==
mv[1])
198 for (
i = 0;
i < 8;
i++)
220 uint64_t cost, cost_min;
227 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
234 for (
i = 0;
i < 8;
i++)
237 if (x ==
mv[0] && y ==
mv[1])
252 uint64_t cost, cost_min;
256 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
267 for (
i = 0;
i < 8;
i++)
273 if (dir_x <= 0 && dir_y <= 0)
277 if (dir_x >= 0 && dir_y <= 0)
281 if (dir_x >= 0 && dir_y >= 0)
285 if (dir_x <= 0 && dir_y >= 0)
292 }
while (x !=
mv[0] || y !=
mv[1]);
294 for (
i = 0;
i < 4;
i++)
307 uint64_t cost, cost_min;
310 if (!(cost_min = me_ctx->
get_cost(me_ctx, x_mb, y_mb, x_mb, y_mb)))
317 for (
i = 0;
i < 6;
i++)
320 }
while (x !=
mv[0] || y !=
mv[1]);
322 for (
i = 0;
i < 4;
i++)
340 uint64_t cost, cost_min;
345 cost_min = UINT64_MAX;
349 for (
i = 0;
i < preds[0].
nb;
i++)
350 COST_P_MV(x_mb + preds[0].mvs[
i][0], y_mb + preds[0].mvs[
i][1]);
352 for (
i = 0;
i < preds[1].
nb;
i++)
353 COST_P_MV(x_mb + preds[1].mvs[
i][0], y_mb + preds[1].mvs[
i][1]);
359 for (
i = 0;
i < 4;
i++)
362 }
while (x !=
mv[0] || y !=
mv[1]);
381 uint64_t cost, cost_min;
387 cost_min = UINT64_MAX;
400 if (d <= me_ctx->search_param / 2) {
407 end_x =
FFMIN(
mv[0] + 2, x_max);
408 end_y =
FFMIN(
mv[1] + 2, y_max);
409 for (y =
FFMAX(y_min,
mv[1] - 2); y <= end_y; y++)
410 for (x =
FFMAX(x_min,
mv[0] - 2); x <= end_x; x++)
416 for (
i = 1;
i < 16;
i++)
424 for (
i = 0;
i < 6;
i++)
427 }
while (x !=
mv[0] || y !=
mv[1]);
429 for (
i = 0;
i < 4;
i++)