summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
authorJingning Han <jingning@google.com>2014-02-18 14:52:13 -0800
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2014-02-18 14:52:13 -0800
commite3178d0c1c21534f933cb8196b79e420c5760d1a (patch)
treef09627200260c0db6d0de6463dcda091ec791054 /vp9/encoder
parentf11a85127bab26986fd4c064e5d9a4fb2497d100 (diff)
parent6478673933912195394d80fec5db94ea79c12105 (diff)
downloadlibvpx-e3178d0c1c21534f933cb8196b79e420c5760d1a.tar
libvpx-e3178d0c1c21534f933cb8196b79e420c5760d1a.tar.gz
libvpx-e3178d0c1c21534f933cb8196b79e420c5760d1a.tar.bz2
libvpx-e3178d0c1c21534f933cb8196b79e420c5760d1a.zip
Merge "Enable sub-pixel motion search for rtc mode"
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_encodeframe.c16
-rw-r--r--vp9/encoder/vp9_pickmode.c54
2 files changed, 59 insertions, 11 deletions
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index e156c3a44..1a9ab6000 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1109,8 +1109,8 @@ static void encode_b_rt(VP9_COMP *cpi, const TileInfo *const tile,
}
static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile,
- TOKENEXTRA **tp, int mi_row, int mi_col,
- int output_enabled, BLOCK_SIZE bsize) {
+ TOKENEXTRA **tp, int mi_row, int mi_col,
+ int output_enabled, BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4;
@@ -2252,11 +2252,11 @@ static INLINE int get_block_col(int b32i, int b16i, int b8i) {
}
static void rtc_use_partition(VP9_COMP *cpi,
- const TileInfo *const tile,
- MODE_INFO **mi_8x8,
- TOKENEXTRA **tp, int mi_row, int mi_col,
- BLOCK_SIZE bsize, int *rate, int64_t *dist,
- int do_recon) {
+ const TileInfo *const tile,
+ MODE_INFO **mi_8x8,
+ TOKENEXTRA **tp, int mi_row, int mi_col,
+ BLOCK_SIZE bsize, int *rate, int64_t *dist,
+ int do_recon) {
VP9_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &cpi->mb.e_mbd;
@@ -2314,6 +2314,7 @@ static void rtc_use_partition(VP9_COMP *cpi,
}
}
}
+
encode_sb_rt(cpi, tile, tp, mi_row, mi_col, 1, BLOCK_64X64);
*rate = chosen_rate;
@@ -2696,6 +2697,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
const int mis = cm->mode_info_stride;
const int mi_width = num_8x8_blocks_wide_lookup[bsize];
const int mi_height = num_8x8_blocks_high_lookup[bsize];
+
x->skip_recode = !x->select_txfm_size && mbmi->sb_type >= BLOCK_8X8 &&
(cpi->oxcf.aq_mode != COMPLEXITY_AQ) &&
!cpi->sf.use_pick_mode;
diff --git a/vp9/encoder/vp9_pickmode.c b/vp9/encoder/vp9_pickmode.c
index 822185a8a..945fa81bf 100644
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -127,9 +127,50 @@ static int full_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
// calculate the bit cost on motion vector
*rate_mv = vp9_mv_bit_cost(&tmp_mv->as_mv, &ref_mv.as_mv,
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
+ return bestsme;
+}
+static void sub_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
+ const TileInfo *const tile,
+ BLOCK_SIZE bsize, int mi_row, int mi_col,
+ int_mv *tmp_mv) {
+ MACROBLOCKD *xd = &x->e_mbd;
+ MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi;
+ struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0}};
+ int ref = mbmi->ref_frame[0];
+ int_mv ref_mv = mbmi->ref_mvs[ref][0];
+ int dis;
- return bestsme;
+ const YV12_BUFFER_CONFIG *scaled_ref_frame = vp9_get_scaled_ref_frame(cpi,
+ ref);
+ if (scaled_ref_frame) {
+ int i;
+ // Swap out the reference frame for a version that's been scaled to
+ // match the resolution of the current frame, allowing the existing
+ // motion search code to be used without additional modifications.
+ for (i = 0; i < MAX_MB_PLANE; i++)
+ backup_yv12[i] = xd->plane[i].pre[0];
+
+ setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL);
+ }
+
+ tmp_mv->as_mv.col >>= 3;
+ tmp_mv->as_mv.row >>= 3;
+
+ cpi->find_fractional_mv_step(x, &tmp_mv->as_mv, &ref_mv.as_mv,
+ cpi->common.allow_high_precision_mv,
+ x->errorperbit,
+ &cpi->fn_ptr[bsize],
+ cpi->sf.subpel_force_stop,
+ cpi->sf.subpel_iters_per_step,
+ x->nmvjointcost, x->mvcost,
+ &dis, &x->pred_sse[ref]);
+
+ if (scaled_ref_frame) {
+ int i;
+ for (i = 0; i < MAX_MB_PLANE; i++)
+ xd->plane[i].pre[0] = backup_yv12[i];
+ }
}
// TODO(jingning) placeholder for inter-frame non-RD mode decision.
@@ -161,6 +202,7 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
// initialize mode decisions
*returnrate = INT_MAX;
+ *returndistortion = INT64_MAX;
vpx_memset(mbmi, 0, sizeof(MB_MODE_INFO));
mbmi->sb_type = bsize;
mbmi->ref_frame[0] = NONE;
@@ -200,9 +242,6 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
int64_t dist;
if (this_mode == NEWMV) {
- if (this_rd < 300)
- continue;
-
x->mode_sad[ref_frame][INTER_OFFSET(NEWMV)] =
full_pixel_motion_search(cpi, x, tile, bsize, mi_row, mi_col,
&frame_mv[NEWMV][ref_frame], &rate_mv);
@@ -226,6 +265,13 @@ int64_t vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
}
// TODO(jingning) sub-pixel motion search, if NEWMV is chosen
+ if (mbmi->mode == NEWMV) {
+ ref_frame = mbmi->ref_frame[0];
+ sub_pixel_motion_search(cpi, x, tile, bsize, mi_row, mi_col,
+ &frame_mv[NEWMV][ref_frame]);
+ mbmi->mv[0].as_int = frame_mv[NEWMV][ref_frame].as_int;
+ xd->mi_8x8[0]->bmi[0].as_mv[0].as_int = mbmi->mv[0].as_int;
+ }
// TODO(jingning) intra prediction search, if the best SAD is above a certain
// threshold.