Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_mcomp.c

Issue 23600008: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_mcomp.h ('k') | source/libvpx/vp9/encoder/vp9_modecosts.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <stdio.h>
12 #include <limits.h> 11 #include <limits.h>
13 #include <math.h> 12 #include <math.h>
13 #include <stdio.h>
14
15 #include "./vpx_config.h"
16
17 #include "vpx_mem/vpx_mem.h"
18
19 #include "vp9/common/vp9_findnearmv.h"
20 #include "vp9/common/vp9_common.h"
14 21
15 #include "vp9/encoder/vp9_onyx_int.h" 22 #include "vp9/encoder/vp9_onyx_int.h"
16 #include "vp9/encoder/vp9_mcomp.h" 23 #include "vp9/encoder/vp9_mcomp.h"
17 #include "vpx_mem/vpx_mem.h"
18 #include "./vpx_config.h"
19 #include "vp9/common/vp9_findnearmv.h"
20 #include "vp9/common/vp9_common.h"
21 24
22 // #define NEW_DIAMOND_SEARCH 25 // #define NEW_DIAMOND_SEARCH
23 26
24 void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv) { 27 void vp9_clamp_mv_min_max(MACROBLOCK *x, MV *mv) {
25 int col_min = (ref_mv->as_mv.col >> 3) - MAX_FULL_PEL_VAL + 28 const int col_min = (mv->col >> 3) - MAX_FULL_PEL_VAL + (mv->col & 7 ? 1 : 0);
26 ((ref_mv->as_mv.col & 7) ? 1 : 0); 29 const int row_min = (mv->row >> 3) - MAX_FULL_PEL_VAL + (mv->row & 7 ? 1 : 0);
27 int row_min = (ref_mv->as_mv.row >> 3) - MAX_FULL_PEL_VAL + 30 const int col_max = (mv->col >> 3) + MAX_FULL_PEL_VAL;
28 ((ref_mv->as_mv.row & 7) ? 1 : 0); 31 const int row_max = (mv->row >> 3) + MAX_FULL_PEL_VAL;
29 int col_max = (ref_mv->as_mv.col >> 3) + MAX_FULL_PEL_VAL;
30 int row_max = (ref_mv->as_mv.row >> 3) + MAX_FULL_PEL_VAL;
31 32
32 /* Get intersection of UMV window and valid MV window to reduce # of checks in diamond search. */ 33 // Get intersection of UMV window and valid MV window to reduce # of checks
34 // in diamond search.
33 if (x->mv_col_min < col_min) 35 if (x->mv_col_min < col_min)
34 x->mv_col_min = col_min; 36 x->mv_col_min = col_min;
35 if (x->mv_col_max > col_max) 37 if (x->mv_col_max > col_max)
36 x->mv_col_max = col_max; 38 x->mv_col_max = col_max;
37 if (x->mv_row_min < row_min) 39 if (x->mv_row_min < row_min)
38 x->mv_row_min = row_min; 40 x->mv_row_min = row_min;
39 if (x->mv_row_max > row_max) 41 if (x->mv_row_max > row_max)
40 x->mv_row_max = row_max; 42 x->mv_row_max = row_max;
41 } 43 }
42 44
43 int vp9_init_search_range(VP9_COMP *cpi, int size) { 45 int vp9_init_search_range(VP9_COMP *cpi, int size) {
44 int sr = 0; 46 int sr = 0;
45 47
46 // Minimum search size no matter what the passed in value. 48 // Minimum search size no matter what the passed in value.
47 size = MAX(16, size); 49 size = MAX(16, size);
48 50
49 while ((size << sr) < MAX_FULL_PEL_VAL) 51 while ((size << sr) < MAX_FULL_PEL_VAL)
50 sr++; 52 sr++;
51 53
52 if (sr) 54 if (sr)
53 sr--; 55 sr--;
54 56
55 sr += cpi->sf.reduce_first_step_size; 57 sr += cpi->sf.reduce_first_step_size;
56 sr = MIN(sr, (cpi->sf.max_step_search_steps - 2)); 58 sr = MIN(sr, (cpi->sf.max_step_search_steps - 2));
57 return sr; 59 return sr;
58 } 60 }
59 61
60 int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2], 62 int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2],
61 int weight, int ishp) { 63 int weight) {
62 MV v; 64 MV v;
63 v.row = mv->as_mv.row - ref->as_mv.row; 65 v.row = mv->as_mv.row - ref->as_mv.row;
64 v.col = mv->as_mv.col - ref->as_mv.col; 66 v.col = mv->as_mv.col - ref->as_mv.col;
65 return ROUND_POWER_OF_TWO((mvjcost[vp9_get_mv_joint(&v)] + 67 return ROUND_POWER_OF_TWO((mvjcost[vp9_get_mv_joint(&v)] +
66 mvcost[0][v.row] + 68 mvcost[0][v.row] +
67 mvcost[1][v.col]) * weight, 7); 69 mvcost[1][v.col]) * weight, 7);
68 } 70 }
69 71
70 static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2], 72 static int mv_err_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2],
71 int error_per_bit, int ishp) { 73 int error_per_bit) {
72 if (mvcost) { 74 if (mvcost) {
73 MV v; 75 MV v;
74 v.row = mv->as_mv.row - ref->as_mv.row; 76 v.row = mv->as_mv.row - ref->as_mv.row;
75 v.col = mv->as_mv.col - ref->as_mv.col; 77 v.col = mv->as_mv.col - ref->as_mv.col;
76 return ROUND_POWER_OF_TWO((mvjcost[vp9_get_mv_joint(&v)] + 78 return ROUND_POWER_OF_TWO((mvjcost[vp9_get_mv_joint(&v)] +
77 mvcost[0][v.row] + 79 mvcost[0][v.row] +
78 mvcost[1][v.col]) * error_per_bit, 13); 80 mvcost[1][v.col]) * error_per_bit, 13);
79 } 81 }
80 return 0; 82 return 0;
81 } 83 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 if ((v = MVC(r, c) + thismse) < besterr) { \ 240 if ((v = MVC(r, c) + thismse) < besterr) { \
239 besterr = v; \ 241 besterr = v; \
240 br = r; \ 242 br = r; \
241 bc = c; \ 243 bc = c; \
242 *distortion = thismse; \ 244 *distortion = thismse; \
243 *sse1 = sse; \ 245 *sse1 = sse; \
244 } \ 246 } \
245 }, \ 247 }, \
246 v = INT_MAX;) 248 v = INT_MAX;)
247 249
248 int vp9_find_best_sub_pixel_step_iteratively(MACROBLOCK *x, 250 #define FIRST_LEVEL_CHECKS \
249 int_mv *bestmv, int_mv *ref_mv, 251 { \
250 int error_per_bit, 252 unsigned int left, right, up, down, diag; \
251 const vp9_variance_fn_ptr_t *vfp, 253 CHECK_BETTER(left, tr, tc - hstep); \
252 int *mvjcost, int *mvcost[2], 254 CHECK_BETTER(right, tr, tc + hstep); \
253 int *distortion, 255 CHECK_BETTER(up, tr - hstep, tc); \
254 unsigned int *sse1) { 256 CHECK_BETTER(down, tr + hstep, tc); \
257 whichdir = (left < right ? 0 : 1) + \
258 (up < down ? 0 : 2); \
259 switch (whichdir) { \
260 case 0: \
261 CHECK_BETTER(diag, tr - hstep, tc - hstep); \
262 break; \
263 case 1: \
264 CHECK_BETTER(diag, tr - hstep, tc + hstep); \
265 break; \
266 case 2: \
267 CHECK_BETTER(diag, tr + hstep, tc - hstep); \
268 break; \
269 case 3: \
270 CHECK_BETTER(diag, tr + hstep, tc + hstep); \
271 break; \
272 } \
273 }
274
275 #define SECOND_LEVEL_CHECKS \
276 { \
277 int kr, kc; \
278 unsigned int second; \
279 if (tr != br && tc != bc) { \
280 kr = br - tr; \
281 kc = bc - tc; \
282 CHECK_BETTER(second, tr + kr, tc + 2 * kc); \
283 CHECK_BETTER(second, tr + 2 * kr, tc + kc); \
284 } else if (tr == br && tc != bc) { \
285 kc = bc - tc; \
286 CHECK_BETTER(second, tr + hstep, tc + 2 * kc); \
287 CHECK_BETTER(second, tr - hstep, tc + 2 * kc); \
288 switch (whichdir) { \
289 case 0: \
290 case 1: \
291 CHECK_BETTER(second, tr + hstep, tc + kc); \
292 break; \
293 case 2: \
294 case 3: \
295 CHECK_BETTER(second, tr - hstep, tc + kc); \
296 break; \
297 } \
298 } else if (tr != br && tc == bc) { \
299 kr = br - tr; \
300 CHECK_BETTER(second, tr + 2 * kr, tc + hstep); \
301 CHECK_BETTER(second, tr + 2 * kr, tc - hstep); \
302 switch (whichdir) { \
303 case 0: \
304 case 2: \
305 CHECK_BETTER(second, tr + kr, tc + hstep); \
306 break; \
307 case 1: \
308 case 3: \
309 CHECK_BETTER(second, tr + kr, tc - hstep); \
310 break; \
311 } \
312 } \
313 }
314
315 int vp9_find_best_sub_pixel_iterative(MACROBLOCK *x,
316 int_mv *bestmv, int_mv *ref_mv,
317 int error_per_bit,
318 const vp9_variance_fn_ptr_t *vfp,
319 int forced_stop,
320 int iters_per_step,
321 int *mvjcost, int *mvcost[2],
322 int *distortion,
323 unsigned int *sse1) {
255 uint8_t *z = x->plane[0].src.buf; 324 uint8_t *z = x->plane[0].src.buf;
256 int src_stride = x->plane[0].src.stride; 325 int src_stride = x->plane[0].src.stride;
257 MACROBLOCKD *xd = &x->e_mbd; 326 MACROBLOCKD *xd = &x->e_mbd;
258 327
259 int rr, rc, br, bc, hstep;
260 int tr, tc;
261 unsigned int besterr = INT_MAX; 328 unsigned int besterr = INT_MAX;
262 unsigned int left, right, up, down, diag;
263 unsigned int sse; 329 unsigned int sse;
264 unsigned int whichdir; 330 unsigned int whichdir;
265 unsigned int halfiters = 4; 331 unsigned int halfiters = iters_per_step;
266 unsigned int quarteriters = 4; 332 unsigned int quarteriters = iters_per_step;
267 unsigned int eighthiters = 4; 333 unsigned int eighthiters = iters_per_step;
268 int thismse; 334 int thismse;
269 int maxc, minc, maxr, minr;
270 int y_stride;
271 int offset;
272 int usehp = xd->allow_high_precision_mv;
273 335
274 uint8_t *y = xd->plane[0].pre[0].buf + 336 uint8_t *y = xd->plane[0].pre[0].buf +
275 (bestmv->as_mv.row) * xd->plane[0].pre[0].stride + 337 (bestmv->as_mv.row) * xd->plane[0].pre[0].stride +
276 bestmv->as_mv.col; 338 bestmv->as_mv.col;
277 339
278 y_stride = xd->plane[0].pre[0].stride; 340 const int y_stride = xd->plane[0].pre[0].stride;
279 341
280 rr = ref_mv->as_mv.row; 342 int rr = ref_mv->as_mv.row;
281 rc = ref_mv->as_mv.col; 343 int rc = ref_mv->as_mv.col;
282 br = bestmv->as_mv.row << 3; 344 int br = bestmv->as_mv.row << 3;
283 bc = bestmv->as_mv.col << 3; 345 int bc = bestmv->as_mv.col << 3;
284 hstep = 4; 346 int hstep = 4;
285 minc = MAX(x->mv_col_min << 3, (ref_mv->as_mv.col) - ((1 << MV_MAX_BITS) - 1)) ; 347 const int minc = MAX(x->mv_col_min << 3, ref_mv->as_mv.col - MV_MAX);
286 maxc = MIN(x->mv_col_max << 3, (ref_mv->as_mv.col) + ((1 << MV_MAX_BITS) - 1)) ; 348 const int maxc = MIN(x->mv_col_max << 3, ref_mv->as_mv.col + MV_MAX);
287 minr = MAX(x->mv_row_min << 3, (ref_mv->as_mv.row) - ((1 << MV_MAX_BITS) - 1)) ; 349 const int minr = MAX(x->mv_row_min << 3, ref_mv->as_mv.row - MV_MAX);
288 maxr = MIN(x->mv_row_max << 3, (ref_mv->as_mv.row) + ((1 << MV_MAX_BITS) - 1)) ; 350 const int maxr = MIN(x->mv_row_max << 3, ref_mv->as_mv.row + MV_MAX);
289 351
290 tr = br; 352 int tr = br;
291 tc = bc; 353 int tc = bc;
292 354
293 355 const int offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col;
294 offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col;
295 356
296 // central mv 357 // central mv
297 bestmv->as_mv.row <<= 3; 358 bestmv->as_mv.row <<= 3;
298 bestmv->as_mv.col <<= 3; 359 bestmv->as_mv.col <<= 3;
299 360
300 // calculate central point error 361 // calculate central point error
301 besterr = vfp->vf(y, y_stride, z, src_stride, sse1); 362 besterr = vfp->vf(y, y_stride, z, src_stride, sse1);
302 *distortion = besterr; 363 *distortion = besterr;
303 besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, 364 besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
304 error_per_bit, xd->allow_high_precision_mv);
305 365
306 // TODO: Each subsequent iteration checks at least one point in 366 // TODO: Each subsequent iteration checks at least one point in
307 // common with the last iteration could be 2 ( if diag selected) 367 // common with the last iteration could be 2 ( if diag selected)
308 while (--halfiters) { 368 while (halfiters--) {
309 // 1/2 pel 369 // 1/2 pel
310 CHECK_BETTER(left, tr, tc - hstep); 370 FIRST_LEVEL_CHECKS;
311 CHECK_BETTER(right, tr, tc + hstep);
312 CHECK_BETTER(up, tr - hstep, tc);
313 CHECK_BETTER(down, tr + hstep, tc);
314
315 whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
316
317 switch (whichdir) {
318 case 0:
319 CHECK_BETTER(diag, tr - hstep, tc - hstep);
320 break;
321 case 1:
322 CHECK_BETTER(diag, tr - hstep, tc + hstep);
323 break;
324 case 2:
325 CHECK_BETTER(diag, tr + hstep, tc - hstep);
326 break;
327 case 3:
328 CHECK_BETTER(diag, tr + hstep, tc + hstep);
329 break;
330 }
331
332 // no reason to check the same one again. 371 // no reason to check the same one again.
333 if (tr == br && tc == bc) 372 if (tr == br && tc == bc)
334 break; 373 break;
335
336 tr = br; 374 tr = br;
337 tc = bc; 375 tc = bc;
338 } 376 }
339 377
340 // TODO: Each subsequent iteration checks at least one point in common with 378 // TODO: Each subsequent iteration checks at least one point in common with
341 // the last iteration could be 2 ( if diag selected) 1/4 pel 379 // the last iteration could be 2 ( if diag selected) 1/4 pel
342 hstep >>= 1;
343 while (--quarteriters) {
344 CHECK_BETTER(left, tr, tc - hstep);
345 CHECK_BETTER(right, tr, tc + hstep);
346 CHECK_BETTER(up, tr - hstep, tc);
347 CHECK_BETTER(down, tr + hstep, tc);
348 380
349 whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2); 381 // Note forced_stop: 0 - full, 1 - qtr only, 2 - half only
350 382 if (forced_stop != 2) {
351 switch (whichdir) {
352 case 0:
353 CHECK_BETTER(diag, tr - hstep, tc - hstep);
354 break;
355 case 1:
356 CHECK_BETTER(diag, tr - hstep, tc + hstep);
357 break;
358 case 2:
359 CHECK_BETTER(diag, tr + hstep, tc - hstep);
360 break;
361 case 3:
362 CHECK_BETTER(diag, tr + hstep, tc + hstep);
363 break;
364 }
365
366 // no reason to check the same one again.
367 if (tr == br && tc == bc)
368 break;
369
370 tr = br;
371 tc = bc;
372 }
373
374 if (xd->allow_high_precision_mv) {
375 usehp = vp9_use_mv_hp(&ref_mv->as_mv);
376 } else {
377 usehp = 0;
378 }
379
380 if (usehp) {
381 hstep >>= 1; 383 hstep >>= 1;
382 while (--eighthiters) { 384 while (quarteriters--) {
383 CHECK_BETTER(left, tr, tc - hstep); 385 FIRST_LEVEL_CHECKS;
384 CHECK_BETTER(right, tr, tc + hstep);
385 CHECK_BETTER(up, tr - hstep, tc);
386 CHECK_BETTER(down, tr + hstep, tc);
387
388 whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
389
390 switch (whichdir) {
391 case 0:
392 CHECK_BETTER(diag, tr - hstep, tc - hstep);
393 break;
394 case 1:
395 CHECK_BETTER(diag, tr - hstep, tc + hstep);
396 break;
397 case 2:
398 CHECK_BETTER(diag, tr + hstep, tc - hstep);
399 break;
400 case 3:
401 CHECK_BETTER(diag, tr + hstep, tc + hstep);
402 break;
403 }
404
405 // no reason to check the same one again. 386 // no reason to check the same one again.
406 if (tr == br && tc == bc) 387 if (tr == br && tc == bc)
407 break; 388 break;
408
409 tr = br; 389 tr = br;
410 tc = bc; 390 tc = bc;
411 } 391 }
412 } 392 }
393
394 if (xd->allow_high_precision_mv && vp9_use_mv_hp(&ref_mv->as_mv) &&
395 forced_stop == 0) {
396 hstep >>= 1;
397 while (eighthiters--) {
398 FIRST_LEVEL_CHECKS;
399 // no reason to check the same one again.
400 if (tr == br && tc == bc)
401 break;
402 tr = br;
403 tc = bc;
404 }
405 }
406
413 bestmv->as_mv.row = br; 407 bestmv->as_mv.row = br;
414 bestmv->as_mv.col = bc; 408 bestmv->as_mv.col = bc;
415 409
416 if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) || 410 if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) ||
417 (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3))) 411 (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3)))
418 return INT_MAX; 412 return INT_MAX;
419 413
420 return besterr; 414 return besterr;
421 } 415 }
422 416
423 #undef DIST 417 int vp9_find_best_sub_pixel_tree(MACROBLOCK *x,
424 /* returns subpixel variance error function */
425 #define DIST(r, c) \
426 vfp->svaf(PRE(r, c), y_stride, SP(c), SP(r), \
427 z, src_stride, &sse, second_pred)
428
429 int vp9_find_best_sub_pixel_comp(MACROBLOCK *x,
430 int_mv *bestmv, int_mv *ref_mv, 418 int_mv *bestmv, int_mv *ref_mv,
431 int error_per_bit, 419 int error_per_bit,
432 const vp9_variance_fn_ptr_t *vfp, 420 const vp9_variance_fn_ptr_t *vfp,
421 int forced_stop,
422 int iters_per_step,
433 int *mvjcost, int *mvcost[2], 423 int *mvjcost, int *mvcost[2],
434 int *distortion, 424 int *distortion,
435 unsigned int *sse1, 425 unsigned int *sse1) {
436 const uint8_t *second_pred, int w, int h) {
437 uint8_t *z = x->plane[0].src.buf; 426 uint8_t *z = x->plane[0].src.buf;
438 int src_stride = x->plane[0].src.stride; 427 int src_stride = x->plane[0].src.stride;
439 MACROBLOCKD *xd = &x->e_mbd; 428 MACROBLOCKD *xd = &x->e_mbd;
440
441 int rr, rc, br, bc, hstep; 429 int rr, rc, br, bc, hstep;
442 int tr, tc; 430 int tr, tc;
443 unsigned int besterr = INT_MAX; 431 unsigned int besterr = INT_MAX;
444 unsigned int left, right, up, down, diag;
445 unsigned int sse; 432 unsigned int sse;
446 unsigned int whichdir; 433 unsigned int whichdir;
447 unsigned int halfiters = 4;
448 unsigned int quarteriters = 4;
449 unsigned int eighthiters = 4;
450 int thismse; 434 int thismse;
451 int maxc, minc, maxr, minr; 435 int maxc, minc, maxr, minr;
452 int y_stride; 436 int y_stride;
453 int offset; 437 int offset;
454 int usehp = xd->allow_high_precision_mv; 438 unsigned int halfiters = iters_per_step;
439 unsigned int quarteriters = iters_per_step;
440 unsigned int eighthiters = iters_per_step;
455 441
456 DECLARE_ALIGNED_ARRAY(16, uint8_t, comp_pred, 64 * 64);
457 uint8_t *y = xd->plane[0].pre[0].buf + 442 uint8_t *y = xd->plane[0].pre[0].buf +
458 (bestmv->as_mv.row) * xd->plane[0].pre[0].stride + 443 (bestmv->as_mv.row) * xd->plane[0].pre[0].stride +
459 bestmv->as_mv.col; 444 bestmv->as_mv.col;
460 445
461 y_stride = xd->plane[0].pre[0].stride; 446 y_stride = xd->plane[0].pre[0].stride;
462 447
463 rr = ref_mv->as_mv.row; 448 rr = ref_mv->as_mv.row;
464 rc = ref_mv->as_mv.col; 449 rc = ref_mv->as_mv.col;
465 br = bestmv->as_mv.row << 3; 450 br = bestmv->as_mv.row << 3;
466 bc = bestmv->as_mv.col << 3; 451 bc = bestmv->as_mv.col << 3;
467 hstep = 4; 452 hstep = 4;
468 minc = MAX(x->mv_col_min << 3, (ref_mv->as_mv.col) - 453 minc = MAX(x->mv_col_min << 3,
469 ((1 << MV_MAX_BITS) - 1)); 454 (ref_mv->as_mv.col) - ((1 << MV_MAX_BITS) - 1));
470 maxc = MIN(x->mv_col_max << 3, (ref_mv->as_mv.col) + 455 maxc = MIN(x->mv_col_max << 3,
471 ((1 << MV_MAX_BITS) - 1)); 456 (ref_mv->as_mv.col) + ((1 << MV_MAX_BITS) - 1));
472 minr = MAX(x->mv_row_min << 3, (ref_mv->as_mv.row) - 457 minr = MAX(x->mv_row_min << 3,
473 ((1 << MV_MAX_BITS) - 1)); 458 (ref_mv->as_mv.row) - ((1 << MV_MAX_BITS) - 1));
474 maxr = MIN(x->mv_row_max << 3, (ref_mv->as_mv.row) + 459 maxr = MIN(x->mv_row_max << 3,
475 ((1 << MV_MAX_BITS) - 1)); 460 (ref_mv->as_mv.row) + ((1 << MV_MAX_BITS) - 1));
476 461
477 tr = br; 462 tr = br;
478 tc = bc; 463 tc = bc;
479 464
480
481 offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col; 465 offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col;
482 466
483 // central mv 467 // central mv
484 bestmv->as_mv.row <<= 3; 468 bestmv->as_mv.row <<= 3;
485 bestmv->as_mv.col <<= 3; 469 bestmv->as_mv.col <<= 3;
486 470
487 // calculate central point error 471 // calculate central point error
488 // TODO(yunqingwang): central pointer error was already calculated in full- 472 besterr = vfp->vf(y, y_stride, z, src_stride, sse1);
489 // pixel search, and can be passed in this function.
490 comp_avg_pred(comp_pred, second_pred, w, h, y, y_stride);
491 besterr = vfp->vf(comp_pred, w, z, src_stride, sse1);
492 *distortion = besterr; 473 *distortion = besterr;
493 besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, 474 besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
494 error_per_bit, xd->allow_high_precision_mv);
495 475
496 // Each subsequent iteration checks at least one point in 476 // 1/2 pel
497 // common with the last iteration could be 2 ( if diag selected) 477 FIRST_LEVEL_CHECKS;
498 while (--halfiters) { 478 if (halfiters > 1) {
499 // 1/2 pel 479 SECOND_LEVEL_CHECKS;
500 CHECK_BETTER(left, tr, tc - hstep); 480 }
501 CHECK_BETTER(right, tr, tc + hstep); 481 tr = br;
502 CHECK_BETTER(up, tr - hstep, tc); 482 tc = bc;
503 CHECK_BETTER(down, tr + hstep, tc);
504 483
505 whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2); 484 // Note forced_stop: 0 - full, 1 - qtr only, 2 - half only
506 485 if (forced_stop != 2) {
507 switch (whichdir) { 486 hstep >>= 1;
508 case 0: 487 FIRST_LEVEL_CHECKS;
509 CHECK_BETTER(diag, tr - hstep, tc - hstep); 488 if (quarteriters > 1) {
510 break; 489 SECOND_LEVEL_CHECKS;
511 case 1:
512 CHECK_BETTER(diag, tr - hstep, tc + hstep);
513 break;
514 case 2:
515 CHECK_BETTER(diag, tr + hstep, tc - hstep);
516 break;
517 case 3:
518 CHECK_BETTER(diag, tr + hstep, tc + hstep);
519 break;
520 } 490 }
521
522 // no reason to check the same one again.
523 if (tr == br && tc == bc)
524 break;
525
526 tr = br; 491 tr = br;
527 tc = bc; 492 tc = bc;
528 } 493 }
529 494
530 // Each subsequent iteration checks at least one point in common with 495 if (xd->allow_high_precision_mv && vp9_use_mv_hp(&ref_mv->as_mv) &&
531 // the last iteration could be 2 ( if diag selected) 1/4 pel 496 forced_stop == 0) {
532 hstep >>= 1; 497 hstep >>= 1;
533 while (--quarteriters) { 498 FIRST_LEVEL_CHECKS;
534 CHECK_BETTER(left, tr, tc - hstep); 499 if (eighthiters > 1) {
535 CHECK_BETTER(right, tr, tc + hstep); 500 SECOND_LEVEL_CHECKS;
536 CHECK_BETTER(up, tr - hstep, tc);
537 CHECK_BETTER(down, tr + hstep, tc);
538
539 whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
540
541 switch (whichdir) {
542 case 0:
543 CHECK_BETTER(diag, tr - hstep, tc - hstep);
544 break;
545 case 1:
546 CHECK_BETTER(diag, tr - hstep, tc + hstep);
547 break;
548 case 2:
549 CHECK_BETTER(diag, tr + hstep, tc - hstep);
550 break;
551 case 3:
552 CHECK_BETTER(diag, tr + hstep, tc + hstep);
553 break;
554 } 501 }
555
556 // no reason to check the same one again.
557 if (tr == br && tc == bc)
558 break;
559
560 tr = br; 502 tr = br;
561 tc = bc; 503 tc = bc;
562 } 504 }
563 505
564 if (xd->allow_high_precision_mv) {
565 usehp = vp9_use_mv_hp(&ref_mv->as_mv);
566 } else {
567 usehp = 0;
568 }
569
570 if (usehp) {
571 hstep >>= 1;
572 while (--eighthiters) {
573 CHECK_BETTER(left, tr, tc - hstep);
574 CHECK_BETTER(right, tr, tc + hstep);
575 CHECK_BETTER(up, tr - hstep, tc);
576 CHECK_BETTER(down, tr + hstep, tc);
577
578 whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
579
580 switch (whichdir) {
581 case 0:
582 CHECK_BETTER(diag, tr - hstep, tc - hstep);
583 break;
584 case 1:
585 CHECK_BETTER(diag, tr - hstep, tc + hstep);
586 break;
587 case 2:
588 CHECK_BETTER(diag, tr + hstep, tc - hstep);
589 break;
590 case 3:
591 CHECK_BETTER(diag, tr + hstep, tc + hstep);
592 break;
593 }
594
595 // no reason to check the same one again.
596 if (tr == br && tc == bc)
597 break;
598
599 tr = br;
600 tc = bc;
601 }
602 }
603 bestmv->as_mv.row = br; 506 bestmv->as_mv.row = br;
604 bestmv->as_mv.col = bc; 507 bestmv->as_mv.col = bc;
605 508
606 if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) || 509 if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) ||
607 (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3))) 510 (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3)))
608 return INT_MAX; 511 return INT_MAX;
609 512
610 return besterr; 513 return besterr;
611 } 514 }
612 515
516 #undef DIST
517 /* returns subpixel variance error function */
518 #define DIST(r, c) \
519 vfp->svaf(PRE(r, c), y_stride, SP(c), SP(r), \
520 z, src_stride, &sse, second_pred)
521
522 int vp9_find_best_sub_pixel_comp_iterative(MACROBLOCK *x,
523 int_mv *bestmv, int_mv *ref_mv,
524 int error_per_bit,
525 const vp9_variance_fn_ptr_t *vfp,
526 int forced_stop,
527 int iters_per_step,
528 int *mvjcost, int *mvcost[2],
529 int *distortion,
530 unsigned int *sse1,
531 const uint8_t *second_pred,
532 int w, int h) {
533 uint8_t *const z = x->plane[0].src.buf;
534 const int src_stride = x->plane[0].src.stride;
535 MACROBLOCKD *const xd = &x->e_mbd;
536
537 unsigned int besterr = INT_MAX;
538 unsigned int sse;
539 unsigned int whichdir;
540 unsigned int halfiters = iters_per_step;
541 unsigned int quarteriters = iters_per_step;
542 unsigned int eighthiters = iters_per_step;
543 int thismse;
544
545 DECLARE_ALIGNED_ARRAY(16, uint8_t, comp_pred, 64 * 64);
546 uint8_t *const y = xd->plane[0].pre[0].buf +
547 (bestmv->as_mv.row) * xd->plane[0].pre[0].stride +
548 bestmv->as_mv.col;
549
550 const int y_stride = xd->plane[0].pre[0].stride;
551
552 int rr = ref_mv->as_mv.row;
553 int rc = ref_mv->as_mv.col;
554 int br = bestmv->as_mv.row << 3;
555 int bc = bestmv->as_mv.col << 3;
556 int hstep = 4;
557 const int minc = MAX(x->mv_col_min << 3, ref_mv->as_mv.col - MV_MAX);
558 const int maxc = MIN(x->mv_col_max << 3, ref_mv->as_mv.col + MV_MAX);
559 const int minr = MAX(x->mv_row_min << 3, ref_mv->as_mv.row - MV_MAX);
560 const int maxr = MIN(x->mv_row_max << 3, ref_mv->as_mv.row + MV_MAX);
561
562 int tr = br;
563 int tc = bc;
564
565 const int offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col;
566
567 // central mv
568 bestmv->as_mv.row <<= 3;
569 bestmv->as_mv.col <<= 3;
570
571 // calculate central point error
572 // TODO(yunqingwang): central pointer error was already calculated in full-
573 // pixel search, and can be passed in this function.
574 comp_avg_pred(comp_pred, second_pred, w, h, y, y_stride);
575 besterr = vfp->vf(comp_pred, w, z, src_stride, sse1);
576 *distortion = besterr;
577 besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
578
579 // Each subsequent iteration checks at least one point in
580 // common with the last iteration could be 2 ( if diag selected)
581 while (halfiters--) {
582 // 1/2 pel
583 FIRST_LEVEL_CHECKS;
584 // no reason to check the same one again.
585 if (tr == br && tc == bc)
586 break;
587 tr = br;
588 tc = bc;
589 }
590
591 // Each subsequent iteration checks at least one point in common with
592 // the last iteration could be 2 ( if diag selected) 1/4 pel
593
594 // Note forced_stop: 0 - full, 1 - qtr only, 2 - half only
595 if (forced_stop != 2) {
596 hstep >>= 1;
597 while (quarteriters--) {
598 FIRST_LEVEL_CHECKS;
599 // no reason to check the same one again.
600 if (tr == br && tc == bc)
601 break;
602 tr = br;
603 tc = bc;
604 }
605 }
606
607 if (xd->allow_high_precision_mv && vp9_use_mv_hp(&ref_mv->as_mv) &&
608 forced_stop == 0) {
609 hstep >>= 1;
610 while (eighthiters--) {
611 FIRST_LEVEL_CHECKS;
612 // no reason to check the same one again.
613 if (tr == br && tc == bc)
614 break;
615 tr = br;
616 tc = bc;
617 }
618 }
619 bestmv->as_mv.row = br;
620 bestmv->as_mv.col = bc;
621
622 if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) ||
623 (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3)))
624 return INT_MAX;
625
626 return besterr;
627 }
628
629 int vp9_find_best_sub_pixel_comp_tree(MACROBLOCK *x,
630 int_mv *bestmv, int_mv *ref_mv,
631 int error_per_bit,
632 const vp9_variance_fn_ptr_t *vfp,
633 int forced_stop,
634 int iters_per_step,
635 int *mvjcost, int *mvcost[2],
636 int *distortion,
637 unsigned int *sse1,
638 const uint8_t *second_pred,
639 int w, int h) {
640 uint8_t *z = x->plane[0].src.buf;
641 int src_stride = x->plane[0].src.stride;
642 MACROBLOCKD *xd = &x->e_mbd;
643 int rr, rc, br, bc, hstep;
644 int tr, tc;
645 unsigned int besterr = INT_MAX;
646 unsigned int sse;
647 unsigned int whichdir;
648 int thismse;
649 int maxc, minc, maxr, minr;
650 int y_stride;
651 int offset;
652 unsigned int halfiters = iters_per_step;
653 unsigned int quarteriters = iters_per_step;
654 unsigned int eighthiters = iters_per_step;
655
656 DECLARE_ALIGNED_ARRAY(16, uint8_t, comp_pred, 64 * 64);
657 uint8_t *y = xd->plane[0].pre[0].buf +
658 (bestmv->as_mv.row) * xd->plane[0].pre[0].stride +
659 bestmv->as_mv.col;
660
661 y_stride = xd->plane[0].pre[0].stride;
662
663 rr = ref_mv->as_mv.row;
664 rc = ref_mv->as_mv.col;
665 br = bestmv->as_mv.row << 3;
666 bc = bestmv->as_mv.col << 3;
667 hstep = 4;
668 minc = MAX(x->mv_col_min << 3, (ref_mv->as_mv.col) -
669 ((1 << MV_MAX_BITS) - 1));
670 maxc = MIN(x->mv_col_max << 3, (ref_mv->as_mv.col) +
671 ((1 << MV_MAX_BITS) - 1));
672 minr = MAX(x->mv_row_min << 3, (ref_mv->as_mv.row) -
673 ((1 << MV_MAX_BITS) - 1));
674 maxr = MIN(x->mv_row_max << 3, (ref_mv->as_mv.row) +
675 ((1 << MV_MAX_BITS) - 1));
676
677 tr = br;
678 tc = bc;
679
680
681 offset = (bestmv->as_mv.row) * y_stride + bestmv->as_mv.col;
682
683 // central mv
684 bestmv->as_mv.row <<= 3;
685 bestmv->as_mv.col <<= 3;
686
687 // calculate central point error
688 // TODO(yunqingwang): central pointer error was already calculated in full-
689 // pixel search, and can be passed in this function.
690 comp_avg_pred(comp_pred, second_pred, w, h, y, y_stride);
691 besterr = vfp->vf(comp_pred, w, z, src_stride, sse1);
692 *distortion = besterr;
693 besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
694
695 // Each subsequent iteration checks at least one point in
696 // common with the last iteration could be 2 ( if diag selected)
697 // 1/2 pel
698 FIRST_LEVEL_CHECKS;
699 if (halfiters > 1) {
700 SECOND_LEVEL_CHECKS;
701 }
702 tr = br;
703 tc = bc;
704
705 // Each subsequent iteration checks at least one point in common with
706 // the last iteration could be 2 ( if diag selected) 1/4 pel
707
708 // Note forced_stop: 0 - full, 1 - qtr only, 2 - half only
709 if (forced_stop != 2) {
710 hstep >>= 1;
711 FIRST_LEVEL_CHECKS;
712 if (quarteriters > 1) {
713 SECOND_LEVEL_CHECKS;
714 }
715 tr = br;
716 tc = bc;
717 }
718
719 if (xd->allow_high_precision_mv && vp9_use_mv_hp(&ref_mv->as_mv) &&
720 forced_stop == 0) {
721 hstep >>= 1;
722 FIRST_LEVEL_CHECKS;
723 if (eighthiters > 1) {
724 SECOND_LEVEL_CHECKS;
725 }
726 tr = br;
727 tc = bc;
728 }
729 bestmv->as_mv.row = br;
730 bestmv->as_mv.col = bc;
731
732 if ((abs(bestmv->as_mv.col - ref_mv->as_mv.col) > (MAX_FULL_PEL_VAL << 3)) ||
733 (abs(bestmv->as_mv.row - ref_mv->as_mv.row) > (MAX_FULL_PEL_VAL << 3)))
734 return INT_MAX;
735
736 return besterr;
737 }
613 738
614 #undef MVC 739 #undef MVC
615 #undef PRE 740 #undef PRE
616 #undef DIST 741 #undef DIST
617 #undef IFMVCV 742 #undef IFMVCV
618 #undef CHECK_BETTER 743 #undef CHECK_BETTER
619 #undef MIN
620 #undef MAX
621
622 int vp9_find_best_sub_pixel_step(MACROBLOCK *x,
623 int_mv *bestmv, int_mv *ref_mv,
624 int error_per_bit,
625 const vp9_variance_fn_ptr_t *vfp,
626 int *mvjcost, int *mvcost[2], int *distortion,
627 unsigned int *sse1) {
628 int bestmse = INT_MAX;
629 int_mv startmv;
630 int_mv this_mv;
631 int_mv orig_mv;
632 int yrow_movedback = 0, ycol_movedback = 0;
633 uint8_t *z = x->plane[0].src.buf;
634 int src_stride = x->plane[0].src.stride;
635 int left, right, up, down, diag;
636 unsigned int sse;
637 int whichdir;
638 int thismse;
639 int y_stride;
640 MACROBLOCKD *xd = &x->e_mbd;
641 int usehp = xd->allow_high_precision_mv;
642
643 uint8_t *y = xd->plane[0].pre[0].buf +
644 (bestmv->as_mv.row) * xd->plane[0].pre[0].stride +
645 bestmv->as_mv.col;
646 y_stride = xd->plane[0].pre[0].stride;
647
648 // central mv
649 bestmv->as_mv.row <<= 3;
650 bestmv->as_mv.col <<= 3;
651 startmv = *bestmv;
652 orig_mv = *bestmv;
653
654 // calculate central point error
655 bestmse = vfp->vf(y, y_stride, z, src_stride, sse1);
656 *distortion = bestmse;
657 bestmse += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit,
658 xd->allow_high_precision_mv);
659
660 // go left then right and check error
661 this_mv.as_mv.row = startmv.as_mv.row;
662 this_mv.as_mv.col = ((startmv.as_mv.col - 8) | 4);
663 thismse = vfp->svf_halfpix_h(y - 1, y_stride, z, src_stride, &sse);
664 left = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
665 xd->allow_high_precision_mv);
666
667 if (left < bestmse) {
668 *bestmv = this_mv;
669 bestmse = left;
670 *distortion = thismse;
671 *sse1 = sse;
672 }
673
674 this_mv.as_mv.col += 8;
675 thismse = vfp->svf_halfpix_h(y, y_stride, z, src_stride, &sse);
676 right = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost,
677 error_per_bit, xd->allow_high_precision_mv);
678
679 if (right < bestmse) {
680 *bestmv = this_mv;
681 bestmse = right;
682 *distortion = thismse;
683 *sse1 = sse;
684 }
685
686 // go up then down and check error
687 this_mv.as_mv.col = startmv.as_mv.col;
688 this_mv.as_mv.row = ((startmv.as_mv.row - 8) | 4);
689 thismse = vfp->svf_halfpix_v(y - y_stride, y_stride, z, src_stride, &sse);
690 up = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
691 xd->allow_high_precision_mv);
692
693 if (up < bestmse) {
694 *bestmv = this_mv;
695 bestmse = up;
696 *distortion = thismse;
697 *sse1 = sse;
698 }
699
700 this_mv.as_mv.row += 8;
701 thismse = vfp->svf_halfpix_v(y, y_stride, z, src_stride, &sse);
702 down = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
703 xd->allow_high_precision_mv);
704
705 if (down < bestmse) {
706 *bestmv = this_mv;
707 bestmse = down;
708 *distortion = thismse;
709 *sse1 = sse;
710 }
711
712
713 // now check 1 more diagonal
714 whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
715 // for(whichdir =0;whichdir<4;whichdir++)
716 // {
717 this_mv = startmv;
718
719 switch (whichdir) {
720 case 0:
721 this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
722 this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
723 thismse = vfp->svf_halfpix_hv(y - 1 - y_stride, y_stride, z, src_stride,
724 &sse);
725 break;
726 case 1:
727 this_mv.as_mv.col += 4;
728 this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
729 thismse = vfp->svf_halfpix_hv(y - y_stride, y_stride, z, src_stride,
730 &sse);
731 break;
732 case 2:
733 this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
734 this_mv.as_mv.row += 4;
735 thismse = vfp->svf_halfpix_hv(y - 1, y_stride, z, src_stride, &sse);
736 break;
737 case 3:
738 default:
739 this_mv.as_mv.col += 4;
740 this_mv.as_mv.row += 4;
741 thismse = vfp->svf_halfpix_hv(y, y_stride, z, src_stride, &sse);
742 break;
743 }
744
745 diag = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
746 xd->allow_high_precision_mv);
747
748 if (diag < bestmse) {
749 *bestmv = this_mv;
750 bestmse = diag;
751 *distortion = thismse;
752 *sse1 = sse;
753 }
754
755 // }
756
757
758 // time to check quarter pels.
759 if (bestmv->as_mv.row < startmv.as_mv.row) {
760 y -= y_stride;
761 yrow_movedback = 1;
762 }
763
764 if (bestmv->as_mv.col < startmv.as_mv.col) {
765 y--;
766 ycol_movedback = 1;
767 }
768
769 startmv = *bestmv;
770
771
772
773 // go left then right and check error
774 this_mv.as_mv.row = startmv.as_mv.row;
775
776 if (startmv.as_mv.col & 7) {
777 this_mv.as_mv.col = startmv.as_mv.col - 2;
778 thismse = vfp->svf(y, y_stride,
779 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
780 z, src_stride, &sse);
781 } else {
782 this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
783 thismse = vfp->svf(y - 1, y_stride, SP(6), SP(this_mv.as_mv.row), z,
784 src_stride, &sse);
785 }
786
787 left = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
788 xd->allow_high_precision_mv);
789
790 if (left < bestmse) {
791 *bestmv = this_mv;
792 bestmse = left;
793 *distortion = thismse;
794 *sse1 = sse;
795 }
796
797 this_mv.as_mv.col += 4;
798 thismse = vfp->svf(y, y_stride,
799 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
800 z, src_stride, &sse);
801 right = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost,
802 error_per_bit, xd->allow_high_precision_mv);
803
804 if (right < bestmse) {
805 *bestmv = this_mv;
806 bestmse = right;
807 *distortion = thismse;
808 *sse1 = sse;
809 }
810
811 // go up then down and check error
812 this_mv.as_mv.col = startmv.as_mv.col;
813
814 if (startmv.as_mv.row & 7) {
815 this_mv.as_mv.row = startmv.as_mv.row - 2;
816 thismse = vfp->svf(y, y_stride,
817 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
818 z, src_stride, &sse);
819 } else {
820 this_mv.as_mv.row = (startmv.as_mv.row - 8) | 6;
821 thismse = vfp->svf(y - y_stride, y_stride, SP(this_mv.as_mv.col), SP(6),
822 z, src_stride, &sse);
823 }
824
825 up = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
826 xd->allow_high_precision_mv);
827
828 if (up < bestmse) {
829 *bestmv = this_mv;
830 bestmse = up;
831 *distortion = thismse;
832 *sse1 = sse;
833 }
834
835 this_mv.as_mv.row += 4;
836 thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
837 z, src_stride, &sse);
838 down = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
839 xd->allow_high_precision_mv);
840
841 if (down < bestmse) {
842 *bestmv = this_mv;
843 bestmse = down;
844 *distortion = thismse;
845 *sse1 = sse;
846 }
847
848
849 // now check 1 more diagonal
850 whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
851
852 // for(whichdir=0;whichdir<4;whichdir++)
853 // {
854 this_mv = startmv;
855
856 switch (whichdir) {
857 case 0:
858
859 if (startmv.as_mv.row & 7) {
860 this_mv.as_mv.row -= 2;
861
862 if (startmv.as_mv.col & 7) {
863 this_mv.as_mv.col -= 2;
864 thismse = vfp->svf(y, y_stride,
865 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
866 z, src_stride, &sse);
867 } else {
868 this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
869 thismse = vfp->svf(y - 1, y_stride,
870 SP(6), SP(this_mv.as_mv.row), z, src_stride, &sse);
871 }
872 } else {
873 this_mv.as_mv.row = (startmv.as_mv.row - 8) | 6;
874
875 if (startmv.as_mv.col & 7) {
876 this_mv.as_mv.col -= 2;
877 thismse = vfp->svf(y - y_stride, y_stride,
878 SP(this_mv.as_mv.col), SP(6), z, src_stride, &sse);
879 } else {
880 this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
881 thismse = vfp->svf(y - y_stride - 1, y_stride,
882 SP(6), SP(6), z, src_stride, &sse);
883 }
884 }
885
886 break;
887 case 1:
888 this_mv.as_mv.col += 2;
889
890 if (startmv.as_mv.row & 7) {
891 this_mv.as_mv.row -= 2;
892 thismse = vfp->svf(y, y_stride,
893 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
894 z, src_stride, &sse);
895 } else {
896 this_mv.as_mv.row = (startmv.as_mv.row - 8) | 6;
897 thismse = vfp->svf(y - y_stride, y_stride,
898 SP(this_mv.as_mv.col), SP(6), z, src_stride, &sse);
899 }
900
901 break;
902 case 2:
903 this_mv.as_mv.row += 2;
904
905 if (startmv.as_mv.col & 7) {
906 this_mv.as_mv.col -= 2;
907 thismse = vfp->svf(y, y_stride,
908 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
909 z, src_stride, &sse);
910 } else {
911 this_mv.as_mv.col = (startmv.as_mv.col - 8) | 6;
912 thismse = vfp->svf(y - 1, y_stride, SP(6), SP(this_mv.as_mv.row), z,
913 src_stride, &sse);
914 }
915
916 break;
917 case 3:
918 this_mv.as_mv.col += 2;
919 this_mv.as_mv.row += 2;
920 thismse = vfp->svf(y, y_stride,
921 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
922 z, src_stride, &sse);
923 break;
924 }
925
926 diag = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
927 xd->allow_high_precision_mv);
928
929 if (diag < bestmse) {
930 *bestmv = this_mv;
931 bestmse = diag;
932 *distortion = thismse;
933 *sse1 = sse;
934 }
935
936 if (x->e_mbd.allow_high_precision_mv) {
937 usehp = vp9_use_mv_hp(&ref_mv->as_mv);
938 } else {
939 usehp = 0;
940 }
941 if (!usehp)
942 return bestmse;
943
944 /* Now do 1/8th pixel */
945 if (bestmv->as_mv.row < orig_mv.as_mv.row && !yrow_movedback) {
946 y -= y_stride;
947 yrow_movedback = 1;
948 }
949
950 if (bestmv->as_mv.col < orig_mv.as_mv.col && !ycol_movedback) {
951 y--;
952 ycol_movedback = 1;
953 }
954
955 startmv = *bestmv;
956
957 // go left then right and check error
958 this_mv.as_mv.row = startmv.as_mv.row;
959
960 if (startmv.as_mv.col & 7) {
961 this_mv.as_mv.col = startmv.as_mv.col - 1;
962 thismse = vfp->svf(y, y_stride,
963 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
964 z, src_stride, &sse);
965 } else {
966 this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
967 thismse = vfp->svf(y - 1, y_stride, SP(7), SP(this_mv.as_mv.row),
968 z, src_stride, &sse);
969 }
970
971 left = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
972 xd->allow_high_precision_mv);
973
974 if (left < bestmse) {
975 *bestmv = this_mv;
976 bestmse = left;
977 *distortion = thismse;
978 *sse1 = sse;
979 }
980
981 this_mv.as_mv.col += 2;
982 thismse = vfp->svf(y, y_stride, SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
983 z, src_stride, &sse);
984 right = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost,
985 error_per_bit, xd->allow_high_precision_mv);
986
987 if (right < bestmse) {
988 *bestmv = this_mv;
989 bestmse = right;
990 *distortion = thismse;
991 *sse1 = sse;
992 }
993
994 // go up then down and check error
995 this_mv.as_mv.col = startmv.as_mv.col;
996
997 if (startmv.as_mv.row & 7) {
998 this_mv.as_mv.row = startmv.as_mv.row - 1;
999 thismse = vfp->svf(y, y_stride,
1000 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
1001 z, src_stride, &sse);
1002 } else {
1003 this_mv.as_mv.row = (startmv.as_mv.row - 8) | 7;
1004 thismse = vfp->svf(y - y_stride, y_stride,
1005 SP(this_mv.as_mv.col), SP(7), z, src_stride, &sse);
1006 }
1007
1008 up = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
1009 xd->allow_high_precision_mv);
1010
1011 if (up < bestmse) {
1012 *bestmv = this_mv;
1013 bestmse = up;
1014 *distortion = thismse;
1015 *sse1 = sse;
1016 }
1017
1018 this_mv.as_mv.row += 2;
1019 thismse = vfp->svf(y, y_stride,
1020 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
1021 z, src_stride, &sse);
1022 down = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
1023 xd->allow_high_precision_mv);
1024
1025 if (down < bestmse) {
1026 *bestmv = this_mv;
1027 bestmse = down;
1028 *distortion = thismse;
1029 *sse1 = sse;
1030 }
1031
1032 // now check 1 more diagonal
1033 whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
1034
1035 // for(whichdir=0;whichdir<4;whichdir++)
1036 // {
1037 this_mv = startmv;
1038
1039 switch (whichdir) {
1040 case 0:
1041
1042 if (startmv.as_mv.row & 7) {
1043 this_mv.as_mv.row -= 1;
1044
1045 if (startmv.as_mv.col & 7) {
1046 this_mv.as_mv.col -= 1;
1047 thismse = vfp->svf(y, y_stride,
1048 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
1049 z, src_stride, &sse);
1050 } else {
1051 this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
1052 thismse = vfp->svf(y - 1, y_stride,
1053 SP(7), SP(this_mv.as_mv.row),
1054 z, src_stride, &sse);
1055 }
1056 } else {
1057 this_mv.as_mv.row = (startmv.as_mv.row - 8) | 7;
1058
1059 if (startmv.as_mv.col & 7) {
1060 this_mv.as_mv.col -= 1;
1061 thismse = vfp->svf(y - y_stride, y_stride,
1062 SP(this_mv.as_mv.col), SP(7), z, src_stride, &sse);
1063 } else {
1064 this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
1065 thismse = vfp->svf(y - y_stride - 1, y_stride,
1066 SP(7), SP(7), z, src_stride, &sse);
1067 }
1068 }
1069
1070 break;
1071 case 1:
1072 this_mv.as_mv.col += 1;
1073
1074 if (startmv.as_mv.row & 7) {
1075 this_mv.as_mv.row -= 1;
1076 thismse = vfp->svf(y, y_stride,
1077 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
1078 z, src_stride, &sse);
1079 } else {
1080 this_mv.as_mv.row = (startmv.as_mv.row - 8) | 7;
1081 thismse = vfp->svf(y - y_stride, y_stride,
1082 SP(this_mv.as_mv.col), SP(7), z, src_stride, &sse);
1083 }
1084
1085 break;
1086 case 2:
1087 this_mv.as_mv.row += 1;
1088
1089 if (startmv.as_mv.col & 7) {
1090 this_mv.as_mv.col -= 1;
1091 thismse = vfp->svf(y, y_stride,
1092 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
1093 z, src_stride, &sse);
1094 } else {
1095 this_mv.as_mv.col = (startmv.as_mv.col - 8) | 7;
1096 thismse = vfp->svf(y - 1, y_stride,
1097 SP(7), SP(this_mv.as_mv.row), z, src_stride, &sse);
1098 }
1099
1100 break;
1101 case 3:
1102 this_mv.as_mv.col += 1;
1103 this_mv.as_mv.row += 1;
1104 thismse = vfp->svf(y, y_stride,
1105 SP(this_mv.as_mv.col), SP(this_mv.as_mv.row),
1106 z, src_stride, &sse);
1107 break;
1108 }
1109
1110 diag = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
1111 xd->allow_high_precision_mv);
1112
1113 if (diag < bestmse) {
1114 *bestmv = this_mv;
1115 bestmse = diag;
1116 *distortion = thismse;
1117 *sse1 = sse;
1118 }
1119
1120 return bestmse;
1121 }
1122
1123 #undef SP 744 #undef SP
1124 745
1125 int vp9_find_best_half_pixel_step(MACROBLOCK *x,
1126 int_mv *bestmv, int_mv *ref_mv,
1127 int error_per_bit,
1128 const vp9_variance_fn_ptr_t *vfp,
1129 int *mvjcost, int *mvcost[2],
1130 int *distortion,
1131 unsigned int *sse1) {
1132 int bestmse = INT_MAX;
1133 int_mv startmv;
1134 int_mv this_mv;
1135 uint8_t *z = x->plane[0].src.buf;
1136 int src_stride = x->plane[0].src.stride;
1137 int left, right, up, down, diag;
1138 unsigned int sse;
1139 int whichdir;
1140 int thismse;
1141 int y_stride;
1142 MACROBLOCKD *xd = &x->e_mbd;
1143
1144 uint8_t *y = xd->plane[0].pre[0].buf +
1145 (bestmv->as_mv.row) * xd->plane[0].pre[0].stride + bestmv->as_mv.col;
1146 y_stride = xd->plane[0].pre[0].stride;
1147
1148 // central mv
1149 bestmv->as_mv.row <<= 3;
1150 bestmv->as_mv.col <<= 3;
1151 startmv = *bestmv;
1152
1153 // calculate central point error
1154 bestmse = vfp->vf(y, y_stride, z, src_stride, sse1);
1155 *distortion = bestmse;
1156 bestmse += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit,
1157 xd->allow_high_precision_mv);
1158
1159 // go left then right and check error
1160 this_mv.as_mv.row = startmv.as_mv.row;
1161 this_mv.as_mv.col = ((startmv.as_mv.col - 8) | 4);
1162 thismse = vfp->svf_halfpix_h(y - 1, y_stride, z, src_stride, &sse);
1163 left = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
1164 xd->allow_high_precision_mv);
1165
1166 if (left < bestmse) {
1167 *bestmv = this_mv;
1168 bestmse = left;
1169 *distortion = thismse;
1170 *sse1 = sse;
1171 }
1172
1173 this_mv.as_mv.col += 8;
1174 thismse = vfp->svf_halfpix_h(y, y_stride, z, src_stride, &sse);
1175 right = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost,
1176 error_per_bit, xd->allow_high_precision_mv);
1177
1178 if (right < bestmse) {
1179 *bestmv = this_mv;
1180 bestmse = right;
1181 *distortion = thismse;
1182 *sse1 = sse;
1183 }
1184
1185 // go up then down and check error
1186 this_mv.as_mv.col = startmv.as_mv.col;
1187 this_mv.as_mv.row = ((startmv.as_mv.row - 8) | 4);
1188 thismse = vfp->svf_halfpix_v(y - y_stride, y_stride, z, src_stride, &sse);
1189 up = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
1190 xd->allow_high_precision_mv);
1191
1192 if (up < bestmse) {
1193 *bestmv = this_mv;
1194 bestmse = up;
1195 *distortion = thismse;
1196 *sse1 = sse;
1197 }
1198
1199 this_mv.as_mv.row += 8;
1200 thismse = vfp->svf_halfpix_v(y, y_stride, z, src_stride, &sse);
1201 down = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
1202 xd->allow_high_precision_mv);
1203
1204 if (down < bestmse) {
1205 *bestmv = this_mv;
1206 bestmse = down;
1207 *distortion = thismse;
1208 *sse1 = sse;
1209 }
1210
1211 // now check 1 more diagonal -
1212 whichdir = (left < right ? 0 : 1) + (up < down ? 0 : 2);
1213 this_mv = startmv;
1214
1215 switch (whichdir) {
1216 case 0:
1217 this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
1218 this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
1219 thismse = vfp->svf_halfpix_hv(y - 1 - y_stride, y_stride,
1220 z, src_stride, &sse);
1221 break;
1222 case 1:
1223 this_mv.as_mv.col += 4;
1224 this_mv.as_mv.row = (this_mv.as_mv.row - 8) | 4;
1225 thismse = vfp->svf_halfpix_hv(y - y_stride, y_stride,
1226 z, src_stride, &sse);
1227 break;
1228 case 2:
1229 this_mv.as_mv.col = (this_mv.as_mv.col - 8) | 4;
1230 this_mv.as_mv.row += 4;
1231 thismse = vfp->svf_halfpix_hv(y - 1, y_stride, z, src_stride, &sse);
1232 break;
1233 case 3:
1234 default:
1235 this_mv.as_mv.col += 4;
1236 this_mv.as_mv.row += 4;
1237 thismse = vfp->svf_halfpix_hv(y, y_stride, z, src_stride, &sse);
1238 break;
1239 }
1240
1241 diag = thismse + mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit,
1242 xd->allow_high_precision_mv);
1243
1244 if (diag < bestmse) {
1245 *bestmv = this_mv;
1246 bestmse = diag;
1247 *distortion = thismse;
1248 *sse1 = sse;
1249 }
1250
1251 return bestmse;
1252 }
1253
1254 #define CHECK_BOUNDS(range) \ 746 #define CHECK_BOUNDS(range) \
1255 {\ 747 {\
1256 all_in = 1;\ 748 all_in = 1;\
1257 all_in &= ((br-range) >= x->mv_row_min);\ 749 all_in &= ((br-range) >= x->mv_row_min);\
1258 all_in &= ((br+range) <= x->mv_row_max);\ 750 all_in &= ((br+range) <= x->mv_row_max);\
1259 all_in &= ((bc-range) >= x->mv_col_min);\ 751 all_in &= ((bc-range) >= x->mv_col_min);\
1260 all_in &= ((bc+range) <= x->mv_col_max);\ 752 all_in &= ((bc+range) <= x->mv_col_max);\
1261 } 753 }
1262 754
1263 #define CHECK_POINT \ 755 #define CHECK_POINT \
1264 {\ 756 {\
1265 if (this_mv.as_mv.col < x->mv_col_min) continue;\ 757 if (this_mv.as_mv.col < x->mv_col_min) continue;\
1266 if (this_mv.as_mv.col > x->mv_col_max) continue;\ 758 if (this_mv.as_mv.col > x->mv_col_max) continue;\
1267 if (this_mv.as_mv.row < x->mv_row_min) continue;\ 759 if (this_mv.as_mv.row < x->mv_row_min) continue;\
1268 if (this_mv.as_mv.row > x->mv_row_max) continue;\ 760 if (this_mv.as_mv.row > x->mv_row_max) continue;\
1269 } 761 }
1270 762
1271 #define CHECK_BETTER \ 763 #define CHECK_BETTER \
1272 {\ 764 {\
1273 if (thissad < bestsad)\ 765 if (thissad < bestsad)\
1274 {\ 766 {\
1275 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvjsadcost, mvsadcost, \ 767 if (use_mvcost) \
1276 sad_per_bit);\ 768 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, \
769 mvjsadcost, mvsadcost, \
770 sad_per_bit);\
1277 if (thissad < bestsad)\ 771 if (thissad < bestsad)\
1278 {\ 772 {\
1279 bestsad = thissad;\ 773 bestsad = thissad;\
1280 best_site = i;\ 774 best_site = i;\
1281 }\ 775 }\
1282 }\ 776 }\
1283 } 777 }
1284 778
1285 static const MV next_chkpts[6][3] = { 779 #define get_next_chkpts(list, i, n) \
1286 {{ -2, 0}, { -1, -2}, {1, -2}}, 780 list[0] = ((i) == 0 ? (n) - 1 : (i) - 1); \
1287 {{ -1, -2}, {1, -2}, {2, 0}}, 781 list[1] = (i); \
1288 {{1, -2}, {2, 0}, {1, 2}}, 782 list[2] = ((i) == (n) - 1 ? 0 : (i) + 1);
1289 {{2, 0}, {1, 2}, { -1, 2}},
1290 {{1, 2}, { -1, 2}, { -2, 0}},
1291 {{ -1, 2}, { -2, 0}, { -1, -2}}
1292 };
1293 783
1294 int vp9_hex_search 784 #define MAX_PATTERN_SCALES 11
1295 ( 785 #define MAX_PATTERN_CANDIDATES 8 // max number of canddiates per scale
1296 MACROBLOCK *x, 786 #define PATTERN_CANDIDATES_REF 3 // number of refinement candidates
1297 int_mv *ref_mv, 787
1298 int_mv *best_mv, 788 // Generic pattern search function that searches over multiple scales.
1299 int search_param, 789 // Each scale can have a different number of candidates and shape of
1300 int sad_per_bit, 790 // candidates as indicated in the num_candidates and candidates arrays
1301 const vp9_variance_fn_ptr_t *vfp, 791 // passed into this function
1302 int *mvjsadcost, int *mvsadcost[2], 792 static int vp9_pattern_search(MACROBLOCK *x,
1303 int *mvjcost, int *mvcost[2], 793 int_mv *ref_mv,
1304 int_mv *center_mv 794 int search_param,
1305 ) { 795 int sad_per_bit,
796 int do_init_search,
797 int do_refine,
798 const vp9_variance_fn_ptr_t *vfp,
799 int use_mvcost,
800 int_mv *center_mv, int_mv *best_mv,
801 const int num_candidates[MAX_PATTERN_SCALES],
802 const MV candidates[MAX_PATTERN_SCALES]
803 [MAX_PATTERN_CANDIDATES]) {
1306 const MACROBLOCKD* const xd = &x->e_mbd; 804 const MACROBLOCKD* const xd = &x->e_mbd;
1307 MV hex[6] = { { -1, -2}, {1, -2}, {2, 0}, {1, 2}, { -1, 2}, { -2, 0} }; 805 static const int search_param_to_steps[MAX_MVSEARCH_STEPS] = {
1308 MV neighbors[4] = {{0, -1}, { -1, 0}, {1, 0}, {0, 1}}; 806 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
1309 int i, j; 807 };
1310 808 int i, j, s, t;
1311 uint8_t *what = x->plane[0].src.buf; 809 uint8_t *what = x->plane[0].src.buf;
1312 int what_stride = x->plane[0].src.stride; 810 int what_stride = x->plane[0].src.stride;
1313 int in_what_stride = xd->plane[0].pre[0].stride; 811 int in_what_stride = xd->plane[0].pre[0].stride;
1314 int br, bc; 812 int br, bc;
1315 int_mv this_mv; 813 int_mv this_mv;
1316 unsigned int bestsad = 0x7fffffff; 814 int bestsad = INT_MAX;
1317 unsigned int thissad; 815 int thissad;
1318 uint8_t *base_offset; 816 uint8_t *base_offset;
1319 uint8_t *this_offset; 817 uint8_t *this_offset;
1320 int k = -1; 818 int k = -1;
1321 int all_in; 819 int all_in;
1322 int best_site = -1; 820 int best_site = -1;
821 int_mv fcenter_mv;
822 int best_init_s = search_param_to_steps[search_param];
823 int *mvjsadcost = x->nmvjointsadcost;
824 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
1323 825
1324 int_mv fcenter_mv;
1325 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; 826 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
1326 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; 827 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
1327 828
1328 // adjust ref_mv to make sure it is within MV range 829 // adjust ref_mv to make sure it is within MV range
1329 clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max); 830 clamp_mv(&ref_mv->as_mv,
831 x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
1330 br = ref_mv->as_mv.row; 832 br = ref_mv->as_mv.row;
1331 bc = ref_mv->as_mv.col; 833 bc = ref_mv->as_mv.col;
1332 834
1333 // Work out the start point for the search 835 // Work out the start point for the search
1334 base_offset = (uint8_t *)(xd->plane[0].pre[0].buf); 836 base_offset = (uint8_t *)(xd->plane[0].pre[0].buf);
1335 this_offset = base_offset + (br * (xd->plane[0].pre[0].stride)) + bc; 837 this_offset = base_offset + (br * in_what_stride) + bc;
1336 this_mv.as_mv.row = br; 838 this_mv.as_mv.row = br;
1337 this_mv.as_mv.col = bc; 839 this_mv.as_mv.col = bc;
1338 bestsad = vfp->sdf(what, what_stride, this_offset, 840 bestsad = vfp->sdf(what, what_stride, this_offset,
1339 in_what_stride, 0x7fffffff) 841 in_what_stride, 0x7fffffff)
1340 + mvsad_err_cost(&this_mv, &fcenter_mv, mvjsadcost, mvsadcost, 842 + mvsad_err_cost(&this_mv, &fcenter_mv, mvjsadcost, mvsadcost,
1341 sad_per_bit); 843 sad_per_bit);
1342 844
1343 // hex search 845 // Search all possible scales upto the search param around the center point
1344 // j=0 846 // pick the scale of the point that is best as the starting scale of
1345 CHECK_BOUNDS(2) 847 // further steps around it.
1346 848 if (do_init_search) {
1347 if (all_in) { 849 s = best_init_s;
1348 for (i = 0; i < 6; i++) { 850 best_init_s = -1;
1349 this_mv.as_mv.row = br + hex[i].row; 851 for (t = 0; t <= s; ++t) {
1350 this_mv.as_mv.col = bc + hex[i].col; 852 best_site = -1;
1351 this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + this_mv .as_mv.col; 853 CHECK_BOUNDS((1 << t))
1352 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad ); 854 if (all_in) {
1353 CHECK_BETTER 855 for (i = 0; i < num_candidates[t]; i++) {
856 this_mv.as_mv.row = br + candidates[t][i].row;
857 this_mv.as_mv.col = bc + candidates[t][i].col;
858 this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) +
859 this_mv.as_mv.col;
860 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
861 bestsad);
862 CHECK_BETTER
863 }
864 } else {
865 for (i = 0; i < num_candidates[t]; i++) {
866 this_mv.as_mv.row = br + candidates[t][i].row;
867 this_mv.as_mv.col = bc + candidates[t][i].col;
868 CHECK_POINT
869 this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) +
870 this_mv.as_mv.col;
871 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
872 bestsad);
873 CHECK_BETTER
874 }
875 }
876 if (best_site == -1) {
877 continue;
878 } else {
879 best_init_s = t;
880 k = best_site;
881 }
1354 } 882 }
1355 } else { 883 if (best_init_s != -1) {
1356 for (i = 0; i < 6; i++) { 884 br += candidates[best_init_s][k].row;
1357 this_mv.as_mv.row = br + hex[i].row; 885 bc += candidates[best_init_s][k].col;
1358 this_mv.as_mv.col = bc + hex[i].col;
1359 CHECK_POINT
1360 this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + this_mv .as_mv.col;
1361 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bestsad );
1362 CHECK_BETTER
1363 } 886 }
1364 } 887 }
1365 888
1366 if (best_site == -1) 889 // If the center point is still the best, just skip this and move to
1367 goto cal_neighbors; 890 // the refinement step.
1368 else { 891 if (best_init_s != -1) {
1369 br += hex[best_site].row; 892 s = best_init_s;
1370 bc += hex[best_site].col; 893 best_site = -1;
1371 k = best_site; 894 do {
895 // No need to search all 6 points the 1st time if initial search was used
896 if (!do_init_search || s != best_init_s) {
897 CHECK_BOUNDS((1 << s))
898 if (all_in) {
899 for (i = 0; i < num_candidates[s]; i++) {
900 this_mv.as_mv.row = br + candidates[s][i].row;
901 this_mv.as_mv.col = bc + candidates[s][i].col;
902 this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) +
903 this_mv.as_mv.col;
904 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
905 bestsad);
906 CHECK_BETTER
907 }
908 } else {
909 for (i = 0; i < num_candidates[s]; i++) {
910 this_mv.as_mv.row = br + candidates[s][i].row;
911 this_mv.as_mv.col = bc + candidates[s][i].col;
912 CHECK_POINT
913 this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) +
914 this_mv.as_mv.col;
915 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
916 bestsad);
917 CHECK_BETTER
918 }
919 }
920
921 if (best_site == -1) {
922 continue;
923 } else {
924 br += candidates[s][best_site].row;
925 bc += candidates[s][best_site].col;
926 k = best_site;
927 }
928 }
929
930 do {
931 int next_chkpts_indices[PATTERN_CANDIDATES_REF];
932 best_site = -1;
933 CHECK_BOUNDS((1 << s))
934
935 get_next_chkpts(next_chkpts_indices, k, num_candidates[s]);
936 if (all_in) {
937 for (i = 0; i < PATTERN_CANDIDATES_REF; i++) {
938 this_mv.as_mv.row = br +
939 candidates[s][next_chkpts_indices[i]].row;
940 this_mv.as_mv.col = bc +
941 candidates[s][next_chkpts_indices[i]].col;
942 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) +
943 this_mv.as_mv.col;
944 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
945 bestsad);
946 CHECK_BETTER
947 }
948 } else {
949 for (i = 0; i < PATTERN_CANDIDATES_REF; i++) {
950 this_mv.as_mv.row = br +
951 candidates[s][next_chkpts_indices[i]].row;
952 this_mv.as_mv.col = bc +
953 candidates[s][next_chkpts_indices[i]].col;
954 CHECK_POINT
955 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) +
956 this_mv.as_mv.col;
957 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
958 bestsad);
959 CHECK_BETTER
960 }
961 }
962
963 if (best_site != -1) {
964 k = next_chkpts_indices[best_site];
965 br += candidates[s][k].row;
966 bc += candidates[s][k].col;
967 }
968 } while (best_site != -1);
969 } while (s--);
1372 } 970 }
1373 971
1374 for (j = 1; j < 127; j++) { 972 // Check 4 1-away neighbors if do_refine is true.
1375 best_site = -1; 973 // For most well-designed schemes do_refine will not be necessary.
1376 CHECK_BOUNDS(2) 974 if (do_refine) {
1377 975 static const MV neighbors[4] = {
1378 if (all_in) { 976 {0, -1}, { -1, 0}, {1, 0}, {0, 1},
1379 for (i = 0; i < 3; i++) { 977 };
1380 this_mv.as_mv.row = br + next_chkpts[k][i].row; 978 for (j = 0; j < 16; j++) {
1381 this_mv.as_mv.col = bc + next_chkpts[k][i].col; 979 best_site = -1;
1382 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + thi s_mv.as_mv.col; 980 CHECK_BOUNDS(1)
1383 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bests ad); 981 if (all_in) {
1384 CHECK_BETTER 982 for (i = 0; i < 4; i++) {
1385 } 983 this_mv.as_mv.row = br + neighbors[i].row;
1386 } else { 984 this_mv.as_mv.col = bc + neighbors[i].col;
1387 for (i = 0; i < 3; i++) { 985 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) +
1388 this_mv.as_mv.row = br + next_chkpts[k][i].row; 986 this_mv.as_mv.col;
1389 this_mv.as_mv.col = bc + next_chkpts[k][i].col; 987 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
1390 CHECK_POINT 988 bestsad);
1391 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + thi s_mv.as_mv.col; 989 CHECK_BETTER
1392 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bests ad); 990 }
1393 CHECK_BETTER 991 } else {
992 for (i = 0; i < 4; i++) {
993 this_mv.as_mv.row = br + neighbors[i].row;
994 this_mv.as_mv.col = bc + neighbors[i].col;
995 CHECK_POINT
996 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) +
997 this_mv.as_mv.col;
998 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
999 bestsad);
1000 CHECK_BETTER
1001 }
1002 }
1003
1004 if (best_site == -1) {
1005 break;
1006 } else {
1007 br += neighbors[best_site].row;
1008 bc += neighbors[best_site].col;
1394 } 1009 }
1395 } 1010 }
1396
1397 if (best_site == -1)
1398 break;
1399 else {
1400 br += next_chkpts[k][best_site].row;
1401 bc += next_chkpts[k][best_site].col;
1402 k += 5 + best_site;
1403 if (k >= 12) k -= 12;
1404 else if (k >= 6) k -= 6;
1405 }
1406 }
1407
1408 // check 4 1-away neighbors
1409 cal_neighbors:
1410 for (j = 0; j < 32; j++) {
1411 best_site = -1;
1412 CHECK_BOUNDS(1)
1413
1414 if (all_in) {
1415 for (i = 0; i < 4; i++) {
1416 this_mv.as_mv.row = br + neighbors[i].row;
1417 this_mv.as_mv.col = bc + neighbors[i].col;
1418 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + thi s_mv.as_mv.col;
1419 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bests ad);
1420 CHECK_BETTER
1421 }
1422 } else {
1423 for (i = 0; i < 4; i++) {
1424 this_mv.as_mv.row = br + neighbors[i].row;
1425 this_mv.as_mv.col = bc + neighbors[i].col;
1426 CHECK_POINT
1427 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride)) + thi s_mv.as_mv.col;
1428 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, bests ad);
1429 CHECK_BETTER
1430 }
1431 }
1432
1433 if (best_site == -1)
1434 break;
1435 else {
1436 br += neighbors[best_site].row;
1437 bc += neighbors[best_site].col;
1438 }
1439 } 1011 }
1440 1012
1441 best_mv->as_mv.row = br; 1013 best_mv->as_mv.row = br;
1442 best_mv->as_mv.col = bc; 1014 best_mv->as_mv.col = bc;
1443 1015
1444 return bestsad; 1016 this_offset = base_offset + (best_mv->as_mv.row * (in_what_stride)) +
1017 best_mv->as_mv.col;
1018 this_mv.as_mv.row = best_mv->as_mv.row << 3;
1019 this_mv.as_mv.col = best_mv->as_mv.col << 3;
1020 if (bestsad == INT_MAX)
1021 return INT_MAX;
1022 return
1023 vfp->vf(what, what_stride, this_offset, in_what_stride,
1024 (unsigned int *)(&bestsad)) +
1025 use_mvcost ? mv_err_cost(&this_mv, center_mv, x->nmvjointcost, x->mvcost,
1026 x->errorperbit) : 0;
1445 } 1027 }
1028
1029
1030 int vp9_hex_search(MACROBLOCK *x,
1031 int_mv *ref_mv,
1032 int search_param,
1033 int sad_per_bit,
1034 int do_init_search,
1035 const vp9_variance_fn_ptr_t *vfp,
1036 int use_mvcost,
1037 int_mv *center_mv, int_mv *best_mv) {
1038 // First scale has 8-closest points, the rest have 6 points in hex shape
1039 // at increasing scales
1040 static const int hex_num_candidates[MAX_PATTERN_SCALES] = {
1041 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
1042 };
1043 // Note that the largest candidate step at each scale is 2^scale
1044 static const MV hex_candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES] = {
1045 {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, { 0, 1}, { -1, 1}, {-1, 0}},
1046 {{-1, -2}, {1, -2}, {2, 0}, {1, 2}, { -1, 2}, { -2, 0}},
1047 {{-2, -4}, {2, -4}, {4, 0}, {2, 4}, { -2, 4}, { -4, 0}},
1048 {{-4, -8}, {4, -8}, {8, 0}, {4, 8}, { -4, 8}, { -8, 0}},
1049 {{-8, -16}, {8, -16}, {16, 0}, {8, 16}, { -8, 16}, { -16, 0}},
1050 {{-16, -32}, {16, -32}, {32, 0}, {16, 32}, { -16, 32}, { -32, 0}},
1051 {{-32, -64}, {32, -64}, {64, 0}, {32, 64}, { -32, 64}, { -64, 0}},
1052 {{-64, -128}, {64, -128}, {128, 0}, {64, 128}, { -64, 128}, { -128, 0}},
1053 {{-128, -256}, {128, -256}, {256, 0}, {128, 256}, { -128, 256}, { -256, 0}},
1054 {{-256, -512}, {256, -512}, {512, 0}, {256, 512}, { -256, 512}, { -512, 0}},
1055 {{-512, -1024}, {512, -1024}, {1024, 0}, {512, 1024}, { -512, 1024},
1056 { -1024, 0}},
1057 };
1058 return
1059 vp9_pattern_search(x, ref_mv, search_param, sad_per_bit,
1060 do_init_search, 0, vfp, use_mvcost,
1061 center_mv, best_mv,
1062 hex_num_candidates, hex_candidates);
1063 }
1064
1065 int vp9_bigdia_search(MACROBLOCK *x,
1066 int_mv *ref_mv,
1067 int search_param,
1068 int sad_per_bit,
1069 int do_init_search,
1070 const vp9_variance_fn_ptr_t *vfp,
1071 int use_mvcost,
1072 int_mv *center_mv,
1073 int_mv *best_mv) {
1074 // First scale has 4-closest points, the rest have 8 points in diamond
1075 // shape at increasing scales
1076 static const int bigdia_num_candidates[MAX_PATTERN_SCALES] = {
1077 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
1078 };
1079 // Note that the largest candidate step at each scale is 2^scale
1080 static const MV bigdia_candidates[MAX_PATTERN_SCALES]
1081 [MAX_PATTERN_CANDIDATES] = {
1082 {{0, -1}, {1, 0}, { 0, 1}, {-1, 0}},
1083 {{-1, -1}, {0, -2}, {1, -1}, {2, 0}, {1, 1}, {0, 2}, {-1, 1}, {-2, 0}},
1084 {{-2, -2}, {0, -4}, {2, -2}, {4, 0}, {2, 2}, {0, 4}, {-2, 2}, {-4, 0}},
1085 {{-4, -4}, {0, -8}, {4, -4}, {8, 0}, {4, 4}, {0, 8}, {-4, 4}, {-8, 0}},
1086 {{-8, -8}, {0, -16}, {8, -8}, {16, 0}, {8, 8}, {0, 16}, {-8, 8}, {-16, 0}},
1087 {{-16, -16}, {0, -32}, {16, -16}, {32, 0}, {16, 16}, {0, 32},
1088 {-16, 16}, {-32, 0}},
1089 {{-32, -32}, {0, -64}, {32, -32}, {64, 0}, {32, 32}, {0, 64},
1090 {-32, 32}, {-64, 0}},
1091 {{-64, -64}, {0, -128}, {64, -64}, {128, 0}, {64, 64}, {0, 128},
1092 {-64, 64}, {-128, 0}},
1093 {{-128, -128}, {0, -256}, {128, -128}, {256, 0}, {128, 128}, {0, 256},
1094 {-128, 128}, {-256, 0}},
1095 {{-256, -256}, {0, -512}, {256, -256}, {512, 0}, {256, 256}, {0, 512},
1096 {-256, 256}, {-512, 0}},
1097 {{-512, -512}, {0, -1024}, {512, -512}, {1024, 0}, {512, 512}, {0, 1024},
1098 {-512, 512}, {-1024, 0}},
1099 };
1100 return
1101 vp9_pattern_search(x, ref_mv, search_param, sad_per_bit,
1102 do_init_search, 0, vfp, use_mvcost,
1103 center_mv, best_mv,
1104 bigdia_num_candidates, bigdia_candidates);
1105 }
1106
1107 int vp9_square_search(MACROBLOCK *x,
1108 int_mv *ref_mv,
1109 int search_param,
1110 int sad_per_bit,
1111 int do_init_search,
1112 const vp9_variance_fn_ptr_t *vfp,
1113 int use_mvcost,
1114 int_mv *center_mv,
1115 int_mv *best_mv) {
1116 // All scales have 8 closest points in square shape
1117 static const int square_num_candidates[MAX_PATTERN_SCALES] = {
1118 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
1119 };
1120 // Note that the largest candidate step at each scale is 2^scale
1121 static const MV square_candidates[MAX_PATTERN_SCALES]
1122 [MAX_PATTERN_CANDIDATES] = {
1123 {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}},
1124 {{-2, -2}, {0, -2}, {2, -2}, {2, 0}, {2, 2}, {0, 2}, {-2, 2}, {-2, 0}},
1125 {{-4, -4}, {0, -4}, {4, -4}, {4, 0}, {4, 4}, {0, 4}, {-4, 4}, {-4, 0}},
1126 {{-8, -8}, {0, -8}, {8, -8}, {8, 0}, {8, 8}, {0, 8}, {-8, 8}, {-8, 0}},
1127 {{-16, -16}, {0, -16}, {16, -16}, {16, 0}, {16, 16}, {0, 16},
1128 {-16, 16}, {-16, 0}},
1129 {{-32, -32}, {0, -32}, {32, -32}, {32, 0}, {32, 32}, {0, 32},
1130 {-32, 32}, {-32, 0}},
1131 {{-64, -64}, {0, -64}, {64, -64}, {64, 0}, {64, 64}, {0, 64},
1132 {-64, 64}, {-64, 0}},
1133 {{-128, -128}, {0, -128}, {128, -128}, {128, 0}, {128, 128}, {0, 128},
1134 {-128, 128}, {-128, 0}},
1135 {{-256, -256}, {0, -256}, {256, -256}, {256, 0}, {256, 256}, {0, 256},
1136 {-256, 256}, {-256, 0}},
1137 {{-512, -512}, {0, -512}, {512, -512}, {512, 0}, {512, 512}, {0, 512},
1138 {-512, 512}, {-512, 0}},
1139 {{-1024, -1024}, {0, -1024}, {1024, -1024}, {1024, 0}, {1024, 1024},
1140 {0, 1024}, {-1024, 1024}, {-1024, 0}},
1141 };
1142 return
1143 vp9_pattern_search(x, ref_mv, search_param, sad_per_bit,
1144 do_init_search, 0, vfp, use_mvcost,
1145 center_mv, best_mv,
1146 square_num_candidates, square_candidates);
1147 };
1148
1446 #undef CHECK_BOUNDS 1149 #undef CHECK_BOUNDS
1447 #undef CHECK_POINT 1150 #undef CHECK_POINT
1448 #undef CHECK_BETTER 1151 #undef CHECK_BETTER
1449 1152
1450 int vp9_diamond_search_sad_c(MACROBLOCK *x, 1153 int vp9_diamond_search_sad_c(MACROBLOCK *x,
1451 int_mv *ref_mv, int_mv *best_mv, 1154 int_mv *ref_mv, int_mv *best_mv,
1452 int search_param, int sad_per_bit, int *num00, 1155 int search_param, int sad_per_bit, int *num00,
1453 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, 1156 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost,
1454 int *mvcost[2], int_mv *center_mv) { 1157 int *mvcost[2], int_mv *center_mv) {
1455 int i, j, step; 1158 int i, j, step;
(...skipping 19 matching lines...) Expand all
1475 uint8_t *check_here; 1178 uint8_t *check_here;
1476 int thissad; 1179 int thissad;
1477 int_mv fcenter_mv; 1180 int_mv fcenter_mv;
1478 1181
1479 int *mvjsadcost = x->nmvjointsadcost; 1182 int *mvjsadcost = x->nmvjointsadcost;
1480 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; 1183 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
1481 1184
1482 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; 1185 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
1483 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; 1186 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
1484 1187
1485 clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max); 1188 clamp_mv(&ref_mv->as_mv,
1189 x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
1486 ref_row = ref_mv->as_mv.row; 1190 ref_row = ref_mv->as_mv.row;
1487 ref_col = ref_mv->as_mv.col; 1191 ref_col = ref_mv->as_mv.col;
1488 *num00 = 0; 1192 *num00 = 0;
1489 best_mv->as_mv.row = ref_row; 1193 best_mv->as_mv.row = ref_row;
1490 best_mv->as_mv.col = ref_col; 1194 best_mv->as_mv.col = ref_col;
1491 1195
1492 // Work out the start point for the search 1196 // Work out the start point for the search
1493 in_what = (uint8_t *)(xd->plane[0].pre[0].buf + 1197 in_what = (uint8_t *)(xd->plane[0].pre[0].buf +
1494 (ref_row * (xd->plane[0].pre[0].stride)) + ref_col); 1198 (ref_row * (xd->plane[0].pre[0].stride)) + ref_col);
1495 best_address = in_what; 1199 best_address = in_what;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 } else if (best_address == in_what) 1277 } else if (best_address == in_what)
1574 (*num00)++; 1278 (*num00)++;
1575 } 1279 }
1576 1280
1577 this_mv.as_mv.row = best_mv->as_mv.row << 3; 1281 this_mv.as_mv.row = best_mv->as_mv.row << 3;
1578 this_mv.as_mv.col = best_mv->as_mv.col << 3; 1282 this_mv.as_mv.col = best_mv->as_mv.col << 3;
1579 1283
1580 if (bestsad == INT_MAX) 1284 if (bestsad == INT_MAX)
1581 return INT_MAX; 1285 return INT_MAX;
1582 1286
1583 return 1287 return fn_ptr->vf(what, what_stride, best_address, in_what_stride,
1584 fn_ptr->vf(what, what_stride, best_address, in_what_stride, 1288 (unsigned int *)(&thissad)) + mv_err_cost(&this_mv, center_mv, mvjcost,
1585 (unsigned int *)(&thissad)) + 1289 mvcost, x->errorperbit);
1586 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit,
1587 xd->allow_high_precision_mv);
1588 } 1290 }
1589 1291
1590 int vp9_diamond_search_sadx4(MACROBLOCK *x, 1292 int vp9_diamond_search_sadx4(MACROBLOCK *x,
1591 int_mv *ref_mv, int_mv *best_mv, int search_param, 1293 int_mv *ref_mv, int_mv *best_mv, int search_param,
1592 int sad_per_bit, int *num00, 1294 int sad_per_bit, int *num00,
1593 vp9_variance_fn_ptr_t *fn_ptr, 1295 vp9_variance_fn_ptr_t *fn_ptr,
1594 int *mvjcost, int *mvcost[2], int_mv *center_mv) { 1296 int *mvjcost, int *mvcost[2], int_mv *center_mv) {
1595 int i, j, step; 1297 int i, j, step;
1596 1298
1597 const MACROBLOCKD* const xd = &x->e_mbd; 1299 const MACROBLOCKD* const xd = &x->e_mbd;
(...skipping 19 matching lines...) Expand all
1617 uint8_t *check_here; 1319 uint8_t *check_here;
1618 unsigned int thissad; 1320 unsigned int thissad;
1619 int_mv fcenter_mv; 1321 int_mv fcenter_mv;
1620 1322
1621 int *mvjsadcost = x->nmvjointsadcost; 1323 int *mvjsadcost = x->nmvjointsadcost;
1622 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; 1324 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
1623 1325
1624 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; 1326 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
1625 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; 1327 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
1626 1328
1627 clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max); 1329 clamp_mv(&ref_mv->as_mv,
1330 x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
1628 ref_row = ref_mv->as_mv.row; 1331 ref_row = ref_mv->as_mv.row;
1629 ref_col = ref_mv->as_mv.col; 1332 ref_col = ref_mv->as_mv.col;
1630 *num00 = 0; 1333 *num00 = 0;
1631 best_mv->as_mv.row = ref_row; 1334 best_mv->as_mv.row = ref_row;
1632 best_mv->as_mv.col = ref_col; 1335 best_mv->as_mv.col = ref_col;
1633 1336
1634 // Work out the start point for the search 1337 // Work out the start point for the search
1635 in_what = (uint8_t *)(xd->plane[0].pre[0].buf + 1338 in_what = (uint8_t *)(xd->plane[0].pre[0].buf +
1636 (ref_row * (xd->plane[0].pre[0].stride)) + ref_col); 1339 (ref_row * (xd->plane[0].pre[0].stride)) + ref_col);
1637 best_address = in_what; 1340 best_address = in_what;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 } else if (best_address == in_what) 1450 } else if (best_address == in_what)
1748 (*num00)++; 1451 (*num00)++;
1749 } 1452 }
1750 1453
1751 this_mv.as_mv.row = best_mv->as_mv.row << 3; 1454 this_mv.as_mv.row = best_mv->as_mv.row << 3;
1752 this_mv.as_mv.col = best_mv->as_mv.col << 3; 1455 this_mv.as_mv.col = best_mv->as_mv.col << 3;
1753 1456
1754 if (bestsad == INT_MAX) 1457 if (bestsad == INT_MAX)
1755 return INT_MAX; 1458 return INT_MAX;
1756 1459
1757 return 1460 return fn_ptr->vf(what, what_stride, best_address, in_what_stride,
1758 fn_ptr->vf(what, what_stride, best_address, in_what_stride, 1461 (unsigned int *)(&thissad)) + mv_err_cost(&this_mv,
1759 (unsigned int *)(&thissad)) + 1462 center_mv, mvjcost, mvcost, x->errorperbit);
1760 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit,
1761 xd->allow_high_precision_mv);
1762 } 1463 }
1763 1464
1764 /* do_refine: If last step (1-away) of n-step search doesn't pick the center 1465 /* do_refine: If last step (1-away) of n-step search doesn't pick the center
1765 point as the best match, we will do a final 1-away diamond 1466 point as the best match, we will do a final 1-away diamond
1766 refining search */ 1467 refining search */
1767 1468
1768 int vp9_full_pixel_diamond(VP9_COMP *cpi, MACROBLOCK *x, 1469 int vp9_full_pixel_diamond(VP9_COMP *cpi, MACROBLOCK *x,
1769 int_mv *mvp_full, int step_param, 1470 int_mv *mvp_full, int step_param,
1770 int sadpb, int further_steps, 1471 int sadpb, int further_steps,
1771 int do_refine, vp9_variance_fn_ptr_t *fn_ptr, 1472 int do_refine, vp9_variance_fn_ptr_t *fn_ptr,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 1566
1866 best_mv->as_mv.row = ref_row; 1567 best_mv->as_mv.row = ref_row;
1867 best_mv->as_mv.col = ref_col; 1568 best_mv->as_mv.col = ref_col;
1868 1569
1869 // Baseline value at the centre 1570 // Baseline value at the centre
1870 bestsad = fn_ptr->sdf(what, what_stride, bestaddress, 1571 bestsad = fn_ptr->sdf(what, what_stride, bestaddress,
1871 in_what_stride, 0x7fffffff) 1572 in_what_stride, 0x7fffffff)
1872 + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost, 1573 + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost,
1873 sad_per_bit); 1574 sad_per_bit);
1874 1575
1875 // Apply further limits to prevent us looking using vectors that stretch beyio nd the UMV border 1576 // Apply further limits to prevent us looking using vectors that stretch
1876 if (col_min < x->mv_col_min) 1577 // beyond the UMV border
1877 col_min = x->mv_col_min; 1578 col_min = MAX(col_min, x->mv_col_min);
1878 1579 col_max = MIN(col_max, x->mv_col_max);
1879 if (col_max > x->mv_col_max) 1580 row_min = MAX(row_min, x->mv_row_min);
1880 col_max = x->mv_col_max; 1581 row_max = MIN(row_max, x->mv_row_max);
1881
1882 if (row_min < x->mv_row_min)
1883 row_min = x->mv_row_min;
1884
1885 if (row_max > x->mv_row_max)
1886 row_max = x->mv_row_max;
1887 1582
1888 for (r = row_min; r < row_max; r++) { 1583 for (r = row_min; r < row_max; r++) {
1889 this_mv.as_mv.row = r; 1584 this_mv.as_mv.row = r;
1890 check_here = r * mv_stride + in_what + col_min; 1585 check_here = r * mv_stride + in_what + col_min;
1891 1586
1892 for (c = col_min; c < col_max; c++) { 1587 for (c = col_min; c < col_max; c++) {
1893 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, bests ad); 1588 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, bests ad);
1894 1589
1895 this_mv.as_mv.col = c; 1590 this_mv.as_mv.col = c;
1896 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, 1591 thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
(...skipping 10 matching lines...) Expand all
1907 } 1602 }
1908 } 1603 }
1909 1604
1910 this_mv.as_mv.row = best_mv->as_mv.row << 3; 1605 this_mv.as_mv.row = best_mv->as_mv.row << 3;
1911 this_mv.as_mv.col = best_mv->as_mv.col << 3; 1606 this_mv.as_mv.col = best_mv->as_mv.col << 3;
1912 1607
1913 if (bestsad < INT_MAX) 1608 if (bestsad < INT_MAX)
1914 return 1609 return
1915 fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, 1610 fn_ptr->vf(what, what_stride, bestaddress, in_what_stride,
1916 (unsigned int *)(&thissad)) + 1611 (unsigned int *)(&thissad)) +
1917 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, 1612 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit);
1918 xd->allow_high_precision_mv);
1919 else 1613 else
1920 return INT_MAX; 1614 return INT_MAX;
1921 } 1615 }
1922 1616
1923 int vp9_full_search_sadx3(MACROBLOCK *x, int_mv *ref_mv, 1617 int vp9_full_search_sadx3(MACROBLOCK *x, int_mv *ref_mv,
1924 int sad_per_bit, int distance, 1618 int sad_per_bit, int distance,
1925 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost, 1619 vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost,
1926 int *mvcost[2], int_mv *center_mv, int n) { 1620 int *mvcost[2], int_mv *center_mv, int n) {
1927 const MACROBLOCKD* const xd = &x->e_mbd; 1621 const MACROBLOCKD* const xd = &x->e_mbd;
1928 uint8_t *what = x->plane[0].src.buf; 1622 uint8_t *what = x->plane[0].src.buf;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 1656
1963 best_mv->as_mv.row = ref_row; 1657 best_mv->as_mv.row = ref_row;
1964 best_mv->as_mv.col = ref_col; 1658 best_mv->as_mv.col = ref_col;
1965 1659
1966 // Baseline value at the centre 1660 // Baseline value at the centre
1967 bestsad = fn_ptr->sdf(what, what_stride, 1661 bestsad = fn_ptr->sdf(what, what_stride,
1968 bestaddress, in_what_stride, 0x7fffffff) 1662 bestaddress, in_what_stride, 0x7fffffff)
1969 + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost, 1663 + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost,
1970 sad_per_bit); 1664 sad_per_bit);
1971 1665
1972 // Apply further limits to prevent us looking using vectors that stretch beyio nd the UMV border 1666 // Apply further limits to prevent us looking using vectors that stretch
1973 if (col_min < x->mv_col_min) 1667 // beyond the UMV border
1974 col_min = x->mv_col_min; 1668 col_min = MAX(col_min, x->mv_col_min);
1975 1669 col_max = MIN(col_max, x->mv_col_max);
1976 if (col_max > x->mv_col_max) 1670 row_min = MAX(row_min, x->mv_row_min);
1977 col_max = x->mv_col_max; 1671 row_max = MIN(row_max, x->mv_row_max);
1978
1979 if (row_min < x->mv_row_min)
1980 row_min = x->mv_row_min;
1981
1982 if (row_max > x->mv_row_max)
1983 row_max = x->mv_row_max;
1984 1672
1985 for (r = row_min; r < row_max; r++) { 1673 for (r = row_min; r < row_max; r++) {
1986 this_mv.as_mv.row = r; 1674 this_mv.as_mv.row = r;
1987 check_here = r * mv_stride + in_what + col_min; 1675 check_here = r * mv_stride + in_what + col_min;
1988 c = col_min; 1676 c = col_min;
1989 1677
1990 while ((c + 2) < col_max) { 1678 while ((c + 2) < col_max) {
1991 int i; 1679 int i;
1992 1680
1993 fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array); 1681 fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 1723
2036 } 1724 }
2037 1725
2038 this_mv.as_mv.row = best_mv->as_mv.row << 3; 1726 this_mv.as_mv.row = best_mv->as_mv.row << 3;
2039 this_mv.as_mv.col = best_mv->as_mv.col << 3; 1727 this_mv.as_mv.col = best_mv->as_mv.col << 3;
2040 1728
2041 if (bestsad < INT_MAX) 1729 if (bestsad < INT_MAX)
2042 return 1730 return
2043 fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, 1731 fn_ptr->vf(what, what_stride, bestaddress, in_what_stride,
2044 (unsigned int *)(&thissad)) + 1732 (unsigned int *)(&thissad)) +
2045 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, 1733 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit);
2046 xd->allow_high_precision_mv);
2047 else 1734 else
2048 return INT_MAX; 1735 return INT_MAX;
2049 } 1736 }
2050 1737
2051 int vp9_full_search_sadx8(MACROBLOCK *x, int_mv *ref_mv, 1738 int vp9_full_search_sadx8(MACROBLOCK *x, int_mv *ref_mv,
2052 int sad_per_bit, int distance, 1739 int sad_per_bit, int distance,
2053 vp9_variance_fn_ptr_t *fn_ptr, 1740 vp9_variance_fn_ptr_t *fn_ptr,
2054 int *mvjcost, int *mvcost[2], 1741 int *mvjcost, int *mvcost[2],
2055 int_mv *center_mv, int n) { 1742 int_mv *center_mv, int n) {
2056 const MACROBLOCKD* const xd = &x->e_mbd; 1743 const MACROBLOCKD* const xd = &x->e_mbd;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 1779
2093 best_mv->as_mv.row = ref_row; 1780 best_mv->as_mv.row = ref_row;
2094 best_mv->as_mv.col = ref_col; 1781 best_mv->as_mv.col = ref_col;
2095 1782
2096 // Baseline value at the centre 1783 // Baseline value at the centre
2097 bestsad = fn_ptr->sdf(what, what_stride, 1784 bestsad = fn_ptr->sdf(what, what_stride,
2098 bestaddress, in_what_stride, 0x7fffffff) 1785 bestaddress, in_what_stride, 0x7fffffff)
2099 + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost, 1786 + mvsad_err_cost(best_mv, &fcenter_mv, mvjsadcost, mvsadcost,
2100 sad_per_bit); 1787 sad_per_bit);
2101 1788
2102 // Apply further limits to prevent us looking using vectors that stretch beyio nd the UMV border 1789 // Apply further limits to prevent us looking using vectors that stretch
2103 if (col_min < x->mv_col_min) 1790 // beyond the UMV border
2104 col_min = x->mv_col_min; 1791 col_min = MAX(col_min, x->mv_col_min);
2105 1792 col_max = MIN(col_max, x->mv_col_max);
2106 if (col_max > x->mv_col_max) 1793 row_min = MAX(row_min, x->mv_row_min);
2107 col_max = x->mv_col_max; 1794 row_max = MIN(row_max, x->mv_row_max);
2108
2109 if (row_min < x->mv_row_min)
2110 row_min = x->mv_row_min;
2111
2112 if (row_max > x->mv_row_max)
2113 row_max = x->mv_row_max;
2114 1795
2115 for (r = row_min; r < row_max; r++) { 1796 for (r = row_min; r < row_max; r++) {
2116 this_mv.as_mv.row = r; 1797 this_mv.as_mv.row = r;
2117 check_here = r * mv_stride + in_what + col_min; 1798 check_here = r * mv_stride + in_what + col_min;
2118 c = col_min; 1799 c = col_min;
2119 1800
2120 while ((c + 7) < col_max) { 1801 while ((c + 7) < col_max) {
2121 int i; 1802 int i;
2122 1803
2123 fn_ptr->sdx8f(what, what_stride, check_here, in_what_stride, sad_array8); 1804 fn_ptr->sdx8f(what, what_stride, check_here, in_what_stride, sad_array8);
(...skipping 12 matching lines...) Expand all
2136 best_mv->as_mv.col = c; 1817 best_mv->as_mv.col = c;
2137 bestaddress = check_here; 1818 bestaddress = check_here;
2138 } 1819 }
2139 } 1820 }
2140 1821
2141 check_here++; 1822 check_here++;
2142 c++; 1823 c++;
2143 } 1824 }
2144 } 1825 }
2145 1826
2146 while ((c + 2) < col_max) { 1827 while ((c + 2) < col_max && fn_ptr->sdx3f != NULL) {
2147 int i; 1828 int i;
2148 1829
2149 fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array); 1830 fn_ptr->sdx3f(what, what_stride, check_here, in_what_stride, sad_array);
2150 1831
2151 for (i = 0; i < 3; i++) { 1832 for (i = 0; i < 3; i++) {
2152 thissad = sad_array[i]; 1833 thissad = sad_array[i];
2153 1834
2154 if (thissad < bestsad) { 1835 if (thissad < bestsad) {
2155 this_mv.as_mv.col = c; 1836 this_mv.as_mv.col = c;
2156 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, 1837 thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 } 1871 }
2191 } 1872 }
2192 1873
2193 this_mv.as_mv.row = best_mv->as_mv.row << 3; 1874 this_mv.as_mv.row = best_mv->as_mv.row << 3;
2194 this_mv.as_mv.col = best_mv->as_mv.col << 3; 1875 this_mv.as_mv.col = best_mv->as_mv.col << 3;
2195 1876
2196 if (bestsad < INT_MAX) 1877 if (bestsad < INT_MAX)
2197 return 1878 return
2198 fn_ptr->vf(what, what_stride, bestaddress, in_what_stride, 1879 fn_ptr->vf(what, what_stride, bestaddress, in_what_stride,
2199 (unsigned int *)(&thissad)) + 1880 (unsigned int *)(&thissad)) +
2200 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, 1881 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit);
2201 xd->allow_high_precision_mv);
2202 else 1882 else
2203 return INT_MAX; 1883 return INT_MAX;
2204 } 1884 }
2205 int vp9_refining_search_sad_c(MACROBLOCK *x, 1885 int vp9_refining_search_sad_c(MACROBLOCK *x,
2206 int_mv *ref_mv, int error_per_bit, 1886 int_mv *ref_mv, int error_per_bit,
2207 int search_range, vp9_variance_fn_ptr_t *fn_ptr, 1887 int search_range, vp9_variance_fn_ptr_t *fn_ptr,
2208 int *mvjcost, int *mvcost[2], int_mv *center_mv) { 1888 int *mvjcost, int *mvcost[2], int_mv *center_mv) {
2209 const MACROBLOCKD* const xd = &x->e_mbd; 1889 const MACROBLOCKD* const xd = &x->e_mbd;
2210 MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; 1890 MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
2211 int i, j; 1891 int i, j;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2267 } 1947 }
2268 } 1948 }
2269 1949
2270 this_mv.as_mv.row = ref_mv->as_mv.row << 3; 1950 this_mv.as_mv.row = ref_mv->as_mv.row << 3;
2271 this_mv.as_mv.col = ref_mv->as_mv.col << 3; 1951 this_mv.as_mv.col = ref_mv->as_mv.col << 3;
2272 1952
2273 if (bestsad < INT_MAX) 1953 if (bestsad < INT_MAX)
2274 return 1954 return
2275 fn_ptr->vf(what, what_stride, best_address, in_what_stride, 1955 fn_ptr->vf(what, what_stride, best_address, in_what_stride,
2276 (unsigned int *)(&thissad)) + 1956 (unsigned int *)(&thissad)) +
2277 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, 1957 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit);
2278 xd->allow_high_precision_mv);
2279 else 1958 else
2280 return INT_MAX; 1959 return INT_MAX;
2281 } 1960 }
2282 1961
2283 int vp9_refining_search_sadx4(MACROBLOCK *x, 1962 int vp9_refining_search_sadx4(MACROBLOCK *x,
2284 int_mv *ref_mv, int error_per_bit, 1963 int_mv *ref_mv, int error_per_bit,
2285 int search_range, vp9_variance_fn_ptr_t *fn_ptr, 1964 int search_range, vp9_variance_fn_ptr_t *fn_ptr,
2286 int *mvjcost, int *mvcost[2], int_mv *center_mv) { 1965 int *mvjcost, int *mvcost[2], int_mv *center_mv) {
2287 const MACROBLOCKD* const xd = &x->e_mbd; 1966 const MACROBLOCKD* const xd = &x->e_mbd;
2288 MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; 1967 MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 } 2053 }
2375 } 2054 }
2376 2055
2377 this_mv.as_mv.row = ref_mv->as_mv.row << 3; 2056 this_mv.as_mv.row = ref_mv->as_mv.row << 3;
2378 this_mv.as_mv.col = ref_mv->as_mv.col << 3; 2057 this_mv.as_mv.col = ref_mv->as_mv.col << 3;
2379 2058
2380 if (bestsad < INT_MAX) 2059 if (bestsad < INT_MAX)
2381 return 2060 return
2382 fn_ptr->vf(what, what_stride, best_address, in_what_stride, 2061 fn_ptr->vf(what, what_stride, best_address, in_what_stride,
2383 (unsigned int *)(&thissad)) + 2062 (unsigned int *)(&thissad)) +
2384 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, 2063 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit);
2385 xd->allow_high_precision_mv);
2386 else 2064 else
2387 return INT_MAX; 2065 return INT_MAX;
2388 } 2066 }
2389 2067
2390 /* This function is called when we do joint motion search in comp_inter_inter 2068 /* This function is called when we do joint motion search in comp_inter_inter
2391 * mode. 2069 * mode.
2392 */ 2070 */
2393 int vp9_refining_search_8p_c(MACROBLOCK *x, 2071 int vp9_refining_search_8p_c(MACROBLOCK *x,
2394 int_mv *ref_mv, int error_per_bit, 2072 int_mv *ref_mv, int error_per_bit,
2395 int search_range, vp9_variance_fn_ptr_t *fn_ptr, 2073 int search_range, vp9_variance_fn_ptr_t *fn_ptr,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 neighbors[best_site].col; 2143 neighbors[best_site].col;
2466 } 2144 }
2467 } 2145 }
2468 2146
2469 this_mv.as_mv.row = ref_mv->as_mv.row << 3; 2147 this_mv.as_mv.row = ref_mv->as_mv.row << 3;
2470 this_mv.as_mv.col = ref_mv->as_mv.col << 3; 2148 this_mv.as_mv.col = ref_mv->as_mv.col << 3;
2471 2149
2472 if (bestsad < INT_MAX) { 2150 if (bestsad < INT_MAX) {
2473 // FIXME(rbultje, yunqing): add full-pixel averaging variance functions 2151 // FIXME(rbultje, yunqing): add full-pixel averaging variance functions
2474 // so we don't have to use the subpixel with xoff=0,yoff=0 here. 2152 // so we don't have to use the subpixel with xoff=0,yoff=0 here.
2475 int besterr = fn_ptr->svaf(best_address, in_what_stride, 0, 0, 2153 return fn_ptr->svaf(best_address, in_what_stride, 0, 0,
2476 what, what_stride, (unsigned int *)(&thissad), 2154 what, what_stride, (unsigned int *)(&thissad),
2477 second_pred) + 2155 second_pred) +
2478 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit, 2156 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit);
2479 xd->allow_high_precision_mv);
2480 return besterr;
2481 } else { 2157 } else {
2482 return INT_MAX; 2158 return INT_MAX;
2483 } 2159 }
2484 } 2160 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_mcomp.h ('k') | source/libvpx/vp9/encoder/vp9_modecosts.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698