2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
2013-03-05 23:12:16 +01:00
|
|
|
#include <limits.h>
|
|
|
|
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_findnearmv.h"
|
2012-11-27 22:59:17 +01:00
|
|
|
#include "vp9/common/vp9_sadmxn.h"
|
|
|
|
#include "vp9/common/vp9_subpelvar.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-12-19 00:31:19 +01:00
|
|
|
const uint8_t vp9_mbsplit_offset[4][16] = {
|
2012-07-14 00:21:29 +02:00
|
|
|
{ 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
|
|
{ 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
|
|
{ 0, 2, 8, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
|
|
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
|
2011-03-17 22:07:59 +01:00
|
|
|
};
|
|
|
|
|
2013-04-17 23:33:05 +02:00
|
|
|
static void lower_mv_precision(int_mv *mv, int usehp) {
|
2012-10-31 00:25:53 +01:00
|
|
|
if (!usehp || !vp9_use_nmv_hp(&mv->as_mv)) {
|
2012-09-06 18:07:42 +02:00
|
|
|
if (mv->as_mv.row & 1)
|
|
|
|
mv->as_mv.row += (mv->as_mv.row > 0 ? -1 : 1);
|
|
|
|
if (mv->as_mv.col & 1)
|
|
|
|
mv->as_mv.col += (mv->as_mv.col > 0 ? -1 : 1);
|
|
|
|
}
|
2012-08-06 19:51:20 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 23:33:05 +02:00
|
|
|
vp9_prob *vp9_mv_ref_probs(VP9_COMMON *pc, vp9_prob p[4], int context) {
|
2012-11-12 16:09:25 +01:00
|
|
|
p[0] = pc->fc.vp9_mode_contexts[context][0];
|
|
|
|
p[1] = pc->fc.vp9_mode_contexts[context][1];
|
|
|
|
p[2] = pc->fc.vp9_mode_contexts[context][2];
|
|
|
|
p[3] = pc->fc.vp9_mode_contexts[context][3];
|
2012-07-14 00:21:29 +02:00
|
|
|
return p;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2012-08-06 19:51:20 +02:00
|
|
|
|
2013-03-13 00:49:15 +01:00
|
|
|
void vp9_find_best_ref_mvs(MACROBLOCKD *xd,
|
|
|
|
int_mv *mvlist,
|
|
|
|
int_mv *nearest,
|
|
|
|
int_mv *near) {
|
|
|
|
int i;
|
|
|
|
// Make sure all the candidates are properly clamped etc
|
|
|
|
for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
|
|
|
|
lower_mv_precision(&mvlist[i], xd->allow_high_precision_mv);
|
|
|
|
clamp_mv2(&mvlist[i], xd);
|
|
|
|
}
|
|
|
|
*nearest = mvlist[0];
|
|
|
|
*near = mvlist[1];
|
|
|
|
}
|