1*77c1e3ccSAndroid Build Coastguard Worker /*
2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3*77c1e3ccSAndroid Build Coastguard Worker *
4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and
5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can
7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the
9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10*77c1e3ccSAndroid Build Coastguard Worker */
11*77c1e3ccSAndroid Build Coastguard Worker
12*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/common.h"
13*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/pred_common.h"
14*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/reconinter.h"
15*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/reconintra.h"
16*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/seg_common.h"
17*77c1e3ccSAndroid Build Coastguard Worker
18*77c1e3ccSAndroid Build Coastguard Worker // Returns a context number for the given MB prediction signal
get_ref_filter_type(const MB_MODE_INFO * ref_mbmi,const MACROBLOCKD * xd,int dir,MV_REFERENCE_FRAME ref_frame)19*77c1e3ccSAndroid Build Coastguard Worker static InterpFilter get_ref_filter_type(const MB_MODE_INFO *ref_mbmi,
20*77c1e3ccSAndroid Build Coastguard Worker const MACROBLOCKD *xd, int dir,
21*77c1e3ccSAndroid Build Coastguard Worker MV_REFERENCE_FRAME ref_frame) {
22*77c1e3ccSAndroid Build Coastguard Worker (void)xd;
23*77c1e3ccSAndroid Build Coastguard Worker
24*77c1e3ccSAndroid Build Coastguard Worker return ((ref_mbmi->ref_frame[0] == ref_frame ||
25*77c1e3ccSAndroid Build Coastguard Worker ref_mbmi->ref_frame[1] == ref_frame)
26*77c1e3ccSAndroid Build Coastguard Worker ? av1_extract_interp_filter(ref_mbmi->interp_filters, dir & 0x01)
27*77c1e3ccSAndroid Build Coastguard Worker : SWITCHABLE_FILTERS);
28*77c1e3ccSAndroid Build Coastguard Worker }
29*77c1e3ccSAndroid Build Coastguard Worker
av1_get_pred_context_switchable_interp(const MACROBLOCKD * xd,int dir)30*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_switchable_interp(const MACROBLOCKD *xd, int dir) {
31*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *const mbmi = xd->mi[0];
32*77c1e3ccSAndroid Build Coastguard Worker const int ctx_offset =
33*77c1e3ccSAndroid Build Coastguard Worker (mbmi->ref_frame[1] > INTRA_FRAME) * INTER_FILTER_COMP_OFFSET;
34*77c1e3ccSAndroid Build Coastguard Worker assert(dir == 0 || dir == 1);
35*77c1e3ccSAndroid Build Coastguard Worker const MV_REFERENCE_FRAME ref_frame = mbmi->ref_frame[0];
36*77c1e3ccSAndroid Build Coastguard Worker // Note:
37*77c1e3ccSAndroid Build Coastguard Worker // The mode info data structure has a one element border above and to the
38*77c1e3ccSAndroid Build Coastguard Worker // left of the entries corresponding to real macroblocks.
39*77c1e3ccSAndroid Build Coastguard Worker // The prediction flags in these dummy entries are initialized to 0.
40*77c1e3ccSAndroid Build Coastguard Worker int filter_type_ctx = ctx_offset + (dir & 0x01) * INTER_FILTER_DIR_OFFSET;
41*77c1e3ccSAndroid Build Coastguard Worker int left_type = SWITCHABLE_FILTERS;
42*77c1e3ccSAndroid Build Coastguard Worker int above_type = SWITCHABLE_FILTERS;
43*77c1e3ccSAndroid Build Coastguard Worker
44*77c1e3ccSAndroid Build Coastguard Worker if (xd->left_available)
45*77c1e3ccSAndroid Build Coastguard Worker left_type = get_ref_filter_type(xd->mi[-1], xd, dir, ref_frame);
46*77c1e3ccSAndroid Build Coastguard Worker
47*77c1e3ccSAndroid Build Coastguard Worker if (xd->up_available)
48*77c1e3ccSAndroid Build Coastguard Worker above_type =
49*77c1e3ccSAndroid Build Coastguard Worker get_ref_filter_type(xd->mi[-xd->mi_stride], xd, dir, ref_frame);
50*77c1e3ccSAndroid Build Coastguard Worker
51*77c1e3ccSAndroid Build Coastguard Worker if (left_type == above_type) {
52*77c1e3ccSAndroid Build Coastguard Worker filter_type_ctx += left_type;
53*77c1e3ccSAndroid Build Coastguard Worker } else if (left_type == SWITCHABLE_FILTERS) {
54*77c1e3ccSAndroid Build Coastguard Worker assert(above_type != SWITCHABLE_FILTERS);
55*77c1e3ccSAndroid Build Coastguard Worker filter_type_ctx += above_type;
56*77c1e3ccSAndroid Build Coastguard Worker } else if (above_type == SWITCHABLE_FILTERS) {
57*77c1e3ccSAndroid Build Coastguard Worker assert(left_type != SWITCHABLE_FILTERS);
58*77c1e3ccSAndroid Build Coastguard Worker filter_type_ctx += left_type;
59*77c1e3ccSAndroid Build Coastguard Worker } else {
60*77c1e3ccSAndroid Build Coastguard Worker filter_type_ctx += SWITCHABLE_FILTERS;
61*77c1e3ccSAndroid Build Coastguard Worker }
62*77c1e3ccSAndroid Build Coastguard Worker
63*77c1e3ccSAndroid Build Coastguard Worker return filter_type_ctx;
64*77c1e3ccSAndroid Build Coastguard Worker }
65*77c1e3ccSAndroid Build Coastguard Worker
palette_add_to_cache(uint16_t * cache,int * n,uint16_t val)66*77c1e3ccSAndroid Build Coastguard Worker static void palette_add_to_cache(uint16_t *cache, int *n, uint16_t val) {
67*77c1e3ccSAndroid Build Coastguard Worker // Do not add an already existing value
68*77c1e3ccSAndroid Build Coastguard Worker if (*n > 0 && val == cache[*n - 1]) return;
69*77c1e3ccSAndroid Build Coastguard Worker
70*77c1e3ccSAndroid Build Coastguard Worker cache[(*n)++] = val;
71*77c1e3ccSAndroid Build Coastguard Worker }
72*77c1e3ccSAndroid Build Coastguard Worker
av1_get_palette_cache(const MACROBLOCKD * const xd,int plane,uint16_t * cache)73*77c1e3ccSAndroid Build Coastguard Worker int av1_get_palette_cache(const MACROBLOCKD *const xd, int plane,
74*77c1e3ccSAndroid Build Coastguard Worker uint16_t *cache) {
75*77c1e3ccSAndroid Build Coastguard Worker const int row = -xd->mb_to_top_edge >> 3;
76*77c1e3ccSAndroid Build Coastguard Worker // Do not refer to above SB row when on SB boundary.
77*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *const above_mi =
78*77c1e3ccSAndroid Build Coastguard Worker (row % (1 << MIN_SB_SIZE_LOG2)) ? xd->above_mbmi : NULL;
79*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *const left_mi = xd->left_mbmi;
80*77c1e3ccSAndroid Build Coastguard Worker int above_n = 0, left_n = 0;
81*77c1e3ccSAndroid Build Coastguard Worker if (above_mi) above_n = above_mi->palette_mode_info.palette_size[plane != 0];
82*77c1e3ccSAndroid Build Coastguard Worker if (left_mi) left_n = left_mi->palette_mode_info.palette_size[plane != 0];
83*77c1e3ccSAndroid Build Coastguard Worker if (above_n == 0 && left_n == 0) return 0;
84*77c1e3ccSAndroid Build Coastguard Worker int above_idx = plane * PALETTE_MAX_SIZE;
85*77c1e3ccSAndroid Build Coastguard Worker int left_idx = plane * PALETTE_MAX_SIZE;
86*77c1e3ccSAndroid Build Coastguard Worker int n = 0;
87*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *above_colors =
88*77c1e3ccSAndroid Build Coastguard Worker above_mi ? above_mi->palette_mode_info.palette_colors : NULL;
89*77c1e3ccSAndroid Build Coastguard Worker const uint16_t *left_colors =
90*77c1e3ccSAndroid Build Coastguard Worker left_mi ? left_mi->palette_mode_info.palette_colors : NULL;
91*77c1e3ccSAndroid Build Coastguard Worker // Merge the sorted lists of base colors from above and left to get
92*77c1e3ccSAndroid Build Coastguard Worker // combined sorted color cache.
93*77c1e3ccSAndroid Build Coastguard Worker while (above_n > 0 && left_n > 0) {
94*77c1e3ccSAndroid Build Coastguard Worker uint16_t v_above = above_colors[above_idx];
95*77c1e3ccSAndroid Build Coastguard Worker uint16_t v_left = left_colors[left_idx];
96*77c1e3ccSAndroid Build Coastguard Worker if (v_left < v_above) {
97*77c1e3ccSAndroid Build Coastguard Worker palette_add_to_cache(cache, &n, v_left);
98*77c1e3ccSAndroid Build Coastguard Worker ++left_idx, --left_n;
99*77c1e3ccSAndroid Build Coastguard Worker } else {
100*77c1e3ccSAndroid Build Coastguard Worker palette_add_to_cache(cache, &n, v_above);
101*77c1e3ccSAndroid Build Coastguard Worker ++above_idx, --above_n;
102*77c1e3ccSAndroid Build Coastguard Worker if (v_left == v_above) ++left_idx, --left_n;
103*77c1e3ccSAndroid Build Coastguard Worker }
104*77c1e3ccSAndroid Build Coastguard Worker }
105*77c1e3ccSAndroid Build Coastguard Worker while (above_n-- > 0) {
106*77c1e3ccSAndroid Build Coastguard Worker uint16_t val = above_colors[above_idx++];
107*77c1e3ccSAndroid Build Coastguard Worker palette_add_to_cache(cache, &n, val);
108*77c1e3ccSAndroid Build Coastguard Worker }
109*77c1e3ccSAndroid Build Coastguard Worker while (left_n-- > 0) {
110*77c1e3ccSAndroid Build Coastguard Worker uint16_t val = left_colors[left_idx++];
111*77c1e3ccSAndroid Build Coastguard Worker palette_add_to_cache(cache, &n, val);
112*77c1e3ccSAndroid Build Coastguard Worker }
113*77c1e3ccSAndroid Build Coastguard Worker assert(n <= 2 * PALETTE_MAX_SIZE);
114*77c1e3ccSAndroid Build Coastguard Worker return n;
115*77c1e3ccSAndroid Build Coastguard Worker }
116*77c1e3ccSAndroid Build Coastguard Worker
117*77c1e3ccSAndroid Build Coastguard Worker // The mode info data structure has a one element border above and to the
118*77c1e3ccSAndroid Build Coastguard Worker // left of the entries corresponding to real macroblocks.
119*77c1e3ccSAndroid Build Coastguard Worker // The prediction flags in these dummy entries are initialized to 0.
120*77c1e3ccSAndroid Build Coastguard Worker // 0 - inter/inter, inter/--, --/inter, --/--
121*77c1e3ccSAndroid Build Coastguard Worker // 1 - intra/inter, inter/intra
122*77c1e3ccSAndroid Build Coastguard Worker // 2 - intra/--, --/intra
123*77c1e3ccSAndroid Build Coastguard Worker // 3 - intra/intra
av1_get_intra_inter_context(const MACROBLOCKD * xd)124*77c1e3ccSAndroid Build Coastguard Worker int av1_get_intra_inter_context(const MACROBLOCKD *xd) {
125*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
126*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
127*77c1e3ccSAndroid Build Coastguard Worker const int has_above = xd->up_available;
128*77c1e3ccSAndroid Build Coastguard Worker const int has_left = xd->left_available;
129*77c1e3ccSAndroid Build Coastguard Worker
130*77c1e3ccSAndroid Build Coastguard Worker if (has_above && has_left) { // both edges available
131*77c1e3ccSAndroid Build Coastguard Worker const int above_intra = !is_inter_block(above_mbmi);
132*77c1e3ccSAndroid Build Coastguard Worker const int left_intra = !is_inter_block(left_mbmi);
133*77c1e3ccSAndroid Build Coastguard Worker return left_intra && above_intra ? 3 : left_intra || above_intra;
134*77c1e3ccSAndroid Build Coastguard Worker } else if (has_above || has_left) { // one edge available
135*77c1e3ccSAndroid Build Coastguard Worker return 2 * !is_inter_block(has_above ? above_mbmi : left_mbmi);
136*77c1e3ccSAndroid Build Coastguard Worker } else {
137*77c1e3ccSAndroid Build Coastguard Worker return 0;
138*77c1e3ccSAndroid Build Coastguard Worker }
139*77c1e3ccSAndroid Build Coastguard Worker }
140*77c1e3ccSAndroid Build Coastguard Worker
141*77c1e3ccSAndroid Build Coastguard Worker #define CHECK_BACKWARD_REFS(ref_frame) \
142*77c1e3ccSAndroid Build Coastguard Worker (((ref_frame) >= BWDREF_FRAME) && ((ref_frame) <= ALTREF_FRAME))
143*77c1e3ccSAndroid Build Coastguard Worker #define IS_BACKWARD_REF_FRAME(ref_frame) CHECK_BACKWARD_REFS(ref_frame)
144*77c1e3ccSAndroid Build Coastguard Worker
av1_get_reference_mode_context(const MACROBLOCKD * xd)145*77c1e3ccSAndroid Build Coastguard Worker int av1_get_reference_mode_context(const MACROBLOCKD *xd) {
146*77c1e3ccSAndroid Build Coastguard Worker int ctx;
147*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
148*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
149*77c1e3ccSAndroid Build Coastguard Worker const int has_above = xd->up_available;
150*77c1e3ccSAndroid Build Coastguard Worker const int has_left = xd->left_available;
151*77c1e3ccSAndroid Build Coastguard Worker
152*77c1e3ccSAndroid Build Coastguard Worker // Note:
153*77c1e3ccSAndroid Build Coastguard Worker // The mode info data structure has a one element border above and to the
154*77c1e3ccSAndroid Build Coastguard Worker // left of the entries corresponding to real macroblocks.
155*77c1e3ccSAndroid Build Coastguard Worker // The prediction flags in these dummy entries are initialized to 0.
156*77c1e3ccSAndroid Build Coastguard Worker if (has_above && has_left) { // both edges available
157*77c1e3ccSAndroid Build Coastguard Worker if (!has_second_ref(above_mbmi) && !has_second_ref(left_mbmi))
158*77c1e3ccSAndroid Build Coastguard Worker // neither edge uses comp pred (0/1)
159*77c1e3ccSAndroid Build Coastguard Worker ctx = IS_BACKWARD_REF_FRAME(above_mbmi->ref_frame[0]) ^
160*77c1e3ccSAndroid Build Coastguard Worker IS_BACKWARD_REF_FRAME(left_mbmi->ref_frame[0]);
161*77c1e3ccSAndroid Build Coastguard Worker else if (!has_second_ref(above_mbmi))
162*77c1e3ccSAndroid Build Coastguard Worker // one of two edges uses comp pred (2/3)
163*77c1e3ccSAndroid Build Coastguard Worker ctx = 2 + (IS_BACKWARD_REF_FRAME(above_mbmi->ref_frame[0]) ||
164*77c1e3ccSAndroid Build Coastguard Worker !is_inter_block(above_mbmi));
165*77c1e3ccSAndroid Build Coastguard Worker else if (!has_second_ref(left_mbmi))
166*77c1e3ccSAndroid Build Coastguard Worker // one of two edges uses comp pred (2/3)
167*77c1e3ccSAndroid Build Coastguard Worker ctx = 2 + (IS_BACKWARD_REF_FRAME(left_mbmi->ref_frame[0]) ||
168*77c1e3ccSAndroid Build Coastguard Worker !is_inter_block(left_mbmi));
169*77c1e3ccSAndroid Build Coastguard Worker else // both edges use comp pred (4)
170*77c1e3ccSAndroid Build Coastguard Worker ctx = 4;
171*77c1e3ccSAndroid Build Coastguard Worker } else if (has_above || has_left) { // one edge available
172*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *edge_mbmi = has_above ? above_mbmi : left_mbmi;
173*77c1e3ccSAndroid Build Coastguard Worker
174*77c1e3ccSAndroid Build Coastguard Worker if (!has_second_ref(edge_mbmi))
175*77c1e3ccSAndroid Build Coastguard Worker // edge does not use comp pred (0/1)
176*77c1e3ccSAndroid Build Coastguard Worker ctx = IS_BACKWARD_REF_FRAME(edge_mbmi->ref_frame[0]);
177*77c1e3ccSAndroid Build Coastguard Worker else
178*77c1e3ccSAndroid Build Coastguard Worker // edge uses comp pred (3)
179*77c1e3ccSAndroid Build Coastguard Worker ctx = 3;
180*77c1e3ccSAndroid Build Coastguard Worker } else { // no edges available (1)
181*77c1e3ccSAndroid Build Coastguard Worker ctx = 1;
182*77c1e3ccSAndroid Build Coastguard Worker }
183*77c1e3ccSAndroid Build Coastguard Worker assert(ctx >= 0 && ctx < COMP_INTER_CONTEXTS);
184*77c1e3ccSAndroid Build Coastguard Worker return ctx;
185*77c1e3ccSAndroid Build Coastguard Worker }
186*77c1e3ccSAndroid Build Coastguard Worker
av1_get_comp_reference_type_context(const MACROBLOCKD * xd)187*77c1e3ccSAndroid Build Coastguard Worker int av1_get_comp_reference_type_context(const MACROBLOCKD *xd) {
188*77c1e3ccSAndroid Build Coastguard Worker int pred_context;
189*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *const above_mbmi = xd->above_mbmi;
190*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
191*77c1e3ccSAndroid Build Coastguard Worker const int above_in_image = xd->up_available;
192*77c1e3ccSAndroid Build Coastguard Worker const int left_in_image = xd->left_available;
193*77c1e3ccSAndroid Build Coastguard Worker
194*77c1e3ccSAndroid Build Coastguard Worker if (above_in_image && left_in_image) { // both edges available
195*77c1e3ccSAndroid Build Coastguard Worker const int above_intra = !is_inter_block(above_mbmi);
196*77c1e3ccSAndroid Build Coastguard Worker const int left_intra = !is_inter_block(left_mbmi);
197*77c1e3ccSAndroid Build Coastguard Worker
198*77c1e3ccSAndroid Build Coastguard Worker if (above_intra && left_intra) { // intra/intra
199*77c1e3ccSAndroid Build Coastguard Worker pred_context = 2;
200*77c1e3ccSAndroid Build Coastguard Worker } else if (above_intra || left_intra) { // intra/inter
201*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *inter_mbmi = above_intra ? left_mbmi : above_mbmi;
202*77c1e3ccSAndroid Build Coastguard Worker
203*77c1e3ccSAndroid Build Coastguard Worker if (!has_second_ref(inter_mbmi)) // single pred
204*77c1e3ccSAndroid Build Coastguard Worker pred_context = 2;
205*77c1e3ccSAndroid Build Coastguard Worker else // comp pred
206*77c1e3ccSAndroid Build Coastguard Worker pred_context = 1 + 2 * has_uni_comp_refs(inter_mbmi);
207*77c1e3ccSAndroid Build Coastguard Worker } else { // inter/inter
208*77c1e3ccSAndroid Build Coastguard Worker const int a_sg = !has_second_ref(above_mbmi);
209*77c1e3ccSAndroid Build Coastguard Worker const int l_sg = !has_second_ref(left_mbmi);
210*77c1e3ccSAndroid Build Coastguard Worker const MV_REFERENCE_FRAME frfa = above_mbmi->ref_frame[0];
211*77c1e3ccSAndroid Build Coastguard Worker const MV_REFERENCE_FRAME frfl = left_mbmi->ref_frame[0];
212*77c1e3ccSAndroid Build Coastguard Worker
213*77c1e3ccSAndroid Build Coastguard Worker if (a_sg && l_sg) { // single/single
214*77c1e3ccSAndroid Build Coastguard Worker pred_context = 1 + 2 * (!(IS_BACKWARD_REF_FRAME(frfa) ^
215*77c1e3ccSAndroid Build Coastguard Worker IS_BACKWARD_REF_FRAME(frfl)));
216*77c1e3ccSAndroid Build Coastguard Worker } else if (l_sg || a_sg) { // single/comp
217*77c1e3ccSAndroid Build Coastguard Worker const int uni_rfc =
218*77c1e3ccSAndroid Build Coastguard Worker a_sg ? has_uni_comp_refs(left_mbmi) : has_uni_comp_refs(above_mbmi);
219*77c1e3ccSAndroid Build Coastguard Worker
220*77c1e3ccSAndroid Build Coastguard Worker if (!uni_rfc) // comp bidir
221*77c1e3ccSAndroid Build Coastguard Worker pred_context = 1;
222*77c1e3ccSAndroid Build Coastguard Worker else // comp unidir
223*77c1e3ccSAndroid Build Coastguard Worker pred_context = 3 + (!(IS_BACKWARD_REF_FRAME(frfa) ^
224*77c1e3ccSAndroid Build Coastguard Worker IS_BACKWARD_REF_FRAME(frfl)));
225*77c1e3ccSAndroid Build Coastguard Worker } else { // comp/comp
226*77c1e3ccSAndroid Build Coastguard Worker const int a_uni_rfc = has_uni_comp_refs(above_mbmi);
227*77c1e3ccSAndroid Build Coastguard Worker const int l_uni_rfc = has_uni_comp_refs(left_mbmi);
228*77c1e3ccSAndroid Build Coastguard Worker
229*77c1e3ccSAndroid Build Coastguard Worker if (!a_uni_rfc && !l_uni_rfc) // bidir/bidir
230*77c1e3ccSAndroid Build Coastguard Worker pred_context = 0;
231*77c1e3ccSAndroid Build Coastguard Worker else if (!a_uni_rfc || !l_uni_rfc) // unidir/bidir
232*77c1e3ccSAndroid Build Coastguard Worker pred_context = 2;
233*77c1e3ccSAndroid Build Coastguard Worker else // unidir/unidir
234*77c1e3ccSAndroid Build Coastguard Worker pred_context =
235*77c1e3ccSAndroid Build Coastguard Worker 3 + (!((frfa == BWDREF_FRAME) ^ (frfl == BWDREF_FRAME)));
236*77c1e3ccSAndroid Build Coastguard Worker }
237*77c1e3ccSAndroid Build Coastguard Worker }
238*77c1e3ccSAndroid Build Coastguard Worker } else if (above_in_image || left_in_image) { // one edge available
239*77c1e3ccSAndroid Build Coastguard Worker const MB_MODE_INFO *edge_mbmi = above_in_image ? above_mbmi : left_mbmi;
240*77c1e3ccSAndroid Build Coastguard Worker
241*77c1e3ccSAndroid Build Coastguard Worker if (!is_inter_block(edge_mbmi)) { // intra
242*77c1e3ccSAndroid Build Coastguard Worker pred_context = 2;
243*77c1e3ccSAndroid Build Coastguard Worker } else { // inter
244*77c1e3ccSAndroid Build Coastguard Worker if (!has_second_ref(edge_mbmi)) // single pred
245*77c1e3ccSAndroid Build Coastguard Worker pred_context = 2;
246*77c1e3ccSAndroid Build Coastguard Worker else // comp pred
247*77c1e3ccSAndroid Build Coastguard Worker pred_context = 4 * has_uni_comp_refs(edge_mbmi);
248*77c1e3ccSAndroid Build Coastguard Worker }
249*77c1e3ccSAndroid Build Coastguard Worker } else { // no edges available
250*77c1e3ccSAndroid Build Coastguard Worker pred_context = 2;
251*77c1e3ccSAndroid Build Coastguard Worker }
252*77c1e3ccSAndroid Build Coastguard Worker
253*77c1e3ccSAndroid Build Coastguard Worker assert(pred_context >= 0 && pred_context < COMP_REF_TYPE_CONTEXTS);
254*77c1e3ccSAndroid Build Coastguard Worker return pred_context;
255*77c1e3ccSAndroid Build Coastguard Worker }
256*77c1e3ccSAndroid Build Coastguard Worker
257*77c1e3ccSAndroid Build Coastguard Worker // Returns a context number for the given MB prediction signal
258*77c1e3ccSAndroid Build Coastguard Worker //
259*77c1e3ccSAndroid Build Coastguard Worker // Signal the uni-directional compound reference frame pair as either
260*77c1e3ccSAndroid Build Coastguard Worker // (BWDREF, ALTREF), or (LAST, LAST2) / (LAST, LAST3) / (LAST, GOLDEN),
261*77c1e3ccSAndroid Build Coastguard Worker // conditioning on the pair is known as uni-directional.
262*77c1e3ccSAndroid Build Coastguard Worker //
263*77c1e3ccSAndroid Build Coastguard Worker // 3 contexts: Voting is used to compare the count of forward references with
264*77c1e3ccSAndroid Build Coastguard Worker // that of backward references from the spatial neighbors.
av1_get_pred_context_uni_comp_ref_p(const MACROBLOCKD * xd)265*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_uni_comp_ref_p(const MACROBLOCKD *xd) {
266*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const ref_counts = &xd->neighbors_ref_counts[0];
267*77c1e3ccSAndroid Build Coastguard Worker
268*77c1e3ccSAndroid Build Coastguard Worker // Count of forward references (L, L2, L3, or G)
269*77c1e3ccSAndroid Build Coastguard Worker const int frf_count = ref_counts[LAST_FRAME] + ref_counts[LAST2_FRAME] +
270*77c1e3ccSAndroid Build Coastguard Worker ref_counts[LAST3_FRAME] + ref_counts[GOLDEN_FRAME];
271*77c1e3ccSAndroid Build Coastguard Worker // Count of backward references (B or A)
272*77c1e3ccSAndroid Build Coastguard Worker const int brf_count = ref_counts[BWDREF_FRAME] + ref_counts[ALTREF2_FRAME] +
273*77c1e3ccSAndroid Build Coastguard Worker ref_counts[ALTREF_FRAME];
274*77c1e3ccSAndroid Build Coastguard Worker
275*77c1e3ccSAndroid Build Coastguard Worker const int pred_context =
276*77c1e3ccSAndroid Build Coastguard Worker (frf_count == brf_count) ? 1 : ((frf_count < brf_count) ? 0 : 2);
277*77c1e3ccSAndroid Build Coastguard Worker
278*77c1e3ccSAndroid Build Coastguard Worker assert(pred_context >= 0 && pred_context < UNI_COMP_REF_CONTEXTS);
279*77c1e3ccSAndroid Build Coastguard Worker return pred_context;
280*77c1e3ccSAndroid Build Coastguard Worker }
281*77c1e3ccSAndroid Build Coastguard Worker
282*77c1e3ccSAndroid Build Coastguard Worker // Returns a context number for the given MB prediction signal
283*77c1e3ccSAndroid Build Coastguard Worker //
284*77c1e3ccSAndroid Build Coastguard Worker // Signal the uni-directional compound reference frame pair as
285*77c1e3ccSAndroid Build Coastguard Worker // either (LAST, LAST2), or (LAST, LAST3) / (LAST, GOLDEN),
286*77c1e3ccSAndroid Build Coastguard Worker // conditioning on the pair is known as one of the above three.
287*77c1e3ccSAndroid Build Coastguard Worker //
288*77c1e3ccSAndroid Build Coastguard Worker // 3 contexts: Voting is used to compare the count of LAST2_FRAME with the
289*77c1e3ccSAndroid Build Coastguard Worker // total count of LAST3/GOLDEN from the spatial neighbors.
av1_get_pred_context_uni_comp_ref_p1(const MACROBLOCKD * xd)290*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_uni_comp_ref_p1(const MACROBLOCKD *xd) {
291*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const ref_counts = &xd->neighbors_ref_counts[0];
292*77c1e3ccSAndroid Build Coastguard Worker
293*77c1e3ccSAndroid Build Coastguard Worker // Count of LAST2
294*77c1e3ccSAndroid Build Coastguard Worker const int last2_count = ref_counts[LAST2_FRAME];
295*77c1e3ccSAndroid Build Coastguard Worker // Count of LAST3 or GOLDEN
296*77c1e3ccSAndroid Build Coastguard Worker const int last3_or_gld_count =
297*77c1e3ccSAndroid Build Coastguard Worker ref_counts[LAST3_FRAME] + ref_counts[GOLDEN_FRAME];
298*77c1e3ccSAndroid Build Coastguard Worker
299*77c1e3ccSAndroid Build Coastguard Worker const int pred_context = (last2_count == last3_or_gld_count)
300*77c1e3ccSAndroid Build Coastguard Worker ? 1
301*77c1e3ccSAndroid Build Coastguard Worker : ((last2_count < last3_or_gld_count) ? 0 : 2);
302*77c1e3ccSAndroid Build Coastguard Worker
303*77c1e3ccSAndroid Build Coastguard Worker assert(pred_context >= 0 && pred_context < UNI_COMP_REF_CONTEXTS);
304*77c1e3ccSAndroid Build Coastguard Worker return pred_context;
305*77c1e3ccSAndroid Build Coastguard Worker }
306*77c1e3ccSAndroid Build Coastguard Worker
307*77c1e3ccSAndroid Build Coastguard Worker // Returns a context number for the given MB prediction signal
308*77c1e3ccSAndroid Build Coastguard Worker //
309*77c1e3ccSAndroid Build Coastguard Worker // Signal the uni-directional compound reference frame pair as
310*77c1e3ccSAndroid Build Coastguard Worker // either (LAST, LAST3) or (LAST, GOLDEN),
311*77c1e3ccSAndroid Build Coastguard Worker // conditioning on the pair is known as one of the above two.
312*77c1e3ccSAndroid Build Coastguard Worker //
313*77c1e3ccSAndroid Build Coastguard Worker // 3 contexts: Voting is used to compare the count of LAST3_FRAME with the
314*77c1e3ccSAndroid Build Coastguard Worker // total count of GOLDEN_FRAME from the spatial neighbors.
av1_get_pred_context_uni_comp_ref_p2(const MACROBLOCKD * xd)315*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_uni_comp_ref_p2(const MACROBLOCKD *xd) {
316*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const ref_counts = &xd->neighbors_ref_counts[0];
317*77c1e3ccSAndroid Build Coastguard Worker
318*77c1e3ccSAndroid Build Coastguard Worker // Count of LAST3
319*77c1e3ccSAndroid Build Coastguard Worker const int last3_count = ref_counts[LAST3_FRAME];
320*77c1e3ccSAndroid Build Coastguard Worker // Count of GOLDEN
321*77c1e3ccSAndroid Build Coastguard Worker const int gld_count = ref_counts[GOLDEN_FRAME];
322*77c1e3ccSAndroid Build Coastguard Worker
323*77c1e3ccSAndroid Build Coastguard Worker const int pred_context =
324*77c1e3ccSAndroid Build Coastguard Worker (last3_count == gld_count) ? 1 : ((last3_count < gld_count) ? 0 : 2);
325*77c1e3ccSAndroid Build Coastguard Worker
326*77c1e3ccSAndroid Build Coastguard Worker assert(pred_context >= 0 && pred_context < UNI_COMP_REF_CONTEXTS);
327*77c1e3ccSAndroid Build Coastguard Worker return pred_context;
328*77c1e3ccSAndroid Build Coastguard Worker }
329*77c1e3ccSAndroid Build Coastguard Worker
330*77c1e3ccSAndroid Build Coastguard Worker // == Common context functions for both comp and single ref ==
331*77c1e3ccSAndroid Build Coastguard Worker //
332*77c1e3ccSAndroid Build Coastguard Worker // Obtain contexts to signal a reference frame to be either LAST/LAST2 or
333*77c1e3ccSAndroid Build Coastguard Worker // LAST3/GOLDEN.
get_pred_context_ll2_or_l3gld(const MACROBLOCKD * xd)334*77c1e3ccSAndroid Build Coastguard Worker static int get_pred_context_ll2_or_l3gld(const MACROBLOCKD *xd) {
335*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const ref_counts = &xd->neighbors_ref_counts[0];
336*77c1e3ccSAndroid Build Coastguard Worker
337*77c1e3ccSAndroid Build Coastguard Worker // Count of LAST + LAST2
338*77c1e3ccSAndroid Build Coastguard Worker const int last_last2_count = ref_counts[LAST_FRAME] + ref_counts[LAST2_FRAME];
339*77c1e3ccSAndroid Build Coastguard Worker // Count of LAST3 + GOLDEN
340*77c1e3ccSAndroid Build Coastguard Worker const int last3_gld_count =
341*77c1e3ccSAndroid Build Coastguard Worker ref_counts[LAST3_FRAME] + ref_counts[GOLDEN_FRAME];
342*77c1e3ccSAndroid Build Coastguard Worker
343*77c1e3ccSAndroid Build Coastguard Worker const int pred_context = (last_last2_count == last3_gld_count)
344*77c1e3ccSAndroid Build Coastguard Worker ? 1
345*77c1e3ccSAndroid Build Coastguard Worker : ((last_last2_count < last3_gld_count) ? 0 : 2);
346*77c1e3ccSAndroid Build Coastguard Worker
347*77c1e3ccSAndroid Build Coastguard Worker assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
348*77c1e3ccSAndroid Build Coastguard Worker return pred_context;
349*77c1e3ccSAndroid Build Coastguard Worker }
350*77c1e3ccSAndroid Build Coastguard Worker
351*77c1e3ccSAndroid Build Coastguard Worker // Obtain contexts to signal a reference frame to be either LAST or LAST2.
get_pred_context_last_or_last2(const MACROBLOCKD * xd)352*77c1e3ccSAndroid Build Coastguard Worker static int get_pred_context_last_or_last2(const MACROBLOCKD *xd) {
353*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const ref_counts = &xd->neighbors_ref_counts[0];
354*77c1e3ccSAndroid Build Coastguard Worker
355*77c1e3ccSAndroid Build Coastguard Worker // Count of LAST
356*77c1e3ccSAndroid Build Coastguard Worker const int last_count = ref_counts[LAST_FRAME];
357*77c1e3ccSAndroid Build Coastguard Worker // Count of LAST2
358*77c1e3ccSAndroid Build Coastguard Worker const int last2_count = ref_counts[LAST2_FRAME];
359*77c1e3ccSAndroid Build Coastguard Worker
360*77c1e3ccSAndroid Build Coastguard Worker const int pred_context =
361*77c1e3ccSAndroid Build Coastguard Worker (last_count == last2_count) ? 1 : ((last_count < last2_count) ? 0 : 2);
362*77c1e3ccSAndroid Build Coastguard Worker
363*77c1e3ccSAndroid Build Coastguard Worker assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
364*77c1e3ccSAndroid Build Coastguard Worker return pred_context;
365*77c1e3ccSAndroid Build Coastguard Worker }
366*77c1e3ccSAndroid Build Coastguard Worker
367*77c1e3ccSAndroid Build Coastguard Worker // Obtain contexts to signal a reference frame to be either LAST3 or GOLDEN.
get_pred_context_last3_or_gld(const MACROBLOCKD * xd)368*77c1e3ccSAndroid Build Coastguard Worker static int get_pred_context_last3_or_gld(const MACROBLOCKD *xd) {
369*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const ref_counts = &xd->neighbors_ref_counts[0];
370*77c1e3ccSAndroid Build Coastguard Worker
371*77c1e3ccSAndroid Build Coastguard Worker // Count of LAST3
372*77c1e3ccSAndroid Build Coastguard Worker const int last3_count = ref_counts[LAST3_FRAME];
373*77c1e3ccSAndroid Build Coastguard Worker // Count of GOLDEN
374*77c1e3ccSAndroid Build Coastguard Worker const int gld_count = ref_counts[GOLDEN_FRAME];
375*77c1e3ccSAndroid Build Coastguard Worker
376*77c1e3ccSAndroid Build Coastguard Worker const int pred_context =
377*77c1e3ccSAndroid Build Coastguard Worker (last3_count == gld_count) ? 1 : ((last3_count < gld_count) ? 0 : 2);
378*77c1e3ccSAndroid Build Coastguard Worker
379*77c1e3ccSAndroid Build Coastguard Worker assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
380*77c1e3ccSAndroid Build Coastguard Worker return pred_context;
381*77c1e3ccSAndroid Build Coastguard Worker }
382*77c1e3ccSAndroid Build Coastguard Worker
383*77c1e3ccSAndroid Build Coastguard Worker // Obtain contexts to signal a reference frame be either BWDREF/ALTREF2, or
384*77c1e3ccSAndroid Build Coastguard Worker // ALTREF.
get_pred_context_brfarf2_or_arf(const MACROBLOCKD * xd)385*77c1e3ccSAndroid Build Coastguard Worker static int get_pred_context_brfarf2_or_arf(const MACROBLOCKD *xd) {
386*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const ref_counts = &xd->neighbors_ref_counts[0];
387*77c1e3ccSAndroid Build Coastguard Worker
388*77c1e3ccSAndroid Build Coastguard Worker // Counts of BWDREF, ALTREF2, or ALTREF frames (B, A2, or A)
389*77c1e3ccSAndroid Build Coastguard Worker const int brfarf2_count =
390*77c1e3ccSAndroid Build Coastguard Worker ref_counts[BWDREF_FRAME] + ref_counts[ALTREF2_FRAME];
391*77c1e3ccSAndroid Build Coastguard Worker const int arf_count = ref_counts[ALTREF_FRAME];
392*77c1e3ccSAndroid Build Coastguard Worker
393*77c1e3ccSAndroid Build Coastguard Worker const int pred_context =
394*77c1e3ccSAndroid Build Coastguard Worker (brfarf2_count == arf_count) ? 1 : ((brfarf2_count < arf_count) ? 0 : 2);
395*77c1e3ccSAndroid Build Coastguard Worker
396*77c1e3ccSAndroid Build Coastguard Worker assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
397*77c1e3ccSAndroid Build Coastguard Worker return pred_context;
398*77c1e3ccSAndroid Build Coastguard Worker }
399*77c1e3ccSAndroid Build Coastguard Worker
400*77c1e3ccSAndroid Build Coastguard Worker // Obtain contexts to signal a reference frame be either BWDREF or ALTREF2.
get_pred_context_brf_or_arf2(const MACROBLOCKD * xd)401*77c1e3ccSAndroid Build Coastguard Worker static int get_pred_context_brf_or_arf2(const MACROBLOCKD *xd) {
402*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const ref_counts = &xd->neighbors_ref_counts[0];
403*77c1e3ccSAndroid Build Coastguard Worker
404*77c1e3ccSAndroid Build Coastguard Worker // Count of BWDREF frames (B)
405*77c1e3ccSAndroid Build Coastguard Worker const int brf_count = ref_counts[BWDREF_FRAME];
406*77c1e3ccSAndroid Build Coastguard Worker // Count of ALTREF2 frames (A2)
407*77c1e3ccSAndroid Build Coastguard Worker const int arf2_count = ref_counts[ALTREF2_FRAME];
408*77c1e3ccSAndroid Build Coastguard Worker
409*77c1e3ccSAndroid Build Coastguard Worker const int pred_context =
410*77c1e3ccSAndroid Build Coastguard Worker (brf_count == arf2_count) ? 1 : ((brf_count < arf2_count) ? 0 : 2);
411*77c1e3ccSAndroid Build Coastguard Worker
412*77c1e3ccSAndroid Build Coastguard Worker assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
413*77c1e3ccSAndroid Build Coastguard Worker return pred_context;
414*77c1e3ccSAndroid Build Coastguard Worker }
415*77c1e3ccSAndroid Build Coastguard Worker
416*77c1e3ccSAndroid Build Coastguard Worker // == Context functions for comp ref ==
417*77c1e3ccSAndroid Build Coastguard Worker //
418*77c1e3ccSAndroid Build Coastguard Worker // Returns a context number for the given MB prediction signal
419*77c1e3ccSAndroid Build Coastguard Worker // Signal the first reference frame for a compound mode be either
420*77c1e3ccSAndroid Build Coastguard Worker // GOLDEN/LAST3, or LAST/LAST2.
av1_get_pred_context_comp_ref_p(const MACROBLOCKD * xd)421*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_comp_ref_p(const MACROBLOCKD *xd) {
422*77c1e3ccSAndroid Build Coastguard Worker return get_pred_context_ll2_or_l3gld(xd);
423*77c1e3ccSAndroid Build Coastguard Worker }
424*77c1e3ccSAndroid Build Coastguard Worker
425*77c1e3ccSAndroid Build Coastguard Worker // Returns a context number for the given MB prediction signal
426*77c1e3ccSAndroid Build Coastguard Worker // Signal the first reference frame for a compound mode be LAST,
427*77c1e3ccSAndroid Build Coastguard Worker // conditioning on that it is known either LAST/LAST2.
av1_get_pred_context_comp_ref_p1(const MACROBLOCKD * xd)428*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_comp_ref_p1(const MACROBLOCKD *xd) {
429*77c1e3ccSAndroid Build Coastguard Worker return get_pred_context_last_or_last2(xd);
430*77c1e3ccSAndroid Build Coastguard Worker }
431*77c1e3ccSAndroid Build Coastguard Worker
432*77c1e3ccSAndroid Build Coastguard Worker // Returns a context number for the given MB prediction signal
433*77c1e3ccSAndroid Build Coastguard Worker // Signal the first reference frame for a compound mode be GOLDEN,
434*77c1e3ccSAndroid Build Coastguard Worker // conditioning on that it is known either GOLDEN or LAST3.
av1_get_pred_context_comp_ref_p2(const MACROBLOCKD * xd)435*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_comp_ref_p2(const MACROBLOCKD *xd) {
436*77c1e3ccSAndroid Build Coastguard Worker return get_pred_context_last3_or_gld(xd);
437*77c1e3ccSAndroid Build Coastguard Worker }
438*77c1e3ccSAndroid Build Coastguard Worker
439*77c1e3ccSAndroid Build Coastguard Worker // Signal the 2nd reference frame for a compound mode be either
440*77c1e3ccSAndroid Build Coastguard Worker // ALTREF, or ALTREF2/BWDREF.
av1_get_pred_context_comp_bwdref_p(const MACROBLOCKD * xd)441*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_comp_bwdref_p(const MACROBLOCKD *xd) {
442*77c1e3ccSAndroid Build Coastguard Worker return get_pred_context_brfarf2_or_arf(xd);
443*77c1e3ccSAndroid Build Coastguard Worker }
444*77c1e3ccSAndroid Build Coastguard Worker
445*77c1e3ccSAndroid Build Coastguard Worker // Signal the 2nd reference frame for a compound mode be either
446*77c1e3ccSAndroid Build Coastguard Worker // ALTREF2 or BWDREF.
av1_get_pred_context_comp_bwdref_p1(const MACROBLOCKD * xd)447*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_comp_bwdref_p1(const MACROBLOCKD *xd) {
448*77c1e3ccSAndroid Build Coastguard Worker return get_pred_context_brf_or_arf2(xd);
449*77c1e3ccSAndroid Build Coastguard Worker }
450*77c1e3ccSAndroid Build Coastguard Worker
451*77c1e3ccSAndroid Build Coastguard Worker // == Context functions for single ref ==
452*77c1e3ccSAndroid Build Coastguard Worker //
453*77c1e3ccSAndroid Build Coastguard Worker // For the bit to signal whether the single reference is a forward reference
454*77c1e3ccSAndroid Build Coastguard Worker // frame or a backward reference frame.
av1_get_pred_context_single_ref_p1(const MACROBLOCKD * xd)455*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_single_ref_p1(const MACROBLOCKD *xd) {
456*77c1e3ccSAndroid Build Coastguard Worker const uint8_t *const ref_counts = &xd->neighbors_ref_counts[0];
457*77c1e3ccSAndroid Build Coastguard Worker
458*77c1e3ccSAndroid Build Coastguard Worker // Count of forward reference frames
459*77c1e3ccSAndroid Build Coastguard Worker const int fwd_count = ref_counts[LAST_FRAME] + ref_counts[LAST2_FRAME] +
460*77c1e3ccSAndroid Build Coastguard Worker ref_counts[LAST3_FRAME] + ref_counts[GOLDEN_FRAME];
461*77c1e3ccSAndroid Build Coastguard Worker // Count of backward reference frames
462*77c1e3ccSAndroid Build Coastguard Worker const int bwd_count = ref_counts[BWDREF_FRAME] + ref_counts[ALTREF2_FRAME] +
463*77c1e3ccSAndroid Build Coastguard Worker ref_counts[ALTREF_FRAME];
464*77c1e3ccSAndroid Build Coastguard Worker
465*77c1e3ccSAndroid Build Coastguard Worker const int pred_context =
466*77c1e3ccSAndroid Build Coastguard Worker (fwd_count == bwd_count) ? 1 : ((fwd_count < bwd_count) ? 0 : 2);
467*77c1e3ccSAndroid Build Coastguard Worker
468*77c1e3ccSAndroid Build Coastguard Worker assert(pred_context >= 0 && pred_context < REF_CONTEXTS);
469*77c1e3ccSAndroid Build Coastguard Worker return pred_context;
470*77c1e3ccSAndroid Build Coastguard Worker }
471*77c1e3ccSAndroid Build Coastguard Worker
472*77c1e3ccSAndroid Build Coastguard Worker // For the bit to signal whether the single reference is ALTREF_FRAME or
473*77c1e3ccSAndroid Build Coastguard Worker // non-ALTREF backward reference frame, knowing that it shall be either of
474*77c1e3ccSAndroid Build Coastguard Worker // these 2 choices.
av1_get_pred_context_single_ref_p2(const MACROBLOCKD * xd)475*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) {
476*77c1e3ccSAndroid Build Coastguard Worker return get_pred_context_brfarf2_or_arf(xd);
477*77c1e3ccSAndroid Build Coastguard Worker }
478*77c1e3ccSAndroid Build Coastguard Worker
479*77c1e3ccSAndroid Build Coastguard Worker // For the bit to signal whether the single reference is LAST3/GOLDEN or
480*77c1e3ccSAndroid Build Coastguard Worker // LAST2/LAST, knowing that it shall be either of these 2 choices.
av1_get_pred_context_single_ref_p3(const MACROBLOCKD * xd)481*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_single_ref_p3(const MACROBLOCKD *xd) {
482*77c1e3ccSAndroid Build Coastguard Worker return get_pred_context_ll2_or_l3gld(xd);
483*77c1e3ccSAndroid Build Coastguard Worker }
484*77c1e3ccSAndroid Build Coastguard Worker
485*77c1e3ccSAndroid Build Coastguard Worker // For the bit to signal whether the single reference is LAST2_FRAME or
486*77c1e3ccSAndroid Build Coastguard Worker // LAST_FRAME, knowing that it shall be either of these 2 choices.
av1_get_pred_context_single_ref_p4(const MACROBLOCKD * xd)487*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_single_ref_p4(const MACROBLOCKD *xd) {
488*77c1e3ccSAndroid Build Coastguard Worker return get_pred_context_last_or_last2(xd);
489*77c1e3ccSAndroid Build Coastguard Worker }
490*77c1e3ccSAndroid Build Coastguard Worker
491*77c1e3ccSAndroid Build Coastguard Worker // For the bit to signal whether the single reference is GOLDEN_FRAME or
492*77c1e3ccSAndroid Build Coastguard Worker // LAST3_FRAME, knowing that it shall be either of these 2 choices.
av1_get_pred_context_single_ref_p5(const MACROBLOCKD * xd)493*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_single_ref_p5(const MACROBLOCKD *xd) {
494*77c1e3ccSAndroid Build Coastguard Worker return get_pred_context_last3_or_gld(xd);
495*77c1e3ccSAndroid Build Coastguard Worker }
496*77c1e3ccSAndroid Build Coastguard Worker
497*77c1e3ccSAndroid Build Coastguard Worker // For the bit to signal whether the single reference is ALTREF2_FRAME or
498*77c1e3ccSAndroid Build Coastguard Worker // BWDREF_FRAME, knowing that it shall be either of these 2 choices.
av1_get_pred_context_single_ref_p6(const MACROBLOCKD * xd)499*77c1e3ccSAndroid Build Coastguard Worker int av1_get_pred_context_single_ref_p6(const MACROBLOCKD *xd) {
500*77c1e3ccSAndroid Build Coastguard Worker return get_pred_context_brf_or_arf2(xd);
501*77c1e3ccSAndroid Build Coastguard Worker }
502