2012-08-24 16:44:01 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
*/
|
|
|
|
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/common/vp9_mvref_common.h"
|
2012-08-24 16:44:01 +02:00
|
|
|
|
|
|
|
#define MVREF_NEIGHBOURS 8
|
2013-06-06 02:05:19 +02:00
|
|
|
static int mv_ref_blocks[BLOCK_SIZE_TYPES][MVREF_NEIGHBOURS][2] = {
|
|
|
|
// SB4X4
|
|
|
|
{{0, -1}, {-1, 0}, {-1, -1}, {0, -2}, {-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}},
|
|
|
|
// SB4X8
|
|
|
|
{{0, -1}, {-1, 0}, {-1, -1}, {0, -2}, {-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}},
|
|
|
|
// SB8X4
|
|
|
|
{{0, -1}, {-1, 0}, {-1, -1}, {0, -2}, {-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}},
|
|
|
|
// SB8X8
|
|
|
|
{{0, -1}, {-1, 0}, {-1, -1}, {0, -2}, {-2, 0}, {-1, -2}, {-2, -1}, {-2, -2}},
|
|
|
|
// SB8X16
|
|
|
|
{{-1, 0}, {0, -1}, {-1, 1}, {-1, -1}, {-2, 0}, {0, -2}, {-1, -2}, {-2, -1}},
|
|
|
|
// SB16X8
|
|
|
|
{{0, -1}, {-1, 0}, {1, -1}, {-1, -1}, {0, -2}, {-2, 0}, {-2, -1}, {-1, -2}},
|
|
|
|
// SB16X16
|
|
|
|
{{0, -1}, {-1, 0}, {1, -1}, {-1, 1}, {-1, -1}, {0, -3}, {-3, 0}, {-3, -3}},
|
|
|
|
// SB16X32
|
|
|
|
{{-1, 0}, {0, -1}, {-1, 2}, {-1, -1}, {1, -1}, {-3, 0}, {0, -3}, {-3, -3}},
|
|
|
|
// SB32X16
|
|
|
|
{{0, -1}, {-1, 0}, {2, -1}, {-1, -1}, {-1, 1}, {0, -3}, {-3, 0}, {-3, -3}},
|
|
|
|
// SB32X32
|
|
|
|
{{1, -1}, {-1, 1}, {2, -1}, {-1, 2}, {-1, -1}, {0, -3}, {-3, 0}, {-3, -3}},
|
|
|
|
// SB32X64
|
|
|
|
{{-1, 0}, {0, -1}, {-1, 4}, {2, -1}, {-1, -1}, {-3, 0}, {0, -3}, {-1, 2}},
|
|
|
|
// SB64X32
|
|
|
|
{{0, -1}, {-1, 0}, {4, -1}, {-1, 2}, {-1, -1}, {0, -3}, {-3, 0}, {2, -1}},
|
|
|
|
// SB64X64
|
|
|
|
{{3, -1}, {-1, 3}, {4, -1}, {-1, 4}, {-1, -1}, {0, -1}, {-1, 0}, {6, -1}}
|
2013-04-26 20:57:17 +02:00
|
|
|
};
|
2013-01-24 13:52:13 +01:00
|
|
|
// clamp_mv_ref
|
2012-08-24 16:44:01 +02:00
|
|
|
#define MV_BORDER (16 << 3) // Allow 16 pels in 1/8th pel units
|
|
|
|
|
2013-03-05 23:12:16 +01:00
|
|
|
static void clamp_mv_ref(const MACROBLOCKD *xd, int_mv *mv) {
|
2013-03-25 23:16:14 +01:00
|
|
|
mv->as_mv.col = clamp(mv->as_mv.col, xd->mb_to_left_edge - MV_BORDER,
|
|
|
|
xd->mb_to_right_edge + MV_BORDER);
|
|
|
|
mv->as_mv.row = clamp(mv->as_mv.row, xd->mb_to_top_edge - MV_BORDER,
|
|
|
|
xd->mb_to_bottom_edge + MV_BORDER);
|
2012-08-24 16:44:01 +02:00
|
|
|
}
|
|
|
|
|
2013-06-06 02:05:19 +02:00
|
|
|
// Gets a candidate reference motion vector from the given mode info
|
2013-01-03 16:14:36 +01:00
|
|
|
// structure if one exists that matches the given reference frame.
|
2013-03-05 23:12:16 +01:00
|
|
|
static int get_matching_candidate(const MODE_INFO *candidate_mi,
|
2013-03-25 23:16:14 +01:00
|
|
|
MV_REFERENCE_FRAME ref_frame,
|
2013-05-26 23:40:49 +02:00
|
|
|
int_mv *c_mv, int block_idx) {
|
2013-06-06 22:44:34 +02:00
|
|
|
if (ref_frame == candidate_mi->mbmi.ref_frame[0]) {
|
2013-05-26 23:40:49 +02:00
|
|
|
if (block_idx >= 0 && candidate_mi->mbmi.sb_type < BLOCK_SIZE_SB8X8)
|
|
|
|
c_mv->as_int = candidate_mi->bmi[block_idx].as_mv[0].as_int;
|
|
|
|
else
|
|
|
|
c_mv->as_int = candidate_mi->mbmi.mv[0].as_int;
|
2013-06-06 22:44:34 +02:00
|
|
|
} else if (ref_frame == candidate_mi->mbmi.ref_frame[1]) {
|
2013-05-26 23:40:49 +02:00
|
|
|
if (block_idx >= 0 && candidate_mi->mbmi.sb_type < BLOCK_SIZE_SB8X8)
|
|
|
|
c_mv->as_int = candidate_mi->bmi[block_idx].as_mv[1].as_int;
|
|
|
|
else
|
|
|
|
c_mv->as_int = candidate_mi->mbmi.mv[1].as_int;
|
2013-01-03 16:14:36 +01:00
|
|
|
} else {
|
2013-03-25 23:16:14 +01:00
|
|
|
return 0;
|
2013-01-03 16:14:36 +01:00
|
|
|
}
|
|
|
|
|
2013-03-25 23:16:14 +01:00
|
|
|
return 1;
|
2013-01-03 16:14:36 +01:00
|
|
|
}
|
2012-08-24 16:44:01 +02:00
|
|
|
|
2013-06-06 02:05:19 +02:00
|
|
|
// Gets candidate reference motion vector(s) from the given mode info
|
2013-01-03 16:14:36 +01:00
|
|
|
// structure if they exists and do NOT match the given reference frame.
|
2013-03-25 23:16:14 +01:00
|
|
|
static void get_non_matching_candidates(const MODE_INFO *candidate_mi,
|
|
|
|
MV_REFERENCE_FRAME ref_frame,
|
|
|
|
MV_REFERENCE_FRAME *c_ref_frame,
|
|
|
|
int_mv *c_mv,
|
|
|
|
MV_REFERENCE_FRAME *c2_ref_frame,
|
|
|
|
int_mv *c2_mv) {
|
2012-08-24 16:44:01 +02:00
|
|
|
|
2013-01-03 16:14:36 +01:00
|
|
|
c_mv->as_int = 0;
|
2012-09-07 13:46:41 +02:00
|
|
|
c2_mv->as_int = 0;
|
2013-01-03 16:14:36 +01:00
|
|
|
*c_ref_frame = INTRA_FRAME;
|
2012-09-07 13:46:41 +02:00
|
|
|
*c2_ref_frame = INTRA_FRAME;
|
2012-08-24 16:44:01 +02:00
|
|
|
|
2013-01-03 16:14:36 +01:00
|
|
|
// If first candidate not valid neither will be.
|
2013-06-06 22:44:34 +02:00
|
|
|
if (candidate_mi->mbmi.ref_frame[0] > INTRA_FRAME) {
|
2013-01-03 16:14:36 +01:00
|
|
|
// First candidate
|
2013-06-06 22:44:34 +02:00
|
|
|
if (candidate_mi->mbmi.ref_frame[0] != ref_frame) {
|
|
|
|
*c_ref_frame = candidate_mi->mbmi.ref_frame[0];
|
2013-01-03 16:14:36 +01:00
|
|
|
c_mv->as_int = candidate_mi->mbmi.mv[0].as_int;
|
2012-09-07 13:46:41 +02:00
|
|
|
}
|
|
|
|
|
2013-01-03 16:14:36 +01:00
|
|
|
// Second candidate
|
2013-06-06 22:44:34 +02:00
|
|
|
if ((candidate_mi->mbmi.ref_frame[1] > INTRA_FRAME) &&
|
|
|
|
(candidate_mi->mbmi.ref_frame[1] != ref_frame) &&
|
2013-03-25 23:16:14 +01:00
|
|
|
(candidate_mi->mbmi.mv[1].as_int != candidate_mi->mbmi.mv[0].as_int)) {
|
2013-06-06 22:44:34 +02:00
|
|
|
*c2_ref_frame = candidate_mi->mbmi.ref_frame[1];
|
2013-01-03 16:14:36 +01:00
|
|
|
c2_mv->as_int = candidate_mi->mbmi.mv[1].as_int;
|
2012-09-07 13:46:41 +02:00
|
|
|
}
|
2012-08-24 16:44:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-24 13:52:13 +01:00
|
|
|
|
|
|
|
// Performs mv sign inversion if indicated by the reference frame combination.
|
2013-03-25 23:16:14 +01:00
|
|
|
static void scale_mv(MACROBLOCKD *xd, MV_REFERENCE_FRAME this_ref_frame,
|
|
|
|
MV_REFERENCE_FRAME candidate_ref_frame,
|
|
|
|
int_mv *candidate_mv, int *ref_sign_bias) {
|
2013-01-24 13:52:13 +01:00
|
|
|
|
|
|
|
// Sign inversion where appropriate.
|
|
|
|
if (ref_sign_bias[candidate_ref_frame] != ref_sign_bias[this_ref_frame]) {
|
|
|
|
candidate_mv->as_mv.row = -candidate_mv->as_mv.row;
|
|
|
|
candidate_mv->as_mv.col = -candidate_mv->as_mv.col;
|
2012-08-24 16:44:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-19 12:10:16 +02:00
|
|
|
// Add a candidate mv.
|
|
|
|
// Discard if it has already been seen.
|
2013-03-25 23:16:14 +01:00
|
|
|
static void add_candidate_mv(int_mv *mv_list, int *mv_scores,
|
|
|
|
int *candidate_count, int_mv candidate_mv,
|
|
|
|
int weight) {
|
2013-04-19 12:10:16 +02:00
|
|
|
if (*candidate_count == 0) {
|
|
|
|
mv_list[0].as_int = candidate_mv.as_int;
|
|
|
|
mv_scores[0] = weight;
|
|
|
|
*candidate_count += 1;
|
|
|
|
} else if ((*candidate_count == 1) &&
|
|
|
|
(candidate_mv.as_int != mv_list[0].as_int)) {
|
|
|
|
mv_list[1].as_int = candidate_mv.as_int;
|
|
|
|
mv_scores[1] = weight;
|
|
|
|
*candidate_count += 1;
|
2013-01-24 13:52:13 +01:00
|
|
|
}
|
|
|
|
}
|
2012-08-24 16:44:01 +02:00
|
|
|
|
2013-04-19 12:10:16 +02:00
|
|
|
// This function searches the neighbourhood of a given MB/SB
|
|
|
|
// to try and find candidate reference vectors.
|
2012-08-24 16:44:01 +02:00
|
|
|
//
|
2013-05-26 23:40:49 +02:00
|
|
|
void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
|
|
|
|
MODE_INFO *lf_here, MV_REFERENCE_FRAME ref_frame,
|
|
|
|
int_mv *mv_ref_list, int *ref_sign_bias,
|
|
|
|
int block_idx) {
|
2012-08-24 16:44:01 +02:00
|
|
|
int i;
|
|
|
|
MODE_INFO *candidate_mi;
|
2012-11-12 16:09:25 +01:00
|
|
|
MB_MODE_INFO * mbmi = &xd->mode_info_context->mbmi;
|
2012-08-24 16:44:01 +02:00
|
|
|
int_mv c_refmv;
|
2012-09-07 13:46:41 +02:00
|
|
|
int_mv c2_refmv;
|
2012-12-04 18:21:05 +01:00
|
|
|
MV_REFERENCE_FRAME c_ref_frame;
|
2012-09-07 13:46:41 +02:00
|
|
|
MV_REFERENCE_FRAME c2_ref_frame;
|
2012-12-04 18:21:05 +01:00
|
|
|
int candidate_scores[MAX_MV_REF_CANDIDATES];
|
2013-01-24 13:52:13 +01:00
|
|
|
int refmv_count = 0;
|
2012-11-16 17:31:32 +01:00
|
|
|
int split_count = 0;
|
2012-11-16 15:31:53 +01:00
|
|
|
int (*mv_ref_search)[2];
|
2013-04-26 20:57:17 +02:00
|
|
|
const int mi_col = get_mi_col(xd);
|
2013-06-10 18:21:11 +02:00
|
|
|
const int mi_row = get_mi_row(xd);
|
2013-05-16 12:27:12 +02:00
|
|
|
int intra_count = 0;
|
|
|
|
int zero_count = 0;
|
|
|
|
int newmv_count = 0;
|
2013-05-26 23:40:49 +02:00
|
|
|
int x_idx = 0, y_idx = 0;
|
2013-05-16 12:27:12 +02:00
|
|
|
|
2012-08-24 16:44:01 +02:00
|
|
|
// Blank the reference vector lists and other local structures.
|
2012-12-04 18:21:05 +01:00
|
|
|
vpx_memset(mv_ref_list, 0, sizeof(int_mv) * MAX_MV_REF_CANDIDATES);
|
2012-08-24 16:44:01 +02:00
|
|
|
vpx_memset(candidate_scores, 0, sizeof(candidate_scores));
|
|
|
|
|
2013-06-06 02:05:19 +02:00
|
|
|
mv_ref_search = mv_ref_blocks[mbmi->sb_type];
|
2013-06-07 20:40:42 +02:00
|
|
|
if (mbmi->sb_type < BLOCK_SIZE_SB8X8) {
|
|
|
|
x_idx = block_idx & 1;
|
|
|
|
y_idx = block_idx >> 1;
|
2012-11-16 15:31:53 +01:00
|
|
|
}
|
2013-01-03 16:14:36 +01:00
|
|
|
|
|
|
|
// We first scan for candidate vectors that match the current reference frame
|
|
|
|
// Look at nearest neigbours
|
2012-08-24 16:44:01 +02:00
|
|
|
for (i = 0; i < 2; ++i) {
|
2013-04-26 20:57:17 +02:00
|
|
|
const int mi_search_col = mi_col + mv_ref_search[i][0];
|
2013-06-10 18:21:11 +02:00
|
|
|
const int mi_search_row = mi_row + mv_ref_search[i][1];
|
2013-04-26 20:57:17 +02:00
|
|
|
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
|
|
|
|
(mi_search_col < cm->cur_tile_mi_col_end) &&
|
2013-06-10 18:21:11 +02:00
|
|
|
(mi_search_row >= 0) && (mi_search_row < cm->mi_rows)) {
|
2013-05-26 23:40:49 +02:00
|
|
|
int b;
|
2012-08-24 16:44:01 +02:00
|
|
|
|
|
|
|
candidate_mi = here + mv_ref_search[i][0] +
|
|
|
|
(mv_ref_search[i][1] * xd->mode_info_stride);
|
|
|
|
|
2013-05-26 23:40:49 +02:00
|
|
|
if (block_idx >= 0) {
|
|
|
|
if (mv_ref_search[i][0])
|
|
|
|
b = 1 + y_idx * 2;
|
|
|
|
else
|
|
|
|
b = 2 + x_idx;
|
|
|
|
} else {
|
|
|
|
b = -1;
|
|
|
|
}
|
|
|
|
if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, b)) {
|
2013-04-19 16:40:36 +02:00
|
|
|
add_candidate_mv(mv_ref_list, candidate_scores,
|
|
|
|
&refmv_count, c_refmv, 16);
|
2012-08-24 16:44:01 +02:00
|
|
|
}
|
2013-05-30 21:49:38 +02:00
|
|
|
split_count += (candidate_mi->mbmi.sb_type < BLOCK_SIZE_SB8X8 &&
|
2013-06-06 22:44:34 +02:00
|
|
|
candidate_mi->mbmi.ref_frame[0] != INTRA_FRAME);
|
2013-05-16 12:27:12 +02:00
|
|
|
|
|
|
|
// Count number of neihgbours coded intra and zeromv
|
|
|
|
intra_count += (candidate_mi->mbmi.mode < NEARESTMV);
|
|
|
|
zero_count += (candidate_mi->mbmi.mode == ZEROMV);
|
|
|
|
newmv_count += (candidate_mi->mbmi.mode >= NEWMV);
|
2012-08-24 16:44:01 +02:00
|
|
|
}
|
|
|
|
}
|
2013-04-19 12:10:16 +02:00
|
|
|
|
2013-01-03 16:14:36 +01:00
|
|
|
// More distant neigbours
|
|
|
|
for (i = 2; (i < MVREF_NEIGHBOURS) &&
|
2013-04-19 12:10:16 +02:00
|
|
|
(refmv_count < MAX_MV_REF_CANDIDATES); ++i) {
|
2013-04-26 20:57:17 +02:00
|
|
|
const int mi_search_col = mi_col + mv_ref_search[i][0];
|
2013-06-10 18:21:11 +02:00
|
|
|
const int mi_search_row = mi_row + mv_ref_search[i][1];
|
2013-04-26 20:57:17 +02:00
|
|
|
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
|
|
|
|
(mi_search_col < cm->cur_tile_mi_col_end) &&
|
2013-06-10 18:21:11 +02:00
|
|
|
(mi_search_row >= 0) && (mi_search_row < cm->mi_rows)) {
|
2012-08-24 16:44:01 +02:00
|
|
|
candidate_mi = here + mv_ref_search[i][0] +
|
|
|
|
(mv_ref_search[i][1] * xd->mode_info_stride);
|
|
|
|
|
2013-05-26 23:40:49 +02:00
|
|
|
if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1)) {
|
2013-04-19 16:40:36 +02:00
|
|
|
add_candidate_mv(mv_ref_list, candidate_scores,
|
|
|
|
&refmv_count, c_refmv, 16);
|
2013-01-03 16:14:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-24 16:44:01 +02:00
|
|
|
|
2013-04-19 12:10:16 +02:00
|
|
|
// Look in the last frame if it exists
|
|
|
|
if (lf_here && (refmv_count < MAX_MV_REF_CANDIDATES)) {
|
|
|
|
candidate_mi = lf_here;
|
2013-05-31 16:36:10 +02:00
|
|
|
if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1)) {
|
2013-04-19 16:40:36 +02:00
|
|
|
add_candidate_mv(mv_ref_list, candidate_scores,
|
|
|
|
&refmv_count, c_refmv, 16);
|
2013-04-19 12:10:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-03 16:14:36 +01:00
|
|
|
// If we have not found enough candidates consider ones where the
|
|
|
|
// reference frame does not match. Break out when we have
|
|
|
|
// MAX_MV_REF_CANDIDATES candidates.
|
|
|
|
// Look first at spatial neighbours
|
2013-04-19 12:10:16 +02:00
|
|
|
for (i = 0; (i < MVREF_NEIGHBOURS) &&
|
|
|
|
(refmv_count < MAX_MV_REF_CANDIDATES); ++i) {
|
2013-04-26 20:57:17 +02:00
|
|
|
const int mi_search_col = mi_col + mv_ref_search[i][0];
|
2013-06-10 18:21:11 +02:00
|
|
|
const int mi_search_row = mi_row + mv_ref_search[i][1];
|
2013-04-26 20:57:17 +02:00
|
|
|
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
|
|
|
|
(mi_search_col < cm->cur_tile_mi_col_end) &&
|
2013-06-10 18:21:11 +02:00
|
|
|
(mi_search_row >= 0) && (mi_search_row < cm->mi_rows)) {
|
2013-04-19 12:10:16 +02:00
|
|
|
candidate_mi = here + mv_ref_search[i][0] +
|
|
|
|
(mv_ref_search[i][1] * xd->mode_info_stride);
|
|
|
|
|
|
|
|
get_non_matching_candidates(candidate_mi, ref_frame,
|
|
|
|
&c_ref_frame, &c_refmv,
|
|
|
|
&c2_ref_frame, &c2_refmv);
|
|
|
|
|
|
|
|
if (c_ref_frame != INTRA_FRAME) {
|
|
|
|
scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias);
|
2013-04-19 16:40:36 +02:00
|
|
|
add_candidate_mv(mv_ref_list, candidate_scores,
|
|
|
|
&refmv_count, c_refmv, 1);
|
2012-08-24 16:44:01 +02:00
|
|
|
}
|
2013-01-03 16:14:36 +01:00
|
|
|
|
2013-04-19 12:10:16 +02:00
|
|
|
if (c2_ref_frame != INTRA_FRAME) {
|
|
|
|
scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias);
|
2013-04-19 16:40:36 +02:00
|
|
|
add_candidate_mv(mv_ref_list, candidate_scores,
|
|
|
|
&refmv_count, c2_refmv, 1);
|
2013-01-03 16:14:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-19 12:10:16 +02:00
|
|
|
|
2013-01-15 15:43:35 +01:00
|
|
|
// Look at the last frame if it exists
|
2013-04-19 12:10:16 +02:00
|
|
|
if (lf_here && (refmv_count < MAX_MV_REF_CANDIDATES)) {
|
2013-01-03 16:14:36 +01:00
|
|
|
candidate_mi = lf_here;
|
|
|
|
get_non_matching_candidates(candidate_mi, ref_frame,
|
|
|
|
&c_ref_frame, &c_refmv,
|
|
|
|
&c2_ref_frame, &c2_refmv);
|
|
|
|
|
|
|
|
if (c_ref_frame != INTRA_FRAME) {
|
|
|
|
scale_mv(xd, ref_frame, c_ref_frame, &c_refmv, ref_sign_bias);
|
2013-04-19 16:40:36 +02:00
|
|
|
add_candidate_mv(mv_ref_list, candidate_scores,
|
2013-04-19 12:10:16 +02:00
|
|
|
&refmv_count, c_refmv, 1);
|
2013-01-03 16:14:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (c2_ref_frame != INTRA_FRAME) {
|
|
|
|
scale_mv(xd, ref_frame, c2_ref_frame, &c2_refmv, ref_sign_bias);
|
2013-04-19 16:40:36 +02:00
|
|
|
add_candidate_mv(mv_ref_list, candidate_scores,
|
2013-04-19 12:10:16 +02:00
|
|
|
&refmv_count, c2_refmv, 1);
|
2012-08-24 16:44:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-16 12:27:12 +02:00
|
|
|
if (!intra_count) {
|
|
|
|
if (!newmv_count) {
|
|
|
|
// 0 = both zero mv
|
|
|
|
// 1 = one zero mv + one a predicted mv
|
|
|
|
// 2 = two predicted mvs
|
|
|
|
mbmi->mb_mode_context[ref_frame] = 2 - zero_count;
|
2012-11-12 16:09:25 +01:00
|
|
|
} else {
|
2013-05-16 12:27:12 +02:00
|
|
|
// 3 = one predicted/zero and one new mv
|
|
|
|
// 4 = two new mvs
|
|
|
|
mbmi->mb_mode_context[ref_frame] = 2 + newmv_count;
|
2012-11-12 16:09:25 +01:00
|
|
|
}
|
|
|
|
} else {
|
2013-05-16 12:27:12 +02:00
|
|
|
// 5 = one intra neighbour + x
|
|
|
|
// 6 = two intra neighbours
|
|
|
|
mbmi->mb_mode_context[ref_frame] = 4 + intra_count;
|
2012-11-12 16:09:25 +01:00
|
|
|
}
|
|
|
|
|
2013-04-19 16:40:36 +02:00
|
|
|
// Clamp vectors
|
2012-12-04 18:21:05 +01:00
|
|
|
for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
|
2013-04-19 16:40:36 +02:00
|
|
|
clamp_mv_ref(xd, &mv_ref_list[i]);
|
2012-11-16 17:31:32 +01:00
|
|
|
}
|
2012-08-24 16:44:01 +02:00
|
|
|
}
|