diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2015-10-13 14:06:28 -0400 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2015-10-16 19:30:38 -0400 |
commit | 6e5a1165bef829b3fcc73c36e5c950592b5c6801 (patch) | |
tree | 477f0a118cebdbf8d00d30070245bb405b5dcc58 /vp10/decoder/decodemv.c | |
parent | 7dd7a7da206bddb7d3d3deffa23984719bb89d87 (diff) | |
download | libvpx-6e5a1165bef829b3fcc73c36e5c950592b5c6801.tar libvpx-6e5a1165bef829b3fcc73c36e5c950592b5c6801.tar.gz libvpx-6e5a1165bef829b3fcc73c36e5c950592b5c6801.tar.bz2 libvpx-6e5a1165bef829b3fcc73c36e5c950592b5c6801.zip |
vp10: make segmentation probs use generic probability model.
Locate them (code-wise) in frame_context, and have them be updated
as any other probability using the subexp forward and adaptive bw
updates.
See issue 1040 point 1.
TODOs:
- real-world default probabilities
- why is counts sometimes NULL in the decoder? Does that mean bw
adaptivity updates only work on some frames? (I haven't looked
very closely yet, maybe this is a red herring.)
Change-Id: I23b57b4e5e7574b75f16eb64823b29c22fbab42e
Diffstat (limited to 'vp10/decoder/decodemv.c')
-rw-r--r-- | vp10/decoder/decodemv.c | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/vp10/decoder/decodemv.c b/vp10/decoder/decodemv.c index e82ddd697..90a98b40f 100644 --- a/vp10/decoder/decodemv.c +++ b/vp10/decoder/decodemv.c @@ -73,8 +73,9 @@ static PREDICTION_MODE read_inter_mode(VP10_COMMON *cm, MACROBLOCKD *xd, return NEARESTMV + mode; } -static int read_segment_id(vpx_reader *r, const struct segmentation *seg) { - return vpx_read_tree(r, vp10_segment_tree, seg->tree_probs); +static int read_segment_id(vpx_reader *r, + const struct segmentation_probs *segp) { + return vpx_read_tree(r, vp10_segment_tree, segp->tree_probs); } static TX_SIZE read_selected_tx_size(VP10_COMMON *cm, MACROBLOCKD *xd, @@ -129,18 +130,32 @@ 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; } -static int read_intra_segment_id(VP10_COMMON *const cm, int mi_offset, - int x_mis, int y_mis, +static int read_intra_segment_id(VP10_COMMON *const cm, MACROBLOCKD *const xd, + int mi_offset, int x_mis, int y_mis, vpx_reader *r) { struct segmentation *const seg = &cm->seg; +#if CONFIG_MISC_FIXES + FRAME_COUNTS *counts = xd->counts; + struct segmentation_probs *const segp = &cm->fc->seg; +#else + struct segmentation_probs *const segp = &cm->segp; +#endif int segment_id; +#if !CONFIG_MISC_FIXES + (void) xd; +#endif + if (!seg->enabled) return 0; // Default for disabled segmentation assert(seg->update_map && !seg->temporal_update); - segment_id = read_segment_id(r, seg); + segment_id = read_segment_id(r, segp); +#if CONFIG_MISC_FIXES + if (counts) + ++counts->seg.tree_total[segment_id]; +#endif set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id); return segment_id; } @@ -160,6 +175,12 @@ static void copy_segment_id(const VP10_COMMON *cm, static int read_inter_segment_id(VP10_COMMON *const cm, MACROBLOCKD *const xd, int mi_row, int mi_col, vpx_reader *r) { struct segmentation *const seg = &cm->seg; +#if CONFIG_MISC_FIXES + FRAME_COUNTS *counts = xd->counts; + struct segmentation_probs *const segp = &cm->fc->seg; +#else + struct segmentation_probs *const segp = &cm->segp; +#endif MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; int predicted_segment_id, segment_id; const int mi_offset = mi_row * cm->mi_cols + mi_col; @@ -184,12 +205,28 @@ static int read_inter_segment_id(VP10_COMMON *const cm, MACROBLOCKD *const xd, } if (seg->temporal_update) { - const vpx_prob pred_prob = vp10_get_pred_prob_seg_id(seg, xd); + const int ctx = vp10_get_pred_context_seg_id(xd); + const vpx_prob pred_prob = segp->pred_probs[ctx]; mbmi->seg_id_predicted = vpx_read(r, pred_prob); - segment_id = mbmi->seg_id_predicted ? predicted_segment_id - : read_segment_id(r, seg); +#if CONFIG_MISC_FIXES + if (counts) + ++counts->seg.pred[ctx][mbmi->seg_id_predicted]; +#endif + if (mbmi->seg_id_predicted) { + segment_id = predicted_segment_id; + } else { + segment_id = read_segment_id(r, segp); +#if CONFIG_MISC_FIXES + if (counts) + ++counts->seg.tree_mispred[segment_id]; +#endif + } } else { - segment_id = read_segment_id(r, seg); + segment_id = read_segment_id(r, segp); +#if CONFIG_MISC_FIXES + if (counts) + ++counts->seg.tree_total[segment_id]; +#endif } set_segment_id(cm, mi_offset, x_mis, y_mis, segment_id); return segment_id; @@ -258,7 +295,7 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm, const int x_mis = VPXMIN(cm->mi_cols - mi_col, bw); const int y_mis = VPXMIN(cm->mi_rows - mi_row, bh); - mbmi->segment_id = read_intra_segment_id(cm, mi_offset, x_mis, y_mis, r); + mbmi->segment_id = read_intra_segment_id(cm, xd, mi_offset, x_mis, y_mis, r); mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r); mbmi->tx_size = read_tx_size(cm, xd, 1, r); mbmi->ref_frame[0] = INTRA_FRAME; |