1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libvpx/vp9/common/vp9_pred_common.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,148 @@ 1.4 +/* 1.5 + * Copyright (c) 2012 The WebM project authors. All Rights Reserved. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license 1.8 + * that can be found in the LICENSE file in the root of the source 1.9 + * tree. An additional intellectual property rights grant can be found 1.10 + * in the file PATENTS. All contributing project authors may 1.11 + * be found in the AUTHORS file in the root of the source tree. 1.12 + */ 1.13 + 1.14 +#ifndef VP9_COMMON_VP9_PRED_COMMON_H_ 1.15 +#define VP9_COMMON_VP9_PRED_COMMON_H_ 1.16 + 1.17 +#include "vp9/common/vp9_blockd.h" 1.18 +#include "vp9/common/vp9_onyxc_int.h" 1.19 + 1.20 +static INLINE const MODE_INFO *get_above_mi(const MACROBLOCKD *const xd) { 1.21 + return xd->up_available ? xd->mi_8x8[-xd->mode_info_stride] : NULL; 1.22 +} 1.23 + 1.24 +static INLINE const MODE_INFO *get_left_mi(const MACROBLOCKD *const xd) { 1.25 + return xd->left_available ? xd->mi_8x8[-1] : NULL; 1.26 +} 1.27 + 1.28 +int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids, 1.29 + BLOCK_SIZE bsize, int mi_row, int mi_col); 1.30 + 1.31 +static INLINE int vp9_get_pred_context_seg_id(const MACROBLOCKD *xd) { 1.32 + const MODE_INFO *const above_mi = get_above_mi(xd); 1.33 + const MODE_INFO *const left_mi = get_left_mi(xd); 1.34 + const int above_sip = (above_mi != NULL) ? 1.35 + above_mi->mbmi.seg_id_predicted : 0; 1.36 + const int left_sip = (left_mi != NULL) ? left_mi->mbmi.seg_id_predicted : 0; 1.37 + 1.38 + return above_sip + left_sip; 1.39 +} 1.40 + 1.41 +static INLINE vp9_prob vp9_get_pred_prob_seg_id(struct segmentation *seg, 1.42 + const MACROBLOCKD *xd) { 1.43 + return seg->pred_probs[vp9_get_pred_context_seg_id(xd)]; 1.44 +} 1.45 + 1.46 +void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, uint8_t pred_flag); 1.47 + 1.48 +static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) { 1.49 + const MODE_INFO *const above_mi = get_above_mi(xd); 1.50 + const MODE_INFO *const left_mi = get_left_mi(xd); 1.51 + const int above_skip_coeff = (above_mi != NULL) ? 1.52 + above_mi->mbmi.skip_coeff : 0; 1.53 + const int left_skip_coeff = (left_mi != NULL) ? left_mi->mbmi.skip_coeff : 0; 1.54 + 1.55 + return above_skip_coeff + left_skip_coeff; 1.56 +} 1.57 + 1.58 +static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm, 1.59 + const MACROBLOCKD *xd) { 1.60 + return cm->fc.mbskip_probs[vp9_get_pred_context_mbskip(xd)]; 1.61 +} 1.62 + 1.63 +static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) { 1.64 + return xd->mi_8x8[0]->mbmi.skip_coeff; 1.65 +} 1.66 + 1.67 +unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd); 1.68 + 1.69 +unsigned char vp9_get_pred_context_intra_inter(const MACROBLOCKD *xd); 1.70 + 1.71 +static INLINE vp9_prob vp9_get_pred_prob_intra_inter(const VP9_COMMON *cm, 1.72 + const MACROBLOCKD *xd) { 1.73 + const int pred_context = vp9_get_pred_context_intra_inter(xd); 1.74 + return cm->fc.intra_inter_prob[pred_context]; 1.75 +} 1.76 + 1.77 +unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm, 1.78 + const MACROBLOCKD *xd); 1.79 + 1.80 + 1.81 +static INLINE 1.82 +vp9_prob vp9_get_pred_prob_comp_inter_inter(const VP9_COMMON *cm, 1.83 + const MACROBLOCKD *xd) { 1.84 + const int pred_context = vp9_get_pred_context_comp_inter_inter(cm, xd); 1.85 + return cm->fc.comp_inter_prob[pred_context]; 1.86 +} 1.87 + 1.88 +unsigned char vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm, 1.89 + const MACROBLOCKD *xd); 1.90 + 1.91 +static INLINE vp9_prob vp9_get_pred_prob_comp_ref_p(const VP9_COMMON *cm, 1.92 + const MACROBLOCKD *xd) { 1.93 + const int pred_context = vp9_get_pred_context_comp_ref_p(cm, xd); 1.94 + return cm->fc.comp_ref_prob[pred_context]; 1.95 +} 1.96 + 1.97 +unsigned char vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd); 1.98 + 1.99 +static INLINE vp9_prob vp9_get_pred_prob_single_ref_p1(const VP9_COMMON *cm, 1.100 + const MACROBLOCKD *xd) { 1.101 + const int pred_context = vp9_get_pred_context_single_ref_p1(xd); 1.102 + return cm->fc.single_ref_prob[pred_context][0]; 1.103 +} 1.104 + 1.105 +unsigned char vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd); 1.106 + 1.107 +static INLINE vp9_prob vp9_get_pred_prob_single_ref_p2(const VP9_COMMON *cm, 1.108 + const MACROBLOCKD *xd) { 1.109 + const int pred_context = vp9_get_pred_context_single_ref_p2(xd); 1.110 + return cm->fc.single_ref_prob[pred_context][1]; 1.111 +} 1.112 + 1.113 +unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd); 1.114 + 1.115 +static const vp9_prob *get_tx_probs(TX_SIZE max_tx_size, int ctx, 1.116 + const struct tx_probs *tx_probs) { 1.117 + switch (max_tx_size) { 1.118 + case TX_8X8: 1.119 + return tx_probs->p8x8[ctx]; 1.120 + case TX_16X16: 1.121 + return tx_probs->p16x16[ctx]; 1.122 + case TX_32X32: 1.123 + return tx_probs->p32x32[ctx]; 1.124 + default: 1.125 + assert(!"Invalid max_tx_size."); 1.126 + return NULL; 1.127 + } 1.128 +} 1.129 + 1.130 +static const vp9_prob *get_tx_probs2(TX_SIZE max_tx_size, const MACROBLOCKD *xd, 1.131 + const struct tx_probs *tx_probs) { 1.132 + const int ctx = vp9_get_pred_context_tx_size(xd); 1.133 + return get_tx_probs(max_tx_size, ctx, tx_probs); 1.134 +} 1.135 + 1.136 +static unsigned int *get_tx_counts(TX_SIZE max_tx_size, int ctx, 1.137 + struct tx_counts *tx_counts) { 1.138 + switch (max_tx_size) { 1.139 + case TX_8X8: 1.140 + return tx_counts->p8x8[ctx]; 1.141 + case TX_16X16: 1.142 + return tx_counts->p16x16[ctx]; 1.143 + case TX_32X32: 1.144 + return tx_counts->p32x32[ctx]; 1.145 + default: 1.146 + assert(!"Invalid max_tx_size."); 1.147 + return NULL; 1.148 + } 1.149 +} 1.150 + 1.151 +#endif // VP9_COMMON_VP9_PRED_COMMON_H_