OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef VP9_COMMON_VP9_PRED_COMMON_H_ | 11 #ifndef VP9_COMMON_VP9_PRED_COMMON_H_ |
12 #define VP9_COMMON_VP9_PRED_COMMON_H_ | 12 #define VP9_COMMON_VP9_PRED_COMMON_H_ |
13 | 13 |
14 #include "vp9/common/vp9_blockd.h" | 14 #include "vp9/common/vp9_blockd.h" |
15 #include "vp9/common/vp9_onyxc_int.h" | 15 #include "vp9/common/vp9_onyxc_int.h" |
16 | 16 |
| 17 static INLINE const MODE_INFO *get_above_mi(const MACROBLOCKD *const xd) { |
| 18 return xd->up_available ? xd->mi_8x8[-xd->mode_info_stride] : NULL; |
| 19 } |
| 20 |
| 21 static INLINE const MODE_INFO *get_left_mi(const MACROBLOCKD *const xd) { |
| 22 return xd->left_available ? xd->mi_8x8[-1] : NULL; |
| 23 } |
| 24 |
17 int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids, | 25 int vp9_get_segment_id(VP9_COMMON *cm, const uint8_t *segment_ids, |
18 BLOCK_SIZE bsize, int mi_row, int mi_col); | 26 BLOCK_SIZE bsize, int mi_row, int mi_col); |
19 | 27 |
| 28 static INLINE int vp9_get_pred_context_seg_id(const MACROBLOCKD *xd) { |
| 29 const MODE_INFO *const above_mi = get_above_mi(xd); |
| 30 const MODE_INFO *const left_mi = get_left_mi(xd); |
| 31 const int above_sip = (above_mi != NULL) ? |
| 32 above_mi->mbmi.seg_id_predicted : 0; |
| 33 const int left_sip = (left_mi != NULL) ? left_mi->mbmi.seg_id_predicted : 0; |
20 | 34 |
21 static INLINE int vp9_get_pred_context_seg_id(const MACROBLOCKD *xd) { | 35 return above_sip + left_sip; |
22 const MODE_INFO * const above_mi = xd->mi_8x8[-xd->mode_info_stride]; | |
23 const MODE_INFO * const left_mi = xd->mi_8x8[-1]; | |
24 const int above_sip = above_mi ? above_mi->mbmi.seg_id_predicted : 0; | |
25 const int left_sip = left_mi ? left_mi->mbmi.seg_id_predicted : 0; | |
26 | |
27 return above_sip + (xd->left_available ? left_sip : 0); | |
28 } | 36 } |
29 | 37 |
30 static INLINE vp9_prob vp9_get_pred_prob_seg_id(struct segmentation *seg, | 38 static INLINE vp9_prob vp9_get_pred_prob_seg_id(struct segmentation *seg, |
31 const MACROBLOCKD *xd) { | 39 const MACROBLOCKD *xd) { |
32 return seg->pred_probs[vp9_get_pred_context_seg_id(xd)]; | 40 return seg->pred_probs[vp9_get_pred_context_seg_id(xd)]; |
33 } | 41 } |
34 | 42 |
35 void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, uint8_t pred_flag); | 43 void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, uint8_t pred_flag); |
36 | 44 |
37 static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) { | 45 static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) { |
38 const MODE_INFO * const above_mi = xd->mi_8x8[-xd->mode_info_stride]; | 46 const MODE_INFO *const above_mi = get_above_mi(xd); |
39 const MODE_INFO * const left_mi = xd->mi_8x8[-1]; | 47 const MODE_INFO *const left_mi = get_left_mi(xd); |
40 const int above_skip_coeff = above_mi ? above_mi->mbmi.skip_coeff : 0; | 48 const int above_skip_coeff = (above_mi != NULL) ? |
41 const int left_skip_coeff = left_mi ? left_mi->mbmi.skip_coeff : 0; | 49 above_mi->mbmi.skip_coeff : 0; |
| 50 const int left_skip_coeff = (left_mi != NULL) ? left_mi->mbmi.skip_coeff : 0; |
42 | 51 |
43 return above_skip_coeff + (xd->left_available ? left_skip_coeff : 0); | 52 return above_skip_coeff + left_skip_coeff; |
44 } | 53 } |
45 | 54 |
46 static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm, | 55 static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm, |
47 const MACROBLOCKD *xd) { | 56 const MACROBLOCKD *xd) { |
48 return cm->fc.mbskip_probs[vp9_get_pred_context_mbskip(xd)]; | 57 return cm->fc.mbskip_probs[vp9_get_pred_context_mbskip(xd)]; |
49 } | 58 } |
50 | 59 |
51 static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) { | 60 static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) { |
52 return xd->this_mi->mbmi.skip_coeff; | 61 return xd->mi_8x8[0]->mbmi.skip_coeff; |
53 } | 62 } |
54 | 63 |
55 void vp9_set_pred_flag_mbskip(MACROBLOCKD *xd, BLOCK_SIZE bsize, | |
56 uint8_t pred_flag); | |
57 | |
58 unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd); | 64 unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd); |
59 | 65 |
60 unsigned char vp9_get_pred_context_intra_inter(const MACROBLOCKD *xd); | 66 unsigned char vp9_get_pred_context_intra_inter(const MACROBLOCKD *xd); |
61 | 67 |
62 static INLINE vp9_prob vp9_get_pred_prob_intra_inter(const VP9_COMMON *cm, | 68 static INLINE vp9_prob vp9_get_pred_prob_intra_inter(const VP9_COMMON *cm, |
63 const MACROBLOCKD *xd) { | 69 const MACROBLOCKD *xd) { |
64 const int pred_context = vp9_get_pred_context_intra_inter(xd); | 70 const int pred_context = vp9_get_pred_context_intra_inter(xd); |
65 return cm->fc.intra_inter_prob[pred_context]; | 71 return cm->fc.intra_inter_prob[pred_context]; |
66 } | 72 } |
67 | 73 |
68 unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm, | 74 unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm, |
69 const MACROBLOCKD *xd); | 75 const MACROBLOCKD *xd); |
70 | 76 |
71 | 77 |
72 static INLINE vp9_prob vp9_get_pred_prob_comp_inter_inter(const VP9_COMMON *cm, | 78 static INLINE |
73 const MACROBLOCKD *xd)
{ | 79 vp9_prob vp9_get_pred_prob_comp_inter_inter(const VP9_COMMON *cm, |
| 80 const MACROBLOCKD *xd) { |
74 const int pred_context = vp9_get_pred_context_comp_inter_inter(cm, xd); | 81 const int pred_context = vp9_get_pred_context_comp_inter_inter(cm, xd); |
75 return cm->fc.comp_inter_prob[pred_context]; | 82 return cm->fc.comp_inter_prob[pred_context]; |
76 } | 83 } |
77 | 84 |
78 unsigned char vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm, | 85 unsigned char vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm, |
79 const MACROBLOCKD *xd); | 86 const MACROBLOCKD *xd); |
80 | 87 |
81 static INLINE vp9_prob vp9_get_pred_prob_comp_ref_p(const VP9_COMMON *cm, | 88 static INLINE vp9_prob vp9_get_pred_prob_comp_ref_p(const VP9_COMMON *cm, |
82 const MACROBLOCKD *xd) { | 89 const MACROBLOCKD *xd) { |
83 const int pred_context = vp9_get_pred_context_comp_ref_p(cm, xd); | 90 const int pred_context = vp9_get_pred_context_comp_ref_p(cm, xd); |
(...skipping 29 matching lines...) Expand all Loading... |
113 } | 120 } |
114 | 121 |
115 static const vp9_prob *get_tx_probs2(const MACROBLOCKD *xd, | 122 static const vp9_prob *get_tx_probs2(const MACROBLOCKD *xd, |
116 const struct tx_probs *tx_probs, | 123 const struct tx_probs *tx_probs, |
117 const MODE_INFO *m) { | 124 const MODE_INFO *m) { |
118 const BLOCK_SIZE bsize = m->mbmi.sb_type; | 125 const BLOCK_SIZE bsize = m->mbmi.sb_type; |
119 const int context = vp9_get_pred_context_tx_size(xd); | 126 const int context = vp9_get_pred_context_tx_size(xd); |
120 return get_tx_probs(bsize, context, tx_probs); | 127 return get_tx_probs(bsize, context, tx_probs); |
121 } | 128 } |
122 | 129 |
123 static void update_tx_counts(BLOCK_SIZE bsize, uint8_t context, | 130 static unsigned int *get_tx_counts(BLOCK_SIZE bsize, uint8_t context, |
124 TX_SIZE tx_size, struct tx_counts *tx_counts) { | 131 struct tx_counts *tx_counts) { |
125 if (bsize >= BLOCK_32X32) | 132 if (bsize < BLOCK_16X16) |
126 tx_counts->p32x32[context][tx_size]++; | 133 return tx_counts->p8x8[context]; |
127 else if (bsize >= BLOCK_16X16) | 134 else if (bsize < BLOCK_32X32) |
128 tx_counts->p16x16[context][tx_size]++; | 135 return tx_counts->p16x16[context]; |
129 else | 136 else |
130 tx_counts->p8x8[context][tx_size]++; | 137 return tx_counts->p32x32[context]; |
131 } | 138 } |
132 | 139 |
133 #endif // VP9_COMMON_VP9_PRED_COMMON_H_ | 140 #endif // VP9_COMMON_VP9_PRED_COMMON_H_ |
OLD | NEW |