Merge "Removing unused vp9_mcomp_x86.h file."
diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c
index 4c896b1..6ca6087 100644
--- a/vp8/vp8_cx_iface.c
+++ b/vp8/vp8_cx_iface.c
@@ -1235,6 +1235,8 @@
0, /* rc_dropframe_thresh */
0, /* rc_resize_allowed */
+ 1, /* rc_scaled_width */
+ 1, /* rc_scaled_height */
60, /* rc_resize_down_thresold */
30, /* rc_resize_up_thresold */
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 795765d..f8a83dd 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1355,6 +1355,25 @@
}
}
+static void copy_partitioning(VP9_COMMON *cm, MODE_INFO **mi_8x8,
+ MODE_INFO **prev_mi_8x8) {
+ const int mis = cm->mi_stride;
+ int block_row, block_col;
+
+ for (block_row = 0; block_row < 8; ++block_row) {
+ for (block_col = 0; block_col < 8; ++block_col) {
+ MODE_INFO *const prev_mi = prev_mi_8x8[block_row * mis + block_col];
+ const BLOCK_SIZE sb_type = prev_mi ? prev_mi->mbmi.sb_type : 0;
+
+ if (prev_mi) {
+ const ptrdiff_t offset = prev_mi - cm->prev_mi;
+ mi_8x8[block_row * mis + block_col] = cm->mi + offset;
+ mi_8x8[block_row * mis + block_col]->mbmi.sb_type = sb_type;
+ }
+ }
+ }
+}
+
static void constrain_copy_partitioning(VP9_COMP *const cpi,
const TileInfo *const tile,
MODE_INFO **mi_8x8,
@@ -1404,38 +1423,10 @@
}
} else {
// Else this is a partial SB64, copy previous partition.
- for (block_row = 0; block_row < 8; ++block_row) {
- for (block_col = 0; block_col < 8; ++block_col) {
- MODE_INFO *const prev_mi = prev_mi_8x8[block_row * mis + block_col];
- const BLOCK_SIZE sb_type = prev_mi ? prev_mi->mbmi.sb_type : 0;
- if (prev_mi) {
- const ptrdiff_t offset = prev_mi - cm->prev_mi;
- mi_8x8[block_row * mis + block_col] = cm->mi + offset;
- mi_8x8[block_row * mis + block_col]->mbmi.sb_type = sb_type;
- }
- }
- }
+ copy_partitioning(cm, mi_8x8, prev_mi_8x8);
}
}
-static void copy_partitioning(VP9_COMMON *cm, MODE_INFO **mi_8x8,
- MODE_INFO **prev_mi_8x8) {
- const int mis = cm->mi_stride;
- int block_row, block_col;
-
- for (block_row = 0; block_row < 8; ++block_row) {
- for (block_col = 0; block_col < 8; ++block_col) {
- MODE_INFO *const prev_mi = prev_mi_8x8[block_row * mis + block_col];
- const BLOCK_SIZE sb_type = prev_mi ? prev_mi->mbmi.sb_type : 0;
-
- if (prev_mi) {
- const ptrdiff_t offset = prev_mi - cm->prev_mi;
- mi_8x8[block_row * mis + block_col] = cm->mi + offset;
- mi_8x8[block_row * mis + block_col]->mbmi.sb_type = sb_type;
- }
- }
- }
-}
const struct {
int row;
diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c
index 44b171f..a9da728 100644
--- a/vp9/encoder/vp9_mbgraph.c
+++ b/vp9/encoder/vp9_mbgraph.c
@@ -77,12 +77,12 @@
INT_MAX);
}
-static int do_16x16_motion_search(VP9_COMP *cpi, const int_mv *ref_mv,
+static int do_16x16_motion_search(VP9_COMP *cpi, const MV *ref_mv,
int_mv *dst_mv, int mb_row, int mb_col) {
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
unsigned int err, tmp_err;
- int_mv tmp_mv;
+ MV tmp_mv;
// Try zero MV first
// FIXME should really use something like near/nearest MV and/or MV prediction
@@ -93,24 +93,22 @@
// Test last reference frame using the previous best mv as the
// starting point (best reference) for the search
- tmp_err = do_16x16_motion_iteration(cpi, &ref_mv->as_mv, &tmp_mv.as_mv,
- mb_row, mb_col);
+ tmp_err = do_16x16_motion_iteration(cpi, ref_mv, &tmp_mv, mb_row, mb_col);
if (tmp_err < err) {
err = tmp_err;
- dst_mv->as_int = tmp_mv.as_int;
+ dst_mv->as_mv = tmp_mv;
}
// If the current best reference mv is not centered on 0,0 then do a 0,0
// based search as well.
- if (ref_mv->as_int) {
+ if (ref_mv->row != 0 || ref_mv->col != 0) {
unsigned int tmp_err;
- int_mv zero_ref_mv, tmp_mv;
+ MV zero_ref_mv = {0, 0}, tmp_mv;
- zero_ref_mv.as_int = 0;
- tmp_err = do_16x16_motion_iteration(cpi, &zero_ref_mv.as_mv, &tmp_mv.as_mv,
+ tmp_err = do_16x16_motion_iteration(cpi, &zero_ref_mv, &tmp_mv,
mb_row, mb_col);
if (tmp_err < err) {
- dst_mv->as_int = tmp_mv.as_int;
+ dst_mv->as_mv = tmp_mv;
err = tmp_err;
}
}
@@ -173,7 +171,7 @@
YV12_BUFFER_CONFIG *buf,
int mb_y_offset,
YV12_BUFFER_CONFIG *golden_ref,
- int_mv *prev_golden_ref_mv,
+ const MV *prev_golden_ref_mv,
YV12_BUFFER_CONFIG *alt_ref,
int mb_row,
int mb_col
@@ -239,13 +237,11 @@
int mb_col, mb_row, offset = 0;
int mb_y_offset = 0, arf_y_offset = 0, gld_y_offset = 0;
- int_mv arf_top_mv, gld_top_mv;
+ MV arf_top_mv = {0, 0}, gld_top_mv = {0, 0};
MODE_INFO mi_local = { { 0 } };
// Set up limit values for motion vectors to prevent them extending outside
// the UMV borders.
- arf_top_mv.as_int = 0;
- gld_top_mv.as_int = 0;
x->mv_row_min = -BORDER_MV_PIXELS_B16;
x->mv_row_max = (cm->mb_rows - 1) * 8 + BORDER_MV_PIXELS_B16;
xd->up_available = 0;
@@ -258,15 +254,13 @@
mi_local.mbmi.ref_frame[1] = NONE;
for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) {
- int_mv arf_left_mv, gld_left_mv;
+ MV arf_left_mv = arf_top_mv, gld_left_mv = gld_top_mv;
int mb_y_in_offset = mb_y_offset;
int arf_y_in_offset = arf_y_offset;
int gld_y_in_offset = gld_y_offset;
// Set up limit values for motion vectors to prevent them extending outside
// the UMV borders.
- arf_left_mv.as_int = arf_top_mv.as_int;
- gld_left_mv.as_int = gld_top_mv.as_int;
x->mv_col_min = -BORDER_MV_PIXELS_B16;
x->mv_col_max = (cm->mb_cols - 1) * 8 + BORDER_MV_PIXELS_B16;
xd->left_available = 0;
@@ -277,11 +271,11 @@
update_mbgraph_mb_stats(cpi, mb_stats, buf, mb_y_in_offset,
golden_ref, &gld_left_mv, alt_ref,
mb_row, mb_col);
- arf_left_mv.as_int = mb_stats->ref[ALTREF_FRAME].m.mv.as_int;
- gld_left_mv.as_int = mb_stats->ref[GOLDEN_FRAME].m.mv.as_int;
+ arf_left_mv = mb_stats->ref[ALTREF_FRAME].m.mv.as_mv;
+ gld_left_mv = mb_stats->ref[GOLDEN_FRAME].m.mv.as_mv;
if (mb_col == 0) {
- arf_top_mv.as_int = arf_left_mv.as_int;
- gld_top_mv.as_int = gld_left_mv.as_int;
+ arf_top_mv = arf_left_mv;
+ gld_top_mv = gld_left_mv;
}
xd->left_available = 1;
mb_y_in_offset += 16;
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 1d70538..4b2aa87 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -2997,6 +2997,15 @@
cm->frame_flags = *frame_flags;
+ if (cpi->pass == 2 &&
+ cm->current_video_frame == 0 &&
+ cpi->oxcf.allow_spatial_resampling &&
+ cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK) {
+ // Internal scaling is triggered on the first frame.
+ vp9_set_size_literal(cpi, cpi->oxcf.scaled_frame_width,
+ cpi->oxcf.scaled_frame_height);
+ }
+
// Reset the frame pointers to the current frame size
vp9_realloc_frame_buffer(get_frame_new_buffer(cm),
cm->width, cm->height,
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index 9ad6ae4..446080ce 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -232,6 +232,11 @@
int lossless;
AQ_MODE aq_mode; // Adaptive Quantization mode
+ // Internal frame size scaling.
+ int allow_spatial_resampling;
+ int scaled_frame_width;
+ int scaled_frame_height;
+
// Enable feature to reduce the frame quantization every x frames.
int frame_periodic_boost;
@@ -596,7 +601,7 @@
// Intra only frames, golden frames (except alt ref overlays) and
// alt ref frames tend to be coded at a higher than ambient quality
-static INLINE int vp9_frame_is_boosted(const VP9_COMP *cpi) {
+static INLINE int frame_is_boosted(const VP9_COMP *cpi) {
return frame_is_intra_only(&cpi->common) || cpi->refresh_alt_ref_frame ||
(cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref);
}
diff --git a/vp9/encoder/vp9_speed_features.c b/vp9/encoder/vp9_speed_features.c
index adad800..6948396 100644
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -49,8 +49,8 @@
if (speed >= 1) {
sf->use_square_partition_only = !frame_is_intra_only(cm);
sf->less_rectangular_check = 1;
- sf->tx_size_search_method = vp9_frame_is_boosted(cpi) ? USE_FULL_RD
- : USE_LARGESTALL;
+ sf->tx_size_search_method = frame_is_boosted(cpi) ? USE_FULL_RD
+ : USE_LARGESTALL;
if (MIN(cm->width, cm->height) >= 720)
sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
@@ -73,8 +73,8 @@
}
if (speed >= 2) {
- sf->tx_size_search_method = vp9_frame_is_boosted(cpi) ? USE_FULL_RD
- : USE_LARGESTALL;
+ sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD
+ : USE_LARGESTALL;
if (MIN(cm->width, cm->height) >= 720)
sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index 0623ad1..967431c 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -168,6 +168,11 @@
RANGE_CHECK_HI(cfg, rc_resize_down_thresh, 100);
RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS);
+ if (cfg->rc_resize_allowed == 1) {
+ RANGE_CHECK(cfg, rc_scaled_width, 1, cfg->g_w);
+ RANGE_CHECK(cfg, rc_scaled_height, 1, cfg->g_h);
+ }
+
RANGE_CHECK(cfg, ss_number_layers, 1, VPX_SS_MAX_LAYERS);
RANGE_CHECK(cfg, ts_number_layers, 1, VPX_TS_MAX_LAYERS);
if (cfg->ts_number_layers > 1) {
@@ -332,6 +337,10 @@
oxcf->under_shoot_pct = cfg->rc_undershoot_pct;
oxcf->over_shoot_pct = cfg->rc_overshoot_pct;
+ oxcf->allow_spatial_resampling = cfg->rc_resize_allowed;
+ oxcf->scaled_frame_width = cfg->rc_scaled_width;
+ oxcf->scaled_frame_height = cfg->rc_scaled_height;
+
oxcf->maximum_buffer_size = cfg->rc_buf_sz;
oxcf->starting_buffer_level = cfg->rc_buf_initial_sz;
oxcf->optimal_buffer_level = cfg->rc_buf_optimal_sz;
@@ -410,6 +419,9 @@
printf("fixed_q: %d\n", oxcf->fixed_q);
printf("worst_allowed_q: %d\n", oxcf->worst_allowed_q);
printf("best_allowed_q: %d\n", oxcf->best_allowed_q);
+ printf("allow_spatial_resampling: %d\n", oxcf->allow_spatial_resampling);
+ printf("scaled_frame_width: %d\n", oxcf->scaled_frame_width);
+ printf("scaled_frame_height: %d\n", oxcf->scaled_frame_height);
printf("two_pass_vbrbias: %d\n", oxcf->two_pass_vbrbias);
printf("two_pass_vbrmin_section: %d\n", oxcf->two_pass_vbrmin_section);
printf("two_pass_vbrmax_section: %d\n", oxcf->two_pass_vbrmax_section);
@@ -1128,6 +1140,8 @@
0, // rc_dropframe_thresh
0, // rc_resize_allowed
+ 1, // rc_scaled_width
+ 1, // rc_scaled_height
60, // rc_resize_down_thresold
30, // rc_resize_up_thresold
diff --git a/vpx/vpx_encoder.h b/vpx/vpx_encoder.h
index 2c882c1..571ad3f 100644
--- a/vpx/vpx_encoder.h
+++ b/vpx/vpx_encoder.h
@@ -396,6 +396,19 @@
*/
unsigned int rc_resize_allowed;
+ /*!\brief Internal coded frame width.
+ *
+ * If spatial resampling is enabled this specifies the width of the
+ * encoded frame.
+ */
+ unsigned int rc_scaled_width;
+
+ /*!\brief Internal coded frame height.
+ *
+ * If spatial resampling is enabled this specifies the height of the
+ * encoded frame.
+ */
+ unsigned int rc_scaled_height;
/*!\brief Spatial resampling up watermark.
*
diff --git a/vpxenc.c b/vpxenc.c
index cb91d94..c4d6421 100644
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -235,6 +235,10 @@
"Temporal resampling threshold (buf %)");
static const arg_def_t resize_allowed = ARG_DEF(NULL, "resize-allowed", 1,
"Spatial resampling enabled (bool)");
+static const arg_def_t resize_width = ARG_DEF(NULL, "resize-width", 1,
+ "Width of encoded frame");
+static const arg_def_t resize_height = ARG_DEF(NULL, "resize-height", 1,
+ "Height of encoded frame");
static const arg_def_t resize_up_thresh = ARG_DEF(NULL, "resize-up", 1,
"Upscale threshold (buf %)");
static const arg_def_t resize_down_thresh = ARG_DEF(NULL, "resize-down", 1,
@@ -265,10 +269,10 @@
static const arg_def_t buf_optimal_sz = ARG_DEF(NULL, "buf-optimal-sz", 1,
"Client optimal buffer size (ms)");
static const arg_def_t *rc_args[] = {
- &dropframe_thresh, &resize_allowed, &resize_up_thresh, &resize_down_thresh,
- &end_usage, &target_bitrate, &min_quantizer, &max_quantizer,
- &undershoot_pct, &overshoot_pct, &buf_sz, &buf_initial_sz, &buf_optimal_sz,
- NULL
+ &dropframe_thresh, &resize_allowed, &resize_width, &resize_height,
+ &resize_up_thresh, &resize_down_thresh, &end_usage, &target_bitrate,
+ &min_quantizer, &max_quantizer, &undershoot_pct, &overshoot_pct, &buf_sz,
+ &buf_initial_sz, &buf_optimal_sz, NULL
};
@@ -883,6 +887,10 @@
config->cfg.rc_dropframe_thresh = arg_parse_uint(&arg);
} else if (arg_match(&arg, &resize_allowed, argi)) {
config->cfg.rc_resize_allowed = arg_parse_uint(&arg);
+ } else if (arg_match(&arg, &resize_width, argi)) {
+ config->cfg.rc_scaled_width = arg_parse_uint(&arg);
+ } else if (arg_match(&arg, &resize_height, argi)) {
+ config->cfg.rc_scaled_height = arg_parse_uint(&arg);
} else if (arg_match(&arg, &resize_up_thresh, argi)) {
config->cfg.rc_resize_up_thresh = arg_parse_uint(&arg);
} else if (arg_match(&arg, &resize_down_thresh, argi)) {
@@ -1067,6 +1075,8 @@
SHOW(g_lag_in_frames);
SHOW(rc_dropframe_thresh);
SHOW(rc_resize_allowed);
+ SHOW(rc_scaled_width);
+ SHOW(rc_scaled_height);
SHOW(rc_resize_up_thresh);
SHOW(rc_resize_down_thresh);
SHOW(rc_end_usage);