summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure1
-rw-r--r--vp9/common/vp9_blockd.h55
-rw-r--r--vp9/common/vp9_entropymode.c117
-rw-r--r--vp9/common/vp9_entropymode.h16
-rw-r--r--vp9/common/vp9_findnearmv.c57
-rw-r--r--vp9/common/vp9_findnearmv.h75
-rw-r--r--vp9/common/vp9_header.h1
-rw-r--r--vp9/common/vp9_idct.c82
-rw-r--r--vp9/common/vp9_loopfilter.c56
-rw-r--r--vp9/common/vp9_loopfilter.h3
-rw-r--r--vp9/common/vp9_modecontext.c6
-rw-r--r--vp9/common/vp9_mvref_common.c39
-rw-r--r--vp9/common/vp9_mvref_common.h26
-rw-r--r--vp9/common/vp9_onyxc_int.h16
-rw-r--r--vp9/common/vp9_postproc.c2
-rw-r--r--vp9/common/vp9_reconintra.h10
-rw-r--r--vp9/decoder/vp9_decodemv.c144
-rw-r--r--vp9/decoder/vp9_decodframe.c11
-rw-r--r--vp9/decoder/vp9_onyxd_if.c3
-rw-r--r--vp9/encoder/vp9_bitstream.c100
-rw-r--r--vp9/encoder/vp9_block.h6
-rw-r--r--vp9/encoder/vp9_dct.c56
-rw-r--r--vp9/encoder/vp9_encodeframe.c6
-rw-r--r--vp9/encoder/vp9_encodeintra.c24
-rw-r--r--vp9/encoder/vp9_encodemb.c2
-rw-r--r--vp9/encoder/vp9_encodemv.c2
-rw-r--r--vp9/encoder/vp9_modecosts.c8
-rw-r--r--vp9/encoder/vp9_onyx_if.c14
-rw-r--r--vp9/encoder/vp9_onyx_int.h6
-rw-r--r--vp9/encoder/vp9_picklpf.c32
-rw-r--r--vp9/encoder/vp9_ratectrl.c2
-rw-r--r--vp9/encoder/vp9_rdopt.c296
32 files changed, 451 insertions, 823 deletions
diff --git a/configure b/configure
index 8c22505cc..f22a2dd4d 100755
--- a/configure
+++ b/configure
@@ -240,7 +240,6 @@ HAVE_LIST="
EXPERIMENT_LIST="
csm
implicit_segmentation
- loop_dering
oneshotq
multiple_arf
non420
diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h
index 889e90ac0..9626540c3 100644
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -91,6 +91,7 @@ static INLINE int is_inter_mode(MB_PREDICTION_MODE mode) {
return mode >= NEARESTMV && mode <= SPLITMV;
}
+#define INTRA_MODE_COUNT (TM_PRED + 1)
// Segment level features.
typedef enum {
@@ -126,31 +127,7 @@ typedef enum {
#define WHT_UPSCALE_FACTOR 2
-typedef enum {
- B_DC_PRED, /* average of above and left pixels */
- B_V_PRED, /* vertical prediction */
- B_H_PRED, /* horizontal prediction */
- B_D45_PRED,
- B_D135_PRED,
- B_D117_PRED,
- B_D153_PRED,
- B_D27_PRED,
- B_D63_PRED,
- B_TM_PRED,
-
- LEFT4X4,
- ABOVE4X4,
- ZERO4X4,
- NEW4X4,
-
- B_MODE_COUNT
-} B_PREDICTION_MODE;
-
-#define VP9_BINTRAMODES (LEFT4X4)
-#define VP9_SUBMVREFS (1 + NEW4X4 - LEFT4X4)
-
-#define VP9_KF_BINTRAMODES (VP9_BINTRAMODES) /* 10 */
-#define VP9_NKF_BINTRAMODES (VP9_BINTRAMODES) /* 10 */
+#define VP9_BINTRAMODES INTRA_MODE_COUNT
/* For keyframes, intra block modes are predicted by the (already decoded)
modes for the Y blocks to the left and above us; for interframes, there
@@ -260,7 +237,7 @@ typedef struct {
typedef struct {
MB_MODE_INFO mbmi;
- union b_mode_info bmi[16];
+ union b_mode_info bmi[4];
} MODE_INFO;
struct scale_factors {
@@ -538,25 +515,6 @@ static BLOCK_SIZE_TYPE get_subsize(BLOCK_SIZE_TYPE bsize,
return subsize;
}
-// convert MB_PREDICTION_MODE to B_PREDICTION_MODE
-static MB_PREDICTION_MODE pred_mode_conv(MB_PREDICTION_MODE mode) {
- switch (mode) {
- case DC_PRED: return DC_PRED;
- case V_PRED: return V_PRED;
- case H_PRED: return H_PRED;
- case TM_PRED: return TM_PRED;
- case D45_PRED: return D45_PRED;
- case D135_PRED: return D135_PRED;
- case D117_PRED: return D117_PRED;
- case D153_PRED: return D153_PRED;
- case D27_PRED: return D27_PRED;
- case D63_PRED: return D63_PRED;
- default:
- assert(0);
- return MB_MODE_COUNT; // Dummy value
- }
-}
-
// transform mapping
static TX_TYPE txfm_map(MB_PREDICTION_MODE bmode) {
switch (bmode) {
@@ -579,7 +537,6 @@ static TX_TYPE txfm_map(MB_PREDICTION_MODE bmode) {
}
}
-
static TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, int ib) {
TX_TYPE tx_type = DCT_DCT;
if (xd->lossless)
@@ -588,7 +545,7 @@ static TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, int ib) {
tx_type = txfm_map(
xd->mode_info_context->bmi[ib].as_mode.first);
} else if (xd->mode_info_context->mbmi.mode <= TM_PRED) {
- tx_type = txfm_map(pred_mode_conv(xd->mode_info_context->mbmi.mode));
+ tx_type = txfm_map(xd->mode_info_context->mbmi.mode);
}
return tx_type;
}
@@ -596,7 +553,7 @@ static TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, int ib) {
static TX_TYPE get_tx_type_8x8(const MACROBLOCKD *xd, int ib) {
TX_TYPE tx_type = DCT_DCT;
if (xd->mode_info_context->mbmi.mode <= TM_PRED) {
- tx_type = txfm_map(pred_mode_conv(xd->mode_info_context->mbmi.mode));
+ tx_type = txfm_map(xd->mode_info_context->mbmi.mode);
}
return tx_type;
}
@@ -604,7 +561,7 @@ static TX_TYPE get_tx_type_8x8(const MACROBLOCKD *xd, int ib) {
static TX_TYPE get_tx_type_16x16(const MACROBLOCKD *xd, int ib) {
TX_TYPE tx_type = DCT_DCT;
if (xd->mode_info_context->mbmi.mode <= TM_PRED) {
- tx_type = txfm_map(pred_mode_conv(xd->mode_info_context->mbmi.mode));
+ tx_type = txfm_map(xd->mode_info_context->mbmi.mode);
}
return tx_type;
}
diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c
index 5474f72c9..622f1dcf4 100644
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -29,7 +29,7 @@ static const unsigned int kf_y_mode_cts[8][VP9_YMODES] = {
static const unsigned int y_mode_cts [VP9_YMODES] = {
/* DC V H D45 135 117 153 D27 D63 TM i4X4 */
- 98, 19, 15, 14, 14, 14, 14, 12, 12, 13, 70
+ 98, 19, 15, 14, 14, 14, 14, 12, 12, 13, 0
};
static const unsigned int uv_mode_cts [VP9_YMODES] [VP9_UV_MODES] = {
@@ -62,47 +62,11 @@ static const unsigned int kf_uv_mode_cts [VP9_YMODES] [VP9_UV_MODES] = {
{ 122, 41, 35, 20, 20, 20, 20, 20, 20, 18}, /* I4X4 */
};
-static const unsigned int bmode_cts[VP9_NKF_BINTRAMODES] = {
+static const unsigned int bmode_cts[VP9_BINTRAMODES] = {
/* DC V H D45 D135 D117 D153 D27 D63 TM */
43891, 10036, 3920, 3363, 2546, 5119, 2471, 1723, 3221, 17694
};
-typedef enum {
- SUBMVREF_NORMAL,
- SUBMVREF_LEFT_ZED,
- SUBMVREF_ABOVE_ZED,
- SUBMVREF_LEFT_ABOVE_SAME,
- SUBMVREF_LEFT_ABOVE_ZED
-} sumvfref_t;
-
-int vp9_mv_cont(const int_mv *l, const int_mv *a) {
- const int lez = (l->as_int == 0);
- const int aez = (a->as_int == 0);
- const int lea = (l->as_int == a->as_int);
-
- if (lea && lez)
- return SUBMVREF_LEFT_ABOVE_ZED;
-
- if (lea)
- return SUBMVREF_LEFT_ABOVE_SAME;
-
- if (aez)
- return SUBMVREF_ABOVE_ZED;
-
- if (lez)
- return SUBMVREF_LEFT_ZED;
-
- return SUBMVREF_NORMAL;
-}
-
-const vp9_prob vp9_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP9_SUBMVREFS - 1] = {
- { 147, 136, 18 },
- { 106, 145, 1 },
- { 179, 121, 1 },
- { 223, 1, 34 },
- { 208, 1, 1 }
-};
-
const vp9_prob vp9_partition_probs[NUM_PARTITION_CONTEXTS]
[PARTITION_TYPES - 1] = {
// FIXME(jingning,rbultje) put real probabilities here
@@ -125,29 +89,16 @@ const vp9_prob vp9_partition_probs[NUM_PARTITION_CONTEXTS]
};
/* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
-
-const vp9_tree_index vp9_kf_bmode_tree[VP9_KF_BINTRAMODES * 2 - 2] = {
- -B_DC_PRED, 2, /* 0 = DC_NODE */
- -B_TM_PRED, 4, /* 1 = TM_NODE */
- -B_V_PRED, 6, /* 2 = V_NODE */
- 8, 12, /* 3 = COM_NODE */
- -B_H_PRED, 10, /* 4 = H_NODE */
- -B_D135_PRED, -B_D117_PRED, /* 5 = D135_NODE */
- -B_D45_PRED, 14, /* 6 = D45_NODE */
- -B_D63_PRED, 16, /* 7 = D63_NODE */
- -B_D153_PRED, -B_D27_PRED /* 8 = D153_NODE */
-};
-
-const vp9_tree_index vp9_bmode_tree[VP9_NKF_BINTRAMODES * 2 - 2] = {
- -B_DC_PRED, 2, /* 0 = DC_NODE */
- -B_TM_PRED, 4, /* 1 = TM_NODE */
- -B_V_PRED, 6, /* 2 = V_NODE */
- 8, 12, /* 3 = COM_NODE */
- -B_H_PRED, 10, /* 4 = H_NODE */
- -B_D135_PRED, -B_D117_PRED, /* 5 = D135_NODE */
- -B_D45_PRED, 14, /* 6 = D45_NODE */
- -B_D63_PRED, 16, /* 7 = D63_NODE */
- -B_D153_PRED, -B_D27_PRED /* 8 = D153_NODE */
+const vp9_tree_index vp9_bmode_tree[VP9_BINTRAMODES * 2 - 2] = {
+ -DC_PRED, 2, /* 0 = DC_NODE */
+ -TM_PRED, 4, /* 1 = TM_NODE */
+ -V_PRED, 6, /* 2 = V_NODE */
+ 8, 12, /* 3 = COM_NODE */
+ -H_PRED, 10, /* 4 = H_NODE */
+ -D135_PRED, -D117_PRED, /* 5 = D135_NODE */
+ -D45_PRED, 14, /* 6 = D45_NODE */
+ -D63_PRED, 16, /* 7 = D63_NODE */
+ -D153_PRED, -D27_PRED /* 8 = D153_NODE */
};
/* Again, these trees use the same probability indices as their
@@ -203,20 +154,14 @@ const vp9_tree_index vp9_sb_mv_ref_tree[6] = {
-NEARMV, -NEWMV
};
-const vp9_tree_index vp9_sub_mv_ref_tree[6] = {
- -LEFT4X4, 2,
- -ABOVE4X4, 4,
- -ZERO4X4, -NEW4X4
-};
-
const vp9_tree_index vp9_partition_tree[6] = {
-PARTITION_NONE, 2,
-PARTITION_HORZ, 4,
-PARTITION_VERT, -PARTITION_SPLIT
};
-struct vp9_token vp9_bmode_encodings[VP9_NKF_BINTRAMODES];
-struct vp9_token vp9_kf_bmode_encodings[VP9_KF_BINTRAMODES];
+struct vp9_token vp9_bmode_encodings[VP9_BINTRAMODES];
+struct vp9_token vp9_kf_bmode_encodings[VP9_BINTRAMODES];
struct vp9_token vp9_ymode_encodings[VP9_YMODES];
struct vp9_token vp9_sb_ymode_encodings[VP9_I32X32_MODES];
struct vp9_token vp9_sb_kf_ymode_encodings[VP9_I32X32_MODES];
@@ -225,7 +170,6 @@ struct vp9_token vp9_uv_mode_encodings[VP9_UV_MODES];
struct vp9_token vp9_mv_ref_encoding_array[VP9_MVREFS];
struct vp9_token vp9_sb_mv_ref_encoding_array[VP9_MVREFS];
-struct vp9_token vp9_sub_mv_ref_encoding_array[VP9_SUBMVREFS];
struct vp9_token vp9_partition_encodings[PARTITION_TYPES];
@@ -252,8 +196,6 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) {
bct, uv_mode_cts[i], 0);
}
- vpx_memcpy(x->fc.sub_mv_ref_prob, vp9_sub_mv_ref_prob2,
- sizeof(vp9_sub_mv_ref_prob2));
vpx_memcpy(x->fc.switchable_interp_prob, vp9_switchable_interp_prob,
sizeof(vp9_switchable_interp_prob));
@@ -267,14 +209,14 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) {
static void intra_bmode_probs_from_distribution(
- vp9_prob p[VP9_NKF_BINTRAMODES - 1],
- unsigned int branch_ct[VP9_NKF_BINTRAMODES - 1][2],
- const unsigned int events[VP9_NKF_BINTRAMODES]) {
+ vp9_prob p[VP9_BINTRAMODES - 1],
+ unsigned int branch_ct[VP9_BINTRAMODES - 1][2],
+ const unsigned int events[VP9_BINTRAMODES]) {
vp9_tree_probs_from_distribution(vp9_bmode_tree, p, branch_ct, events, 0);
}
-void vp9_default_bmode_probs(vp9_prob p[VP9_NKF_BINTRAMODES - 1]) {
- unsigned int branch_ct[VP9_NKF_BINTRAMODES - 1][2];
+void vp9_default_bmode_probs(vp9_prob p[VP9_BINTRAMODES - 1]) {
+ unsigned int branch_ct[VP9_BINTRAMODES - 1][2];
intra_bmode_probs_from_distribution(p, branch_ct, bmode_cts);
}
@@ -312,7 +254,7 @@ const int vp9_switchable_interp_map[SWITCHABLE+1] = {-1, 0, 1, -1, -1};
const int vp9_is_interpolating_filter[SWITCHABLE + 1] = {0, 1, 1, 1, -1};
void vp9_entropy_mode_init() {
- vp9_tokens_from_tree(vp9_kf_bmode_encodings, vp9_kf_bmode_tree);
+ vp9_tokens_from_tree(vp9_kf_bmode_encodings, vp9_bmode_tree);
vp9_tokens_from_tree(vp9_bmode_encodings, vp9_bmode_tree);
vp9_tokens_from_tree(vp9_ymode_encodings, vp9_ymode_tree);
vp9_tokens_from_tree(vp9_kf_ymode_encodings, vp9_kf_ymode_tree);
@@ -327,8 +269,6 @@ void vp9_entropy_mode_init() {
vp9_mv_ref_tree, NEARESTMV);
vp9_tokens_from_tree_offset(vp9_sb_mv_ref_encoding_array,
vp9_sb_mv_ref_tree, NEARESTMV);
- vp9_tokens_from_tree_offset(vp9_sub_mv_ref_encoding_array,
- vp9_sub_mv_ref_tree, LEFT4X4);
}
void vp9_init_mode_contexts(VP9_COMMON *pc) {
@@ -438,15 +378,6 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
for (t = 0; t < VP9_I8X8_MODES; ++t)
printf("%d, ", fc->i8x8_mode_counts[t]);
printf("};\n");
- printf("static const unsigned int\nsub_mv_ref_counts"
- "[SUBMVREF_COUNT] [VP9_SUBMVREFS] = {\n");
- for (i = 0; i < SUBMVREF_COUNT; ++i) {
- printf(" {");
- for (t = 0; t < VP9_SUBMVREFS; ++t)
- printf("%d, ", fc->sub_mv_ref_counts[i][t]);
- printf("},\n");
- }
- printf("};\n");
printf("static const unsigned int\nmbsplit_counts"
"[VP9_NUMMBSPLITS] = {\n");
for (t = 0; t < VP9_NUMMBSPLITS; ++t)
@@ -466,16 +397,10 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
fc->uv_mode_counts[i], fc->pre_uv_mode_prob[i],
fc->uv_mode_prob[i], 0);
- update_mode_probs(VP9_NKF_BINTRAMODES, vp9_bmode_tree,
+ update_mode_probs(VP9_BINTRAMODES, vp9_bmode_tree,
fc->bmode_counts, fc->pre_bmode_prob,
fc->bmode_prob, 0);
- for (i = 0; i < SUBMVREF_COUNT; ++i)
- update_mode_probs(VP9_SUBMVREFS,
- vp9_sub_mv_ref_tree, fc->sub_mv_ref_counts[i],
- fc->pre_sub_mv_ref_prob[i], fc->sub_mv_ref_prob[i],
- LEFT4X4);
-
for (i = 0; i < NUM_PARTITION_CONTEXTS; i++)
update_mode_probs(PARTITION_TYPES, vp9_partition_tree,
fc->partition_counts[i], fc->pre_partition_prob[i],
diff --git a/vp9/common/vp9_entropymode.h b/vp9/common/vp9_entropymode.h
index 08bb2d6be..8fbc6f20e 100644
--- a/vp9/common/vp9_entropymode.h
+++ b/vp9/common/vp9_entropymode.h
@@ -18,15 +18,12 @@
extern int vp9_mv_cont(const int_mv *l, const int_mv *a);
-extern const vp9_prob vp9_sub_mv_ref_prob2[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
-extern const vp9_prob vp9_kf_default_bmode_probs[VP9_KF_BINTRAMODES]
- [VP9_KF_BINTRAMODES]
- [VP9_KF_BINTRAMODES -1 ];
+extern const vp9_prob vp9_kf_default_bmode_probs[VP9_BINTRAMODES]
+ [VP9_BINTRAMODES]
+ [VP9_BINTRAMODES -1 ];
extern const vp9_tree_index vp9_bmode_tree[];
-extern const vp9_tree_index vp9_kf_bmode_tree[];
-
extern const vp9_tree_index vp9_ymode_tree[];
extern const vp9_tree_index vp9_kf_ymode_tree[];
extern const vp9_tree_index vp9_uv_mode_tree[];
@@ -36,8 +33,8 @@ extern const vp9_tree_index vp9_mv_ref_tree[];
extern const vp9_tree_index vp9_sb_mv_ref_tree[];
extern const vp9_tree_index vp9_sub_mv_ref_tree[];
-extern struct vp9_token vp9_bmode_encodings[VP9_NKF_BINTRAMODES];
-extern struct vp9_token vp9_kf_bmode_encodings[VP9_KF_BINTRAMODES];
+extern struct vp9_token vp9_bmode_encodings[VP9_BINTRAMODES];
+extern struct vp9_token vp9_kf_bmode_encodings[VP9_BINTRAMODES];
extern struct vp9_token vp9_ymode_encodings[VP9_YMODES];
extern struct vp9_token vp9_sb_ymode_encodings[VP9_I32X32_MODES];
extern struct vp9_token vp9_sb_kf_ymode_encodings[VP9_I32X32_MODES];
@@ -48,7 +45,6 @@ extern struct vp9_token vp9_uv_mode_encodings[VP9_UV_MODES];
extern struct vp9_token vp9_mv_ref_encoding_array[VP9_MVREFS];
extern struct vp9_token vp9_sb_mv_ref_encoding_array[VP9_MVREFS];
-extern struct vp9_token vp9_sub_mv_ref_encoding_array[VP9_SUBMVREFS];
// probability models for partition information
extern const vp9_tree_index vp9_partition_tree[];
@@ -71,7 +67,7 @@ extern void vp9_accum_mv_refs(struct VP9Common *pc,
MB_PREDICTION_MODE m,
const int context);
-void vp9_default_bmode_probs(vp9_prob dest[VP9_NKF_BINTRAMODES - 1]);
+void vp9_default_bmode_probs(vp9_prob dest[VP9_BINTRAMODES - 1]);
void vp9_adapt_mode_probs(struct VP9Common *);
diff --git a/vp9/common/vp9_findnearmv.c b/vp9/common/vp9_findnearmv.c
index b5a32d9b3..5e14a8c43 100644
--- a/vp9/common/vp9_findnearmv.c
+++ b/vp9/common/vp9_findnearmv.c
@@ -11,6 +11,7 @@
#include <limits.h>
#include "vp9/common/vp9_findnearmv.h"
+#include "vp9/common/vp9_mvref_common.h"
#include "vp9/common/vp9_sadmxn.h"
#include "vp9/common/vp9_subpelvar.h"
@@ -51,3 +52,59 @@ void vp9_find_best_ref_mvs(MACROBLOCKD *xd,
*nearest = mvlist[0];
*near = mvlist[1];
}
+
+void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
+ int_mv *dst_nearest,
+ int_mv *dst_near,
+ int block_idx, int ref_idx) {
+ int_mv dst_list[MAX_MV_REF_CANDIDATES];
+ int_mv mv_list[MAX_MV_REF_CANDIDATES];
+ MODE_INFO *mi = xd->mode_info_context;
+ MB_MODE_INFO *const mbmi = &mi->mbmi;
+ int use_prev_in_find_mv_refs;
+
+ assert(ref_idx == 0 || ref_idx == 1);
+ assert(MAX_MV_REF_CANDIDATES == 2); // makes code here slightly easier
+
+ use_prev_in_find_mv_refs = cm->width == cm->last_width &&
+ cm->height == cm->last_height &&
+ !cm->error_resilient_mode &&
+ cm->last_show_frame;
+ vp9_find_mv_refs_idx(cm, xd, xd->mode_info_context,
+ use_prev_in_find_mv_refs ?
+ xd->prev_mode_info_context : NULL,
+ ref_idx ? mbmi->second_ref_frame : mbmi->ref_frame,
+ mv_list, cm->ref_frame_sign_bias, block_idx);
+
+ dst_list[1].as_int = 0;
+ if (block_idx == 0) {
+ memcpy(dst_list, mv_list, MAX_MV_REF_CANDIDATES * sizeof(int_mv));
+ } else if (block_idx == 1 || block_idx == 2) {
+ int dst = 0, n;
+ union b_mode_info *bmi = mi->bmi;
+
+ dst_list[dst++].as_int = bmi[0].as_mv[ref_idx].as_int;
+ for (n = 0; dst < MAX_MV_REF_CANDIDATES &&
+ n < MAX_MV_REF_CANDIDATES; n++)
+ if (mv_list[n].as_int != dst_list[0].as_int)
+ dst_list[dst++].as_int = mv_list[n].as_int;
+ } else {
+ int dst = 0, n;
+ union b_mode_info *bmi = mi->bmi;
+
+ assert(block_idx == 3);
+ dst_list[dst++].as_int = bmi[2].as_mv[ref_idx].as_int;
+ if (dst_list[0].as_int != bmi[1].as_mv[ref_idx].as_int)
+ dst_list[dst++].as_int = bmi[1].as_mv[ref_idx].as_int;
+ if (dst < MAX_MV_REF_CANDIDATES &&
+ dst_list[0].as_int != bmi[0].as_mv[ref_idx].as_int)
+ dst_list[dst++].as_int = bmi[0].as_mv[ref_idx].as_int;
+ for (n = 0; dst < MAX_MV_REF_CANDIDATES &&
+ n < MAX_MV_REF_CANDIDATES; n++)
+ if (mv_list[n].as_int != dst_list[0].as_int)
+ dst_list[dst++].as_int = mv_list[n].as_int;
+ }
+
+ dst_nearest->as_int = dst_list[0].as_int;
+ dst_near->as_int = dst_list[1].as_int;
+}
diff --git a/vp9/common/vp9_findnearmv.h b/vp9/common/vp9_findnearmv.h
index 027e063f7..bc5afb12d 100644
--- a/vp9/common/vp9_findnearmv.h
+++ b/vp9/common/vp9_findnearmv.h
@@ -74,72 +74,11 @@ vp9_prob *vp9_mv_ref_probs(VP9_COMMON *pc,
vp9_prob p[VP9_MVREFS - 1],
const int context);
-static int left_block_mv(const MACROBLOCKD *xd,
- const MODE_INFO *cur_mb, int b) {
- if (!(b & 1)) {
- if (!xd->left_available)
- return 0;
-
- // On L edge, get from MB to left of us
- --cur_mb;
-
- if (cur_mb->mbmi.mode != SPLITMV)
- return cur_mb->mbmi.mv[0].as_int;
-
- b += 2;
- }
-
- return (cur_mb->bmi + b - 1)->as_mv[0].as_int;
-}
-
-static int left_block_second_mv(const MACROBLOCKD *xd,
- const MODE_INFO *cur_mb, int b) {
- if (!(b & 1)) {
- if (!xd->left_available)
- return 0;
-
- /* On L edge, get from MB to left of us */
- --cur_mb;
-
- if (cur_mb->mbmi.mode != SPLITMV)
- return cur_mb->mbmi.second_ref_frame > 0 ?
- cur_mb->mbmi.mv[1].as_int : cur_mb->mbmi.mv[0].as_int;
- b += 2;
- }
-
- return cur_mb->mbmi.second_ref_frame > 0 ?
- (cur_mb->bmi + b - 1)->as_mv[1].as_int :
- (cur_mb->bmi + b - 1)->as_mv[0].as_int;
-}
-
-static int above_block_mv(const MODE_INFO *cur_mb, int b, int mi_stride) {
- if (!(b >> 1)) {
- /* On top edge, get from MB above us */
- cur_mb -= mi_stride;
-
- if (cur_mb->mbmi.mode != SPLITMV)
- return cur_mb->mbmi.mv[0].as_int;
- b += 4;
- }
-
- return (cur_mb->bmi + b - 2)->as_mv[0].as_int;
-}
-
-static int above_block_second_mv(const MODE_INFO *cur_mb, int b, int mi_stride) {
- if (!(b >> 1)) {
- /* On top edge, get from MB above us */
- cur_mb -= mi_stride;
-
- if (cur_mb->mbmi.mode != SPLITMV)
- return cur_mb->mbmi.second_ref_frame > 0 ?
- cur_mb->mbmi.mv[1].as_int : cur_mb->mbmi.mv[0].as_int;
- b += 4;
- }
-
- return cur_mb->mbmi.second_ref_frame > 0 ?
- (cur_mb->bmi + b - 2)->as_mv[1].as_int :
- (cur_mb->bmi + b - 2)->as_mv[0].as_int;
-}
+void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *pc,
+ MACROBLOCKD *xd,
+ int_mv *dst_nearest,
+ int_mv *dst_near,
+ int block_idx, int ref_idx);
static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b) {
// FIXME(rbultje, jingning): temporary hack because jenkins doesn't
@@ -149,7 +88,7 @@ static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b) {
--cur_mb;
if (cur_mb->mbmi.mode <= TM_PRED) {
- return pred_mode_conv(cur_mb->mbmi.mode);
+ return cur_mb->mbmi.mode;
} else if (cur_mb->mbmi.mode == I4X4_PRED) {
return ((cur_mb->bmi + 1 + b)->as_mode.first);
} else {
@@ -167,7 +106,7 @@ static MB_PREDICTION_MODE above_block_mode(const MODE_INFO *cur_mb,
cur_mb -= mi_stride;
if (cur_mb->mbmi.mode <= TM_PRED) {
- return pred_mode_conv(cur_mb->mbmi.mode);
+ return cur_mb->mbmi.mode;
} else if (cur_mb->mbmi.mode == I4X4_PRED) {
return ((cur_mb->bmi + 2 + b)->as_mode.first);
} else {
diff --git a/vp9/common/vp9_header.h b/vp9/common/vp9_header.h
index c51ce135d..96b04e7d7 100644
--- a/vp9/common/vp9_header.h
+++ b/vp9/common/vp9_header.h
@@ -28,7 +28,6 @@ typedef struct {
unsigned int update_last: 1;
unsigned int uses_last: 1;
#endif
-
} VP9_HEADER;
#ifdef PACKET_TESTING
diff --git a/vp9/common/vp9_idct.c b/vp9/common/vp9_idct.c
index f61230c80..026ba913d 100644
--- a/vp9/common/vp9_idct.c
+++ b/vp9/common/vp9_idct.c
@@ -19,22 +19,32 @@
#include "vp9/common/vp9_idct.h"
void vp9_short_iwalsh4x4_add_c(int16_t *input, uint8_t *dest, int dest_stride) {
+/* 4-point reversible, orthonormal inverse Walsh-Hadamard in 3.5 adds,
+ 0.5 shifts per pixel. */
int i;
int16_t output[16];
- int a1, b1, c1, d1;
+ int a1, b1, c1, d1, e1;
int16_t *ip = input;
int16_t *op = output;
for (i = 0; i < 4; i++) {
- a1 = (ip[0] + ip[3]) >> WHT_UPSCALE_FACTOR;
- b1 = (ip[1] + ip[2]) >> WHT_UPSCALE_FACTOR;
- c1 = (ip[1] - ip[2]) >> WHT_UPSCALE_FACTOR;
- d1 = (ip[0] - ip[3]) >> WHT_UPSCALE_FACTOR;
-
- op[0] = (a1 + b1 + 1) >> 1;
- op[1] = (c1 + d1) >> 1;
- op[2] = (a1 - b1) >> 1;
- op[3] = (d1 - c1) >> 1;
+ a1 = ip[0] >> WHT_UPSCALE_FACTOR;
+ c1 = ip[1] >> WHT_UPSCALE_FACTOR;
+ d1 = ip[2] >> WHT_UPSCALE_FACTOR;
+ b1 = ip[3] >> WHT_UPSCALE_FACTOR;
+
+ c1 = a1 - c1;
+ b1 += d1;
+ e1 = (c1 - b1) >> 1;
+ a1 -= e1;
+ d1 += e1;
+ b1 = a1 - b1;
+ c1 -= d1;
+
+ op[0] = a1;
+ op[1] = b1;
+ op[2] = c1;
+ op[3] = d1;
ip += 4;
op += 4;
@@ -42,20 +52,23 @@ void vp9_short_iwalsh4x4_add_c(int16_t *input, uint8_t *dest, int dest_stride) {
ip = output;
for (i = 0; i < 4; i++) {
- a1 = ip[4 * 0] + ip[4 * 3];
- b1 = ip[4 * 1] + ip[4 * 2];
- c1 = ip[4 * 1] - ip[4 * 2];
- d1 = ip[4 * 0] - ip[4 * 3];
-
-
- dest[dest_stride * 0] = clip_pixel(dest[dest_stride * 0] +
- ((a1 + b1 + 1) >> 1));
- dest[dest_stride * 1] = clip_pixel(dest[dest_stride * 1] +
- ((c1 + d1) >> 1));
- dest[dest_stride * 2] = clip_pixel(dest[dest_stride * 2] +
- ((a1 - b1) >> 1));
- dest[dest_stride * 3] = clip_pixel(dest[dest_stride * 3] +
- ((d1 - c1) >> 1));
+ a1 = ip[4 * 0];
+ c1 = ip[4 * 1];
+ d1 = ip[4 * 2];
+ b1 = ip[4 * 3];
+
+ c1 = a1 - c1;
+ b1 += d1;
+ e1 = (c1 - b1) >> 1;
+ a1 -= e1;
+ d1 += e1;
+ b1 = a1 - b1;
+ c1 -= d1;
+
+ dest[dest_stride * 0] = clip_pixel(dest[dest_stride * 0] + a1);
+ dest[dest_stride * 1] = clip_pixel(dest[dest_stride * 1] + b1);
+ dest[dest_stride * 2] = clip_pixel(dest[dest_stride * 2] + c1);
+ dest[dest_stride * 3] = clip_pixel(dest[dest_stride * 3] + d1);
ip++;
dest++;
@@ -64,23 +77,24 @@ void vp9_short_iwalsh4x4_add_c(int16_t *input, uint8_t *dest, int dest_stride) {
void vp9_short_iwalsh4x4_1_add_c(int16_t *in, uint8_t *dest, int dest_stride) {
int i;
+ int a1, e1;
int16_t tmp[4];
int16_t *ip = in;
int16_t *op = tmp;
- op[0] = ((ip[0] >> WHT_UPSCALE_FACTOR) + 1) >> 1;
- op[1] = op[2] = op[3] = (ip[0] >> WHT_UPSCALE_FACTOR) >> 1;
+ a1 = ip[0] >> WHT_UPSCALE_FACTOR;
+ e1 = a1 >> 1;
+ op[0] = op[1] = op[2] = a1 - e1;
+ op[3] = e1;
ip = tmp;
for (i = 0; i < 4; i++) {
- dest[dest_stride * 0] = clip_pixel(dest[dest_stride * 0] +
- ((ip[0] + 1) >> 1));
- dest[dest_stride * 1] = clip_pixel(dest[dest_stride * 1] +
- (ip[0] >> 1));
- dest[dest_stride * 2] = clip_pixel(dest[dest_stride * 2] +
- (ip[0] >> 1));
- dest[dest_stride * 3] = clip_pixel(dest[dest_stride * 3] +
- (ip[0] >> 1));
+ e1 = ip[0] >> 1;
+ a1 = ip[0] - e1;
+ dest[dest_stride * 0] = clip_pixel(dest[dest_stride * 0] + a1);
+ dest[dest_stride * 1] = clip_pixel(dest[dest_stride * 1] + a1);
+ dest[dest_stride * 2] = clip_pixel(dest[dest_stride * 2] + a1);
+ dest[dest_stride * 3] = clip_pixel(dest[dest_stride * 3] + e1);
ip++;
dest++;
}
diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c
index b668212fc..ab1499485 100644
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -187,7 +187,7 @@ static void lpf_mb(VP9_COMMON *cm, const MODE_INFO *mi,
int do_left_mb_v, int do_above_mb_h,
int do_left_mbuv_v, int do_above_mbuv_h,
uint8_t *y_ptr, uint8_t *u_ptr, uint8_t *v_ptr,
- int y_stride, int uv_stride, int dering) {
+ int y_stride, int uv_stride) {
loop_filter_info_n *lfi_n = &cm->lf_info;
struct loop_filter_info lfi;
int mode = mi->mbmi.mode;
@@ -254,21 +254,6 @@ static void lpf_mb(VP9_COMMON *cm, const MODE_INFO *mi,
y_stride, uv_stride, &lfi);
}
}
- if (dering) {
-#if CONFIG_LOOP_DERING
- vp9_post_proc_down_and_across(y_ptr, y_ptr,
- y_stride, y_stride,
- 16, 16, dering);
- if (u_ptr && v_ptr) {
- vp9_post_proc_down_and_across(u_ptr, u_ptr,
- uv_stride, uv_stride,
- 8, 8, dering);
- vp9_post_proc_down_and_across(v_ptr, v_ptr,
- uv_stride, uv_stride,
- 8, 8, dering);
- }
-#endif
- }
}
}
@@ -276,7 +261,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
int mb_row, int mb_col,
uint8_t *y_ptr, uint8_t *u_ptr, uint8_t *v_ptr,
int y_stride, int uv_stride,
- int y_only, int dering) {
+ int y_only) {
BLOCK_SIZE_TYPE sb_type = mode_info_context->mbmi.sb_type;
const int wbl = b_width_log2(sb_type), hbl = b_height_log2(sb_type);
TX_SIZE tx_size = mode_info_context->mbmi.txfm_size;
@@ -298,7 +283,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
y_ptr,
y_only? 0 : u_ptr,
y_only? 0 : v_ptr,
- y_stride, uv_stride, dering);
+ y_stride, uv_stride);
// process 2nd MB top-right
mi = mode_info_context + 2;
do_left_v = !(wbl >= 3 /* 32x16 or >=32x32 */ && (tx_size >= TX_32X32 ||
@@ -313,7 +298,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
y_ptr + 16,
y_only ? 0 : (u_ptr + 8),
y_only ? 0 : (v_ptr + 8),
- y_stride, uv_stride, dering);
+ y_stride, uv_stride);
// process 3rd MB bottom-left
mi = mode_info_context + (mis << 1);
@@ -329,7 +314,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
y_ptr + 16 * y_stride,
y_only ? 0 : (u_ptr + 8 * uv_stride),
y_only ? 0 : (v_ptr + 8 * uv_stride),
- y_stride, uv_stride, dering);
+ y_stride, uv_stride);
// process 4th MB bottom right
mi = mode_info_context + ((mis + 1) << 1);
@@ -346,39 +331,38 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
y_ptr + 16 * y_stride + 16,
y_only ? 0 : (u_ptr + 8 * uv_stride + 8),
y_only ? 0 : (v_ptr + 8 * uv_stride + 8),
- y_stride, uv_stride, dering);
+ y_stride, uv_stride);
}
static void lpf_sb64(VP9_COMMON *cm, const MODE_INFO *mode_info_context,
int mb_row, int mb_col,
uint8_t *y_ptr, uint8_t *u_ptr, uint8_t *v_ptr,
int y_stride, int uv_stride,
- int y_only, int dering) {
+ int y_only) {
lpf_sb32(cm, mode_info_context, mb_row, mb_col,
y_ptr, u_ptr, v_ptr,
- y_stride, uv_stride, y_only, dering);
+ y_stride, uv_stride, y_only);
lpf_sb32(cm, mode_info_context + 4, mb_row, mb_col + 2,
y_ptr + 32, u_ptr + 16, v_ptr + 16,
- y_stride, uv_stride, y_only, dering);
+ y_stride, uv_stride, y_only);
lpf_sb32(cm, mode_info_context + cm->mode_info_stride * 4,
mb_row + 2, mb_col,
y_ptr + 32 * y_stride,
u_ptr + 16 * uv_stride,
v_ptr + 16 * uv_stride,
- y_stride, uv_stride, y_only, dering);
+ y_stride, uv_stride, y_only);
lpf_sb32(cm, mode_info_context + cm->mode_info_stride * 4 + 4,
mb_row + 2, mb_col + 2,
y_ptr + 32 * y_stride + 32,
u_ptr + 16 * uv_stride + 16,
v_ptr + 16 * uv_stride + 16,
- y_stride, uv_stride, y_only, dering);
+ y_stride, uv_stride, y_only);
}
void vp9_loop_filter_frame(VP9_COMMON *cm,
MACROBLOCKD *xd,
int frame_filter_level,
- int y_only,
- int dering) {
+ int y_only) {
YV12_BUFFER_CONFIG *post = cm->frame_to_show;
int mb_row, mb_col;
const int sb64_rows = cm->mb_rows / 4;
@@ -432,7 +416,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
for (mb_col = 0; mb_col < sb64_cols * 4; mb_col += 4) {
lpf_sb64(cm, mode_info_context, mb_row, mb_col,
y_ptr, u_ptr, v_ptr,
- y_stride, uv_stride, y_only, dering);
+ y_stride, uv_stride, y_only);
y_ptr += 64;
u_ptr = y_only? 0 : u_ptr + 32;
v_ptr = y_only? 0 : v_ptr + 32;
@@ -442,13 +426,13 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
// process 2 SB32s in the extra SB32 col
lpf_sb32(cm, mode_info_context, mb_row, mb_col,
y_ptr, u_ptr, v_ptr,
- y_stride, uv_stride, y_only, dering);
+ y_stride, uv_stride, y_only);
lpf_sb32(cm, mode_info_context + mis * 4,
mb_row + 2, mb_col,
y_ptr + 32 * y_stride,
u_ptr + 16 * uv_stride,
v_ptr + 16 * uv_stride,
- y_stride, uv_stride, y_only, dering);
+ y_stride, uv_stride, y_only);
y_ptr += 32;
u_ptr = y_only? 0 : u_ptr + 16;
v_ptr = y_only? 0 : v_ptr + 16;
@@ -469,7 +453,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr + (k * 16) * y_stride,
y_only ? 0 : (u_ptr + (k * 8) * uv_stride),
y_only ? 0 : (v_ptr + (k * 8) * uv_stride),
- y_stride, uv_stride, dering);
+ y_stride, uv_stride);
}
y_ptr += 16;
@@ -491,7 +475,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
for (mb_col = 0; mb_col < sb32_cols * 2; mb_col += 2) {
lpf_sb32(cm, mode_info_context, mb_row, mb_col,
y_ptr, u_ptr, v_ptr,
- y_stride, uv_stride, y_only, dering);
+ y_stride, uv_stride, y_only);
y_ptr += 32;
u_ptr = y_only? 0 : u_ptr + 16;
v_ptr = y_only? 0 : v_ptr + 16;
@@ -509,7 +493,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr,
y_only? NULL : u_ptr,
y_only? NULL : v_ptr,
- y_stride, uv_stride, dering);
+ y_stride, uv_stride);
// process 2nd MB
mi = mode_info_context + (mis << 1);
do_left_v = (mb_col > 0);
@@ -521,7 +505,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr + 16 * y_stride,
y_only ? NULL : (u_ptr + 8 * uv_stride),
y_only ? NULL : (v_ptr + 8 * uv_stride),
- y_stride, uv_stride, dering);
+ y_stride, uv_stride);
y_ptr += 16;
u_ptr = y_only? 0 : u_ptr + 8;
v_ptr = y_only? 0 : v_ptr + 8;
@@ -547,7 +531,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm,
y_ptr,
y_only? 0 : u_ptr,
y_only? 0 : v_ptr,
- y_stride, uv_stride, dering);
+ y_stride, uv_stride);
y_ptr += 16;
u_ptr = y_only? 0 : u_ptr + 8;
v_ptr = y_only? 0 : v_ptr + 8;
diff --git a/vp9/common/vp9_loopfilter.h b/vp9/common/vp9_loopfilter.h
index 589984f18..65f522bab 100644
--- a/vp9/common/vp9_loopfilter.h
+++ b/vp9/common/vp9_loopfilter.h
@@ -73,8 +73,7 @@ void vp9_loop_filter_frame_init(struct VP9Common *cm,
void vp9_loop_filter_frame(struct VP9Common *cm,
struct macroblockd *mbd,
int filter_level,
- int y_only,
- int dering);
+ int y_only);
void vp9_loop_filter_partial_frame(struct VP9Common *cm,
struct macroblockd *mbd,
diff --git a/vp9/common/vp9_modecontext.c b/vp9/common/vp9_modecontext.c
index 697683ab1..5f084eadc 100644
--- a/vp9/common/vp9_modecontext.c
+++ b/vp9/common/vp9_modecontext.c
@@ -11,9 +11,9 @@
#include "vp9/common/vp9_entropymode.h"
-const vp9_prob vp9_kf_default_bmode_probs[VP9_KF_BINTRAMODES]
- [VP9_KF_BINTRAMODES]
- [VP9_KF_BINTRAMODES-1] = {
+const vp9_prob vp9_kf_default_bmode_probs[VP9_BINTRAMODES]
+ [VP9_BINTRAMODES]
+ [VP9_BINTRAMODES-1] = {
{ // Above 0
{ 231, 9, 124, 138, 96, 200, 76, 42, 88, }, // left 0
{ 152, 11, 187, 112, 170, 139, 130, 91, 113, }, // left 1
diff --git a/vp9/common/vp9_mvref_common.c b/vp9/common/vp9_mvref_common.c
index fa84ce6bd..68937807a 100644
--- a/vp9/common/vp9_mvref_common.c
+++ b/vp9/common/vp9_mvref_common.c
@@ -46,11 +46,17 @@ static void clamp_mv_ref(const MACROBLOCKD *xd, int_mv *mv) {
// structure if one exists that matches the given reference frame.
static int get_matching_candidate(const MODE_INFO *candidate_mi,
MV_REFERENCE_FRAME ref_frame,
- int_mv *c_mv) {
+ int_mv *c_mv, int block_idx) {
if (ref_frame == candidate_mi->mbmi.ref_frame) {
- c_mv->as_int = candidate_mi->mbmi.mv[0].as_int;
+ 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;
} else if (ref_frame == candidate_mi->mbmi.second_ref_frame) {
- c_mv->as_int = candidate_mi->mbmi.mv[1].as_int;
+ 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;
} else {
return 0;
}
@@ -150,9 +156,10 @@ static void add_candidate_mv(int_mv *mv_list, int *mv_scores,
// This function searches the neighbourhood of a given MB/SB
// to try and find candidate reference vectors.
//
-void vp9_find_mv_refs(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) {
+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) {
int i;
MODE_INFO *candidate_mi;
MB_MODE_INFO * mbmi = &xd->mode_info_context->mbmi;
@@ -168,6 +175,7 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
int intra_count = 0;
int zero_count = 0;
int newmv_count = 0;
+ int x_idx = 0, y_idx = 0;
// Blank the reference vector lists and other local structures.
vpx_memset(mv_ref_list, 0, sizeof(int_mv) * MAX_MV_REF_CANDIDATES);
@@ -181,6 +189,10 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
mv_ref_search = mb_mv_ref_search;
} else {
mv_ref_search = b_mv_ref_search;
+ if (mbmi->sb_type < BLOCK_SIZE_SB8X8) {
+ x_idx = block_idx & 1;
+ y_idx = block_idx >> 1;
+ }
}
// We first scan for candidate vectors that match the current reference frame
@@ -191,11 +203,20 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
if ((mi_search_col >= cm->cur_tile_mi_col_start) &&
(mi_search_col < cm->cur_tile_mi_col_end) &&
((mv_ref_search[i][1] << 6) >= xd->mb_to_top_edge)) {
+ int b;
candidate_mi = here + mv_ref_search[i][0] +
(mv_ref_search[i][1] * xd->mode_info_stride);
- if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv)) {
+ 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)) {
add_candidate_mv(mv_ref_list, candidate_scores,
&refmv_count, c_refmv, 16);
}
@@ -229,7 +250,7 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
candidate_mi = here + mv_ref_search[i][0] +
(mv_ref_search[i][1] * xd->mode_info_stride);
- if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv)) {
+ if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, -1)) {
add_candidate_mv(mv_ref_list, candidate_scores,
&refmv_count, c_refmv, 16);
}
@@ -239,7 +260,7 @@ void vp9_find_mv_refs(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
// Look in the last frame if it exists
if (lf_here && (refmv_count < MAX_MV_REF_CANDIDATES)) {
candidate_mi = lf_here;
- if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv)) {
+ if (get_matching_candidate(candidate_mi, ref_frame, &c_refmv, block_idx)) {
add_candidate_mv(mv_ref_list, candidate_scores,
&refmv_count, c_refmv, 16);
}
diff --git a/vp9/common/vp9_mvref_common.h b/vp9/common/vp9_mvref_common.h
index a81366997..7290f10ab 100644
--- a/vp9/common/vp9_mvref_common.h
+++ b/vp9/common/vp9_mvref_common.h
@@ -14,12 +14,24 @@
#ifndef VP9_COMMON_VP9_MVREF_COMMON_H_
#define VP9_COMMON_VP9_MVREF_COMMON_H_
-void vp9_find_mv_refs(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);
+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);
+
+static INLINE void vp9_find_mv_refs(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) {
+ vp9_find_mv_refs_idx(cm, xd, here, lf_here, ref_frame,
+ mv_ref_list, ref_sign_bias, -1);
+}
#endif // VP9_COMMON_VP9_MVREF_COMMON_H_
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index acca8479b..c277ea3cb 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -51,26 +51,23 @@ void vp9_initialize_common(void);
#define MAX_LAG_BUFFERS 25
typedef struct frame_contexts {
- vp9_prob bmode_prob[VP9_NKF_BINTRAMODES - 1];
+ vp9_prob bmode_prob[VP9_BINTRAMODES - 1];
vp9_prob ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */
vp9_prob sb_ymode_prob[VP9_I32X32_MODES - 1];
vp9_prob uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1];
- vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
vp9_prob partition_prob[NUM_PARTITION_CONTEXTS][PARTITION_TYPES - 1];
nmv_context nmvc;
nmv_context pre_nmvc;
- vp9_prob pre_bmode_prob[VP9_NKF_BINTRAMODES - 1];
+ vp9_prob pre_bmode_prob[VP9_BINTRAMODES - 1];
vp9_prob pre_ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */
vp9_prob pre_sb_ymode_prob[VP9_I32X32_MODES - 1];
vp9_prob pre_uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1];
- vp9_prob pre_sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
vp9_prob pre_partition_prob[NUM_PARTITION_CONTEXTS][PARTITION_TYPES - 1];
- unsigned int bmode_counts[VP9_NKF_BINTRAMODES];
+ unsigned int bmode_counts[VP9_BINTRAMODES];
unsigned int ymode_counts[VP9_YMODES]; /* interframe intra mode probs */
unsigned int sb_ymode_counts[VP9_I32X32_MODES];
unsigned int uv_mode_counts[VP9_YMODES][VP9_UV_MODES];
- unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS];
unsigned int partition_counts[NUM_PARTITION_CONTEXTS][PARTITION_TYPES];
vp9_coeff_probs_model coef_probs_4x4[BLOCK_TYPES];
@@ -209,7 +206,6 @@ typedef struct VP9Common {
int filter_level;
int last_sharpness_level;
int sharpness_level;
- int dering_enabled;
int refresh_frame_context; /* Two state 0 = NO, 1 = YES */
@@ -225,9 +221,9 @@ typedef struct VP9Common {
/* keyframe block modes are predicted by their above, left neighbors */
- vp9_prob kf_bmode_prob[VP9_KF_BINTRAMODES]
- [VP9_KF_BINTRAMODES]
- [VP9_KF_BINTRAMODES - 1];
+ vp9_prob kf_bmode_prob[VP9_BINTRAMODES]
+ [VP9_BINTRAMODES]
+ [VP9_BINTRAMODES - 1];
vp9_prob kf_ymode_prob[8][VP9_YMODES - 1]; /* keyframe "" */
vp9_prob sb_kf_ymode_prob[8][VP9_I32X32_MODES - 1];
int kf_ymode_probs_index;
diff --git a/vp9/common/vp9_postproc.c b/vp9/common/vp9_postproc.c
index d2c52edfd..3aae669bf 100644
--- a/vp9/common/vp9_postproc.c
+++ b/vp9/common/vp9_postproc.c
@@ -53,7 +53,7 @@ static const unsigned char MB_PREDICTION_MODE_colors[MB_MODE_COUNT][3] = {
{ RGB_TO_YUV(0xCC33FF) }, /* Magenta */
};
-static const unsigned char B_PREDICTION_MODE_colors[B_MODE_COUNT][3] = {
+static const unsigned char B_PREDICTION_MODE_colors[INTRA_MODE_COUNT][3] = {
{ RGB_TO_YUV(0x6633ff) }, /* Purple */
{ RGB_TO_YUV(0xcc33ff) }, /* Magenta */
{ RGB_TO_YUV(0xff33cc) }, /* Pink */
diff --git a/vp9/common/vp9_reconintra.h b/vp9/common/vp9_reconintra.h
index b88761b02..f5f5f42c4 100644
--- a/vp9/common/vp9_reconintra.h
+++ b/vp9/common/vp9_reconintra.h
@@ -14,12 +14,12 @@
#include "vpx/vpx_integer.h"
#include "vp9/common/vp9_blockd.h"
-B_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr,
- int stride, int n,
- int tx, int ty);
+MB_PREDICTION_MODE vp9_find_dominant_direction(uint8_t *ptr,
+ int stride, int n,
+ int tx, int ty);
-B_PREDICTION_MODE vp9_find_bpred_context(MACROBLOCKD *xd, int block,
- uint8_t *ptr, int stride);
+MB_PREDICTION_MODE vp9_find_bpred_context(MACROBLOCKD *xd, int block,
+ uint8_t *ptr, int stride);
void vp9_predict_intra_block(MACROBLOCKD *xd,
int block_idx,
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index a5fc07b59..6b511b504 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -35,13 +35,13 @@ int dec_mvcount = 0;
extern int dec_debug;
#endif
-static B_PREDICTION_MODE read_bmode(vp9_reader *r, const vp9_prob *p) {
- B_PREDICTION_MODE m = treed_read(r, vp9_bmode_tree, p);
+static MB_PREDICTION_MODE read_bmode(vp9_reader *r, const vp9_prob *p) {
+ MB_PREDICTION_MODE m = treed_read(r, vp9_bmode_tree, p);
return m;
}
-static B_PREDICTION_MODE read_kf_bmode(vp9_reader *r, const vp9_prob *p) {
- return (B_PREDICTION_MODE)treed_read(r, vp9_kf_bmode_tree, p);
+static MB_PREDICTION_MODE read_kf_bmode(vp9_reader *r, const vp9_prob *p) {
+ return (MB_PREDICTION_MODE)treed_read(r, vp9_bmode_tree, p);
}
static MB_PREDICTION_MODE read_ymode(vp9_reader *r, const vp9_prob *p) {
@@ -118,6 +118,24 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
if (!m->mbmi.mb_skip_coeff)
m->mbmi.mb_skip_coeff = vp9_read(r, vp9_get_pred_prob(cm, xd, PRED_MBSKIP));
+ if (cm->txfm_mode == TX_MODE_SELECT &&
+ m->mbmi.sb_type >= BLOCK_SIZE_SB8X8) {
+ const int allow_16x16 = m->mbmi.sb_type >= BLOCK_SIZE_MB16X16;
+ const int allow_32x32 = m->mbmi.sb_type >= BLOCK_SIZE_SB32X32;
+ m->mbmi.txfm_size = select_txfm_size(cm, r, allow_16x16, allow_32x32);
+ } else if (cm->txfm_mode >= ALLOW_32X32 &&
+ m->mbmi.sb_type >= BLOCK_SIZE_SB32X32) {
+ m->mbmi.txfm_size = TX_32X32;
+ } else if (cm->txfm_mode >= ALLOW_16X16 &&
+ m->mbmi.sb_type >= BLOCK_SIZE_MB16X16) {
+ m->mbmi.txfm_size = TX_16X16;
+ } else if (cm->txfm_mode >= ALLOW_8X8 &&
+ m->mbmi.sb_type >= BLOCK_SIZE_SB8X8) {
+ m->mbmi.txfm_size = TX_8X8;
+ } else {
+ m->mbmi.txfm_size = TX_4X4;
+ }
+
// luma mode
if (m->mbmi.sb_type >= BLOCK_SIZE_SB8X8) {
const MB_PREDICTION_MODE A = above_block_mode(m, 0, mis);
@@ -153,26 +171,6 @@ static void kfread_modes(VP9D_COMP *pbi, MODE_INFO *m,
}
m->mbmi.uv_mode = read_uv_mode(r, cm->kf_uv_mode_prob[m->mbmi.mode]);
-
- if (cm->txfm_mode == TX_MODE_SELECT &&
- !(m->mbmi.mb_skip_coeff && m->mbmi.ref_frame != INTRA_FRAME)
- && m->mbmi.sb_type >= BLOCK_SIZE_SB8X8) {
- const int allow_16x16 = m->mbmi.sb_type >= BLOCK_SIZE_MB16X16;
- const int allow_32x32 = m->mbmi.sb_type >= BLOCK_SIZE_SB32X32;
- m->mbmi.txfm_size = select_txfm_size(cm, r, allow_16x16, allow_32x32);
- } else if (cm->txfm_mode >= ALLOW_32X32 &&
- m->mbmi.sb_type >= BLOCK_SIZE_SB32X32) {
- m->mbmi.txfm_size = TX_32X32;
- } else if (cm->txfm_mode >= ALLOW_16X16 &&
- m->mbmi.sb_type >= BLOCK_SIZE_MB16X16 &&
- m->mbmi.mode <= TM_PRED) {
- m->mbmi.txfm_size = TX_16X16;
- } else if (cm->txfm_mode >= ALLOW_8X8 &&
- m->mbmi.sb_type >= BLOCK_SIZE_SB8X8) {
- m->mbmi.txfm_size = TX_8X8;
- } else {
- m->mbmi.txfm_size = TX_4X4;
- }
}
static int read_mv_component(vp9_reader *r,
@@ -368,10 +366,6 @@ static MB_PREDICTION_MODE read_mv_ref(vp9_reader *r, const vp9_prob *p) {
return (MB_PREDICTION_MODE) treed_read(r, vp9_mv_ref_tree, p);
}
-static B_PREDICTION_MODE read_sub_mv_ref(vp9_reader *r, const vp9_prob *p) {
- return (B_PREDICTION_MODE) treed_read(r, vp9_sub_mv_ref_tree, p);
-}
-
#ifdef VPX_MODE_COUNT
unsigned int vp9_mv_cont_count[5][4] = {
{ 0, 0, 0, 0 },
@@ -528,7 +522,6 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
nmv_context *const nmvc = &cm->fc.nmvc;
- const int mis = cm->mode_info_stride;
MACROBLOCKD *const xd = &pbi->mb;
int_mv *const mv0 = &mbmi->mv[0];
@@ -575,23 +568,32 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
// Read the reference frame
mbmi->ref_frame = read_ref_frame(pbi, r, mbmi->segment_id);
+ if (cm->txfm_mode == TX_MODE_SELECT &&
+ (mbmi->mb_skip_coeff == 0 || mbmi->ref_frame == INTRA_FRAME) &&
+ bsize >= BLOCK_SIZE_SB8X8) {
+ const int allow_16x16 = bsize >= BLOCK_SIZE_MB16X16;
+ const int allow_32x32 = bsize >= BLOCK_SIZE_SB32X32;
+ mbmi->txfm_size = select_txfm_size(cm, r, allow_16x16, allow_32x32);
+ } else if (bsize >= BLOCK_SIZE_SB32X32 &&
+ cm->txfm_mode >= ALLOW_32X32) {
+ mbmi->txfm_size = TX_32X32;
+ } else if (cm->txfm_mode >= ALLOW_16X16 &&
+ bsize >= BLOCK_SIZE_MB16X16) {
+ mbmi->txfm_size = TX_16X16;
+ } else if (cm->txfm_mode >= ALLOW_8X8 && (bsize >= BLOCK_SIZE_SB8X8)) {
+ mbmi->txfm_size = TX_8X8;
+ } else {
+ mbmi->txfm_size = TX_4X4;
+ }
+
// If reference frame is an Inter frame
if (mbmi->ref_frame) {
int_mv nearest, nearby, best_mv;
int_mv nearest_second, nearby_second, best_mv_second;
vp9_prob mv_ref_p[VP9_MVREFS - 1];
-
const MV_REFERENCE_FRAME ref_frame = mbmi->ref_frame;
- struct scale_factors *sf0 = &xd->scale_factor[0];
- *sf0 = cm->active_ref_scale[mbmi->ref_frame - 1];
{
- // Select the appropriate reference frame for this MB
- const int ref_fb_idx = cm->active_ref_idx[ref_frame - 1];
-
- setup_pre_planes(xd, &cm->yv12_fb[ref_fb_idx], NULL,
- mi_row, mi_col, xd->scale_factor, xd->scale_factor_uv);
-
#ifdef DEC_DEBUG
if (dec_debug)
printf("%d %d\n", xd->mode_info_context->mbmi.mv[0].as_mv.row,
@@ -650,12 +652,6 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
mbmi->second_ref_frame = 1;
if (mbmi->second_ref_frame > 0) {
const MV_REFERENCE_FRAME second_ref_frame = mbmi->second_ref_frame;
- struct scale_factors *sf1 = &xd->scale_factor[1];
- const int second_ref_fb_idx = cm->active_ref_idx[second_ref_frame - 1];
- *sf1 = cm->active_ref_scale[second_ref_frame - 1];
-
- setup_pre_planes(xd, NULL, &cm->yv12_fb[second_ref_fb_idx],
- mi_row, mi_col, xd->scale_factor, xd->scale_factor_uv);
vp9_find_mv_refs(cm, xd, mi,
use_prev_in_find_mv_refs ?
@@ -680,28 +676,24 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
mbmi->need_to_clamp_mvs = 0;
for (idy = 0; idy < 2; idy += bh) {
for (idx = 0; idx < 2; idx += bw) {
- int_mv leftmv, abovemv, second_leftmv, second_abovemv;
int_mv blockmv, secondmv;
- int mv_contz;
int blockmode;
- int i, k;
+ int i;
j = idy * 2 + idx;
- k = j;
-
- leftmv.as_int = left_block_mv(xd, mi, k);
- abovemv.as_int = above_block_mv(mi, k, mis);
- second_leftmv.as_int = 0;
- second_abovemv.as_int = 0;
- if (mbmi->second_ref_frame > 0) {
- second_leftmv.as_int = left_block_second_mv(xd, mi, k);
- second_abovemv.as_int = above_block_second_mv(mi, k, mis);
+
+ blockmode = read_sb_mv_ref(r, mv_ref_p);
+ vp9_accum_mv_refs(cm, blockmode, mbmi->mb_mode_context[ref_frame]);
+ if (blockmode == NEARESTMV || blockmode == NEARMV) {
+ MV_REFERENCE_FRAME rf2 = mbmi->second_ref_frame;
+ vp9_append_sub8x8_mvs_for_idx(cm, xd, &nearest, &nearby, j, 0);
+ if (rf2 > 0) {
+ vp9_append_sub8x8_mvs_for_idx(cm, xd, &nearest_second,
+ &nearby_second, j, 1);
+ }
}
- mv_contz = vp9_mv_cont(&leftmv, &abovemv);
- blockmode = read_sub_mv_ref(r, cm->fc.sub_mv_ref_prob[mv_contz]);
- cm->fc.sub_mv_ref_counts[mv_contz][blockmode - LEFT4X4]++;
switch (blockmode) {
- case NEW4X4:
+ case NEWMV:
decode_mv(r, &blockmv.as_mv, &best_mv.as_mv, nmvc,
&cm->fc.NMVcount, xd->allow_high_precision_mv);
@@ -713,23 +705,23 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
vp9_mv_cont_count[mv_contz][3]++;
#endif
break;
- case LEFT4X4:
- blockmv.as_int = leftmv.as_int;
+ case NEARESTMV:
+ blockmv.as_int = nearest.as_int;
if (mbmi->second_ref_frame > 0)
- secondmv.as_int = second_leftmv.as_int;
+ secondmv.as_int = nearest_second.as_int;
#ifdef VPX_MODE_COUNT
vp9_mv_cont_count[mv_contz][0]++;
#endif
break;
- case ABOVE4X4:
- blockmv.as_int = abovemv.as_int;
+ case NEARMV:
+ blockmv.as_int = nearby.as_int;
if (mbmi->second_ref_frame > 0)
- secondmv.as_int = second_abovemv.as_int;
+ secondmv.as_int = nearby_second.as_int;
#ifdef VPX_MODE_COUNT
vp9_mv_cont_count[mv_contz][1]++;
#endif
break;
- case ZERO4X4:
+ case ZEROMV:
blockmv.as_int = 0;
if (mbmi->second_ref_frame > 0)
secondmv.as_int = 0;
@@ -843,24 +835,6 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
mbmi->uv_mode = read_uv_mode(r, cm->fc.uv_mode_prob[mbmi->mode]);
cm->fc.uv_mode_counts[mbmi->mode][mbmi->uv_mode]++;
}
-
- if (cm->txfm_mode == TX_MODE_SELECT &&
- (mbmi->mb_skip_coeff == 0 || mbmi->ref_frame == INTRA_FRAME) &&
- bsize >= BLOCK_SIZE_SB8X8) {
- const int allow_16x16 = bsize >= BLOCK_SIZE_MB16X16;
- const int allow_32x32 = bsize >= BLOCK_SIZE_SB32X32;
- mbmi->txfm_size = select_txfm_size(cm, r, allow_16x16, allow_32x32);
- } else if (bsize >= BLOCK_SIZE_SB32X32 &&
- cm->txfm_mode >= ALLOW_32X32) {
- mbmi->txfm_size = TX_32X32;
- } else if (cm->txfm_mode >= ALLOW_16X16 &&
- bsize >= BLOCK_SIZE_MB16X16) {
- mbmi->txfm_size = TX_16X16;
- } else if (cm->txfm_mode >= ALLOW_8X8 && (bsize >= BLOCK_SIZE_SB8X8)) {
- mbmi->txfm_size = TX_8X8;
- } else {
- mbmi->txfm_size = TX_4X4;
- }
}
void vp9_decode_mode_mvs_init(VP9D_COMP* const pbi, vp9_reader *r) {
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index e8de4a7af..70e0c8759 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -32,7 +32,7 @@
#include "vp9/common/vp9_seg_common.h"
#include "vp9/common/vp9_tile_common.h"
-#include "vp9_rtcd.h"
+#include "./vp9_rtcd.h"
// #define DEC_DEBUG
#ifdef DEC_DEBUG
@@ -698,13 +698,6 @@ static void setup_loopfilter(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_reader *r) {
pc->filter_level = vp9_read_literal(r, 6);
pc->sharpness_level = vp9_read_literal(r, 3);
-#if CONFIG_LOOP_DERING
- if (vp9_read_bit(r))
- pc->dering_enabled = 1 + vp9_read_literal(r, 4);
- else
- pc->dering_enabled = 0;
-#endif
-
// Read in loop filter deltas applied at the MB level based on mode or ref
// frame.
xd->mode_ref_lf_delta_update = 0;
@@ -826,7 +819,6 @@ static void update_frame_context(FRAME_CONTEXT *fc) {
vp9_copy(fc->pre_sb_ymode_prob, fc->sb_ymode_prob);
vp9_copy(fc->pre_uv_mode_prob, fc->uv_mode_prob);
vp9_copy(fc->pre_bmode_prob, fc->bmode_prob);
- vp9_copy(fc->pre_sub_mv_ref_prob, fc->sub_mv_ref_prob);
vp9_copy(fc->pre_partition_prob, fc->partition_prob);
fc->pre_nmvc = fc->nmvc;
@@ -839,7 +831,6 @@ static void update_frame_context(FRAME_CONTEXT *fc) {
vp9_zero(fc->sb_ymode_counts);
vp9_zero(fc->uv_mode_counts);
vp9_zero(fc->bmode_counts);
- vp9_zero(fc->sub_mv_ref_counts);
vp9_zero(fc->NMVcount);
vp9_zero(fc->mv_ref_ct);
vp9_zero(fc->partition_counts);
diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c
index 5d5a543a3..24f9ca3f9 100644
--- a/vp9/decoder/vp9_onyxd_if.c
+++ b/vp9/decoder/vp9_onyxd_if.c
@@ -349,8 +349,7 @@ int vp9_receive_compressed_data(VP9D_PTR ptr,
if (cm->filter_level) {
/* Apply the loop filter if appropriate. */
- vp9_loop_filter_frame(cm, &pbi->mb, cm->filter_level, 0,
- cm->dering_enabled);
+ vp9_loop_filter_frame(cm, &pbi->mb, cm->filter_level, 0);
}
#if WRITE_RECON_BUFFER == 2
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index 98cdb1590..1dd822b89 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -29,7 +29,6 @@
#include "vp9/common/vp9_seg_common.h"
#include "vp9/common/vp9_pred_common.h"
#include "vp9/common/vp9_entropy.h"
-#include "vp9/encoder/vp9_encodemv.h"
#include "vp9/common/vp9_entropymv.h"
#include "vp9/common/vp9_mvref_common.h"
#include "vp9/common/vp9_treecoder.h"
@@ -370,7 +369,7 @@ static void write_uv_mode(vp9_writer *bc, int m, const vp9_prob *p) {
}
static void write_kf_bmode(vp9_writer *bc, int m, const vp9_prob *p) {
- write_token(bc, vp9_kf_bmode_tree, p, vp9_kf_bmode_encodings + m);
+ write_token(bc, vp9_bmode_tree, p, vp9_kf_bmode_encodings + m);
}
static int prob_update_savings(const unsigned int *ct,
@@ -543,16 +542,6 @@ static void write_sb_mv_ref(vp9_writer *bc, MB_PREDICTION_MODE m,
vp9_sb_mv_ref_encoding_array - NEARESTMV + m);
}
-static void write_sub_mv_ref(vp9_writer *bc, B_PREDICTION_MODE m,
- const vp9_prob *p) {
-#if CONFIG_DEBUG
- assert(LEFT4X4 <= m && m <= NEW4X4);
-#endif
- write_token(bc, vp9_sub_mv_ref_tree, p,
- vp9_sub_mv_ref_encoding_array - LEFT4X4 + m);
-}
-
-
// This function writes the current macro block's segnment id to the bitstream
// It should only be called if a segment map update is indicated.
static void write_mb_segid(vp9_writer *bc,
@@ -668,7 +657,6 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
const nmv_context *nmvc = &pc->fc.nmvc;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
- const int mis = pc->mode_info_stride;
MB_MODE_INFO *const mi = &m->mbmi;
const MV_REFERENCE_FRAME rf = mi->ref_frame;
const MB_PREDICTION_MODE mode = mi->mode;
@@ -711,6 +699,19 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
// Encode the reference frame.
encode_ref_frame(bc, pc, xd, segment_id, rf);
+ if (mi->sb_type >= BLOCK_SIZE_SB8X8 && pc->txfm_mode == TX_MODE_SELECT &&
+ !(rf != INTRA_FRAME &&
+ (skip_coeff || vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)))) {
+ TX_SIZE sz = mi->txfm_size;
+ // FIXME(rbultje) code ternary symbol once all experiments are merged
+ vp9_write(bc, sz != TX_4X4, pc->prob_tx[0]);
+ if (mi->sb_type >= BLOCK_SIZE_MB16X16 && sz != TX_4X4) {
+ vp9_write(bc, sz != TX_8X8, pc->prob_tx[1]);
+ if (mi->sb_type >= BLOCK_SIZE_SB32X32 && sz != TX_8X8)
+ vp9_write(bc, sz != TX_16X16, pc->prob_tx[2]);
+ }
+ }
+
if (rf == INTRA_FRAME) {
#ifdef ENTROPY_STATS
active_section = 6;
@@ -781,11 +782,8 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
break;
case SPLITMV: {
int j;
- B_PREDICTION_MODE blockmode;
+ MB_PREDICTION_MODE blockmode;
int_mv blockmv;
- int k = -1; /* first block in subset j */
- int mv_contz;
- int_mv leftmv, abovemv;
int bwl = b_width_log2(mi->sb_type), bw = 1 << bwl;
int bhl = b_height_log2(mi->sb_type), bh = 1 << bhl;
int idx, idy;
@@ -794,15 +792,9 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
j = idy * 2 + idx;
blockmode = cpi->mb.partition_info->bmi[j].mode;
blockmv = cpi->mb.partition_info->bmi[j].mv;
- k = j;
- leftmv.as_int = left_block_mv(xd, m, k);
- abovemv.as_int = above_block_mv(m, k, mis);
- mv_contz = vp9_mv_cont(&leftmv, &abovemv);
-
- write_sub_mv_ref(bc, blockmode,
- cpi->common.fc.sub_mv_ref_prob[mv_contz]);
- cpi->sub_mv_ref_count[mv_contz][blockmode - LEFT4X4]++;
- if (blockmode == NEW4X4) {
+ write_sb_mv_ref(bc, blockmode, mv_ref_p);
+ vp9_accum_mv_refs(&cpi->common, blockmode, mi->mb_mode_context[rf]);
+ if (blockmode == NEWMV) {
#ifdef ENTROPY_STATS
active_section = 11;
#endif
@@ -827,19 +819,6 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
break;
}
}
-
- if (mi->sb_type >= BLOCK_SIZE_SB8X8 && pc->txfm_mode == TX_MODE_SELECT &&
- !(rf != INTRA_FRAME &&
- (skip_coeff || vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)))) {
- TX_SIZE sz = mi->txfm_size;
- // FIXME(rbultje) code ternary symbol once all experiments are merged
- vp9_write(bc, sz != TX_4X4, pc->prob_tx[0]);
- if (mi->sb_type >= BLOCK_SIZE_MB16X16 && sz != TX_4X4) {
- vp9_write(bc, sz != TX_8X8, pc->prob_tx[1]);
- if (mi->sb_type >= BLOCK_SIZE_SB32X32 && sz != TX_8X8)
- vp9_write(bc, sz != TX_16X16, pc->prob_tx[2]);
- }
- }
}
static void write_mb_modes_kf(const VP9_COMP *cpi,
@@ -862,9 +841,20 @@ static void write_mb_modes_kf(const VP9_COMP *cpi,
vp9_write(bc, skip_coeff, vp9_get_pred_prob(c, xd, PRED_MBSKIP));
}
+ if (m->mbmi.sb_type >= BLOCK_SIZE_SB8X8 && c->txfm_mode == TX_MODE_SELECT) {
+ TX_SIZE sz = m->mbmi.txfm_size;
+ // FIXME(rbultje) code ternary symbol once all experiments are merged
+ vp9_write(bc, sz != TX_4X4, c->prob_tx[0]);
+ if (m->mbmi.sb_type >= BLOCK_SIZE_MB16X16 && sz != TX_4X4) {
+ vp9_write(bc, sz != TX_8X8, c->prob_tx[1]);
+ if (m->mbmi.sb_type >= BLOCK_SIZE_SB32X32 && sz != TX_8X8)
+ vp9_write(bc, sz != TX_16X16, c->prob_tx[2]);
+ }
+ }
+
if (m->mbmi.sb_type >= BLOCK_SIZE_SB8X8) {
- const B_PREDICTION_MODE A = above_block_mode(m, 0, mis);
- const B_PREDICTION_MODE L = xd->left_available ?
+ const MB_PREDICTION_MODE A = above_block_mode(m, 0, mis);
+ const MB_PREDICTION_MODE L = xd->left_available ?
left_block_mode(m, 0) : DC_PRED;
write_kf_bmode(bc, ym, c->kf_bmode_prob[A][L]);
}
@@ -876,8 +866,8 @@ static void write_mb_modes_kf(const VP9_COMP *cpi,
for (idy = 0; idy < 2; idy += bh) {
for (idx = 0; idx < 2; idx += bw) {
int i = idy * 2 + idx;
- const B_PREDICTION_MODE A = above_block_mode(m, i, mis);
- const B_PREDICTION_MODE L = (xd->left_available || idx) ?
+ const MB_PREDICTION_MODE A = above_block_mode(m, i, mis);
+ const MB_PREDICTION_MODE L = (xd->left_available || idx) ?
left_block_mode(m, i) : DC_PRED;
write_kf_bmode(bc, m->bmi[i].as_mode.first,
c->kf_bmode_prob[A][L]);
@@ -886,18 +876,6 @@ static void write_mb_modes_kf(const VP9_COMP *cpi,
}
write_uv_mode(bc, m->mbmi.uv_mode, c->kf_uv_mode_prob[ym]);
-
- if (m->mbmi.sb_type >= BLOCK_SIZE_SB8X8 && c->txfm_mode == TX_MODE_SELECT &&
- !((skip_coeff || vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)))) {
- TX_SIZE sz = m->mbmi.txfm_size;
- // FIXME(rbultje) code ternary symbol once all experiments are merged
- vp9_write(bc, sz != TX_4X4, c->prob_tx[0]);
- if (m->mbmi.sb_type >= BLOCK_SIZE_MB16X16 && sz != TX_4X4) {
- vp9_write(bc, sz != TX_8X8, c->prob_tx[1]);
- if (m->mbmi.sb_type >= BLOCK_SIZE_SB32X32 && sz != TX_8X8)
- vp9_write(bc, sz != TX_16X16, c->prob_tx[2]);
- }
- }
}
static void write_modes_b(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc,
@@ -1032,7 +1010,7 @@ static void write_modes(VP9_COMP *cpi, vp9_writer* const bc,
vpx_memset(c->left_seg_context, 0, sizeof(c->left_seg_context));
for (mi_col = c->cur_tile_mi_col_start;
mi_col < c->cur_tile_mi_col_end;
- mi_col += 8, m += 8)
+ mi_col += 64 / MI_SIZE, m += 64 / MI_SIZE)
write_modes_sb(cpi, m, bc, tok, tok_end, mi_row, mi_col,
BLOCK_SIZE_SB64X64);
}
@@ -1358,14 +1336,6 @@ static void encode_loopfilter(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_writer *w) {
// Encode the loop filter level and type
vp9_write_literal(w, pc->filter_level, 6);
vp9_write_literal(w, pc->sharpness_level, 3);
-#if CONFIG_LOOP_DERING
- if (pc->dering_enabled) {
- vp9_write_bit(w, 1);
- vp9_write_literal(w, pc->dering_enabled - 1, 4);
- } else {
- vp9_write_bit(w, 0);
- }
-#endif
// Write out loop filter deltas applied at the MB level based on mode or
// ref frame (if they are enabled).
@@ -1767,10 +1737,8 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) {
vp9_copy(cpi->common.fc.pre_ymode_prob, cpi->common.fc.ymode_prob);
vp9_copy(cpi->common.fc.pre_uv_mode_prob, cpi->common.fc.uv_mode_prob);
vp9_copy(cpi->common.fc.pre_bmode_prob, cpi->common.fc.bmode_prob);
- vp9_copy(cpi->common.fc.pre_sub_mv_ref_prob, cpi->common.fc.sub_mv_ref_prob);
vp9_copy(cpi->common.fc.pre_partition_prob, cpi->common.fc.partition_prob);
cpi->common.fc.pre_nmvc = cpi->common.fc.nmvc;
- vp9_zero(cpi->sub_mv_ref_count);
vp9_zero(cpi->common.fc.mv_ref_ct);
update_coef_probs(cpi, &header_bc);
diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h
index 84e1a1fdb..211eca4b4 100644
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -26,7 +26,7 @@ typedef struct {
typedef struct {
int count;
struct {
- B_PREDICTION_MODE mode;
+ MB_PREDICTION_MODE mode;
int_mv mv;
int_mv second_mv;
} bmi[4];
@@ -116,8 +116,8 @@ struct macroblock {
int mbmode_cost[2][MB_MODE_COUNT];
int intra_uv_mode_cost[2][MB_MODE_COUNT];
- int bmode_costs[VP9_KF_BINTRAMODES][VP9_KF_BINTRAMODES][VP9_KF_BINTRAMODES];
- int inter_bmode_costs[B_MODE_COUNT];
+ int bmode_costs[VP9_BINTRAMODES][VP9_BINTRAMODES][VP9_BINTRAMODES];
+ int inter_bmode_costs[INTRA_MODE_COUNT];
int switchable_interp_costs[VP9_SWITCHABLE_FILTERS + 1]
[VP9_SWITCHABLE_FILTERS];
diff --git a/vp9/encoder/vp9_dct.c b/vp9/encoder/vp9_dct.c
index ebf40e4e6..d22644424 100644
--- a/vp9/encoder/vp9_dct.c
+++ b/vp9/encoder/vp9_dct.c
@@ -591,23 +591,33 @@ void vp9_short_fht8x8_c(int16_t *input, int16_t *output,
}
}
+/* 4-point reversible, orthonormal Walsh-Hadamard in 3.5 adds, 0.5 shifts per
+ pixel. */
void vp9_short_walsh4x4_c(short *input, short *output, int pitch) {
int i;
- int a1, b1, c1, d1;
+ int a1, b1, c1, d1, e1;
short *ip = input;
short *op = output;
int pitch_short = pitch >> 1;
for (i = 0; i < 4; i++) {
- a1 = ip[0 * pitch_short] + ip[3 * pitch_short];
- b1 = ip[1 * pitch_short] + ip[2 * pitch_short];
- c1 = ip[1 * pitch_short] - ip[2 * pitch_short];
- d1 = ip[0 * pitch_short] - ip[3 * pitch_short];
-
- op[0] = (a1 + b1 + 1) >> 1;
- op[4] = (c1 + d1) >> 1;
- op[8] = (a1 - b1) >> 1;
- op[12] = (d1 - c1) >> 1;
+ a1 = ip[0 * pitch_short];
+ b1 = ip[1 * pitch_short];
+ c1 = ip[2 * pitch_short];
+ d1 = ip[3 * pitch_short];
+
+ b1 = a1 - b1;
+ c1 += d1;
+ e1 = (c1 - b1) >> 1;
+ a1 += e1;
+ d1 -= e1;
+ c1 = a1 - c1;
+ b1 -= d1;
+
+ op[0] = a1;
+ op[4] = c1;
+ op[8] = d1;
+ op[12] = b1;
ip++;
op++;
@@ -616,15 +626,23 @@ void vp9_short_walsh4x4_c(short *input, short *output, int pitch) {
op = output;
for (i = 0; i < 4; i++) {
- a1 = ip[0] + ip[3];
- b1 = ip[1] + ip[2];
- c1 = ip[1] - ip[2];
- d1 = ip[0] - ip[3];
-
- op[0] = ((a1 + b1 + 1) >> 1) << WHT_UPSCALE_FACTOR;
- op[1] = ((c1 + d1) >> 1) << WHT_UPSCALE_FACTOR;
- op[2] = ((a1 - b1) >> 1) << WHT_UPSCALE_FACTOR;
- op[3] = ((d1 - c1) >> 1) << WHT_UPSCALE_FACTOR;
+ a1 = ip[0];
+ b1 = ip[1];
+ c1 = ip[2];
+ d1 = ip[3];
+
+ b1 = a1 - b1;
+ c1 += d1;
+ e1 = (c1 - b1) >> 1;
+ a1 += e1;
+ d1 -= e1;
+ c1 = a1 - c1;
+ b1 -= d1;
+
+ op[0] = a1 << WHT_UPSCALE_FACTOR;
+ op[1] = c1 << WHT_UPSCALE_FACTOR;
+ op[2] = d1 << WHT_UPSCALE_FACTOR;
+ op[3] = b1 << WHT_UPSCALE_FACTOR;
ip += 4;
op += 4;
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index e426ed7dc..fb8a790f5 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1093,7 +1093,6 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) {
vp9_zero(cpi->bmode_count)
vp9_zero(cpi->ymode_count)
vp9_zero(cpi->y_uv_mode_count)
- vp9_zero(cpi->sub_mv_ref_count)
vp9_zero(cpi->common.fc.mv_ref_ct)
vp9_zero(cpi->sb_ymode_count)
vp9_zero(cpi->partition_count);
@@ -1202,6 +1201,7 @@ static void encode_frame_internal(VP9_COMP *cpi) {
vpx_memset(cpi->txfm_count_8x8p, 0, sizeof(cpi->txfm_count_8x8p));
vpx_memset(cpi->rd_tx_select_diff, 0, sizeof(cpi->rd_tx_select_diff));
vpx_memset(cpi->rd_tx_select_threshes, 0, sizeof(cpi->rd_tx_select_threshes));
+
{
struct vpx_usec_timer emr_timer;
vpx_usec_timer_start(&emr_timer);
@@ -1456,7 +1456,7 @@ void vp9_encode_frame(VP9_COMP *cpi) {
} else
txfm_type = ALLOW_8X8;
#else
- txfm_type = cpi->rd_tx_select_threshes[frame_type][ALLOW_32X32] >=
+ txfm_type = cpi->rd_tx_select_threshes[frame_type][ALLOW_32X32] >
cpi->rd_tx_select_threshes[frame_type][TX_MODE_SELECT] ?
ALLOW_32X32 : TX_MODE_SELECT;
#endif
@@ -1711,7 +1711,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t,
sz = TX_8X8;
if (sz == TX_8X8 && bsize < BLOCK_SIZE_SB8X8)
sz = TX_4X4;
- } else if (mbmi->mode != I4X4_PRED) {
+ } else if (bsize >= BLOCK_SIZE_SB8X8) {
sz = mbmi->txfm_size;
} else {
sz = TX_4X4;
diff --git a/vp9/encoder/vp9_encodeintra.c b/vp9/encoder/vp9_encodeintra.c
index 91866b28f..5d7c244f1 100644
--- a/vp9/encoder/vp9_encodeintra.c
+++ b/vp9/encoder/vp9_encodeintra.c
@@ -32,7 +32,6 @@ int vp9_encode_intra(VP9_COMP *cpi, MACROBLOCK *x, int use_16x16_pred) {
int i;
for (i = 0; i < 16; i++) {
- x->e_mbd.mode_info_context->bmi[i].as_mode.first = B_DC_PRED;
encode_intra4x4block(x, i, BLOCK_SIZE_MB16X16);
}
}
@@ -40,10 +39,10 @@ int vp9_encode_intra(VP9_COMP *cpi, MACROBLOCK *x, int use_16x16_pred) {
return vp9_get_mb_ss(x->plane[0].src_diff);
}
+// This function is used only by the firstpass encoding.
static void encode_intra4x4block(MACROBLOCK *x, int ib,
BLOCK_SIZE_TYPE bsize) {
MACROBLOCKD * const xd = &x->e_mbd;
- TX_TYPE tx_type;
uint8_t* const src =
raster_block_offset_uint8(xd, bsize, 0, ib,
x->plane[0].src.buf, x->plane[0].src.stride);
@@ -58,26 +57,17 @@ static void encode_intra4x4block(MACROBLOCK *x, int ib,
assert(ib < (1 << (bwl + bhl)));
- vp9_intra4x4_predict(&x->e_mbd, ib, bsize,
- xd->mode_info_context->bmi[ib].as_mode.first,
+ vp9_intra4x4_predict(&x->e_mbd, ib, bsize, DC_PRED,
dst, xd->plane[0].dst.stride);
vp9_subtract_block(4, 4, src_diff, 4 << bwl,
src, x->plane[0].src.stride,
dst, xd->plane[0].dst.stride);
- tx_type = get_tx_type_4x4(&x->e_mbd, ib);
- if (tx_type != DCT_DCT) {
- vp9_short_fht4x4(src_diff, coeff, 4 << bwl, tx_type);
- x->quantize_b_4x4(x, ib, tx_type, 16);
- vp9_short_iht4x4_add(BLOCK_OFFSET(xd->plane[0].dqcoeff, ib, 16), dst,
- xd->plane[0].dst.stride, tx_type);
- } else {
- x->fwd_txm4x4(src_diff, coeff, 8 << bwl);
- x->quantize_b_4x4(x, ib, tx_type, 16);
- vp9_inverse_transform_b_4x4_add(&x->e_mbd, xd->plane[0].eobs[ib],
- BLOCK_OFFSET(xd->plane[0].dqcoeff, ib, 16),
- dst, xd->plane[0].dst.stride);
- }
+ x->fwd_txm4x4(src_diff, coeff, 8 << bwl);
+ x->quantize_b_4x4(x, ib, DCT_DCT, 16);
+ vp9_inverse_transform_b_4x4_add(&x->e_mbd, xd->plane[0].eobs[ib],
+ BLOCK_OFFSET(xd->plane[0].dqcoeff, ib, 16),
+ dst, xd->plane[0].dst.stride);
}
void vp9_encode_intra16x16mby(VP9_COMMON *const cm, MACROBLOCK *x) {
diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c
index 3f2061c64..b7f60b127 100644
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -641,7 +641,7 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize,
else
b_mode = mode;
- assert(b_mode >= B_DC_PRED && b_mode <= B_TM_PRED);
+ assert(b_mode >= DC_PRED && b_mode <= TM_PRED);
plane_b_size = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
vp9_predict_intra_block(xd, tx_ib, plane_b_size, tx_size, b_mode,
diff --git a/vp9/encoder/vp9_encodemv.c b/vp9/encoder/vp9_encodemv.c
index 1bb7fa88d..2b6dfba64 100644
--- a/vp9/encoder/vp9_encodemv.c
+++ b/vp9/encoder/vp9_encodemv.c
@@ -579,7 +579,7 @@ void vp9_update_nmv_count(VP9_COMP *cpi, MACROBLOCK *x,
for (idy = 0; idy < 2; idy += bh) {
for (idx = 0; idx < 2; idx += bw) {
i = idy * 2 + idx;
- if (pi->bmi[i].mode == NEW4X4) {
+ if (pi->bmi[i].mode == NEWMV) {
mv.row = (pi->bmi[i].mv.as_mv.row - best_ref_mv->as_mv.row);
mv.col = (pi->bmi[i].mv.as_mv.col - best_ref_mv->as_mv.col);
vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount,
diff --git a/vp9/encoder/vp9_modecosts.c b/vp9/encoder/vp9_modecosts.c
index e58ff40d9..171b44bf9 100644
--- a/vp9/encoder/vp9_modecosts.c
+++ b/vp9/encoder/vp9_modecosts.c
@@ -18,19 +18,17 @@
void vp9_init_mode_costs(VP9_COMP *c) {
VP9_COMMON *x = &c->common;
const vp9_tree_p T = vp9_bmode_tree;
- const vp9_tree_p KT = vp9_kf_bmode_tree;
+ const vp9_tree_p KT = vp9_bmode_tree;
int i, j;
- for (i = 0; i < VP9_KF_BINTRAMODES; i++) {
- for (j = 0; j < VP9_KF_BINTRAMODES; j++) {
+ for (i = 0; i < VP9_BINTRAMODES; i++) {
+ for (j = 0; j < VP9_BINTRAMODES; j++) {
vp9_cost_tokens((int *)c->mb.bmode_costs[i][j],
x->kf_bmode_prob[i][j], KT);
}
}
vp9_cost_tokens((int *)c->mb.inter_bmode_costs, x->fc.bmode_prob, T);
- vp9_cost_tokens((int *)c->mb.inter_bmode_costs,
- x->fc.sub_mv_ref_prob[0], vp9_sub_mv_ref_tree);
// TODO(rbultje) separate tables for superblock costing?
vp9_cost_tokens(c->mb.mbmode_cost[1], x->fc.sb_ymode_prob,
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 697d5d68a..d42bcbb7e 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -2419,8 +2419,7 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
if (cm->filter_level > 0) {
vp9_set_alt_lf_level(cpi, cm->filter_level);
- vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, cm->filter_level, 0,
- cm->dering_enabled);
+ vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, cm->filter_level, 0);
}
vp9_extend_frame_borders(cm->frame_to_show,
@@ -2810,6 +2809,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
}
#endif
loop_count = 0;
+ vpx_memset(cpi->rd_tx_select_threshes, 0, sizeof(cpi->rd_tx_select_threshes));
if (cm->frame_type != KEY_FRAME) {
/* TODO: Decide this more intelligently */
@@ -3216,7 +3216,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
vp9_copy(cpi->common.fc.ymode_counts, cpi->ymode_count);
vp9_copy(cpi->common.fc.uv_mode_counts, cpi->y_uv_mode_count);
vp9_copy(cpi->common.fc.bmode_counts, cpi->bmode_count);
- vp9_copy(cpi->common.fc.sub_mv_ref_counts, cpi->sub_mv_ref_count);
vp9_copy(cpi->common.fc.partition_counts, cpi->partition_count);
cpi->common.fc.NMVcount = cpi->NMVcount;
if (!cpi->common.error_resilient_mode &&
@@ -3336,7 +3335,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
recon_err = vp9_calc_ss_err(cpi->Source,
&cm->yv12_fb[cm->new_fb_idx]);
- if (cpi->twopass.total_left_stats->coded_error != 0.0)
+ if (cpi->twopass.total_left_stats.coded_error != 0.0)
fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d"
"%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
"%6d %6d %5d %5d %5d %8.2f %10d %10.3f"
@@ -3359,9 +3358,9 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cm->frame_type, cpi->gfu_boost,
cpi->twopass.est_max_qcorrection_factor,
(int)cpi->twopass.bits_left,
- cpi->twopass.total_left_stats->coded_error,
+ cpi->twopass.total_left_stats.coded_error,
(double)cpi->twopass.bits_left /
- cpi->twopass.total_left_stats->coded_error,
+ cpi->twopass.total_left_stats.coded_error,
cpi->tot_recode_hits, recon_err, cpi->kf_boost,
cpi->kf_zeromotion_pct);
else
@@ -3388,7 +3387,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
cm->frame_type, cpi->gfu_boost,
cpi->twopass.est_max_qcorrection_factor,
(int)cpi->twopass.bits_left,
- cpi->twopass.total_left_stats->coded_error,
+ cpi->twopass.total_left_stats.coded_error,
cpi->tot_recode_hits, recon_err, cpi->kf_boost,
cpi->kf_zeromotion_pct);
@@ -3513,6 +3512,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// Don't increment frame counters if this was an altref buffer
// update not a real frame
+ cm->last_show_frame = cm->show_frame;
if (cm->show_frame) {
++cm->current_video_frame;
++cpi->frames_since_key;
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index f45a7e8c9..24a2acbd5 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -84,8 +84,7 @@ typedef struct {
vp9_prob sb_ymode_prob[VP9_I32X32_MODES - 1];
vp9_prob ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */
vp9_prob uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1];
- vp9_prob bmode_prob[VP9_NKF_BINTRAMODES - 1];
- vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
+ vp9_prob bmode_prob[VP9_BINTRAMODES - 1];
vp9_prob partition_prob[NUM_PARTITION_CONTEXTS][PARTITION_TYPES - 1];
vp9_prob switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1]
@@ -416,8 +415,7 @@ typedef struct VP9_COMP {
int sb_ymode_count [VP9_I32X32_MODES];
int ymode_count[VP9_YMODES]; /* intra MB type cts this frame */
- int bmode_count[VP9_NKF_BINTRAMODES];
- int sub_mv_ref_count[SUBMVREF_COUNT][VP9_SUBMVREFS];
+ int bmode_count[VP9_BINTRAMODES];
int y_uv_mode_count[VP9_YMODES][VP9_UV_MODES];
unsigned int partition_count[NUM_PARTITION_CONTEXTS][PARTITION_TYPES];
diff --git a/vp9/encoder/vp9_picklpf.c b/vp9/encoder/vp9_picklpf.c
index d69b3a3e3..a87d05838 100644
--- a/vp9/encoder/vp9_picklpf.c
+++ b/vp9/encoder/vp9_picklpf.c
@@ -163,7 +163,7 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) {
// Get baseline error score
vp9_set_alt_lf_level(cpi, filt_mid);
- vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_mid, 1, 0);
+ vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_mid, 1);
best_err = vp9_calc_ss_err(sd, cm->frame_to_show);
filt_best = filt_mid;
@@ -188,7 +188,7 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) {
if ((filt_direction <= 0) && (filt_low != filt_mid)) {
// Get Low filter error score
vp9_set_alt_lf_level(cpi, filt_low);
- vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_low, 1, 0);
+ vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_low, 1);
filt_err = vp9_calc_ss_err(sd, cm->frame_to_show);
@@ -208,7 +208,7 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) {
// Now look at filt_high
if ((filt_direction >= 0) && (filt_high != filt_mid)) {
vp9_set_alt_lf_level(cpi, filt_high);
- vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_high, 1, 0);
+ vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_high, 1);
filt_err = vp9_calc_ss_err(sd, cm->frame_to_show);
@@ -233,30 +233,4 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) {
}
cm->filter_level = filt_best;
-
-#if CONFIG_LOOP_DERING
- /* Decide whether to turn on deringing filter */
- { // NOLINT
- int best_dering = 0;
- int this_dering;
- int last_err_diff = INT_MAX;
-
- for (this_dering = 1; this_dering <= 16; this_dering++) {
- vp9_set_alt_lf_level(cpi, filt_best);
- vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_high, 1, this_dering);
- filt_err = vp9_calc_ss_err(sd, cm->frame_to_show);
- vp8_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show);
- if (filt_err < best_err) {
- best_err = filt_err;
- best_dering = this_dering;
- last_err_diff = INT_MAX;
- } else {
- if (filt_err - best_err > last_err_diff)
- break;
- last_err_diff = filt_err - best_err;
- }
- }
- cm->dering_enabled = best_dering;
- }
-#endif
}
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index 263387185..cf1132e3a 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -128,7 +128,6 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
vp9_copy(cc->sb_ymode_prob, cm->fc.sb_ymode_prob);
vp9_copy(cc->bmode_prob, cm->fc.bmode_prob);
vp9_copy(cc->uv_mode_prob, cm->fc.uv_mode_prob);
- vp9_copy(cc->sub_mv_ref_prob, cm->fc.sub_mv_ref_prob);
vp9_copy(cc->partition_prob, cm->fc.partition_prob);
vp9_copy(cc->segment_pred_probs, cm->segment_pred_probs);
@@ -168,7 +167,6 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
vp9_copy(cm->fc.sb_ymode_prob, cc->sb_ymode_prob);
vp9_copy(cm->fc.bmode_prob, cc->bmode_prob);
vp9_copy(cm->fc.uv_mode_prob, cc->uv_mode_prob);
- vp9_copy(cm->fc.sub_mv_ref_prob, cc->sub_mv_ref_prob);
vp9_copy(cm->fc.partition_prob, cc->partition_prob);
vp9_copy(cm->segment_pred_probs, cc->segment_pred_probs);
diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c
index 15ed8318c..2eb3f9b29 100644
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -576,7 +576,7 @@ static void super_block_yrd(VP9_COMP *cpi,
}
static int64_t rd_pick_intra4x4block(VP9_COMP *cpi, MACROBLOCK *x, int ib,
- B_PREDICTION_MODE *best_mode,
+ MB_PREDICTION_MODE *best_mode,
int *bmode_costs,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
int *bestrate, int *bestratey,
@@ -737,7 +737,7 @@ static int64_t rd_pick_intra4x4mby_modes(VP9_COMP *cpi, MACROBLOCK *mb,
for (idx = 0; idx < 2; idx += bw) {
MODE_INFO *const mic = xd->mode_info_context;
const int mis = xd->mode_info_stride;
- B_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode);
+ MB_PREDICTION_MODE UNINITIALIZED_IS_SAFE(best_mode);
int UNINITIALIZED_IS_SAFE(r), UNINITIALIZED_IS_SAFE(ry);
int UNINITIALIZED_IS_SAFE(d);
i = idy * 2 + idx;
@@ -940,8 +940,9 @@ void vp9_set_mbmode_and_mvs(MACROBLOCK *x, MB_PREDICTION_MODE mb, int_mv *mv) {
static int labels2mode(MACROBLOCK *x,
int const *labelings, int which_label,
- B_PREDICTION_MODE this_mode,
+ MB_PREDICTION_MODE this_mode,
int_mv *this_mv, int_mv *this_second_mv,
+ int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES],
int_mv seg_mvs[MAX_REF_FRAMES - 1],
int_mv *best_ref_mv,
int_mv *second_best_ref_mv,
@@ -949,7 +950,6 @@ static int labels2mode(MACROBLOCK *x,
MACROBLOCKD *const xd = &x->e_mbd;
MODE_INFO *const mic = xd->mode_info_context;
MB_MODE_INFO * mbmi = &mic->mbmi;
- const int mis = xd->mode_info_stride;
int i, cost = 0, thismvcost = 0;
int idx, idy;
int bw = 1 << b_width_log2(mbmi->sb_type);
@@ -959,21 +959,16 @@ static int labels2mode(MACROBLOCK *x,
Ones from this macroblock have to be pulled from the BLOCKD array
as they have not yet made it to the bmi array in our MB_MODE_INFO. */
for (i = 0; i < 4; ++i) {
- const int row = i >> 1, col = i & 1;
- B_PREDICTION_MODE m;
+ MB_PREDICTION_MODE m;
if (labelings[i] != which_label)
continue;
- if (col && labelings[i] == labelings[i - 1])
- m = LEFT4X4;
- else if (row && labelings[i] == labelings[i - 2])
- m = ABOVE4X4;
- else {
+ {
// the only time we should do costing for new motion vector or mode
// is when we are on a new label (jbb May 08, 2007)
switch (m = this_mode) {
- case NEW4X4 :
+ case NEWMV:
if (mbmi->second_ref_frame > 0) {
this_mv->as_int = seg_mvs[mbmi->ref_frame - 1].as_int;
this_second_mv->as_int =
@@ -988,21 +983,19 @@ static int labels2mode(MACROBLOCK *x,
xd->allow_high_precision_mv);
}
break;
- case LEFT4X4:
- this_mv->as_int = col ? mic->bmi[i - 1].as_mv[0].as_int :
- left_block_mv(xd, mic, i);
+ case NEARESTMV:
+ this_mv->as_int = frame_mv[NEARESTMV][mbmi->ref_frame].as_int;
if (mbmi->second_ref_frame > 0)
- this_second_mv->as_int = col ? mic->bmi[i - 1].as_mv[1].as_int :
- left_block_second_mv(xd, mic, i);
+ this_second_mv->as_int =
+ frame_mv[NEARESTMV][mbmi->second_ref_frame].as_int;
break;
- case ABOVE4X4:
- this_mv->as_int = row ? mic->bmi[i - 2].as_mv[0].as_int :
- above_block_mv(mic, i, mis);
+ case NEARMV:
+ this_mv->as_int = frame_mv[NEARMV][mbmi->ref_frame].as_int;
if (mbmi->second_ref_frame > 0)
- this_second_mv->as_int = row ? mic->bmi[i - 2].as_mv[1].as_int :
- above_block_second_mv(mic, i, mis);
+ this_second_mv->as_int =
+ frame_mv[NEARMV][mbmi->second_ref_frame].as_int;
break;
- case ZERO4X4:
+ case ZEROMV:
this_mv->as_int = 0;
if (mbmi->second_ref_frame > 0)
this_second_mv->as_int = 0;
@@ -1011,22 +1004,8 @@ static int labels2mode(MACROBLOCK *x,
break;
}
- if (m == ABOVE4X4) { // replace above with left if same
- int_mv left_mv, left_second_mv;
-
- left_second_mv.as_int = 0;
- left_mv.as_int = col ? mic->bmi[i - 1].as_mv[0].as_int :
- left_block_mv(xd, mic, i);
- if (mbmi->second_ref_frame > 0)
- left_second_mv.as_int = col ? mic->bmi[i - 1].as_mv[1].as_int :
- left_block_second_mv(xd, mic, i);
-
- if (left_mv.as_int == this_mv->as_int &&
- (mbmi->second_ref_frame <= 0 ||
- left_second_mv.as_int == this_second_mv->as_int))
- m = LEFT4X4;
- }
- cost = x->inter_bmode_costs[m];
+ cost = vp9_cost_mv_ref(cpi, this_mode,
+ mbmi->mb_mode_context[mbmi->ref_frame]);
}
mic->bmi[i].as_mv[0].as_int = this_mv->as_int;
@@ -1150,7 +1129,7 @@ typedef struct {
int r;
int d;
int segment_yrate;
- B_PREDICTION_MODE modes[4];
+ MB_PREDICTION_MODE modes[4];
int_mv mvs[4], second_mvs[4];
int eobs[4];
int mvthresh;
@@ -1215,7 +1194,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
int i, j;
static const int labels[4] = { 0, 1, 2, 3 };
int br = 0, bd = 0;
- B_PREDICTION_MODE this_mode;
+ MB_PREDICTION_MODE this_mode;
MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi;
const int label_count = 4;
int64_t this_segment_rd = 0, other_segment_rd;
@@ -1251,191 +1230,37 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
for (idx = 0; idx < 2; idx += bw) {
// TODO(jingning,rbultje): rewrite the rate-distortion optimization
// loop for 4x4/4x8/8x4 block coding. to be replaced with new rd loop
-#if CONFIG_AB4X4 || 1
- int_mv mode_mv[B_MODE_COUNT], second_mode_mv[B_MODE_COUNT];
+ int_mv mode_mv[MB_MODE_COUNT], second_mode_mv[MB_MODE_COUNT];
+ int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES];
int64_t best_label_rd = INT64_MAX, best_other_rd = INT64_MAX;
- B_PREDICTION_MODE mode_selected = ZERO4X4;
+ MB_PREDICTION_MODE mode_selected = ZEROMV;
int bestlabelyrate = 0;
i = idy * 2 + idx;
- // search for the best motion vector on this segment
- for (this_mode = LEFT4X4; this_mode <= NEW4X4; ++this_mode) {
- int64_t this_rd;
- int distortion;
- int labelyrate;
- ENTROPY_CONTEXT t_above_s[4], t_left_s[4];
-
- vpx_memcpy(t_above_s, t_above, sizeof(t_above_s));
- vpx_memcpy(t_left_s, t_left, sizeof(t_left_s));
-
- // motion search for newmv (single predictor case only)
- if (mbmi->second_ref_frame <= 0 && this_mode == NEW4X4) {
- int sseshift, n;
- int step_param = 0;
- int further_steps;
- int thissme, bestsme = INT_MAX;
- const struct buf_2d orig_src = x->plane[0].src;
- const struct buf_2d orig_pre = x->e_mbd.plane[0].pre[0];
-
- /* Is the best so far sufficiently good that we cant justify doing
- * and new motion search. */
- if (best_label_rd < label_mv_thresh)
- break;
-
- if (cpi->compressor_speed) {
- // use previous block's result as next block's MV predictor.
- if (i > 0) {
- bsi->mvp.as_int =
- x->e_mbd.mode_info_context->bmi[i - 1].as_mv[0].as_int;
- if (i == 2)
- bsi->mvp.as_int =
- x->e_mbd.mode_info_context->bmi[i - 2].as_mv[0].as_int;
- step_param = 2;
- }
- }
-
- further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
-
- {
- int sadpb = x->sadperbit4;
- int_mv mvp_full;
-
- mvp_full.as_mv.row = bsi->mvp.as_mv.row >> 3;
- mvp_full.as_mv.col = bsi->mvp.as_mv.col >> 3;
-
- // find first label
- n = i;
-
- // adjust src pointer for this segment
- x->plane[0].src.buf =
- raster_block_offset_uint8(&x->e_mbd, BLOCK_SIZE_SB8X8, 0, n,
- x->plane[0].src.buf,
- x->plane[0].src.stride);
- assert(((intptr_t)x->e_mbd.plane[0].pre[0].buf & 0x7) == 0);
- x->e_mbd.plane[0].pre[0].buf =
- raster_block_offset_uint8(&x->e_mbd, BLOCK_SIZE_SB8X8, 0, n,
- x->e_mbd.plane[0].pre[0].buf,
- x->e_mbd.plane[0].pre[0].stride);
-
- bestsme = vp9_full_pixel_diamond(cpi, x, &mvp_full, step_param,
- sadpb, further_steps, 0, v_fn_ptr,
- bsi->ref_mv, &mode_mv[NEW4X4]);
-
- sseshift = 0;
-
- // Should we do a full search (best quality only)
- if ((cpi->compressor_speed == 0) && (bestsme >> sseshift) > 4000) {
- /* Check if mvp_full is within the range. */
- clamp_mv(&mvp_full, x->mv_col_min, x->mv_col_max,
- x->mv_row_min, x->mv_row_max);
-
- thissme = cpi->full_search_sad(x, &mvp_full,
- sadpb, 16, v_fn_ptr,
- x->nmvjointcost, x->mvcost,
- bsi->ref_mv,
- n);
-
- if (thissme < bestsme) {
- bestsme = thissme;
- mode_mv[NEW4X4].as_int =
- x->e_mbd.mode_info_context->bmi[n].as_mv[0].as_int;
- } else {
- /* The full search result is actually worse so re-instate the
- * previous best vector */
- x->e_mbd.mode_info_context->bmi[n].as_mv[0].as_int =
- mode_mv[NEW4X4].as_int;
- }
- }
- }
-
- if (bestsme < INT_MAX) {
- int distortion;
- unsigned int sse;
- cpi->find_fractional_mv_step(x, &mode_mv[NEW4X4],
- bsi->ref_mv, x->errorperbit, v_fn_ptr,
- x->nmvjointcost, x->mvcost,
- &distortion, &sse);
-
- // safe motion search result for use in compound prediction
- seg_mvs[i][mbmi->ref_frame - 1].as_int = mode_mv[NEW4X4].as_int;
- }
-
- // restore src pointers
- x->plane[0].src = orig_src;
- x->e_mbd.plane[0].pre[0] = orig_pre;
- } else if (mbmi->second_ref_frame > 0 && this_mode == NEW4X4) {
- /* NEW4X4 */
- /* motion search not completed? Then skip newmv for this block with
- * comppred */
- if (seg_mvs[i][mbmi->second_ref_frame - 1].as_int == INVALID_MV ||
- seg_mvs[i][mbmi->ref_frame - 1].as_int == INVALID_MV) {
- continue;
- }
- }
-
- rate = labels2mode(x, labels, i, this_mode, &mode_mv[this_mode],
- &second_mode_mv[this_mode], seg_mvs[i],
- bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost,
- x->mvcost, cpi);
-
- // Trap vectors that reach beyond the UMV borders
- if (((mode_mv[this_mode].as_mv.row >> 3) < x->mv_row_min) ||
- ((mode_mv[this_mode].as_mv.row >> 3) > x->mv_row_max) ||
- ((mode_mv[this_mode].as_mv.col >> 3) < x->mv_col_min) ||
- ((mode_mv[this_mode].as_mv.col >> 3) > x->mv_col_max)) {
- continue;
- }
- if (mbmi->second_ref_frame > 0 &&
- mv_check_bounds(x, &second_mode_mv[this_mode]))
- continue;
-
- this_rd = encode_inter_mb_segment(&cpi->common,
- x, labels, i, &labelyrate,
- &distortion, t_above_s, t_left_s);
- this_rd += RDCOST(x->rdmult, x->rddiv, rate, 0);
- rate += labelyrate;
-
- if (this_rd < best_label_rd) {
- sbr = rate;
- sbd = distortion;
- bestlabelyrate = labelyrate;
- mode_selected = this_mode;
- best_label_rd = this_rd;
- for (j = 0; j < 4; j++)
- if (labels[j] == i)
- best_eobs[j] = x->e_mbd.plane[0].eobs[j];
-
- vpx_memcpy(t_above_b, t_above_s, sizeof(t_above_s));
- vpx_memcpy(t_left_b, t_left_s, sizeof(t_left_s));
- }
- } /*for each 4x4 mode*/
-
- vpx_memcpy(t_above, t_above_b, sizeof(t_above));
- vpx_memcpy(t_left, t_left_b, sizeof(t_left));
-
- labels2mode(x, labels, i, mode_selected, &mode_mv[mode_selected],
- &second_mode_mv[mode_selected], seg_mvs[i],
- bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost,
- x->mvcost, cpi);
-#else
- int_mv mode_mv[B_MODE_COUNT], second_mode_mv[B_MODE_COUNT];
- int64_t best_label_rd = INT64_MAX, best_other_rd = INT64_MAX;
- B_PREDICTION_MODE mode_selected = ZERO4X4;
- int bestlabelyrate = 0;
- i = idy * 2 + idx;
+ frame_mv[ZEROMV][mbmi->ref_frame].as_int = 0;
+ frame_mv[ZEROMV][mbmi->second_ref_frame].as_int = 0;
+ vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd,
+ &frame_mv[NEARESTMV][mbmi->ref_frame],
+ &frame_mv[NEARMV][mbmi->ref_frame],
+ i, 0);
+ if (mbmi->second_ref_frame > 0)
+ vp9_append_sub8x8_mvs_for_idx(&cpi->common, &x->e_mbd,
+ &frame_mv[NEARESTMV][mbmi->second_ref_frame],
+ &frame_mv[NEARMV][mbmi->second_ref_frame],
+ i, 1);
// search for the best motion vector on this segment
- for (this_mode = LEFT4X4; this_mode <= NEW4X4; this_mode ++) {
+ for (this_mode = NEARESTMV; this_mode <= NEWMV; ++this_mode) {
int64_t this_rd;
int distortion;
int labelyrate;
- ENTROPY_CONTEXT t_above_s[2], t_left_s[2];
+ ENTROPY_CONTEXT t_above_s[4], t_left_s[4];
vpx_memcpy(t_above_s, t_above, sizeof(t_above_s));
vpx_memcpy(t_left_s, t_left, sizeof(t_left_s));
// motion search for newmv (single predictor case only)
- if (mbmi->second_ref_frame <= 0 && this_mode == NEW4X4) {
+ if (mbmi->second_ref_frame <= 0 && this_mode == NEWMV) {
int sseshift, n;
int step_param = 0;
int further_steps;
@@ -1485,7 +1310,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
bestsme = vp9_full_pixel_diamond(cpi, x, &mvp_full, step_param,
sadpb, further_steps, 0, v_fn_ptr,
- bsi->ref_mv, &mode_mv[NEW4X4]);
+ bsi->ref_mv, &mode_mv[NEWMV]);
sseshift = 0;
@@ -1503,13 +1328,13 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
if (thissme < bestsme) {
bestsme = thissme;
- mode_mv[NEW4X4].as_int =
+ mode_mv[NEWMV].as_int =
x->e_mbd.mode_info_context->bmi[n].as_mv[0].as_int;
} else {
/* The full search result is actually worse so re-instate the
* previous best vector */
x->e_mbd.mode_info_context->bmi[n].as_mv[0].as_int =
- mode_mv[NEW4X4].as_int;
+ mode_mv[NEWMV].as_int;
}
}
}
@@ -1517,19 +1342,19 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
if (bestsme < INT_MAX) {
int distortion;
unsigned int sse;
- cpi->find_fractional_mv_step(x, &mode_mv[NEW4X4],
+ cpi->find_fractional_mv_step(x, &mode_mv[NEWMV],
bsi->ref_mv, x->errorperbit, v_fn_ptr,
x->nmvjointcost, x->mvcost,
&distortion, &sse);
// safe motion search result for use in compound prediction
- seg_mvs[i][mbmi->ref_frame - 1].as_int = mode_mv[NEW4X4].as_int;
+ seg_mvs[i][mbmi->ref_frame - 1].as_int = mode_mv[NEWMV].as_int;
}
// restore src pointers
x->plane[0].src = orig_src;
x->e_mbd.plane[0].pre[0] = orig_pre;
- } else if (mbmi->second_ref_frame > 0 && this_mode == NEW4X4) {
+ } else if (mbmi->second_ref_frame > 0 && this_mode == NEWMV) {
/* NEW4X4 */
/* motion search not completed? Then skip newmv for this block with
* comppred */
@@ -1540,7 +1365,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
}
rate = labels2mode(x, labels, i, this_mode, &mode_mv[this_mode],
- &second_mode_mv[this_mode], seg_mvs[i],
+ &second_mode_mv[this_mode], frame_mv, seg_mvs[i],
bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost,
x->mvcost, cpi);
@@ -1580,10 +1405,9 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
vpx_memcpy(t_left, t_left_b, sizeof(t_left));
labels2mode(x, labels, i, mode_selected, &mode_mv[mode_selected],
- &second_mode_mv[mode_selected], seg_mvs[i],
+ &second_mode_mv[mode_selected], frame_mv, seg_mvs[i],
bsi->ref_mv, bsi->second_ref_mv, x->nmvjointcost,
x->mvcost, cpi);
-#endif
br += sbr;
bd += sbd;
@@ -1647,7 +1471,7 @@ static int rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x,
bsi.mvthresh = mvthresh;
for (i = 0; i < 4; i++)
- bsi.modes[i] = ZERO4X4;
+ bsi.modes[i] = ZEROMV;
rd_check_segment(cpi, x, &bsi, seg_mvs);
@@ -2066,10 +1890,8 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
int *rate_y, int *distortion_y,
int *rate_uv, int *distortion_uv,
int *mode_excluded, int *disable_skip,
- int mode_index,
INTERPOLATIONFILTERTYPE *best_filter,
- int_mv frame_mv[MB_MODE_COUNT]
- [MAX_REF_FRAMES],
+ int_mv *frame_mv,
YV12_BUFFER_CONFIG **scaled_ref_frame,
int mi_row, int mi_col,
int_mv single_newmv[MAX_REF_FRAMES]) {
@@ -2144,8 +1966,8 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
scaled_first_yv12 = xd->plane[0].pre[0];
// Initialize mv using single prediction mode result.
- frame_mv[NEWMV][refs[0]].as_int = single_newmv[refs[0]].as_int;
- frame_mv[NEWMV][refs[1]].as_int = single_newmv[refs[1]].as_int;
+ frame_mv[refs[0]].as_int = single_newmv[refs[0]].as_int;
+ frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int;
// Allow joint search multiple times iteratively for each ref frame
// and break out the search loop if it couldn't find better mv.
@@ -2170,7 +1992,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
vp9_build_inter_predictor(ref_yv12[!id].buf,
ref_yv12[!id].stride,
second_pred, pw,
- &frame_mv[NEWMV][refs[!id]],
+ &frame_mv[refs[!id]],
&xd->scale_factor[!id],
pw, ph, 0,
&xd->subpix);
@@ -2181,7 +2003,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
vp9_clamp_mv_min_max(x, &ref_mv[id]);
// Use mv result from single mode as mvp.
- tmp_mv.as_int = frame_mv[NEWMV][refs[id]].as_int;
+ tmp_mv.as_int = frame_mv[refs[id]].as_int;
tmp_mv.as_mv.col >>= 3;
tmp_mv.as_mv.row >>= 3;
@@ -2216,7 +2038,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
xd->plane[0].pre[0] = scaled_first_yv12;
if (bestsme < last_besterr[id]) {
- frame_mv[NEWMV][refs[id]].as_int =
+ frame_mv[refs[id]].as_int =
xd->mode_info_context->bmi[0].as_mv[1].as_int = tmp_mv.as_int;
last_besterr[id] = bestsme;
} else {
@@ -2242,14 +2064,14 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
vpx_free(second_pred);
}
- if (frame_mv[NEWMV][refs[0]].as_int == INVALID_MV ||
- frame_mv[NEWMV][refs[1]].as_int == INVALID_MV)
+ if (frame_mv[refs[0]].as_int == INVALID_MV ||
+ frame_mv[refs[1]].as_int == INVALID_MV)
return INT64_MAX;
- *rate2 += vp9_mv_bit_cost(&frame_mv[NEWMV][refs[0]],
+ *rate2 += vp9_mv_bit_cost(&frame_mv[refs[0]],
&ref_mv[0],
x->nmvjointcost, x->mvcost, 96,
x->e_mbd.allow_high_precision_mv);
- *rate2 += vp9_mv_bit_cost(&frame_mv[NEWMV][refs[1]],
+ *rate2 += vp9_mv_bit_cost(&frame_mv[refs[1]],
&ref_mv[1],
x->nmvjointcost, x->mvcost, 96,
x->e_mbd.allow_high_precision_mv);
@@ -2316,7 +2138,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
x->nmvjointcost, x->mvcost,
&dis, &sse);
}
- frame_mv[NEWMV][refs[0]].as_int =
+ frame_mv[refs[0]].as_int =
xd->mode_info_context->bmi[0].as_mv[0].as_int = tmp_mv.as_int;
single_newmv[refs[0]].as_int = tmp_mv.as_int;
@@ -2341,7 +2163,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
break;
}
for (i = 0; i < num_refs; ++i) {
- cur_mv[i] = frame_mv[this_mode][refs[i]];
+ cur_mv[i] = frame_mv[refs[i]];
// Clip "next_nearest" so that it does not extend to far out of image
if (this_mode == NEWMV)
assert(!clamp_mv2(&cur_mv[i], xd));
@@ -3045,7 +2867,7 @@ int64_t vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi, MACROBLOCK *x,
&rate_y, &distortion_y,
&rate_uv, &distortion_uv,
&mode_excluded, &disable_skip,
- mode_index, &tmp_best_filter, frame_mv,
+ &tmp_best_filter, frame_mv[this_mode],
scaled_ref_frame, mi_row, mi_col,
single_newmv);
if (this_rd == INT64_MAX)