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

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

Issue 1328593002: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 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
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_mcomp.h ('k') | source/libvpx/vp9/encoder/vp9_temporal_filter.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
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 const struct buf_2d *const in_what = &xd->plane[0].pre[0]; 1364 const struct buf_2d *const in_what = &xd->plane[0].pre[0];
1365 const MV mv = {best_mv->row * 8, best_mv->col * 8}; 1365 const MV mv = {best_mv->row * 8, best_mv->col * 8};
1366 unsigned int unused; 1366 unsigned int unused;
1367 1367
1368 return vfp->svaf(get_buf_from_mv(in_what, best_mv), in_what->stride, 0, 0, 1368 return vfp->svaf(get_buf_from_mv(in_what, best_mv), in_what->stride, 0, 0,
1369 what->buf, what->stride, &unused, second_pred) + 1369 what->buf, what->stride, &unused, second_pred) +
1370 (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost, 1370 (use_mvcost ? mv_err_cost(&mv, center_mv, x->nmvjointcost,
1371 x->mvcost, x->errorperbit) : 0); 1371 x->mvcost, x->errorperbit) : 0);
1372 } 1372 }
1373 1373
1374 int vp9_hex_search(const MACROBLOCK *x, 1374 static int hex_search(const MACROBLOCK *x,
1375 MV *ref_mv, 1375 MV *ref_mv,
1376 int search_param, 1376 int search_param,
1377 int sad_per_bit, 1377 int sad_per_bit,
1378 int do_init_search, 1378 int do_init_search,
1379 int *cost_list, 1379 int *cost_list,
1380 const vp9_variance_fn_ptr_t *vfp, 1380 const vp9_variance_fn_ptr_t *vfp,
1381 int use_mvcost, 1381 int use_mvcost,
1382 const MV *center_mv, MV *best_mv) { 1382 const MV *center_mv, MV *best_mv) {
1383 // First scale has 8-closest points, the rest have 6 points in hex shape 1383 // First scale has 8-closest points, the rest have 6 points in hex shape
1384 // at increasing scales 1384 // at increasing scales
1385 static const int hex_num_candidates[MAX_PATTERN_SCALES] = { 1385 static const int hex_num_candidates[MAX_PATTERN_SCALES] = {
1386 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 1386 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
1387 }; 1387 };
1388 // Note that the largest candidate step at each scale is 2^scale 1388 // Note that the largest candidate step at each scale is 2^scale
1389 static const MV hex_candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES] = { 1389 static const MV hex_candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES] = {
1390 {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, { 0, 1}, { -1, 1}, {-1, 0}}, 1390 {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, { 0, 1}, { -1, 1}, {-1, 0}},
1391 {{-1, -2}, {1, -2}, {2, 0}, {1, 2}, { -1, 2}, { -2, 0}}, 1391 {{-1, -2}, {1, -2}, {2, 0}, {1, 2}, { -1, 2}, { -2, 0}},
1392 {{-2, -4}, {2, -4}, {4, 0}, {2, 4}, { -2, 4}, { -4, 0}}, 1392 {{-2, -4}, {2, -4}, {4, 0}, {2, 4}, { -2, 4}, { -4, 0}},
1393 {{-4, -8}, {4, -8}, {8, 0}, {4, 8}, { -4, 8}, { -8, 0}}, 1393 {{-4, -8}, {4, -8}, {8, 0}, {4, 8}, { -4, 8}, { -8, 0}},
1394 {{-8, -16}, {8, -16}, {16, 0}, {8, 16}, { -8, 16}, { -16, 0}}, 1394 {{-8, -16}, {8, -16}, {16, 0}, {8, 16}, { -8, 16}, { -16, 0}},
1395 {{-16, -32}, {16, -32}, {32, 0}, {16, 32}, { -16, 32}, { -32, 0}}, 1395 {{-16, -32}, {16, -32}, {32, 0}, {16, 32}, { -16, 32}, { -32, 0}},
1396 {{-32, -64}, {32, -64}, {64, 0}, {32, 64}, { -32, 64}, { -64, 0}}, 1396 {{-32, -64}, {32, -64}, {64, 0}, {32, 64}, { -32, 64}, { -64, 0}},
1397 {{-64, -128}, {64, -128}, {128, 0}, {64, 128}, { -64, 128}, { -128, 0}}, 1397 {{-64, -128}, {64, -128}, {128, 0}, {64, 128}, { -64, 128}, { -128, 0}},
1398 {{-128, -256}, {128, -256}, {256, 0}, {128, 256}, { -128, 256}, { -256, 0}}, 1398 {{-128, -256}, {128, -256}, {256, 0}, {128, 256}, { -128, 256}, { -256, 0}},
1399 {{-256, -512}, {256, -512}, {512, 0}, {256, 512}, { -256, 512}, { -512, 0}}, 1399 {{-256, -512}, {256, -512}, {512, 0}, {256, 512}, { -256, 512}, { -512, 0}},
1400 {{-512, -1024}, {512, -1024}, {1024, 0}, {512, 1024}, { -512, 1024}, 1400 {{-512, -1024}, {512, -1024}, {1024, 0}, {512, 1024}, { -512, 1024},
1401 { -1024, 0}}, 1401 { -1024, 0}},
1402 }; 1402 };
1403 return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit, 1403 return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit,
1404 do_init_search, cost_list, vfp, use_mvcost, 1404 do_init_search, cost_list, vfp, use_mvcost,
1405 center_mv, best_mv, 1405 center_mv, best_mv,
1406 hex_num_candidates, hex_candidates); 1406 hex_num_candidates, hex_candidates);
1407 } 1407 }
1408 1408
1409 int vp9_bigdia_search(const MACROBLOCK *x, 1409 static int bigdia_search(const MACROBLOCK *x,
1410 MV *ref_mv, 1410 MV *ref_mv,
1411 int search_param, 1411 int search_param,
1412 int sad_per_bit, 1412 int sad_per_bit,
1413 int do_init_search, 1413 int do_init_search,
1414 int *cost_list, 1414 int *cost_list,
1415 const vp9_variance_fn_ptr_t *vfp, 1415 const vp9_variance_fn_ptr_t *vfp,
1416 int use_mvcost, 1416 int use_mvcost,
1417 const MV *center_mv, 1417 const MV *center_mv,
1418 MV *best_mv) { 1418 MV *best_mv) {
1419 // First scale has 4-closest points, the rest have 8 points in diamond 1419 // First scale has 4-closest points, the rest have 8 points in diamond
1420 // shape at increasing scales 1420 // shape at increasing scales
1421 static const int bigdia_num_candidates[MAX_PATTERN_SCALES] = { 1421 static const int bigdia_num_candidates[MAX_PATTERN_SCALES] = {
1422 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1422 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
1423 }; 1423 };
1424 // Note that the largest candidate step at each scale is 2^scale 1424 // Note that the largest candidate step at each scale is 2^scale
1425 static const MV bigdia_candidates[MAX_PATTERN_SCALES] 1425 static const MV bigdia_candidates[MAX_PATTERN_SCALES]
1426 [MAX_PATTERN_CANDIDATES] = { 1426 [MAX_PATTERN_CANDIDATES] = {
1427 {{0, -1}, {1, 0}, { 0, 1}, {-1, 0}}, 1427 {{0, -1}, {1, 0}, { 0, 1}, {-1, 0}},
1428 {{-1, -1}, {0, -2}, {1, -1}, {2, 0}, {1, 1}, {0, 2}, {-1, 1}, {-2, 0}}, 1428 {{-1, -1}, {0, -2}, {1, -1}, {2, 0}, {1, 1}, {0, 2}, {-1, 1}, {-2, 0}},
(...skipping 12 matching lines...) Expand all
1441 {-256, 256}, {-512, 0}}, 1441 {-256, 256}, {-512, 0}},
1442 {{-512, -512}, {0, -1024}, {512, -512}, {1024, 0}, {512, 512}, {0, 1024}, 1442 {{-512, -512}, {0, -1024}, {512, -512}, {1024, 0}, {512, 512}, {0, 1024},
1443 {-512, 512}, {-1024, 0}}, 1443 {-512, 512}, {-1024, 0}},
1444 }; 1444 };
1445 return vp9_pattern_search_sad(x, ref_mv, search_param, sad_per_bit, 1445 return vp9_pattern_search_sad(x, ref_mv, search_param, sad_per_bit,
1446 do_init_search, cost_list, vfp, use_mvcost, 1446 do_init_search, cost_list, vfp, use_mvcost,
1447 center_mv, best_mv, 1447 center_mv, best_mv,
1448 bigdia_num_candidates, bigdia_candidates); 1448 bigdia_num_candidates, bigdia_candidates);
1449 } 1449 }
1450 1450
1451 int vp9_square_search(const MACROBLOCK *x, 1451 static int square_search(const MACROBLOCK *x,
1452 MV *ref_mv, 1452 MV *ref_mv,
1453 int search_param, 1453 int search_param,
1454 int sad_per_bit, 1454 int sad_per_bit,
1455 int do_init_search, 1455 int do_init_search,
1456 int *cost_list, 1456 int *cost_list,
1457 const vp9_variance_fn_ptr_t *vfp, 1457 const vp9_variance_fn_ptr_t *vfp,
1458 int use_mvcost, 1458 int use_mvcost,
1459 const MV *center_mv, 1459 const MV *center_mv,
1460 MV *best_mv) { 1460 MV *best_mv) {
1461 // All scales have 8 closest points in square shape 1461 // All scales have 8 closest points in square shape
1462 static const int square_num_candidates[MAX_PATTERN_SCALES] = { 1462 static const int square_num_candidates[MAX_PATTERN_SCALES] = {
1463 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1463 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
1464 }; 1464 };
1465 // Note that the largest candidate step at each scale is 2^scale 1465 // Note that the largest candidate step at each scale is 2^scale
1466 static const MV square_candidates[MAX_PATTERN_SCALES] 1466 static const MV square_candidates[MAX_PATTERN_SCALES]
1467 [MAX_PATTERN_CANDIDATES] = { 1467 [MAX_PATTERN_CANDIDATES] = {
1468 {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}}, 1468 {{-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}},
1469 {{-2, -2}, {0, -2}, {2, -2}, {2, 0}, {2, 2}, {0, 2}, {-2, 2}, {-2, 0}}, 1469 {{-2, -2}, {0, -2}, {2, -2}, {2, 0}, {2, 2}, {0, 2}, {-2, 2}, {-2, 0}},
1470 {{-4, -4}, {0, -4}, {4, -4}, {4, 0}, {4, 4}, {0, 4}, {-4, 4}, {-4, 0}}, 1470 {{-4, -4}, {0, -4}, {4, -4}, {4, 0}, {4, 4}, {0, 4}, {-4, 4}, {-4, 0}},
(...skipping 12 matching lines...) Expand all
1483 {-512, 512}, {-512, 0}}, 1483 {-512, 512}, {-512, 0}},
1484 {{-1024, -1024}, {0, -1024}, {1024, -1024}, {1024, 0}, {1024, 1024}, 1484 {{-1024, -1024}, {0, -1024}, {1024, -1024}, {1024, 0}, {1024, 1024},
1485 {0, 1024}, {-1024, 1024}, {-1024, 0}}, 1485 {0, 1024}, {-1024, 1024}, {-1024, 0}},
1486 }; 1486 };
1487 return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit, 1487 return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit,
1488 do_init_search, cost_list, vfp, use_mvcost, 1488 do_init_search, cost_list, vfp, use_mvcost,
1489 center_mv, best_mv, 1489 center_mv, best_mv,
1490 square_num_candidates, square_candidates); 1490 square_num_candidates, square_candidates);
1491 } 1491 }
1492 1492
1493 int vp9_fast_hex_search(const MACROBLOCK *x, 1493 static int fast_hex_search(const MACROBLOCK *x,
1494 MV *ref_mv, 1494 MV *ref_mv,
1495 int search_param, 1495 int search_param,
1496 int sad_per_bit, 1496 int sad_per_bit,
1497 int do_init_search, // must be zero for fast_hex 1497 int do_init_search, // must be zero for fast_hex
1498 int *cost_list, 1498 int *cost_list,
1499 const vp9_variance_fn_ptr_t *vfp, 1499 const vp9_variance_fn_ptr_t *vfp,
1500 int use_mvcost, 1500 int use_mvcost,
1501 const MV *center_mv, 1501 const MV *center_mv,
1502 MV *best_mv) { 1502 MV *best_mv) {
1503 return vp9_hex_search(x, ref_mv, VPXMAX(MAX_MVSEARCH_STEPS - 2, search_param), 1503 return hex_search(x, ref_mv, VPXMAX(MAX_MVSEARCH_STEPS - 2, search_param),
1504 sad_per_bit, do_init_search, cost_list, vfp, use_mvcost, 1504 sad_per_bit, do_init_search, cost_list, vfp, use_mvcost,
1505 center_mv, best_mv); 1505 center_mv, best_mv);
1506 } 1506 }
1507 1507
1508 int vp9_fast_dia_search(const MACROBLOCK *x, 1508 static int fast_dia_search(const MACROBLOCK *x,
1509 MV *ref_mv, 1509 MV *ref_mv,
1510 int search_param, 1510 int search_param,
1511 int sad_per_bit, 1511 int sad_per_bit,
1512 int do_init_search, 1512 int do_init_search,
1513 int *cost_list, 1513 int *cost_list,
1514 const vp9_variance_fn_ptr_t *vfp, 1514 const vp9_variance_fn_ptr_t *vfp,
1515 int use_mvcost, 1515 int use_mvcost,
1516 const MV *center_mv, 1516 const MV *center_mv,
1517 MV *best_mv) { 1517 MV *best_mv) {
1518 return vp9_bigdia_search( 1518 return bigdia_search(
1519 x, ref_mv, VPXMAX(MAX_MVSEARCH_STEPS - 2, search_param), sad_per_bit, 1519 x, ref_mv, VPXMAX(MAX_MVSEARCH_STEPS - 2, search_param), sad_per_bit,
1520 do_init_search, cost_list, vfp, use_mvcost, center_mv, best_mv); 1520 do_init_search, cost_list, vfp, use_mvcost, center_mv, best_mv);
1521 } 1521 }
1522 1522
1523 #undef CHECK_BETTER 1523 #undef CHECK_BETTER
1524 1524
1525 int vp9_full_range_search_c(const MACROBLOCK *x, 1525 int vp9_full_range_search_c(const MACROBLOCK *x,
1526 const search_site_config *cfg, 1526 const search_site_config *cfg,
1527 MV *ref_mv, MV *best_mv, 1527 MV *ref_mv, MV *best_mv,
1528 int search_param, int sad_per_bit, int *num00, 1528 int search_param, int sad_per_bit, int *num00,
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 1939
1940 if (scaled_ref_frame) { 1940 if (scaled_ref_frame) {
1941 int i; 1941 int i;
1942 for (i = 0; i < MAX_MB_PLANE; i++) 1942 for (i = 0; i < MAX_MB_PLANE; i++)
1943 xd->plane[i].pre[0] = backup_yv12[i]; 1943 xd->plane[i].pre[0] = backup_yv12[i];
1944 } 1944 }
1945 1945
1946 return best_sad; 1946 return best_sad;
1947 } 1947 }
1948 1948
1949 // Runs sequence of diamond searches in smaller steps for RD.
1949 /* do_refine: If last step (1-away) of n-step search doesn't pick the center 1950 /* do_refine: If last step (1-away) of n-step search doesn't pick the center
1950 point as the best match, we will do a final 1-away diamond 1951 point as the best match, we will do a final 1-away diamond
1951 refining search */ 1952 refining search */
1952 int vp9_full_pixel_diamond(const VP9_COMP *cpi, MACROBLOCK *x, 1953 static int full_pixel_diamond(const VP9_COMP *cpi, MACROBLOCK *x,
1953 MV *mvp_full, int step_param, 1954 MV *mvp_full, int step_param,
1954 int sadpb, int further_steps, int do_refine, 1955 int sadpb, int further_steps, int do_refine,
1955 int *cost_list, 1956 int *cost_list,
1956 const vp9_variance_fn_ptr_t *fn_ptr, 1957 const vp9_variance_fn_ptr_t *fn_ptr,
1957 const MV *ref_mv, MV *dst_mv) { 1958 const MV *ref_mv, MV *dst_mv) {
1958 MV temp_mv; 1959 MV temp_mv;
1959 int thissme, n, num00 = 0; 1960 int thissme, n, num00 = 0;
1960 int bestsme = cpi->diamond_search_sad(x, &cpi->ss_cfg, mvp_full, &temp_mv, 1961 int bestsme = cpi->diamond_search_sad(x, &cpi->ss_cfg, mvp_full, &temp_mv,
1961 step_param, sadpb, &n, 1962 step_param, sadpb, &n,
1962 fn_ptr, ref_mv); 1963 fn_ptr, ref_mv);
1963 if (bestsme < INT_MAX) 1964 if (bestsme < INT_MAX)
1964 bestsme = vp9_get_mvpred_var(x, &temp_mv, ref_mv, fn_ptr, 1); 1965 bestsme = vp9_get_mvpred_var(x, &temp_mv, ref_mv, fn_ptr, 1);
1965 *dst_mv = temp_mv; 1966 *dst_mv = temp_mv;
1966 1967
1967 // If there won't be more n-step search, check to see if refining search is 1968 // If there won't be more n-step search, check to see if refining search is
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2339 if (cost_list) { 2340 if (cost_list) {
2340 cost_list[0] = INT_MAX; 2341 cost_list[0] = INT_MAX;
2341 cost_list[1] = INT_MAX; 2342 cost_list[1] = INT_MAX;
2342 cost_list[2] = INT_MAX; 2343 cost_list[2] = INT_MAX;
2343 cost_list[3] = INT_MAX; 2344 cost_list[3] = INT_MAX;
2344 cost_list[4] = INT_MAX; 2345 cost_list[4] = INT_MAX;
2345 } 2346 }
2346 2347
2347 switch (method) { 2348 switch (method) {
2348 case FAST_DIAMOND: 2349 case FAST_DIAMOND:
2349 var = vp9_fast_dia_search(x, mvp_full, step_param, error_per_bit, 0, 2350 var = fast_dia_search(x, mvp_full, step_param, error_per_bit, 0,
2350 cost_list, fn_ptr, 1, ref_mv, tmp_mv); 2351 cost_list, fn_ptr, 1, ref_mv, tmp_mv);
2351 break; 2352 break;
2352 case FAST_HEX: 2353 case FAST_HEX:
2353 var = vp9_fast_hex_search(x, mvp_full, step_param, error_per_bit, 0, 2354 var = fast_hex_search(x, mvp_full, step_param, error_per_bit, 0,
2354 cost_list, fn_ptr, 1, ref_mv, tmp_mv); 2355 cost_list, fn_ptr, 1, ref_mv, tmp_mv);
2355 break; 2356 break;
2356 case HEX: 2357 case HEX:
2357 var = vp9_hex_search(x, mvp_full, step_param, error_per_bit, 1, 2358 var = hex_search(x, mvp_full, step_param, error_per_bit, 1,
2358 cost_list, fn_ptr, 1, ref_mv, tmp_mv); 2359 cost_list, fn_ptr, 1, ref_mv, tmp_mv);
2359 break; 2360 break;
2360 case SQUARE: 2361 case SQUARE:
2361 var = vp9_square_search(x, mvp_full, step_param, error_per_bit, 1, 2362 var = square_search(x, mvp_full, step_param, error_per_bit, 1,
2362 cost_list, fn_ptr, 1, ref_mv, tmp_mv); 2363 cost_list, fn_ptr, 1, ref_mv, tmp_mv);
2363 break; 2364 break;
2364 case BIGDIA: 2365 case BIGDIA:
2365 var = vp9_bigdia_search(x, mvp_full, step_param, error_per_bit, 1, 2366 var = bigdia_search(x, mvp_full, step_param, error_per_bit, 1,
2366 cost_list, fn_ptr, 1, ref_mv, tmp_mv); 2367 cost_list, fn_ptr, 1, ref_mv, tmp_mv);
2367 break; 2368 break;
2368 case NSTEP: 2369 case NSTEP:
2369 var = vp9_full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit, 2370 var = full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit,
2370 MAX_MVSEARCH_STEPS - 1 - step_param, 2371 MAX_MVSEARCH_STEPS - 1 - step_param,
2371 1, cost_list, fn_ptr, ref_mv, tmp_mv); 2372 1, cost_list, fn_ptr, ref_mv, tmp_mv);
2372 break; 2373 break;
2373 default: 2374 default:
2374 assert(0 && "Invalid search method."); 2375 assert(0 && "Invalid search method.");
2375 } 2376 }
2376 2377
2377 if (method != NSTEP && rd && var < var_max) 2378 if (method != NSTEP && rd && var < var_max)
2378 var = vp9_get_mvpred_var(x, tmp_mv, ref_mv, fn_ptr, 1); 2379 var = vp9_get_mvpred_var(x, tmp_mv, ref_mv, fn_ptr, 1);
2379 2380
2380 return var; 2381 return var;
2381 } 2382 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_mcomp.h ('k') | source/libvpx/vp9/encoder/vp9_temporal_filter.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698