Commit 85e8c797 authored by Soo-Chul Han's avatar Soo-Chul Han

[segment_pred_last] fix resolution change issues

explicitly disable segmentation when ref frame has different
resolution

BUG=aomedia:1205
BUG=aomedia:1223
BUG=aomedia:1256

Change-Id: I6db51116db308514d572eb465c2453403e64e1f2
parent 76f34734
......@@ -3081,13 +3081,15 @@ void av1_setup_past_independence(AV1_COMMON *cm) {
av1_clearall_segfeatures(&cm->seg);
if (cm->last_frame_seg_map && !cm->frame_parallel_decode)
#if CONFIG_SEGMENT_PRED_LAST
cm->current_frame_seg_map = cm->cur_frame->seg_map;
#endif
#if !CONFIG_SEGMENT_PRED_LAST
if (cm->last_frame_seg_map && !cm->frame_parallel_decode)
memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
#else
memset(cm->last_frame_seg_map, 0,
(cm->prev_frame->mi_cols * cm->prev_frame->mi_rows));
#endif
if (cm->current_frame_seg_map)
memset(cm->current_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
......
......@@ -48,10 +48,24 @@ static int get_aq_c_strength(int q_index, aom_bit_depth_t bit_depth) {
void av1_setup_in_frame_q_adj(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
struct segmentation *const seg = &cm->seg;
#if CONFIG_SEGMENT_PRED_LAST
int resolution_change =
(cm->width != cm->last_width || cm->height != cm->last_height) &&
cm->prev_frame;
#endif
// Make SURE use of floating point in this function is safe.
aom_clear_system_state();
#if CONFIG_SEGMENT_PRED_LAST
if (resolution_change) {
memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
av1_clearall_segfeatures(seg);
av1_disable_segmentation(seg);
return;
}
#endif
if (frame_is_intra_only(cm) || cm->error_resilient_mode ||
cpi->refresh_alt_ref_frame ||
(cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) {
......
......@@ -479,6 +479,18 @@ void av1_cyclic_refresh_setup(AV1_COMP *const cpi) {
CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
struct segmentation *const seg = &cm->seg;
const int apply_cyclic_refresh = apply_cyclic_refresh_bitrate(cm, rc);
#if CONFIG_SEGMENT_PRED_LAST
int resolution_change =
(cm->width != cm->last_width || cm->height != cm->last_height) &&
cm->prev_frame;
if (resolution_change) {
memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
av1_clearall_segfeatures(seg);
aom_clear_system_state();
av1_disable_segmentation(seg);
return;
}
#endif
if (cm->current_video_frame == 0) cr->low_content_avg = 0.0;
// Don't apply refresh on key frame or enhancement layer frames.
if (!apply_cyclic_refresh || cm->frame_type == KEY_FRAME) {
......
......@@ -47,6 +47,18 @@ void av1_vaq_frame_setup(AV1_COMP *cpi) {
struct segmentation *seg = &cm->seg;
int i;
#if CONFIG_SEGMENT_PRED_LAST
int resolution_change =
(cm->width != cm->last_width || cm->height != cm->last_height) &&
cm->prev_frame;
if (resolution_change) {
memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
av1_clearall_segfeatures(seg);
aom_clear_system_state();
av1_disable_segmentation(seg);
return;
}
#endif
if (frame_is_intra_only(cm) || cm->error_resilient_mode ||
cpi->refresh_alt_ref_frame ||
(cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) {
......
......@@ -310,11 +310,17 @@ static BLOCK_SIZE select_sb_size(const AV1_COMP *const cpi) {
static void setup_frame(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
// Set up entropy context depending on frame type. The decoder mandates
// the use of the default context, index 0, for keyframes and inter
// frames where the error_resilient_mode or intra_only flag is set. For
// other inter-frames the encoder currently uses only two contexts;
// context 1 for ALTREF frames and context 0 for the others.
// Set up entropy context depending on frame type. The decoder mandates
// the use of the default context, index 0, for keyframes and inter
// frames where the error_resilient_mode or intra_only flag is set. For
// other inter-frames the encoder currently uses only two contexts;
// context 1 for ALTREF frames and context 0 for the others.
#if CONFIG_SEGMENT_PRED_LAST
if (cm->prev_frame) cm->last_frame_seg_map = cm->prev_frame->seg_map;
cm->current_frame_seg_map = cm->cur_frame->seg_map;
#endif
if (frame_is_intra_only(cm) || cm->error_resilient_mode) {
av1_setup_past_independence(cm);
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment