From 484ba02435d525e22100255e4741944b582c2831 Mon Sep 17 00:00:00 2001 From: Yunqing Wang Date: Mon, 9 May 2016 14:20:50 -0700 Subject: [PATCH] Refine VP10 REFRESH_FRAME_CONTEXT_MODE In VP10, REFRESH_FRAME_CONTEXT_OFF mode is only set when the error resillient mode is on. Instead of being used to decide how to update the frame contexts, it is used to decide if or not to reset the frame contexts. To verify, ran borg test on lowres set. The result is neutral. Overall PSNR: -0.006%; SSIM: -0.006%. Change-Id: Ic48265cf7488e80c6f5aab3eef7ba1c273506419 --- vp10/common/onyxc_int.h | 4 ---- vp10/decoder/decodeframe.c | 12 +++--------- vp10/encoder/bitstream.c | 5 +---- vp10/encoder/encoder.c | 16 +++++++--------- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/vp10/common/onyxc_int.h b/vp10/common/onyxc_int.h index 7d0b259ee..d88605075 100644 --- a/vp10/common/onyxc_int.h +++ b/vp10/common/onyxc_int.h @@ -66,10 +66,6 @@ typedef enum { } RESET_FRAME_CONTEXT_MODE; typedef enum { - /** - * Don't update frame context - */ - REFRESH_FRAME_CONTEXT_OFF, /** * Update frame context to values resulting from forward probability * updates signaled in the frame header diff --git a/vp10/decoder/decodeframe.c b/vp10/decoder/decodeframe.c index 6006e2dc2..05e37cf41 100644 --- a/vp10/decoder/decodeframe.c +++ b/vp10/decoder/decodeframe.c @@ -3739,14 +3739,9 @@ static size_t read_uncompressed_header(VP10Decoder *pbi, if (!cm->error_resilient_mode) { cm->refresh_frame_context = vpx_rb_read_bit(rb) ? REFRESH_FRAME_CONTEXT_FORWARD - : REFRESH_FRAME_CONTEXT_OFF; - if (cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_FORWARD) { - cm->refresh_frame_context = - vpx_rb_read_bit(rb) ? REFRESH_FRAME_CONTEXT_FORWARD - : REFRESH_FRAME_CONTEXT_BACKWARD; - } + : REFRESH_FRAME_CONTEXT_BACKWARD; } else { - cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_OFF; + cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_FORWARD; } // This flag will be overridden by the call to vp10_setup_past_independence @@ -4274,7 +4269,6 @@ void vp10_decode_frame(VP10Decoder *pbi, } // Non frame parallel update frame context here. - if (cm->refresh_frame_context != REFRESH_FRAME_CONTEXT_OFF && - !context_updated) + if (!cm->error_resilient_mode && !context_updated) cm->frame_contexts[cm->frame_context_idx] = *cm->fc; } diff --git a/vp10/encoder/bitstream.c b/vp10/encoder/bitstream.c index b79b94ad8..afdfd18f6 100644 --- a/vp10/encoder/bitstream.c +++ b/vp10/encoder/bitstream.c @@ -3063,10 +3063,7 @@ static void write_uncompressed_header(VP10_COMP *cpi, if (!cm->error_resilient_mode) { vpx_wb_write_bit(wb, - cm->refresh_frame_context != REFRESH_FRAME_CONTEXT_OFF); - if (cm->refresh_frame_context != REFRESH_FRAME_CONTEXT_OFF) - vpx_wb_write_bit(wb, cm->refresh_frame_context != - REFRESH_FRAME_CONTEXT_BACKWARD); + cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_FORWARD); } vpx_wb_write_literal(wb, cm->frame_context_idx, FRAME_CONTEXTS_LOG2); diff --git a/vp10/encoder/encoder.c b/vp10/encoder/encoder.c index 8ed09f3fe..fc5513396 100644 --- a/vp10/encoder/encoder.c +++ b/vp10/encoder/encoder.c @@ -1986,9 +1986,8 @@ void vp10_change_config(struct VP10_COMP *cpi, const VP10EncoderConfig *oxcf) { cpi->refresh_last_frame = 1; cm->refresh_frame_context = - oxcf->error_resilient_mode ? REFRESH_FRAME_CONTEXT_OFF : - oxcf->frame_parallel_decoding_mode ? REFRESH_FRAME_CONTEXT_FORWARD - : REFRESH_FRAME_CONTEXT_BACKWARD; + (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode) ? + REFRESH_FRAME_CONTEXT_FORWARD : REFRESH_FRAME_CONTEXT_BACKWARD; cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE; cm->allow_screen_content_tools = (cpi->oxcf.content == VP9E_CONTENT_SCREEN); @@ -4324,7 +4323,7 @@ static void encode_frame_to_data_rate(VP10_COMP *cpi, // By default, encoder assumes decoder can use prev_mi. if (cm->error_resilient_mode) { cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE; - cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_OFF; + cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_FORWARD; } else if (cm->intra_only) { // Only reset the current context. cm->reset_frame_context = RESET_FRAME_CONTEXT_CURRENT; @@ -4616,7 +4615,7 @@ static int frame_is_reference(const VP10_COMP *cpi) { cpi->refresh_last_frame || cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame || - cm->refresh_frame_context != REFRESH_FRAME_CONTEXT_OFF || + !cm->error_resilient_mode || cm->lf.mode_ref_delta_update || cm->seg.update_map || cm->seg.update_data; @@ -4844,9 +4843,8 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, // Normal defaults cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE; cm->refresh_frame_context = - oxcf->error_resilient_mode ? REFRESH_FRAME_CONTEXT_OFF : - oxcf->frame_parallel_decoding_mode ? REFRESH_FRAME_CONTEXT_FORWARD - : REFRESH_FRAME_CONTEXT_BACKWARD; + (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode) ? + REFRESH_FRAME_CONTEXT_FORWARD : REFRESH_FRAME_CONTEXT_BACKWARD; cpi->refresh_last_frame = 1; cpi->refresh_golden_frame = 0; @@ -4990,7 +4988,7 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags, Pass0Encode(cpi, size, dest, frame_flags); } - if (cm->refresh_frame_context != REFRESH_FRAME_CONTEXT_OFF) + if (!cm->error_resilient_mode) cm->frame_contexts[cm->frame_context_idx] = *cm->fc; // No frame encoded, or frame was dropped, release scaled references.