Commit a6a854b1 authored by Thomas Daede's avatar Thomas Daede

Frame context signaling: Remove reset symbols from the bitstream.

Because frame contexts now follow reference frames, explicit resets
are no longer necessary, but can simply happen at the same time
as reference frame resets.

Change-Id: Idbed3794e3ed52fa298346943a3014fa1ca23897
parent e9b15e2b
...@@ -5522,6 +5522,12 @@ void av1_setup_past_independence(AV1_COMMON *cm) { ...@@ -5522,6 +5522,12 @@ void av1_setup_past_independence(AV1_COMMON *cm) {
av1_convolve_init(cm); av1_convolve_init(cm);
cm->fc->initialized = 1; cm->fc->initialized = 1;
#if CONFIG_NO_FRAME_CONTEXT_SIGNALING
if (cm->frame_type == KEY_FRAME) {
// Reset all frame contexts, as all reference frames will be lost.
for (i = 0; i < FRAME_CONTEXTS; ++i) cm->frame_contexts[i] = *cm->fc;
}
#else
if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode || if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode ||
cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) { cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) {
// Reset all frame contexts. // Reset all frame contexts.
...@@ -5537,6 +5543,7 @@ void av1_setup_past_independence(AV1_COMMON *cm) { ...@@ -5537,6 +5543,7 @@ void av1_setup_past_independence(AV1_COMMON *cm) {
cm->frame_contexts[cm->frame_context_idx] = *cm->fc; cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
#endif // CONFIG_NO_FRAME_CONTEXT_SIGNALING #endif // CONFIG_NO_FRAME_CONTEXT_SIGNALING
} }
#endif // CONFIG_NO_FRAME_CONTEXT_SIGNALING
// prev_mip will only be allocated in encoder. // prev_mip will only be allocated in encoder.
if (frame_is_intra_only(cm) && cm->prev_mip && !cm->frame_parallel_decode) if (frame_is_intra_only(cm) && cm->prev_mip && !cm->frame_parallel_decode)
......
...@@ -86,11 +86,13 @@ typedef enum { ...@@ -86,11 +86,13 @@ typedef enum {
REFERENCE_MODES = 3, REFERENCE_MODES = 3,
} REFERENCE_MODE; } REFERENCE_MODE;
#if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
typedef enum { typedef enum {
RESET_FRAME_CONTEXT_NONE = 0, RESET_FRAME_CONTEXT_NONE = 0,
RESET_FRAME_CONTEXT_CURRENT = 1, RESET_FRAME_CONTEXT_CURRENT = 1,
RESET_FRAME_CONTEXT_ALL = 2, RESET_FRAME_CONTEXT_ALL = 2,
} RESET_FRAME_CONTEXT_MODE; } RESET_FRAME_CONTEXT_MODE;
#endif
typedef enum { typedef enum {
/** /**
...@@ -235,8 +237,10 @@ typedef struct AV1Common { ...@@ -235,8 +237,10 @@ typedef struct AV1Common {
#endif // CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT #endif // CONFIG_WEDGE || CONFIG_COMPOUND_SEGMENT
#endif // CONFIG_EXT_INTER #endif // CONFIG_EXT_INTER
#if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
// Flag signaling which frame contexts should be reset to default values. // Flag signaling which frame contexts should be reset to default values.
RESET_FRAME_CONTEXT_MODE reset_frame_context; RESET_FRAME_CONTEXT_MODE reset_frame_context;
#endif
// MBs, mb_rows/cols is in 16-pixel units; mi_rows/cols is in // MBs, mb_rows/cols is in 16-pixel units; mi_rows/cols is in
// MODE_INFO (8-pixel) units. // MODE_INFO (8-pixel) units.
......
...@@ -4563,6 +4563,13 @@ static size_t read_uncompressed_header(AV1Decoder *pbi, ...@@ -4563,6 +4563,13 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
#if CONFIG_PALETTE || CONFIG_INTRABC #if CONFIG_PALETTE || CONFIG_INTRABC
if (cm->intra_only) cm->allow_screen_content_tools = aom_rb_read_bit(rb); if (cm->intra_only) cm->allow_screen_content_tools = aom_rb_read_bit(rb);
#endif // CONFIG_PALETTE || CONFIG_INTRABC #endif // CONFIG_PALETTE || CONFIG_INTRABC
#if CONFIG_TEMPMV_SIGNALING
if (cm->intra_only || cm->error_resilient_mode) cm->use_prev_frame_mvs = 0;
#endif
#if CONFIG_NO_FRAME_CONTEXT_SIGNALING
// The only way to reset all frame contexts to their default values is with a
// keyframe.
#else
if (cm->error_resilient_mode) { if (cm->error_resilient_mode) {
cm->reset_frame_context = RESET_FRAME_CONTEXT_ALL; cm->reset_frame_context = RESET_FRAME_CONTEXT_ALL;
} else { } else {
...@@ -4580,6 +4587,7 @@ static size_t read_uncompressed_header(AV1Decoder *pbi, ...@@ -4580,6 +4587,7 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
: RESET_FRAME_CONTEXT_CURRENT; : RESET_FRAME_CONTEXT_CURRENT;
} }
} }
#endif
if (cm->intra_only) { if (cm->intra_only) {
if (!av1_read_sync_code(rb)) if (!av1_read_sync_code(rb))
...@@ -5487,9 +5495,7 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data, ...@@ -5487,9 +5495,7 @@ void av1_decode_frame(AV1Decoder *pbi, const uint8_t *data,
// Non frame parallel update frame context here. // Non frame parallel update frame context here.
#if CONFIG_NO_FRAME_CONTEXT_SIGNALING #if CONFIG_NO_FRAME_CONTEXT_SIGNALING
// TODO(tdaede): Figure out of this condition is required. if (!context_updated) cm->frame_contexts[cm->new_fb_idx] = *cm->fc;
if (!cm->error_resilient_mode && !context_updated)
cm->frame_contexts[cm->new_fb_idx] = *cm->fc;
#else #else
if (!cm->error_resilient_mode && !context_updated) if (!cm->error_resilient_mode && !context_updated)
cm->frame_contexts[cm->frame_context_idx] = *cm->fc; cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
......
...@@ -4358,6 +4358,7 @@ static void write_uncompressed_header(AV1_COMP *cpi, ...@@ -4358,6 +4358,7 @@ static void write_uncompressed_header(AV1_COMP *cpi,
#if CONFIG_PALETTE || CONFIG_INTRABC #if CONFIG_PALETTE || CONFIG_INTRABC
if (cm->intra_only) aom_wb_write_bit(wb, cm->allow_screen_content_tools); if (cm->intra_only) aom_wb_write_bit(wb, cm->allow_screen_content_tools);
#endif // CONFIG_PALETTE || CONFIG_INTRABC #endif // CONFIG_PALETTE || CONFIG_INTRABC
#if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
if (!cm->error_resilient_mode) { if (!cm->error_resilient_mode) {
if (cm->intra_only) { if (cm->intra_only) {
aom_wb_write_bit(wb, aom_wb_write_bit(wb,
...@@ -4370,7 +4371,7 @@ static void write_uncompressed_header(AV1_COMP *cpi, ...@@ -4370,7 +4371,7 @@ static void write_uncompressed_header(AV1_COMP *cpi,
cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL); cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL);
} }
} }
#endif
#if CONFIG_EXT_REFS #if CONFIG_EXT_REFS
cpi->refresh_frame_mask = get_refresh_mask(cpi); cpi->refresh_frame_mask = get_refresh_mask(cpi);
#endif // CONFIG_EXT_REFS #endif // CONFIG_EXT_REFS
......
...@@ -352,10 +352,12 @@ static void setup_frame(AV1_COMP *cpi) { ...@@ -352,10 +352,12 @@ static void setup_frame(AV1_COMP *cpi) {
#endif #endif
#endif #endif
#if CONFIG_NO_FRAME_CONTEXT_SIGNALING #if CONFIG_NO_FRAME_CONTEXT_SIGNALING
if (frame_is_intra_only(cm) || cm->error_resilient_mode) { if (frame_is_intra_only(cm) || cm->error_resilient_mode ||
cm->frame_refs[0].idx < 0) {
// use default frame context values // use default frame context values
cm->pre_fc = &cm->frame_contexts[FRAME_CONTEXT_DEFAULTS]; cm->pre_fc = &cm->frame_contexts[FRAME_CONTEXT_DEFAULTS];
} else { } else {
*cm->fc = cm->frame_contexts[cm->frame_refs[0].idx];
cm->pre_fc = &cm->frame_contexts[cm->frame_refs[0].idx]; cm->pre_fc = &cm->frame_contexts[cm->frame_refs[0].idx];
} }
#else #else
...@@ -2226,7 +2228,9 @@ void av1_change_config(struct AV1_COMP *cpi, const AV1EncoderConfig *oxcf) { ...@@ -2226,7 +2228,9 @@ void av1_change_config(struct AV1_COMP *cpi, const AV1EncoderConfig *oxcf) {
(oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode) (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode)
? REFRESH_FRAME_CONTEXT_FORWARD ? REFRESH_FRAME_CONTEXT_FORWARD
: REFRESH_FRAME_CONTEXT_BACKWARD; : REFRESH_FRAME_CONTEXT_BACKWARD;
#if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE; cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
#endif
#if CONFIG_PALETTE #if CONFIG_PALETTE
if (x->palette_buffer == NULL) { if (x->palette_buffer == NULL) {
...@@ -4884,6 +4888,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size, ...@@ -4884,6 +4888,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
cm->error_resilient_mode = oxcf->error_resilient_mode; cm->error_resilient_mode = oxcf->error_resilient_mode;
#if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
// By default, encoder assumes decoder can use prev_mi. // By default, encoder assumes decoder can use prev_mi.
if (cm->error_resilient_mode) { if (cm->error_resilient_mode) {
cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE; cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
...@@ -4892,6 +4897,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size, ...@@ -4892,6 +4897,7 @@ static void encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size,
// Only reset the current context. // Only reset the current context.
cm->reset_frame_context = RESET_FRAME_CONTEXT_CURRENT; cm->reset_frame_context = RESET_FRAME_CONTEXT_CURRENT;
} }
#endif
} }
if (cpi->oxcf.mtu == 0) { if (cpi->oxcf.mtu == 0) {
cm->num_tg = cpi->oxcf.num_tile_groups; cm->num_tg = cpi->oxcf.num_tile_groups;
...@@ -5632,8 +5638,10 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags, ...@@ -5632,8 +5638,10 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
else else
cpi->multi_arf_allowed = 0; cpi->multi_arf_allowed = 0;
// Normal defaults // Normal defaults
#if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE; cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
#endif
cm->refresh_frame_context = cm->refresh_frame_context =
(oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode) (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode)
? REFRESH_FRAME_CONTEXT_FORWARD ? REFRESH_FRAME_CONTEXT_FORWARD
...@@ -5961,8 +5969,7 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags, ...@@ -5961,8 +5969,7 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
} }
#endif #endif
#if CONFIG_NO_FRAME_CONTEXT_SIGNALING #if CONFIG_NO_FRAME_CONTEXT_SIGNALING
// TODO(tdaede): Check if this condition is really needed. cm->frame_contexts[cm->new_fb_idx] = *cm->fc;
if (!cm->error_resilient_mode) cm->frame_contexts[cm->new_fb_idx] = *cm->fc;
#else #else
if (!cm->error_resilient_mode) if (!cm->error_resilient_mode)
cm->frame_contexts[cm->frame_context_idx] = *cm->fc; cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
......
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