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 |
(...skipping 22 matching lines...) Expand all Loading... |
33 const int left_sip = (left_mi != NULL) ? left_mi->mbmi.seg_id_predicted : 0; | 33 const int left_sip = (left_mi != NULL) ? left_mi->mbmi.seg_id_predicted : 0; |
34 | 34 |
35 return above_sip + left_sip; | 35 return above_sip + left_sip; |
36 } | 36 } |
37 | 37 |
38 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, |
39 const MACROBLOCKD *xd) { | 39 const MACROBLOCKD *xd) { |
40 return seg->pred_probs[vp9_get_pred_context_seg_id(xd)]; | 40 return seg->pred_probs[vp9_get_pred_context_seg_id(xd)]; |
41 } | 41 } |
42 | 42 |
43 void vp9_set_pred_flag_seg_id(MACROBLOCKD *xd, uint8_t pred_flag); | 43 static INLINE int vp9_get_skip_context(const MACROBLOCKD *xd) { |
44 | |
45 static INLINE int vp9_get_pred_context_mbskip(const MACROBLOCKD *xd) { | |
46 const MODE_INFO *const above_mi = get_above_mi(xd); | 44 const MODE_INFO *const above_mi = get_above_mi(xd); |
47 const MODE_INFO *const left_mi = get_left_mi(xd); | 45 const MODE_INFO *const left_mi = get_left_mi(xd); |
48 const int above_skip_coeff = (above_mi != NULL) ? | 46 const int above_skip = (above_mi != NULL) ? above_mi->mbmi.skip_coeff : 0; |
49 above_mi->mbmi.skip_coeff : 0; | 47 const int left_skip = (left_mi != NULL) ? left_mi->mbmi.skip_coeff : 0; |
50 const int left_skip_coeff = (left_mi != NULL) ? left_mi->mbmi.skip_coeff : 0; | 48 return above_skip + left_skip; |
51 | |
52 return above_skip_coeff + left_skip_coeff; | |
53 } | 49 } |
54 | 50 |
55 static INLINE vp9_prob vp9_get_pred_prob_mbskip(const VP9_COMMON *cm, | 51 static INLINE vp9_prob vp9_get_skip_prob(const VP9_COMMON *cm, |
56 const MACROBLOCKD *xd) { | 52 const MACROBLOCKD *xd) { |
57 return cm->fc.mbskip_probs[vp9_get_pred_context_mbskip(xd)]; | 53 return cm->fc.mbskip_probs[vp9_get_skip_context(xd)]; |
58 } | 54 } |
59 | 55 |
60 static INLINE unsigned char vp9_get_pred_flag_mbskip(const MACROBLOCKD *xd) { | 56 int vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd); |
61 return xd->mi_8x8[0]->mbmi.skip_coeff; | 57 |
| 58 int vp9_get_intra_inter_context(const MACROBLOCKD *xd); |
| 59 |
| 60 static INLINE vp9_prob vp9_get_intra_inter_prob(const VP9_COMMON *cm, |
| 61 const MACROBLOCKD *xd) { |
| 62 return cm->fc.intra_inter_prob[vp9_get_intra_inter_context(xd)]; |
62 } | 63 } |
63 | 64 |
64 unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd); | 65 int vp9_get_reference_mode_context(const VP9_COMMON *cm, const MACROBLOCKD *xd); |
65 | 66 |
66 unsigned char vp9_get_pred_context_intra_inter(const MACROBLOCKD *xd); | 67 static INLINE vp9_prob vp9_get_reference_mode_prob(const VP9_COMMON *cm, |
67 | 68 const MACROBLOCKD *xd) { |
68 static INLINE vp9_prob vp9_get_pred_prob_intra_inter(const VP9_COMMON *cm, | 69 return cm->fc.comp_inter_prob[vp9_get_reference_mode_context(cm, xd)]; |
69 const MACROBLOCKD *xd) { | |
70 const int pred_context = vp9_get_pred_context_intra_inter(xd); | |
71 return cm->fc.intra_inter_prob[pred_context]; | |
72 } | 70 } |
73 | 71 |
74 unsigned char vp9_get_pred_context_comp_inter_inter(const VP9_COMMON *cm, | 72 int vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm, |
75 const MACROBLOCKD *xd); | 73 const MACROBLOCKD *xd); |
76 | |
77 | |
78 static INLINE | |
79 vp9_prob vp9_get_pred_prob_comp_inter_inter(const VP9_COMMON *cm, | |
80 const MACROBLOCKD *xd) { | |
81 const int pred_context = vp9_get_pred_context_comp_inter_inter(cm, xd); | |
82 return cm->fc.comp_inter_prob[pred_context]; | |
83 } | |
84 | |
85 unsigned char vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm, | |
86 const MACROBLOCKD *xd); | |
87 | 74 |
88 static INLINE vp9_prob vp9_get_pred_prob_comp_ref_p(const VP9_COMMON *cm, | 75 static INLINE vp9_prob vp9_get_pred_prob_comp_ref_p(const VP9_COMMON *cm, |
89 const MACROBLOCKD *xd) { | 76 const MACROBLOCKD *xd) { |
90 const int pred_context = vp9_get_pred_context_comp_ref_p(cm, xd); | 77 const int pred_context = vp9_get_pred_context_comp_ref_p(cm, xd); |
91 return cm->fc.comp_ref_prob[pred_context]; | 78 return cm->fc.comp_ref_prob[pred_context]; |
92 } | 79 } |
93 | 80 |
94 unsigned char vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd); | 81 int vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd); |
95 | 82 |
96 static INLINE vp9_prob vp9_get_pred_prob_single_ref_p1(const VP9_COMMON *cm, | 83 static INLINE vp9_prob vp9_get_pred_prob_single_ref_p1(const VP9_COMMON *cm, |
97 const MACROBLOCKD *xd) { | 84 const MACROBLOCKD *xd) { |
98 const int pred_context = vp9_get_pred_context_single_ref_p1(xd); | 85 return cm->fc.single_ref_prob[vp9_get_pred_context_single_ref_p1(xd)][0]; |
99 return cm->fc.single_ref_prob[pred_context][0]; | |
100 } | 86 } |
101 | 87 |
102 unsigned char vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd); | 88 int vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd); |
103 | 89 |
104 static INLINE vp9_prob vp9_get_pred_prob_single_ref_p2(const VP9_COMMON *cm, | 90 static INLINE vp9_prob vp9_get_pred_prob_single_ref_p2(const VP9_COMMON *cm, |
105 const MACROBLOCKD *xd) { | 91 const MACROBLOCKD *xd) { |
106 const int pred_context = vp9_get_pred_context_single_ref_p2(xd); | 92 return cm->fc.single_ref_prob[vp9_get_pred_context_single_ref_p2(xd)][1]; |
107 return cm->fc.single_ref_prob[pred_context][1]; | |
108 } | 93 } |
109 | 94 |
110 unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd); | 95 int vp9_get_tx_size_context(const MACROBLOCKD *xd); |
111 | 96 |
112 static const vp9_prob *get_tx_probs(BLOCK_SIZE bsize, uint8_t context, | 97 static const vp9_prob *get_tx_probs(TX_SIZE max_tx_size, int ctx, |
113 const struct tx_probs *tx_probs) { | 98 const struct tx_probs *tx_probs) { |
114 if (bsize < BLOCK_16X16) | 99 switch (max_tx_size) { |
115 return tx_probs->p8x8[context]; | 100 case TX_8X8: |
116 else if (bsize < BLOCK_32X32) | 101 return tx_probs->p8x8[ctx]; |
117 return tx_probs->p16x16[context]; | 102 case TX_16X16: |
118 else | 103 return tx_probs->p16x16[ctx]; |
119 return tx_probs->p32x32[context]; | 104 case TX_32X32: |
| 105 return tx_probs->p32x32[ctx]; |
| 106 default: |
| 107 assert(0 && "Invalid max_tx_size."); |
| 108 return NULL; |
| 109 } |
120 } | 110 } |
121 | 111 |
122 static const vp9_prob *get_tx_probs2(const MACROBLOCKD *xd, | 112 static const vp9_prob *get_tx_probs2(TX_SIZE max_tx_size, const MACROBLOCKD *xd, |
123 const struct tx_probs *tx_probs, | 113 const struct tx_probs *tx_probs) { |
124 const MODE_INFO *m) { | 114 return get_tx_probs(max_tx_size, vp9_get_tx_size_context(xd), tx_probs); |
125 const BLOCK_SIZE bsize = m->mbmi.sb_type; | |
126 const int context = vp9_get_pred_context_tx_size(xd); | |
127 return get_tx_probs(bsize, context, tx_probs); | |
128 } | 115 } |
129 | 116 |
130 static unsigned int *get_tx_counts(BLOCK_SIZE bsize, uint8_t context, | 117 static unsigned int *get_tx_counts(TX_SIZE max_tx_size, int ctx, |
131 struct tx_counts *tx_counts) { | 118 struct tx_counts *tx_counts) { |
132 if (bsize < BLOCK_16X16) | 119 switch (max_tx_size) { |
133 return tx_counts->p8x8[context]; | 120 case TX_8X8: |
134 else if (bsize < BLOCK_32X32) | 121 return tx_counts->p8x8[ctx]; |
135 return tx_counts->p16x16[context]; | 122 case TX_16X16: |
136 else | 123 return tx_counts->p16x16[ctx]; |
137 return tx_counts->p32x32[context]; | 124 case TX_32X32: |
| 125 return tx_counts->p32x32[ctx]; |
| 126 default: |
| 127 assert(0 && "Invalid max_tx_size."); |
| 128 return NULL; |
| 129 } |
138 } | 130 } |
139 | 131 |
140 #endif // VP9_COMMON_VP9_PRED_COMMON_H_ | 132 #endif // VP9_COMMON_VP9_PRED_COMMON_H_ |
OLD | NEW |