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/common | |
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/common')
-rw-r--r-- | vp10/common/entropymode.c | 26 | ||||
-rw-r--r-- | vp10/common/entropymode.h | 13 | ||||
-rw-r--r-- | vp10/common/onyxc_int.h | 3 | ||||
-rw-r--r-- | vp10/common/pred_common.h | 6 | ||||
-rw-r--r-- | vp10/common/seg_common.h | 8 | ||||
-rw-r--r-- | vp10/common/thread_common.c | 11 |
6 files changed, 61 insertions, 6 deletions
diff --git a/vp10/common/entropymode.c b/vp10/common/entropymode.c index 370e1c287..5a729f0b2 100644 --- a/vp10/common/entropymode.c +++ b/vp10/common/entropymode.c @@ -746,6 +746,14 @@ static const vpx_prob default_switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS] { 149, 144, }, }; +#if CONFIG_MISC_FIXES +// FIXME(someone) need real defaults here +static const struct segmentation_probs default_seg_probs = { + { 128, 128, 128, 128, 128, 128, 128 }, + { 128, 128, 128 }, +}; +#endif + static void init_mode_probs(FRAME_CONTEXT *fc) { vp10_copy(fc->uv_mode_prob, default_if_uv_probs); vp10_copy(fc->y_mode_prob, default_if_y_probs); @@ -758,6 +766,10 @@ static void init_mode_probs(FRAME_CONTEXT *fc) { fc->tx_probs = default_tx_probs; vp10_copy(fc->skip_probs, default_skip_probs); vp10_copy(fc->inter_mode_probs, default_inter_mode_probs); +#if CONFIG_MISC_FIXES + vp10_copy(fc->seg.tree_probs, default_seg_probs.tree_probs); + vp10_copy(fc->seg.pred_probs, default_seg_probs.pred_probs); +#endif } const vpx_tree_index vp10_switchable_interp_tree @@ -844,6 +856,20 @@ void vp10_adapt_intra_frame_probs(VP10_COMMON *cm) { for (i = 0; i < SKIP_CONTEXTS; ++i) fc->skip_probs[i] = mode_mv_merge_probs( pre_fc->skip_probs[i], counts->skip[i]); + +#if CONFIG_MISC_FIXES + if (cm->seg.temporal_update) { + for (i = 0; i < INTRA_INTER_CONTEXTS; i++) + fc->seg.pred_probs[i] = mode_mv_merge_probs(pre_fc->seg.pred_probs[i], + counts->seg.pred[i]); + + vpx_tree_merge_probs(vp10_segment_tree, pre_fc->seg.tree_probs, + counts->seg.tree_mispred, fc->seg.tree_probs); + } else { + vpx_tree_merge_probs(vp10_segment_tree, pre_fc->seg.tree_probs, + counts->seg.tree_total, fc->seg.tree_probs); + } +#endif } static void set_default_lf_deltas(struct loopfilter *lf) { diff --git a/vp10/common/entropymode.h b/vp10/common/entropymode.h index 098126331..c5e3bc771 100644 --- a/vp10/common/entropymode.h +++ b/vp10/common/entropymode.h @@ -14,6 +14,7 @@ #include "vp10/common/entropy.h" #include "vp10/common/entropymv.h" #include "vp10/common/filter.h" +#include "vp10/common/seg_common.h" #include "vpx_dsp/vpx_filter.h" #ifdef __cplusplus @@ -47,6 +48,12 @@ struct tx_counts { unsigned int tx_totals[TX_SIZES]; }; +struct seg_counts { + unsigned int tree_total[MAX_SEGMENTS]; + unsigned int tree_mispred[MAX_SEGMENTS]; + unsigned int pred[PREDICTION_PROBS][2]; +}; + typedef struct frame_contexts { vpx_prob y_mode_prob[BLOCK_SIZE_GROUPS][INTRA_MODES - 1]; vpx_prob uv_mode_prob[INTRA_MODES][INTRA_MODES - 1]; @@ -62,6 +69,9 @@ typedef struct frame_contexts { struct tx_probs tx_probs; vpx_prob skip_probs[SKIP_CONTEXTS]; nmv_context nmvc; +#if CONFIG_MISC_FIXES + struct segmentation_probs seg; +#endif int initialized; } FRAME_CONTEXT; @@ -82,6 +92,9 @@ typedef struct FRAME_COUNTS { struct tx_counts tx; unsigned int skip[SKIP_CONTEXTS][2]; nmv_context_counts mv; +#if CONFIG_MISC_FIXES + struct seg_counts seg; +#endif } FRAME_COUNTS; extern const vpx_prob vp10_kf_uv_mode_prob[INTRA_MODES][INTRA_MODES - 1]; diff --git a/vp10/common/onyxc_int.h b/vp10/common/onyxc_int.h index 73157b88d..4a20bb589 100644 --- a/vp10/common/onyxc_int.h +++ b/vp10/common/onyxc_int.h @@ -254,6 +254,9 @@ typedef struct VP10Common { struct loopfilter lf; struct segmentation seg; +#if !CONFIG_MISC_FIXES + struct segmentation_probs segp; +#endif int frame_parallel_decode; // frame-based threading. diff --git a/vp10/common/pred_common.h b/vp10/common/pred_common.h index 1b55f5384..d6d7146d7 100644 --- a/vp10/common/pred_common.h +++ b/vp10/common/pred_common.h @@ -48,9 +48,9 @@ static INLINE int vp10_get_pred_context_seg_id(const MACROBLOCKD *xd) { return above_sip + left_sip; } -static INLINE vpx_prob vp10_get_pred_prob_seg_id(const struct segmentation *seg, - const MACROBLOCKD *xd) { - return seg->pred_probs[vp10_get_pred_context_seg_id(xd)]; +static INLINE vpx_prob vp10_get_pred_prob_seg_id( + const struct segmentation_probs *segp, const MACROBLOCKD *xd) { + return segp->pred_probs[vp10_get_pred_context_seg_id(xd)]; } static INLINE int vp10_get_skip_context(const MACROBLOCKD *xd) { diff --git a/vp10/common/seg_common.h b/vp10/common/seg_common.h index 97b875c9c..cd38e8ee0 100644 --- a/vp10/common/seg_common.h +++ b/vp10/common/seg_common.h @@ -42,13 +42,15 @@ struct segmentation { uint8_t abs_delta; uint8_t temporal_update; - vpx_prob tree_probs[SEG_TREE_PROBS]; - vpx_prob pred_probs[PREDICTION_PROBS]; - int16_t feature_data[MAX_SEGMENTS][SEG_LVL_MAX]; unsigned int feature_mask[MAX_SEGMENTS]; }; +struct segmentation_probs { + vpx_prob tree_probs[SEG_TREE_PROBS]; + vpx_prob pred_probs[PREDICTION_PROBS]; +}; + static INLINE int segfeature_active(const struct segmentation *seg, int segment_id, SEG_LVL_FEATURES feature_id) { diff --git a/vp10/common/thread_common.c b/vp10/common/thread_common.c index bbc6d115d..e83cb8e67 100644 --- a/vp10/common/thread_common.c +++ b/vp10/common/thread_common.c @@ -434,4 +434,15 @@ void vp10_accumulate_frame_counts(VP10_COMMON *cm, FRAME_COUNTS *counts, for (i = 0; i < MV_FP_SIZE; i++) comps->fp[i] += comps_t->fp[i]; } + +#if CONFIG_MISC_FIXES + for (i = 0; i < PREDICTION_PROBS; i++) + for (j = 0; j < 2; j++) + cm->counts.seg.pred[i][j] += counts->seg.pred[i][j]; + + for (i = 0; i < MAX_SEGMENTS; i++) { + cm->counts.seg.tree_total[i] += counts->seg.tree_total[i]; + cm->counts.seg.tree_mispred[i] += counts->seg.tree_mispred[i]; + } +#endif } |