Make reset_frame_context an enum.
In vp9, [0] and [1] had identical meaning, so merge them into a single value. Make it impossible to code RESET_FRAME_CONTEXT_NONE for intra_only frames, since that is a non-sensical combination. See issue 1030. Change-Id: If450c74162d35ca63a9d279beaa53ff9cdd6612b
This commit is contained in:
parent
f79f71fc22
commit
62da0bf162
@ -448,12 +448,12 @@ void vp10_setup_past_independence(VP10_COMMON *cm) {
|
||||
vp10_init_mv_probs(cm);
|
||||
cm->fc->initialized = 1;
|
||||
|
||||
if (cm->frame_type == KEY_FRAME ||
|
||||
cm->error_resilient_mode || cm->reset_frame_context == 3) {
|
||||
if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode ||
|
||||
cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL) {
|
||||
// Reset all frame contexts.
|
||||
for (i = 0; i < FRAME_CONTEXTS; ++i)
|
||||
cm->frame_contexts[i] = *cm->fc;
|
||||
} else if (cm->reset_frame_context == 2) {
|
||||
} else if (cm->reset_frame_context == RESET_FRAME_CONTEXT_CURRENT) {
|
||||
// Reset only the frame context specified in the frame header.
|
||||
cm->frame_contexts[cm->frame_context_idx] = *cm->fc;
|
||||
}
|
||||
|
@ -57,6 +57,12 @@ typedef enum {
|
||||
REFERENCE_MODES = 3,
|
||||
} REFERENCE_MODE;
|
||||
|
||||
typedef enum {
|
||||
RESET_FRAME_CONTEXT_NONE = 0,
|
||||
RESET_FRAME_CONTEXT_CURRENT = 1,
|
||||
RESET_FRAME_CONTEXT_ALL = 2,
|
||||
} RESET_FRAME_CONTEXT_MODE;
|
||||
|
||||
typedef struct {
|
||||
int_mv mv[2];
|
||||
MV_REFERENCE_FRAME ref_frame[2];
|
||||
@ -161,10 +167,8 @@ typedef struct VP10Common {
|
||||
|
||||
int allow_high_precision_mv;
|
||||
|
||||
// Flag signaling that the frame context should be reset to default values.
|
||||
// 0 or 1 implies don't reset, 2 reset just the context specified in the
|
||||
// frame header, 3 reset all contexts.
|
||||
int reset_frame_context;
|
||||
// Flag signaling which frame contexts should be reset to default values.
|
||||
RESET_FRAME_CONTEXT_MODE reset_frame_context;
|
||||
|
||||
// MBs, mb_rows/cols is in 16-pixel units; mi_rows/cols is in
|
||||
// MODE_INFO (8-pixel) units.
|
||||
|
@ -1849,8 +1849,33 @@ static size_t read_uncompressed_header(VP10Decoder *pbi,
|
||||
} else {
|
||||
cm->intra_only = cm->show_frame ? 0 : vpx_rb_read_bit(rb);
|
||||
|
||||
cm->reset_frame_context = cm->error_resilient_mode ?
|
||||
0 : vpx_rb_read_literal(rb, 2);
|
||||
if (cm->error_resilient_mode) {
|
||||
cm->reset_frame_context = RESET_FRAME_CONTEXT_ALL;
|
||||
} else {
|
||||
#if CONFIG_MISC_FIXES
|
||||
if (cm->intra_only) {
|
||||
cm->reset_frame_context =
|
||||
vpx_rb_read_bit(rb) ? RESET_FRAME_CONTEXT_ALL
|
||||
: RESET_FRAME_CONTEXT_CURRENT;
|
||||
} else {
|
||||
cm->reset_frame_context =
|
||||
vpx_rb_read_bit(rb) ? RESET_FRAME_CONTEXT_CURRENT
|
||||
: RESET_FRAME_CONTEXT_NONE;
|
||||
if (cm->reset_frame_context == RESET_FRAME_CONTEXT_CURRENT)
|
||||
cm->reset_frame_context =
|
||||
vpx_rb_read_bit(rb) ? RESET_FRAME_CONTEXT_ALL
|
||||
: RESET_FRAME_CONTEXT_CURRENT;
|
||||
}
|
||||
#else
|
||||
static const RESET_FRAME_CONTEXT_MODE reset_frame_context_conv_tbl[4] = {
|
||||
RESET_FRAME_CONTEXT_NONE, RESET_FRAME_CONTEXT_NONE,
|
||||
RESET_FRAME_CONTEXT_CURRENT, RESET_FRAME_CONTEXT_ALL
|
||||
};
|
||||
|
||||
cm->reset_frame_context =
|
||||
reset_frame_context_conv_tbl[vpx_rb_read_literal(rb, 2)];
|
||||
#endif
|
||||
}
|
||||
|
||||
if (cm->intra_only) {
|
||||
if (!vp10_read_sync_code(rb))
|
||||
|
@ -1092,8 +1092,25 @@ static void write_uncompressed_header(VP10_COMP *cpi,
|
||||
if (!cm->show_frame)
|
||||
vpx_wb_write_bit(wb, cm->intra_only);
|
||||
|
||||
if (!cm->error_resilient_mode)
|
||||
vpx_wb_write_literal(wb, cm->reset_frame_context, 2);
|
||||
if (!cm->error_resilient_mode) {
|
||||
#if CONFIG_MISC_FIXES
|
||||
if (cm->intra_only) {
|
||||
vpx_wb_write_bit(wb,
|
||||
cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL);
|
||||
} else {
|
||||
vpx_wb_write_bit(wb,
|
||||
cm->reset_frame_context != RESET_FRAME_CONTEXT_NONE);
|
||||
if (cm->reset_frame_context != RESET_FRAME_CONTEXT_NONE)
|
||||
vpx_wb_write_bit(wb,
|
||||
cm->reset_frame_context == RESET_FRAME_CONTEXT_ALL);
|
||||
}
|
||||
#else
|
||||
static const int reset_frame_context_conv_tbl[3] = { 0, 2, 3 };
|
||||
|
||||
vpx_wb_write_literal(wb,
|
||||
reset_frame_context_conv_tbl[cm->reset_frame_context], 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (cm->intra_only) {
|
||||
write_sync_code(wb);
|
||||
|
@ -1422,7 +1422,7 @@ void vp10_change_config(struct VP10_COMP *cpi, const VP10EncoderConfig *oxcf) {
|
||||
cpi->refresh_golden_frame = 0;
|
||||
cpi->refresh_last_frame = 1;
|
||||
cm->refresh_frame_context = 1;
|
||||
cm->reset_frame_context = 0;
|
||||
cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
|
||||
|
||||
vp10_reset_segment_features(&cm->seg);
|
||||
vp10_set_high_precision_mv(cpi, 0);
|
||||
@ -3554,11 +3554,11 @@ 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->frame_parallel_decoding_mode = 1;
|
||||
cm->reset_frame_context = 0;
|
||||
cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
|
||||
cm->refresh_frame_context = 0;
|
||||
} else if (cm->intra_only) {
|
||||
// Only reset the current context.
|
||||
cm->reset_frame_context = 2;
|
||||
cm->reset_frame_context = RESET_FRAME_CONTEXT_CURRENT;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3955,7 +3955,7 @@ int vp10_get_compressed_data(VP10_COMP *cpi, unsigned int *frame_flags,
|
||||
cpi->multi_arf_allowed = 0;
|
||||
|
||||
// Normal defaults
|
||||
cm->reset_frame_context = 0;
|
||||
cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
|
||||
cm->refresh_frame_context = 1;
|
||||
|
||||
cpi->refresh_last_frame = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user