aboutsummaryrefslogtreecommitdiff
path: root/libvpx/vp9/encoder/vp9_encodeframe.c
diff options
context:
space:
mode:
Diffstat (limited to 'libvpx/vp9/encoder/vp9_encodeframe.c')
-rw-r--r--libvpx/vp9/encoder/vp9_encodeframe.c62
1 files changed, 46 insertions, 16 deletions
diff --git a/libvpx/vp9/encoder/vp9_encodeframe.c b/libvpx/vp9/encoder/vp9_encodeframe.c
index 131c4887f..a9f392bf5 100644
--- a/libvpx/vp9/encoder/vp9_encodeframe.c
+++ b/libvpx/vp9/encoder/vp9_encodeframe.c
@@ -217,8 +217,8 @@ static void set_segment_index(VP9_COMP *cpi, MACROBLOCK *const x, int mi_row,
break;
}
- // Set segment index from ROI map if it's enabled.
- if (cpi->roi.enabled)
+ // Set segment index if ROI map or active_map is enabled.
+ if (cpi->roi.enabled || cpi->active_map.enabled)
mi->segment_id = get_segment_id(cm, map, bsize, mi_row, mi_col);
vp9_init_plane_quantizers(cpi, x);
@@ -1905,13 +1905,17 @@ void vp9_setup_src_planes(MACROBLOCK *x, const YV12_BUFFER_CONFIG *src,
}
static void set_mode_info_seg_skip(MACROBLOCK *x, TX_MODE tx_mode,
+ INTERP_FILTER interp_filter,
RD_COST *rd_cost, BLOCK_SIZE bsize) {
MACROBLOCKD *const xd = &x->e_mbd;
MODE_INFO *const mi = xd->mi[0];
INTERP_FILTER filter_ref;
filter_ref = get_pred_context_switchable_interp(xd);
- if (filter_ref == SWITCHABLE_FILTERS) filter_ref = EIGHTTAP;
+ if (interp_filter == BILINEAR)
+ filter_ref = BILINEAR;
+ else if (filter_ref == SWITCHABLE_FILTERS)
+ filter_ref = EIGHTTAP;
mi->sb_type = bsize;
mi->mode = ZEROMV;
@@ -2495,7 +2499,8 @@ static void update_state_rt(VP9_COMP *cpi, ThreadData *td,
*(xd->mi[0]) = ctx->mic;
*(x->mbmi_ext) = ctx->mbmi_ext;
- if (seg->enabled && (cpi->oxcf.aq_mode != NO_AQ || cpi->roi.enabled)) {
+ if (seg->enabled && (cpi->oxcf.aq_mode != NO_AQ || cpi->roi.enabled ||
+ cpi->active_map.enabled)) {
// Setting segmentation map for cyclic_refresh.
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ &&
cpi->cyclic_refresh->content_mode) {
@@ -4682,7 +4687,7 @@ static void nonrd_pick_sb_modes(VP9_COMP *cpi, TileDataEnc *tile_data,
hybrid_search_svc_baseiskey(cpi, x, rd_cost, bsize, ctx, tile_data, mi_row,
mi_col);
else if (segfeature_active(&cm->seg, mi->segment_id, SEG_LVL_SKIP))
- set_mode_info_seg_skip(x, cm->tx_mode, rd_cost, bsize);
+ set_mode_info_seg_skip(x, cm->tx_mode, cm->interp_filter, rd_cost, bsize);
else if (bsize >= BLOCK_8X8) {
if (cpi->rc.hybrid_intra_scene_change)
hybrid_search_scene_change(cpi, x, rd_cost, bsize, ctx, tile_data, mi_row,
@@ -5513,16 +5518,6 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td,
x->arf_frame_usage = 0;
x->lastgolden_frame_usage = 0;
- if (seg->enabled) {
- const uint8_t *const map =
- seg->update_map ? cpi->segmentation_map : cm->last_frame_seg_map;
- int segment_id = get_segment_id(cm, map, BLOCK_64X64, mi_row, mi_col);
- seg_skip = segfeature_active(seg, segment_id, SEG_LVL_SKIP);
- if (seg_skip) {
- partition_search_type = FIXED_PARTITION;
- }
- }
-
if (cpi->compute_source_sad_onepass && cpi->sf.use_source_sad) {
int shift = cpi->Source->y_stride * (mi_row << 3) + (mi_col << 3);
int sb_offset2 = ((cm->mi_cols + 7) >> 3) * (mi_row >> 3) + (mi_col >> 3);
@@ -5534,6 +5529,38 @@ static void encode_nonrd_sb_row(VP9_COMP *cpi, ThreadData *td,
partition_search_type = REFERENCE_PARTITION;
}
+ if (seg->enabled) {
+ const uint8_t *const map =
+ seg->update_map ? cpi->segmentation_map : cm->last_frame_seg_map;
+ int segment_id = get_segment_id(cm, map, BLOCK_64X64, mi_row, mi_col);
+ seg_skip = segfeature_active(seg, segment_id, SEG_LVL_SKIP);
+
+ if (cpi->roi.enabled && cpi->roi.skip[BACKGROUND_SEG_SKIP_ID] &&
+ cpi->rc.frames_since_key > FRAMES_NO_SKIPPING_AFTER_KEY &&
+ x->content_state_sb > kLowSadLowSumdiff) {
+ // For ROI with skip, force segment = 0 (no skip) over whole
+ // superblock to avoid artifacts if temporal change in source_sad is
+ // not 0.
+ int xi, yi;
+ const int bw = num_8x8_blocks_wide_lookup[BLOCK_64X64];
+ const int bh = num_8x8_blocks_high_lookup[BLOCK_64X64];
+ const int xmis = VPXMIN(cm->mi_cols - mi_col, bw);
+ const int ymis = VPXMIN(cm->mi_rows - mi_row, bh);
+ const int block_index = mi_row * cm->mi_cols + mi_col;
+ set_mode_info_offsets(cm, x, xd, mi_row, mi_col);
+ for (yi = 0; yi < ymis; yi++)
+ for (xi = 0; xi < xmis; xi++) {
+ int map_offset = block_index + yi * cm->mi_cols + xi;
+ cpi->segmentation_map[map_offset] = 0;
+ }
+ set_segment_index(cpi, x, mi_row, mi_col, BLOCK_64X64, 0);
+ seg_skip = 0;
+ }
+ if (seg_skip) {
+ partition_search_type = FIXED_PARTITION;
+ }
+ }
+
// Set the partition type of the 64X64 block
switch (partition_search_type) {
case VAR_BASED_PARTITION:
@@ -5829,9 +5856,12 @@ void vp9_encode_sb_row(VP9_COMP *cpi, ThreadData *td, int tile_row,
get_start_tok(cpi, tile_row, tile_col, mi_row, &tok);
cpi->tplist[tile_row][tile_col][tile_sb_row].start = tok;
+#if CONFIG_REALTIME_ONLY
+ assert(cpi->sf.use_nonrd_pick_mode);
+ encode_nonrd_sb_row(cpi, td, this_tile, mi_row, &tok);
+#else
if (cpi->sf.use_nonrd_pick_mode)
encode_nonrd_sb_row(cpi, td, this_tile, mi_row, &tok);
-#if !CONFIG_REALTIME_ONLY
else
encode_rd_sb_row(cpi, td, this_tile, mi_row, &tok);
#endif