Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #ifndef AV1_COMMON_PRED_COMMON_H_ |
| 13 | #define AV1_COMMON_PRED_COMMON_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
| 15 | #include "av1/common/blockd.h" |
| 16 | #include "av1/common/onyxc_int.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 17 | #include "aom_dsp/aom_dsp_common.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
Urvang Joshi | 5264844 | 2016-10-13 17:27:51 -0700 | [diff] [blame] | 23 | static INLINE int get_segment_id(const AV1_COMMON *const cm, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 24 | const uint8_t *segment_ids, BLOCK_SIZE bsize, |
| 25 | int mi_row, int mi_col) { |
| 26 | const int mi_offset = mi_row * cm->mi_cols + mi_col; |
Jingning Han | c709e1f | 2016-12-06 14:48:09 -0800 | [diff] [blame] | 27 | const int bw = mi_size_wide[bsize]; |
| 28 | const int bh = mi_size_high[bsize]; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 29 | const int xmis = AOMMIN(cm->mi_cols - mi_col, bw); |
| 30 | const int ymis = AOMMIN(cm->mi_rows - mi_row, bh); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 31 | int x, y, segment_id = MAX_SEGMENTS; |
| 32 | |
| 33 | for (y = 0; y < ymis; ++y) |
| 34 | for (x = 0; x < xmis; ++x) |
| 35 | segment_id = |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 36 | AOMMIN(segment_id, segment_ids[mi_offset + y * cm->mi_cols + x]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 37 | |
| 38 | assert(segment_id >= 0 && segment_id < MAX_SEGMENTS); |
| 39 | return segment_id; |
| 40 | } |
| 41 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 42 | static INLINE int av1_get_pred_context_seg_id(const MACROBLOCKD *xd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 43 | const MODE_INFO *const above_mi = xd->above_mi; |
| 44 | const MODE_INFO *const left_mi = xd->left_mi; |
| 45 | const int above_sip = |
| 46 | (above_mi != NULL) ? above_mi->mbmi.seg_id_predicted : 0; |
| 47 | const int left_sip = (left_mi != NULL) ? left_mi->mbmi.seg_id_predicted : 0; |
| 48 | |
| 49 | return above_sip + left_sip; |
| 50 | } |
| 51 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 52 | static INLINE aom_prob av1_get_pred_prob_seg_id( |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 53 | const struct segmentation_probs *segp, const MACROBLOCKD *xd) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 54 | return segp->pred_probs[av1_get_pred_context_seg_id(xd)]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Thomas Davies | 0002135 | 2017-07-11 16:07:55 +0100 | [diff] [blame] | 57 | #if CONFIG_NEW_MULTISYMBOL |
| 58 | static INLINE aom_cdf_prob *av1_get_pred_cdf_seg_id( |
| 59 | struct segmentation_probs *segp, const MACROBLOCKD *xd) { |
| 60 | return segp->pred_cdf[av1_get_pred_context_seg_id(xd)]; |
| 61 | } |
| 62 | #endif |
| 63 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 64 | static INLINE int av1_get_skip_context(const MACROBLOCKD *xd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 65 | const MODE_INFO *const above_mi = xd->above_mi; |
| 66 | const MODE_INFO *const left_mi = xd->left_mi; |
| 67 | const int above_skip = (above_mi != NULL) ? above_mi->mbmi.skip : 0; |
| 68 | const int left_skip = (left_mi != NULL) ? left_mi->mbmi.skip : 0; |
| 69 | return above_skip + left_skip; |
| 70 | } |
| 71 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 72 | #if CONFIG_DUAL_FILTER |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 73 | int av1_get_pred_context_switchable_interp(const MACROBLOCKD *xd, int dir); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 74 | #else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 75 | int av1_get_pred_context_switchable_interp(const MACROBLOCKD *xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 76 | #endif |
| 77 | |
Urvang Joshi | c6300aa | 2017-06-01 14:46:23 -0700 | [diff] [blame] | 78 | #if CONFIG_PALETTE_DELTA_ENCODING |
hui su | 33567b2 | 2017-04-30 16:40:19 -0700 | [diff] [blame] | 79 | // Get a list of palette base colors that are used in the above and left blocks, |
| 80 | // referred to as "color cache". The return value is the number of colors in the |
| 81 | // cache (<= 2 * PALETTE_MAX_SIZE). The color values are stored in "cache" |
| 82 | // in ascending order. |
Hui Su | 3748bc2 | 2017-08-23 11:30:41 -0700 | [diff] [blame] | 83 | int av1_get_palette_cache(const MACROBLOCKD *const xd, int plane, |
| 84 | uint16_t *cache); |
Urvang Joshi | c6300aa | 2017-06-01 14:46:23 -0700 | [diff] [blame] | 85 | #endif // CONFIG_PALETTE_DELTA_ENCODING |
hui su | 33567b2 | 2017-04-30 16:40:19 -0700 | [diff] [blame] | 86 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 87 | int av1_get_intra_inter_context(const MACROBLOCKD *xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 88 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 89 | int av1_get_reference_mode_context(const AV1_COMMON *cm, const MACROBLOCKD *xd); |
| 90 | |
| 91 | static INLINE aom_prob av1_get_reference_mode_prob(const AV1_COMMON *cm, |
| 92 | const MACROBLOCKD *xd) { |
| 93 | return cm->fc->comp_inter_prob[av1_get_reference_mode_context(cm, xd)]; |
| 94 | } |
Thomas Davies | 860def6 | 2017-06-14 10:00:03 +0100 | [diff] [blame] | 95 | #if CONFIG_NEW_MULTISYMBOL |
| 96 | static INLINE aom_cdf_prob *av1_get_reference_mode_cdf(const AV1_COMMON *cm, |
| 97 | const MACROBLOCKD *xd) { |
| 98 | return xd->tile_ctx->comp_inter_cdf[av1_get_reference_mode_context(cm, xd)]; |
| 99 | } |
| 100 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 101 | |
Zoe Liu | c082bbc | 2017-05-17 13:31:37 -0700 | [diff] [blame] | 102 | #if CONFIG_EXT_COMP_REFS |
Zoe Liu | fcf5fa2 | 2017-06-26 16:00:38 -0700 | [diff] [blame] | 103 | int av1_get_comp_reference_type_context(const MACROBLOCKD *xd); |
Zoe Liu | c082bbc | 2017-05-17 13:31:37 -0700 | [diff] [blame] | 104 | |
| 105 | static INLINE aom_prob av1_get_comp_reference_type_prob(const AV1_COMMON *cm, |
| 106 | const MACROBLOCKD *xd) { |
Zoe Liu | fcf5fa2 | 2017-06-26 16:00:38 -0700 | [diff] [blame] | 107 | return cm->fc->comp_ref_type_prob[av1_get_comp_reference_type_context(xd)]; |
Zoe Liu | c082bbc | 2017-05-17 13:31:37 -0700 | [diff] [blame] | 108 | } |
| 109 | |
Zoe Liu | fcf5fa2 | 2017-06-26 16:00:38 -0700 | [diff] [blame] | 110 | int av1_get_pred_context_uni_comp_ref_p(const MACROBLOCKD *xd); |
Zoe Liu | c082bbc | 2017-05-17 13:31:37 -0700 | [diff] [blame] | 111 | |
| 112 | static INLINE aom_prob av1_get_pred_prob_uni_comp_ref_p(const AV1_COMMON *cm, |
| 113 | const MACROBLOCKD *xd) { |
Zoe Liu | fcf5fa2 | 2017-06-26 16:00:38 -0700 | [diff] [blame] | 114 | const int pred_context = av1_get_pred_context_uni_comp_ref_p(xd); |
Zoe Liu | c082bbc | 2017-05-17 13:31:37 -0700 | [diff] [blame] | 115 | return cm->fc->uni_comp_ref_prob[pred_context][0]; |
| 116 | } |
| 117 | |
Zoe Liu | fcf5fa2 | 2017-06-26 16:00:38 -0700 | [diff] [blame] | 118 | int av1_get_pred_context_uni_comp_ref_p1(const MACROBLOCKD *xd); |
Zoe Liu | c082bbc | 2017-05-17 13:31:37 -0700 | [diff] [blame] | 119 | |
| 120 | static INLINE aom_prob |
| 121 | av1_get_pred_prob_uni_comp_ref_p1(const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
Zoe Liu | fcf5fa2 | 2017-06-26 16:00:38 -0700 | [diff] [blame] | 122 | const int pred_context = av1_get_pred_context_uni_comp_ref_p1(xd); |
Zoe Liu | c082bbc | 2017-05-17 13:31:37 -0700 | [diff] [blame] | 123 | return cm->fc->uni_comp_ref_prob[pred_context][1]; |
| 124 | } |
Zoe Liu | fcf5fa2 | 2017-06-26 16:00:38 -0700 | [diff] [blame] | 125 | |
| 126 | int av1_get_pred_context_uni_comp_ref_p2(const MACROBLOCKD *xd); |
| 127 | |
| 128 | static INLINE aom_prob |
| 129 | av1_get_pred_prob_uni_comp_ref_p2(const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 130 | const int pred_context = av1_get_pred_context_uni_comp_ref_p2(xd); |
| 131 | return cm->fc->uni_comp_ref_prob[pred_context][2]; |
| 132 | } |
| 133 | |
| 134 | #if CONFIG_NEW_MULTISYMBOL |
| 135 | static INLINE aom_cdf_prob *av1_get_comp_reference_type_cdf( |
| 136 | const MACROBLOCKD *xd) { |
| 137 | const int pred_context = av1_get_comp_reference_type_context(xd); |
| 138 | return xd->tile_ctx->comp_ref_type_cdf[pred_context]; |
| 139 | } |
| 140 | |
| 141 | static INLINE aom_cdf_prob *av1_get_pred_cdf_uni_comp_ref_p( |
| 142 | const MACROBLOCKD *xd) { |
| 143 | const int pred_context = av1_get_pred_context_uni_comp_ref_p(xd); |
| 144 | return xd->tile_ctx->uni_comp_ref_cdf[pred_context][0]; |
| 145 | } |
| 146 | |
| 147 | static INLINE aom_cdf_prob *av1_get_pred_cdf_uni_comp_ref_p1( |
| 148 | const MACROBLOCKD *xd) { |
| 149 | const int pred_context = av1_get_pred_context_uni_comp_ref_p1(xd); |
| 150 | return xd->tile_ctx->uni_comp_ref_cdf[pred_context][1]; |
| 151 | } |
| 152 | |
| 153 | static INLINE aom_cdf_prob *av1_get_pred_cdf_uni_comp_ref_p2( |
| 154 | const MACROBLOCKD *xd) { |
| 155 | const int pred_context = av1_get_pred_context_uni_comp_ref_p2(xd); |
| 156 | return xd->tile_ctx->uni_comp_ref_cdf[pred_context][2]; |
| 157 | } |
| 158 | #endif // CONFIG_NEW_MULTISYMBOL |
Zoe Liu | c082bbc | 2017-05-17 13:31:37 -0700 | [diff] [blame] | 159 | #endif // CONFIG_EXT_COMP_REFS |
| 160 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 161 | int av1_get_pred_context_comp_ref_p(const AV1_COMMON *cm, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 162 | const MACROBLOCKD *xd); |
| 163 | |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 164 | #if CONFIG_NEW_MULTISYMBOL |
| 165 | static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_ref_p(const AV1_COMMON *cm, |
| 166 | const MACROBLOCKD *xd) { |
| 167 | const int pred_context = av1_get_pred_context_comp_ref_p(cm, xd); |
| 168 | return xd->tile_ctx->comp_ref_cdf[pred_context][0]; |
| 169 | } |
| 170 | #endif |
| 171 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 172 | static INLINE aom_prob av1_get_pred_prob_comp_ref_p(const AV1_COMMON *cm, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 173 | const MACROBLOCKD *xd) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 174 | const int pred_context = av1_get_pred_context_comp_ref_p(cm, xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 175 | return cm->fc->comp_ref_prob[pred_context][0]; |
| 176 | } |
| 177 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 178 | int av1_get_pred_context_comp_ref_p1(const AV1_COMMON *cm, |
| 179 | const MACROBLOCKD *xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 180 | |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 181 | #if CONFIG_NEW_MULTISYMBOL |
| 182 | static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_ref_p1( |
| 183 | const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 184 | const int pred_context = av1_get_pred_context_comp_ref_p1(cm, xd); |
| 185 | return xd->tile_ctx->comp_ref_cdf[pred_context][1]; |
| 186 | } |
Zoe Liu | 97ad058 | 2017-02-09 10:51:00 -0800 | [diff] [blame] | 187 | #endif // CONFIG_NEW_MULTISYMBOL |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 188 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 189 | static INLINE aom_prob av1_get_pred_prob_comp_ref_p1(const AV1_COMMON *cm, |
| 190 | const MACROBLOCKD *xd) { |
| 191 | const int pred_context = av1_get_pred_context_comp_ref_p1(cm, xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 192 | return cm->fc->comp_ref_prob[pred_context][1]; |
| 193 | } |
| 194 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 195 | int av1_get_pred_context_comp_ref_p2(const AV1_COMMON *cm, |
| 196 | const MACROBLOCKD *xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 197 | |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 198 | #if CONFIG_NEW_MULTISYMBOL |
| 199 | static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_ref_p2( |
| 200 | const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 201 | const int pred_context = av1_get_pred_context_comp_ref_p2(cm, xd); |
| 202 | return xd->tile_ctx->comp_ref_cdf[pred_context][2]; |
| 203 | } |
Zoe Liu | 97ad058 | 2017-02-09 10:51:00 -0800 | [diff] [blame] | 204 | #endif // CONFIG_NEW_MULTISYMBOL |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 205 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 206 | static INLINE aom_prob av1_get_pred_prob_comp_ref_p2(const AV1_COMMON *cm, |
| 207 | const MACROBLOCKD *xd) { |
| 208 | const int pred_context = av1_get_pred_context_comp_ref_p2(cm, xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 209 | return cm->fc->comp_ref_prob[pred_context][2]; |
| 210 | } |
| 211 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 212 | int av1_get_pred_context_comp_bwdref_p(const AV1_COMMON *cm, |
| 213 | const MACROBLOCKD *xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 214 | |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 215 | #if CONFIG_NEW_MULTISYMBOL |
| 216 | static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_bwdref_p( |
| 217 | const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 218 | const int pred_context = av1_get_pred_context_comp_bwdref_p(cm, xd); |
| 219 | return xd->tile_ctx->comp_bwdref_cdf[pred_context][0]; |
| 220 | } |
| 221 | #endif // CONFIG_NEW_MULTISYMBOL |
Zoe Liu | 97ad058 | 2017-02-09 10:51:00 -0800 | [diff] [blame] | 222 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 223 | static INLINE aom_prob av1_get_pred_prob_comp_bwdref_p(const AV1_COMMON *cm, |
| 224 | const MACROBLOCKD *xd) { |
| 225 | const int pred_context = av1_get_pred_context_comp_bwdref_p(cm, xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 226 | return cm->fc->comp_bwdref_prob[pred_context][0]; |
| 227 | } |
Zoe Liu | 97ad058 | 2017-02-09 10:51:00 -0800 | [diff] [blame] | 228 | |
Zoe Liu | 97ad058 | 2017-02-09 10:51:00 -0800 | [diff] [blame] | 229 | int av1_get_pred_context_comp_bwdref_p1(const AV1_COMMON *cm, |
| 230 | const MACROBLOCKD *xd); |
| 231 | |
Zoe Liu | 3ac2093 | 2017-08-30 16:35:55 -0700 | [diff] [blame] | 232 | #if CONFIG_NEW_MULTISYMBOL |
| 233 | static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_bwdref_p1( |
| 234 | const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 235 | const int pred_context = av1_get_pred_context_comp_bwdref_p1(cm, xd); |
| 236 | return xd->tile_ctx->comp_bwdref_cdf[pred_context][1]; |
| 237 | } |
| 238 | #endif // CONFIG_NEW_MULTISYMBOL |
| 239 | |
Zoe Liu | 97ad058 | 2017-02-09 10:51:00 -0800 | [diff] [blame] | 240 | static INLINE aom_prob av1_get_pred_prob_comp_bwdref_p1(const AV1_COMMON *cm, |
| 241 | const MACROBLOCKD *xd) { |
| 242 | const int pred_context = av1_get_pred_context_comp_bwdref_p1(cm, xd); |
| 243 | return cm->fc->comp_bwdref_prob[pred_context][1]; |
| 244 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 245 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 246 | int av1_get_pred_context_single_ref_p1(const MACROBLOCKD *xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 247 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 248 | static INLINE aom_prob av1_get_pred_prob_single_ref_p1(const AV1_COMMON *cm, |
| 249 | const MACROBLOCKD *xd) { |
| 250 | return cm->fc->single_ref_prob[av1_get_pred_context_single_ref_p1(xd)][0]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 253 | int av1_get_pred_context_single_ref_p2(const MACROBLOCKD *xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 254 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 255 | static INLINE aom_prob av1_get_pred_prob_single_ref_p2(const AV1_COMMON *cm, |
| 256 | const MACROBLOCKD *xd) { |
| 257 | return cm->fc->single_ref_prob[av1_get_pred_context_single_ref_p2(xd)][1]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 258 | } |
| 259 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 260 | int av1_get_pred_context_single_ref_p3(const MACROBLOCKD *xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 261 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 262 | static INLINE aom_prob av1_get_pred_prob_single_ref_p3(const AV1_COMMON *cm, |
| 263 | const MACROBLOCKD *xd) { |
| 264 | return cm->fc->single_ref_prob[av1_get_pred_context_single_ref_p3(xd)][2]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 267 | int av1_get_pred_context_single_ref_p4(const MACROBLOCKD *xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 268 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 269 | static INLINE aom_prob av1_get_pred_prob_single_ref_p4(const AV1_COMMON *cm, |
| 270 | const MACROBLOCKD *xd) { |
| 271 | return cm->fc->single_ref_prob[av1_get_pred_context_single_ref_p4(xd)][3]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 274 | int av1_get_pred_context_single_ref_p5(const MACROBLOCKD *xd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 275 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 276 | static INLINE aom_prob av1_get_pred_prob_single_ref_p5(const AV1_COMMON *cm, |
| 277 | const MACROBLOCKD *xd) { |
| 278 | return cm->fc->single_ref_prob[av1_get_pred_context_single_ref_p5(xd)][4]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 279 | } |
Zoe Liu | 97ad058 | 2017-02-09 10:51:00 -0800 | [diff] [blame] | 280 | |
Zoe Liu | 97ad058 | 2017-02-09 10:51:00 -0800 | [diff] [blame] | 281 | int av1_get_pred_context_single_ref_p6(const MACROBLOCKD *xd); |
| 282 | |
| 283 | static INLINE aom_prob av1_get_pred_prob_single_ref_p6(const AV1_COMMON *cm, |
| 284 | const MACROBLOCKD *xd) { |
| 285 | return cm->fc->single_ref_prob[av1_get_pred_context_single_ref_p6(xd)][5]; |
| 286 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 287 | |
Thomas Davies | 315f578 | 2017-06-14 15:14:55 +0100 | [diff] [blame] | 288 | #if CONFIG_NEW_MULTISYMBOL |
| 289 | static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p1( |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 290 | const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 291 | (void)cm; |
Thomas Davies | 315f578 | 2017-06-14 15:14:55 +0100 | [diff] [blame] | 292 | return xd->tile_ctx |
| 293 | ->single_ref_cdf[av1_get_pred_context_single_ref_p1(xd)][0]; |
| 294 | } |
| 295 | static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p2( |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 296 | const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 297 | (void)cm; |
Thomas Davies | 315f578 | 2017-06-14 15:14:55 +0100 | [diff] [blame] | 298 | return xd->tile_ctx |
| 299 | ->single_ref_cdf[av1_get_pred_context_single_ref_p2(xd)][1]; |
| 300 | } |
| 301 | static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p3( |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 302 | const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 303 | (void)cm; |
Thomas Davies | 315f578 | 2017-06-14 15:14:55 +0100 | [diff] [blame] | 304 | return xd->tile_ctx |
| 305 | ->single_ref_cdf[av1_get_pred_context_single_ref_p3(xd)][2]; |
| 306 | } |
| 307 | static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p4( |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 308 | const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 309 | (void)cm; |
Thomas Davies | 315f578 | 2017-06-14 15:14:55 +0100 | [diff] [blame] | 310 | return xd->tile_ctx |
| 311 | ->single_ref_cdf[av1_get_pred_context_single_ref_p4(xd)][3]; |
| 312 | } |
| 313 | static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p5( |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 314 | const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 315 | (void)cm; |
Thomas Davies | 315f578 | 2017-06-14 15:14:55 +0100 | [diff] [blame] | 316 | return xd->tile_ctx |
| 317 | ->single_ref_cdf[av1_get_pred_context_single_ref_p5(xd)][4]; |
| 318 | } |
Zoe Liu | 3ac2093 | 2017-08-30 16:35:55 -0700 | [diff] [blame] | 319 | static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p6( |
| 320 | const AV1_COMMON *cm, const MACROBLOCKD *xd) { |
| 321 | (void)cm; |
| 322 | return xd->tile_ctx |
| 323 | ->single_ref_cdf[av1_get_pred_context_single_ref_p6(xd)][5]; |
| 324 | } |
Thomas Davies | 894cc81 | 2017-06-22 17:51:33 +0100 | [diff] [blame] | 325 | #endif // CONFIG_NEW_MULTISYMBOL |
Thomas Davies | 315f578 | 2017-06-14 15:14:55 +0100 | [diff] [blame] | 326 | |
Sebastien Alaiwan | 0bdea0d | 2017-10-02 15:15:05 +0200 | [diff] [blame] | 327 | #if CONFIG_COMPOUND_SINGLEREF |
Zoe Liu | 239f06b | 2017-04-20 13:10:55 -0700 | [diff] [blame] | 328 | int av1_get_inter_mode_context(const MACROBLOCKD *xd); |
| 329 | |
| 330 | static INLINE aom_prob av1_get_inter_mode_prob(const AV1_COMMON *cm, |
| 331 | const MACROBLOCKD *xd) { |
| 332 | return cm->fc->comp_inter_mode_prob[av1_get_inter_mode_context(xd)]; |
| 333 | } |
Sebastien Alaiwan | 0bdea0d | 2017-10-02 15:15:05 +0200 | [diff] [blame] | 334 | #endif // CONFIG_COMPOUND_SINGLEREF |
Zoe Liu | 239f06b | 2017-04-20 13:10:55 -0700 | [diff] [blame] | 335 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 336 | // Returns a context number for the given MB prediction signal |
| 337 | // The mode info data structure has a one element border above and to the |
| 338 | // left of the entries corresponding to real blocks. |
| 339 | // The prediction flags in these dummy entries are initialized to 0. |
| 340 | static INLINE int get_tx_size_context(const MACROBLOCKD *xd) { |
| 341 | const int max_tx_size = max_txsize_lookup[xd->mi[0]->mbmi.sb_type]; |
| 342 | const MB_MODE_INFO *const above_mbmi = xd->above_mbmi; |
| 343 | const MB_MODE_INFO *const left_mbmi = xd->left_mbmi; |
| 344 | const int has_above = xd->up_available; |
| 345 | const int has_left = xd->left_available; |
| 346 | int above_ctx = (has_above && !above_mbmi->skip) |
| 347 | ? (int)txsize_sqr_map[above_mbmi->tx_size] |
| 348 | : max_tx_size; |
| 349 | int left_ctx = (has_left && !left_mbmi->skip) |
| 350 | ? (int)txsize_sqr_map[left_mbmi->tx_size] |
| 351 | : max_tx_size; |
Jingning Han | 3daa4fd | 2017-01-20 10:33:50 -0800 | [diff] [blame] | 352 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 353 | if (!has_left) left_ctx = above_ctx; |
| 354 | |
| 355 | if (!has_above) above_ctx = left_ctx; |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 356 | return (above_ctx + left_ctx) > max_tx_size + TX_SIZE_LUMA_MIN; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 357 | } |
| 358 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 359 | #ifdef __cplusplus |
| 360 | } // extern "C" |
| 361 | #endif |
| 362 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 363 | #endif // AV1_COMMON_PRED_COMMON_H_ |