media/libvpx/vp9/common/vp9_pred_common.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license
michael@0 5 * that can be found in the LICENSE file in the root of the source
michael@0 6 * tree. An additional intellectual property rights grant can be found
michael@0 7 * in the file PATENTS. All contributing project authors may
michael@0 8 * be found in the AUTHORS file in the root of the source tree.
michael@0 9 */
michael@0 10
michael@0 11 #ifndef VP9_COMMON_VP9_PRED_COMMON_H_
michael@0 12 #define VP9_COMMON_VP9_PRED_COMMON_H_
michael@0 13
michael@0 14 #include "vp9/common/vp9_blockd.h"
michael@0 15 #include "vp9/common/vp9_onyxc_int.h"
michael@0 16
michael@0 17 static INLINE const MODE_INFO *get_above_mi(const MACROBLOCKD *const xd) {
michael@0 18 return xd->up_available ? xd->mi_8x8[-xd->mode_info_stride] : NULL;
michael@0 19 }
michael@0 20
michael@0 21 static INLINE const MODE_INFO *get_left_mi(const MACROBLOCKD *const xd) {
michael@0 22 return xd->left_available ? xd->mi_8x8[-1] : NULL;
michael@0 23 }
michael@0 24
michael@0 25 int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids,
michael@0 26 BLOCK_SIZE bsize, int mi_row, int mi_col);
michael@0 27
michael@0 28 static INLINE int vp9_get_pred_context_seg_id(const MACROBLOCKD *xd) {
michael@0 29 const MODE_INFO *const above_mi = get_above_mi(xd);
michael@0 30 const MODE_INFO *const left_mi = get_left_mi(xd);
michael@0 31 const int above_sip = (above_mi != NULL) ?
michael@0 32 above_mi->mbmi.seg_id_predicted : 0;
michael@0 33 const int left_sip = (left_mi != NULL) ? left_mi->mbmi.seg_id_predicted : 0;
michael@0 34
michael@0 35 return above_sip + left_sip;
michael@0 36 }
michael@0 37
michael@0 38 static INLINE vp9_prob vp9_get_pred_prob_seg_id(struct segmentation *seg,
michael@0 39 const MACROBLOCKD *xd) {
michael@0 40 return seg->pred_probs[vp9_get_pred_context_seg_id(xd)];
michael@0 41 }
michael@0 42
michael@0 43 void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, uint8_t pred_flag);
michael@0 44
michael@0 45 static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) {
michael@0 46 const MODE_INFO *const above_mi = get_above_mi(xd);
michael@0 47 const MODE_INFO *const left_mi = get_left_mi(xd);
michael@0 48 const int above_skip_coeff = (above_mi != NULL) ?
michael@0 49 above_mi->mbmi.skip_coeff : 0;
michael@0 50 const int left_skip_coeff = (left_mi != NULL) ? left_mi->mbmi.skip_coeff : 0;
michael@0 51
michael@0 52 return above_skip_coeff + left_skip_coeff;
michael@0 53 }
michael@0 54
michael@0 55 static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm,
michael@0 56 const MACROBLOCKD *xd) {
michael@0 57 return cm->fc.mbskip_probs[vp9_get_pred_context_mbskip(xd)];
michael@0 58 }
michael@0 59
michael@0 60 static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) {
michael@0 61 return xd->mi_8x8[0]->mbmi.skip_coeff;
michael@0 62 }
michael@0 63
michael@0 64 unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd);
michael@0 65
michael@0 66 unsigned char vp9_get_pred_context_intra_inter(const MACROBLOCKD *xd);
michael@0 67
michael@0 68 static INLINE vp9_prob vp9_get_pred_prob_intra_inter(const VP9_COMMON *cm,
michael@0 69 const MACROBLOCKD *xd) {
michael@0 70 const int pred_context = vp9_get_pred_context_intra_inter(xd);
michael@0 71 return cm->fc.intra_inter_prob[pred_context];
michael@0 72 }
michael@0 73
michael@0 74 unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm,
michael@0 75 const MACROBLOCKD *xd);
michael@0 76
michael@0 77
michael@0 78 static INLINE
michael@0 79 vp9_prob vp9_get_pred_prob_comp_inter_inter(const VP9_COMMON *cm,
michael@0 80 const MACROBLOCKD *xd) {
michael@0 81 const int pred_context = vp9_get_pred_context_comp_inter_inter(cm, xd);
michael@0 82 return cm->fc.comp_inter_prob[pred_context];
michael@0 83 }
michael@0 84
michael@0 85 unsigned char vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm,
michael@0 86 const MACROBLOCKD *xd);
michael@0 87
michael@0 88 static INLINE vp9_prob vp9_get_pred_prob_comp_ref_p(const VP9_COMMON *cm,
michael@0 89 const MACROBLOCKD *xd) {
michael@0 90 const int pred_context = vp9_get_pred_context_comp_ref_p(cm, xd);
michael@0 91 return cm->fc.comp_ref_prob[pred_context];
michael@0 92 }
michael@0 93
michael@0 94 unsigned char vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd);
michael@0 95
michael@0 96 static INLINE vp9_prob vp9_get_pred_prob_single_ref_p1(const VP9_COMMON *cm,
michael@0 97 const MACROBLOCKD *xd) {
michael@0 98 const int pred_context = vp9_get_pred_context_single_ref_p1(xd);
michael@0 99 return cm->fc.single_ref_prob[pred_context][0];
michael@0 100 }
michael@0 101
michael@0 102 unsigned char vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd);
michael@0 103
michael@0 104 static INLINE vp9_prob vp9_get_pred_prob_single_ref_p2(const VP9_COMMON *cm,
michael@0 105 const MACROBLOCKD *xd) {
michael@0 106 const int pred_context = vp9_get_pred_context_single_ref_p2(xd);
michael@0 107 return cm->fc.single_ref_prob[pred_context][1];
michael@0 108 }
michael@0 109
michael@0 110 unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd);
michael@0 111
michael@0 112 static const vp9_prob *get_tx_probs(TX_SIZE max_tx_size, int ctx,
michael@0 113 const struct tx_probs *tx_probs) {
michael@0 114 switch (max_tx_size) {
michael@0 115 case TX_8X8:
michael@0 116 return tx_probs->p8x8[ctx];
michael@0 117 case TX_16X16:
michael@0 118 return tx_probs->p16x16[ctx];
michael@0 119 case TX_32X32:
michael@0 120 return tx_probs->p32x32[ctx];
michael@0 121 default:
michael@0 122 assert(!"Invalid max_tx_size.");
michael@0 123 return NULL;
michael@0 124 }
michael@0 125 }
michael@0 126
michael@0 127 static const vp9_prob *get_tx_probs2(TX_SIZE max_tx_size, const MACROBLOCKD *xd,
michael@0 128 const struct tx_probs *tx_probs) {
michael@0 129 const int ctx = vp9_get_pred_context_tx_size(xd);
michael@0 130 return get_tx_probs(max_tx_size, ctx, tx_probs);
michael@0 131 }
michael@0 132
michael@0 133 static unsigned int *get_tx_counts(TX_SIZE max_tx_size, int ctx,
michael@0 134 struct tx_counts *tx_counts) {
michael@0 135 switch (max_tx_size) {
michael@0 136 case TX_8X8:
michael@0 137 return tx_counts->p8x8[ctx];
michael@0 138 case TX_16X16:
michael@0 139 return tx_counts->p16x16[ctx];
michael@0 140 case TX_32X32:
michael@0 141 return tx_counts->p32x32[ctx];
michael@0 142 default:
michael@0 143 assert(!"Invalid max_tx_size.");
michael@0 144 return NULL;
michael@0 145 }
michael@0 146 }
michael@0 147
michael@0 148 #endif // VP9_COMMON_VP9_PRED_COMMON_H_

mercurial