Make update_map/temporal_update fields implicit for keyframes.
These frame types cannot make bitstream parsing depend on previous frames, so the hypothetical combinations of e.g. keyframe=1 and update_map=0 or keyframe=1 and temporal_update=1 are non-sensical. Therefore, make it impossible to code such combinations in the vp10 bitstream header. See issue 1044. Change-Id: I3f0a83d5c7e3989541a469a909471424a285239d
This commit is contained in:
parent
ecd34e6494
commit
d88cee3712
@ -1012,8 +1012,9 @@ static void read_coef_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode,
|
|||||||
read_coef_probs_common(fc->coef_probs[tx_size], r);
|
read_coef_probs_common(fc->coef_probs[tx_size], r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_segmentation(struct segmentation *seg,
|
static void setup_segmentation(VP10_COMMON *const cm,
|
||||||
struct vpx_read_bit_buffer *rb) {
|
struct vpx_read_bit_buffer *rb) {
|
||||||
|
struct segmentation *const seg = &cm->seg;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
seg->update_map = 0;
|
seg->update_map = 0;
|
||||||
@ -1024,13 +1025,21 @@ static void setup_segmentation(struct segmentation *seg,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Segmentation map update
|
// Segmentation map update
|
||||||
|
if (frame_is_intra_only(cm) || cm->error_resilient_mode) {
|
||||||
|
seg->update_map = 1;
|
||||||
|
} else {
|
||||||
seg->update_map = vpx_rb_read_bit(rb);
|
seg->update_map = vpx_rb_read_bit(rb);
|
||||||
|
}
|
||||||
if (seg->update_map) {
|
if (seg->update_map) {
|
||||||
for (i = 0; i < SEG_TREE_PROBS; i++)
|
for (i = 0; i < SEG_TREE_PROBS; i++)
|
||||||
seg->tree_probs[i] = vpx_rb_read_bit(rb) ? vpx_rb_read_literal(rb, 8)
|
seg->tree_probs[i] = vpx_rb_read_bit(rb) ? vpx_rb_read_literal(rb, 8)
|
||||||
: MAX_PROB;
|
: MAX_PROB;
|
||||||
|
|
||||||
|
if (frame_is_intra_only(cm) || cm->error_resilient_mode) {
|
||||||
|
seg->temporal_update = 0;
|
||||||
|
} else {
|
||||||
seg->temporal_update = vpx_rb_read_bit(rb);
|
seg->temporal_update = vpx_rb_read_bit(rb);
|
||||||
|
}
|
||||||
if (seg->temporal_update) {
|
if (seg->temporal_update) {
|
||||||
for (i = 0; i < PREDICTION_PROBS; i++)
|
for (i = 0; i < PREDICTION_PROBS; i++)
|
||||||
seg->pred_probs[i] = vpx_rb_read_bit(rb) ? vpx_rb_read_literal(rb, 8)
|
seg->pred_probs[i] = vpx_rb_read_bit(rb) ? vpx_rb_read_literal(rb, 8)
|
||||||
@ -1953,7 +1962,7 @@ static size_t read_uncompressed_header(VP10Decoder *pbi,
|
|||||||
|
|
||||||
setup_loopfilter(&cm->lf, rb);
|
setup_loopfilter(&cm->lf, rb);
|
||||||
setup_quantization(cm, &pbi->mb, rb);
|
setup_quantization(cm, &pbi->mb, rb);
|
||||||
setup_segmentation(&cm->seg, rb);
|
setup_segmentation(cm, rb);
|
||||||
setup_segmentation_dequant(cm);
|
setup_segmentation_dequant(cm);
|
||||||
|
|
||||||
setup_tile_info(cm, rb);
|
setup_tile_info(cm, rb);
|
||||||
|
@ -116,6 +116,22 @@ static void set_segment_id(VP10_COMMON *cm, int mi_offset,
|
|||||||
cm->current_frame_seg_map[mi_offset + y * cm->mi_cols + x] = segment_id;
|
cm->current_frame_seg_map[mi_offset + y * cm->mi_cols + x] = segment_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int read_intra_segment_id(VP10_COMMON *const cm, int mi_offset,
|
||||||
|
int x_mis, int y_mis,
|
||||||
|
vpx_reader *r) {
|
||||||
|
struct segmentation *const seg = &cm->seg;
|
||||||
|
int segment_id;
|
||||||
|
|
||||||
|
if (!seg->enabled)
|
||||||
|
return 0; // Default for disabled segmentation
|
||||||
|
|
||||||
|
assert(seg->update_map && !seg->temporal_update);
|
||||||
|
|
||||||
|
segment_id = read_segment_id(r, seg);
|
||||||
|
set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id);
|
||||||
|
return segment_id;
|
||||||
|
}
|
||||||
|
|
||||||
static void copy_segment_id(const VP10_COMMON *cm,
|
static void copy_segment_id(const VP10_COMMON *cm,
|
||||||
const uint8_t *last_segment_ids,
|
const uint8_t *last_segment_ids,
|
||||||
uint8_t *current_segment_ids,
|
uint8_t *current_segment_ids,
|
||||||
@ -128,26 +144,6 @@ static void copy_segment_id(const VP10_COMMON *cm,
|
|||||||
last_segment_ids[mi_offset + y * cm->mi_cols + x] : 0;
|
last_segment_ids[mi_offset + y * cm->mi_cols + x] : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_intra_segment_id(VP10_COMMON *const cm, int mi_offset,
|
|
||||||
int x_mis, int y_mis,
|
|
||||||
vpx_reader *r) {
|
|
||||||
struct segmentation *const seg = &cm->seg;
|
|
||||||
int segment_id;
|
|
||||||
|
|
||||||
if (!seg->enabled)
|
|
||||||
return 0; // Default for disabled segmentation
|
|
||||||
|
|
||||||
if (!seg->update_map) {
|
|
||||||
copy_segment_id(cm, cm->last_frame_seg_map, cm->current_frame_seg_map,
|
|
||||||
mi_offset, x_mis, y_mis);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
segment_id = read_segment_id(r, seg);
|
|
||||||
set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id);
|
|
||||||
return segment_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int read_inter_segment_id(VP10_COMMON *const cm, MACROBLOCKD *const xd,
|
static int read_inter_segment_id(VP10_COMMON *const cm, MACROBLOCKD *const xd,
|
||||||
int mi_row, int mi_col, vpx_reader *r) {
|
int mi_row, int mi_col, vpx_reader *r) {
|
||||||
struct segmentation *const seg = &cm->seg;
|
struct segmentation *const seg = &cm->seg;
|
||||||
|
@ -762,7 +762,11 @@ static void encode_segmentation(VP10_COMMON *cm, MACROBLOCKD *xd,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Segmentation map
|
// Segmentation map
|
||||||
|
if (!frame_is_intra_only(cm) && !cm->error_resilient_mode) {
|
||||||
vpx_wb_write_bit(wb, seg->update_map);
|
vpx_wb_write_bit(wb, seg->update_map);
|
||||||
|
} else {
|
||||||
|
assert(seg->update_map == 1);
|
||||||
|
}
|
||||||
if (seg->update_map) {
|
if (seg->update_map) {
|
||||||
// Select the coding strategy (temporal or spatial)
|
// Select the coding strategy (temporal or spatial)
|
||||||
vp10_choose_segmap_coding_method(cm, xd);
|
vp10_choose_segmap_coding_method(cm, xd);
|
||||||
@ -776,7 +780,11 @@ static void encode_segmentation(VP10_COMMON *cm, MACROBLOCKD *xd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write out the chosen coding method.
|
// Write out the chosen coding method.
|
||||||
|
if (!frame_is_intra_only(cm) && !cm->error_resilient_mode) {
|
||||||
vpx_wb_write_bit(wb, seg->temporal_update);
|
vpx_wb_write_bit(wb, seg->temporal_update);
|
||||||
|
} else {
|
||||||
|
assert(seg->temporal_update == 0);
|
||||||
|
}
|
||||||
if (seg->temporal_update) {
|
if (seg->temporal_update) {
|
||||||
for (i = 0; i < PREDICTION_PROBS; i++) {
|
for (i = 0; i < PREDICTION_PROBS; i++) {
|
||||||
const int prob = seg->pred_probs[i];
|
const int prob = seg->pred_probs[i];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user