/src/aom/av1/common/mvref_common.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2016, Alliance for Open Media. All rights reserved. |
3 | | * |
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. |
10 | | */ |
11 | | #ifndef AOM_AV1_COMMON_MVREF_COMMON_H_ |
12 | | #define AOM_AV1_COMMON_MVREF_COMMON_H_ |
13 | | |
14 | | #include "av1/common/av1_common_int.h" |
15 | | #include "av1/common/blockd.h" |
16 | | |
17 | | #ifdef __cplusplus |
18 | | extern "C" { |
19 | | #endif |
20 | | |
21 | 22.7M | #define MVREF_ROW_COLS 3 |
22 | | |
23 | | // Set the upper limit of the motion vector component magnitude. |
24 | | // This would make a motion vector fit in 26 bits. Plus 3 bits for the |
25 | | // reference frame index. A tuple of motion vector can hence be stored within |
26 | | // 32 bit range for efficient load/store operations. |
27 | 122M | #define REFMVS_LIMIT ((1 << 12) - 1) |
28 | | |
29 | | typedef struct position { |
30 | | int row; |
31 | | int col; |
32 | | } POSITION; |
33 | | |
34 | | // clamp_mv_ref |
35 | 53.2M | #define MV_BORDER (16 << 3) // Allow 16 pels in 1/8th pel units |
36 | | |
37 | 6.60M | static inline int get_relative_dist(const OrderHintInfo *oh, int a, int b) { |
38 | 6.60M | if (!oh->enable_order_hint) return 0; |
39 | | |
40 | 6.60M | const int bits = oh->order_hint_bits_minus_1 + 1; |
41 | | |
42 | 6.60M | assert(bits >= 1); |
43 | 6.60M | assert(a >= 0 && a < (1 << bits)); |
44 | 6.61M | assert(b >= 0 && b < (1 << bits)); |
45 | | |
46 | 6.61M | int diff = a - b; |
47 | 6.61M | const int m = 1 << (bits - 1); |
48 | 6.61M | diff = (diff & (m - 1)) - (diff & m); |
49 | 6.61M | return diff; |
50 | 6.61M | } Unexecuted instantiation: decodeframe.c:get_relative_dist decodemv.c:get_relative_dist Line | Count | Source | 37 | 674k | static inline int get_relative_dist(const OrderHintInfo *oh, int a, int b) { | 38 | 674k | if (!oh->enable_order_hint) return 0; | 39 | | | 40 | 674k | const int bits = oh->order_hint_bits_minus_1 + 1; | 41 | | | 42 | 674k | assert(bits >= 1); | 43 | 674k | assert(a >= 0 && a < (1 << bits)); | 44 | 674k | assert(b >= 0 && b < (1 << bits)); | 45 | | | 46 | 674k | int diff = a - b; | 47 | 674k | const int m = 1 << (bits - 1); | 48 | 674k | diff = (diff & (m - 1)) - (diff & m); | 49 | 674k | return diff; | 50 | 674k | } |
mvref_common.c:get_relative_dist Line | Count | Source | 37 | 4.67M | static inline int get_relative_dist(const OrderHintInfo *oh, int a, int b) { | 38 | 4.67M | if (!oh->enable_order_hint) return 0; | 39 | | | 40 | 4.67M | const int bits = oh->order_hint_bits_minus_1 + 1; | 41 | | | 42 | 4.67M | assert(bits >= 1); | 43 | 4.67M | assert(a >= 0 && a < (1 << bits)); | 44 | 4.68M | assert(b >= 0 && b < (1 << bits)); | 45 | | | 46 | 4.68M | int diff = a - b; | 47 | 4.68M | const int m = 1 << (bits - 1); | 48 | 4.68M | diff = (diff & (m - 1)) - (diff & m); | 49 | 4.68M | return diff; | 50 | 4.68M | } |
Unexecuted instantiation: pred_common.c:get_relative_dist reconinter.c:get_relative_dist Line | Count | Source | 37 | 1.25M | static inline int get_relative_dist(const OrderHintInfo *oh, int a, int b) { | 38 | 1.25M | if (!oh->enable_order_hint) return 0; | 39 | | | 40 | 1.25M | const int bits = oh->order_hint_bits_minus_1 + 1; | 41 | | | 42 | 1.25M | assert(bits >= 1); | 43 | 1.25M | assert(a >= 0 && a < (1 << bits)); | 44 | 1.25M | assert(b >= 0 && b < (1 << bits)); | 45 | | | 46 | 1.25M | int diff = a - b; | 47 | 1.25M | const int m = 1 << (bits - 1); | 48 | 1.25M | diff = (diff & (m - 1)) - (diff & m); | 49 | 1.25M | return diff; | 50 | 1.25M | } |
|
51 | | |
52 | 13.3M | static inline void clamp_mv_ref(MV *mv, int bw, int bh, const MACROBLOCKD *xd) { |
53 | 13.3M | const SubpelMvLimits mv_limits = { |
54 | 13.3M | xd->mb_to_left_edge - GET_MV_SUBPEL(bw) - MV_BORDER, |
55 | 13.3M | xd->mb_to_right_edge + GET_MV_SUBPEL(bw) + MV_BORDER, |
56 | 13.3M | xd->mb_to_top_edge - GET_MV_SUBPEL(bh) - MV_BORDER, |
57 | 13.3M | xd->mb_to_bottom_edge + GET_MV_SUBPEL(bh) + MV_BORDER |
58 | 13.3M | }; |
59 | 13.3M | clamp_mv(mv, &mv_limits); |
60 | 13.3M | } Unexecuted instantiation: decodeframe.c:clamp_mv_ref Unexecuted instantiation: decodemv.c:clamp_mv_ref mvref_common.c:clamp_mv_ref Line | Count | Source | 52 | 13.3M | static inline void clamp_mv_ref(MV *mv, int bw, int bh, const MACROBLOCKD *xd) { | 53 | 13.3M | const SubpelMvLimits mv_limits = { | 54 | 13.3M | xd->mb_to_left_edge - GET_MV_SUBPEL(bw) - MV_BORDER, | 55 | 13.3M | xd->mb_to_right_edge + GET_MV_SUBPEL(bw) + MV_BORDER, | 56 | 13.3M | xd->mb_to_top_edge - GET_MV_SUBPEL(bh) - MV_BORDER, | 57 | 13.3M | xd->mb_to_bottom_edge + GET_MV_SUBPEL(bh) + MV_BORDER | 58 | 13.3M | }; | 59 | 13.3M | clamp_mv(mv, &mv_limits); | 60 | 13.3M | } |
Unexecuted instantiation: pred_common.c:clamp_mv_ref Unexecuted instantiation: reconinter.c:clamp_mv_ref |
61 | | |
62 | 21.3M | static inline int_mv get_block_mv(const MB_MODE_INFO *candidate, int which_mv) { |
63 | 21.3M | return candidate->mv[which_mv]; |
64 | 21.3M | } Unexecuted instantiation: decodeframe.c:get_block_mv Unexecuted instantiation: decodemv.c:get_block_mv mvref_common.c:get_block_mv Line | Count | Source | 62 | 21.3M | static inline int_mv get_block_mv(const MB_MODE_INFO *candidate, int which_mv) { | 63 | 21.3M | return candidate->mv[which_mv]; | 64 | 21.3M | } |
Unexecuted instantiation: pred_common.c:get_block_mv Unexecuted instantiation: reconinter.c:get_block_mv |
65 | | |
66 | | // Checks that the given mi_row, mi_col and search point |
67 | | // are inside the borders of the tile. |
68 | | static inline int is_inside(const TileInfo *const tile, int mi_col, int mi_row, |
69 | 25.9M | const POSITION *mi_pos) { |
70 | 25.9M | return !(mi_row + mi_pos->row < tile->mi_row_start || |
71 | 25.9M | mi_col + mi_pos->col < tile->mi_col_start || |
72 | 25.9M | mi_row + mi_pos->row >= tile->mi_row_end || |
73 | 25.9M | mi_col + mi_pos->col >= tile->mi_col_end); |
74 | 25.9M | } Unexecuted instantiation: decodeframe.c:is_inside Unexecuted instantiation: decodemv.c:is_inside Line | Count | Source | 69 | 25.9M | const POSITION *mi_pos) { | 70 | 25.9M | return !(mi_row + mi_pos->row < tile->mi_row_start || | 71 | 25.9M | mi_col + mi_pos->col < tile->mi_col_start || | 72 | 25.9M | mi_row + mi_pos->row >= tile->mi_row_end || | 73 | 25.9M | mi_col + mi_pos->col >= tile->mi_col_end); | 74 | 25.9M | } |
Unexecuted instantiation: pred_common.c:is_inside Unexecuted instantiation: reconinter.c:is_inside |
75 | | |
76 | | static inline int find_valid_row_offset(const TileInfo *const tile, int mi_row, |
77 | 4.39M | int row_offset) { |
78 | 4.39M | return clamp(row_offset, tile->mi_row_start - mi_row, |
79 | 4.39M | tile->mi_row_end - mi_row - 1); |
80 | 4.39M | } Unexecuted instantiation: decodeframe.c:find_valid_row_offset Unexecuted instantiation: decodemv.c:find_valid_row_offset mvref_common.c:find_valid_row_offset Line | Count | Source | 77 | 4.39M | int row_offset) { | 78 | 4.39M | return clamp(row_offset, tile->mi_row_start - mi_row, | 79 | 4.39M | tile->mi_row_end - mi_row - 1); | 80 | 4.39M | } |
Unexecuted instantiation: pred_common.c:find_valid_row_offset Unexecuted instantiation: reconinter.c:find_valid_row_offset |
81 | | |
82 | | static inline int find_valid_col_offset(const TileInfo *const tile, int mi_col, |
83 | 4.47M | int col_offset) { |
84 | 4.47M | return clamp(col_offset, tile->mi_col_start - mi_col, |
85 | 4.47M | tile->mi_col_end - mi_col - 1); |
86 | 4.47M | } Unexecuted instantiation: decodeframe.c:find_valid_col_offset Unexecuted instantiation: decodemv.c:find_valid_col_offset mvref_common.c:find_valid_col_offset Line | Count | Source | 83 | 4.47M | int col_offset) { | 84 | 4.47M | return clamp(col_offset, tile->mi_col_start - mi_col, | 85 | 4.47M | tile->mi_col_end - mi_col - 1); | 86 | 4.47M | } |
Unexecuted instantiation: pred_common.c:find_valid_col_offset Unexecuted instantiation: reconinter.c:find_valid_col_offset |
87 | | |
88 | 11.1M | static inline void lower_mv_precision(MV *mv, int allow_hp, int is_integer) { |
89 | 11.1M | if (is_integer) { |
90 | 471k | integer_mv_precision(mv); |
91 | 10.6M | } else { |
92 | 10.6M | if (!allow_hp) { |
93 | 6.95M | if (mv->row & 1) mv->row += (mv->row > 0 ? -1 : 1); |
94 | 6.95M | if (mv->col & 1) mv->col += (mv->col > 0 ? -1 : 1); |
95 | 6.95M | } |
96 | 10.6M | } |
97 | 11.1M | } Unexecuted instantiation: decodeframe.c:lower_mv_precision decodemv.c:lower_mv_precision Line | Count | Source | 88 | 2.33M | static inline void lower_mv_precision(MV *mv, int allow_hp, int is_integer) { | 89 | 2.33M | if (is_integer) { | 90 | 226k | integer_mv_precision(mv); | 91 | 2.10M | } else { | 92 | 2.10M | if (!allow_hp) { | 93 | 1.29M | if (mv->row & 1) mv->row += (mv->row > 0 ? -1 : 1); | 94 | 1.29M | if (mv->col & 1) mv->col += (mv->col > 0 ? -1 : 1); | 95 | 1.29M | } | 96 | 2.10M | } | 97 | 2.33M | } |
mvref_common.c:lower_mv_precision Line | Count | Source | 88 | 8.77M | static inline void lower_mv_precision(MV *mv, int allow_hp, int is_integer) { | 89 | 8.77M | if (is_integer) { | 90 | 245k | integer_mv_precision(mv); | 91 | 8.52M | } else { | 92 | 8.52M | if (!allow_hp) { | 93 | 5.66M | if (mv->row & 1) mv->row += (mv->row > 0 ? -1 : 1); | 94 | 5.66M | if (mv->col & 1) mv->col += (mv->col > 0 ? -1 : 1); | 95 | 5.66M | } | 96 | 8.52M | } | 97 | 8.77M | } |
Unexecuted instantiation: pred_common.c:lower_mv_precision Unexecuted instantiation: reconinter.c:lower_mv_precision |
98 | | |
99 | 1.38M | static inline int8_t get_uni_comp_ref_idx(const MV_REFERENCE_FRAME *const rf) { |
100 | | // Single ref pred |
101 | 1.38M | if (rf[1] <= INTRA_FRAME) return -1; |
102 | | |
103 | | // Bi-directional comp ref pred |
104 | 1.38M | if ((rf[0] < BWDREF_FRAME) && (rf[1] >= BWDREF_FRAME)) return -1; |
105 | | |
106 | 772k | for (int8_t ref_idx = 0; ref_idx < TOTAL_UNIDIR_COMP_REFS; ++ref_idx) { |
107 | 772k | if (rf[0] == comp_ref0(ref_idx) && rf[1] == comp_ref1(ref_idx)) |
108 | 292k | return ref_idx; |
109 | 772k | } |
110 | 18.4E | return -1; |
111 | 292k | } Unexecuted instantiation: decodeframe.c:get_uni_comp_ref_idx decodemv.c:get_uni_comp_ref_idx Line | Count | Source | 99 | 1.38M | static inline int8_t get_uni_comp_ref_idx(const MV_REFERENCE_FRAME *const rf) { | 100 | | // Single ref pred | 101 | 1.38M | if (rf[1] <= INTRA_FRAME) return -1; | 102 | | | 103 | | // Bi-directional comp ref pred | 104 | 1.38M | if ((rf[0] < BWDREF_FRAME) && (rf[1] >= BWDREF_FRAME)) return -1; | 105 | | | 106 | 772k | for (int8_t ref_idx = 0; ref_idx < TOTAL_UNIDIR_COMP_REFS; ++ref_idx) { | 107 | 772k | if (rf[0] == comp_ref0(ref_idx) && rf[1] == comp_ref1(ref_idx)) | 108 | 292k | return ref_idx; | 109 | 772k | } | 110 | 18.4E | return -1; | 111 | 292k | } |
Unexecuted instantiation: mvref_common.c:get_uni_comp_ref_idx Unexecuted instantiation: pred_common.c:get_uni_comp_ref_idx Unexecuted instantiation: reconinter.c:get_uni_comp_ref_idx |
112 | | |
113 | 10.8M | static inline int8_t av1_ref_frame_type(const MV_REFERENCE_FRAME *const rf) { |
114 | 10.8M | if (rf[1] > INTRA_FRAME) { |
115 | 1.38M | const int8_t uni_comp_ref_idx = get_uni_comp_ref_idx(rf); |
116 | 1.38M | if (uni_comp_ref_idx >= 0) { |
117 | 292k | assert((REF_FRAMES + FWD_REFS * BWD_REFS + uni_comp_ref_idx) < |
118 | 292k | MODE_CTX_REF_FRAMES); |
119 | 292k | return REF_FRAMES + FWD_REFS * BWD_REFS + uni_comp_ref_idx; |
120 | 1.09M | } else { |
121 | 1.09M | return REF_FRAMES + FWD_RF_OFFSET(rf[0]) + |
122 | 1.09M | BWD_RF_OFFSET(rf[1]) * FWD_REFS; |
123 | 1.09M | } |
124 | 1.38M | } |
125 | | |
126 | 9.48M | return rf[0]; |
127 | 10.8M | } Unexecuted instantiation: decodeframe.c:av1_ref_frame_type decodemv.c:av1_ref_frame_type Line | Count | Source | 113 | 10.8M | static inline int8_t av1_ref_frame_type(const MV_REFERENCE_FRAME *const rf) { | 114 | 10.8M | if (rf[1] > INTRA_FRAME) { | 115 | 1.38M | const int8_t uni_comp_ref_idx = get_uni_comp_ref_idx(rf); | 116 | 1.38M | if (uni_comp_ref_idx >= 0) { | 117 | 292k | assert((REF_FRAMES + FWD_REFS * BWD_REFS + uni_comp_ref_idx) < | 118 | 292k | MODE_CTX_REF_FRAMES); | 119 | 292k | return REF_FRAMES + FWD_REFS * BWD_REFS + uni_comp_ref_idx; | 120 | 1.09M | } else { | 121 | 1.09M | return REF_FRAMES + FWD_RF_OFFSET(rf[0]) + | 122 | 1.09M | BWD_RF_OFFSET(rf[1]) * FWD_REFS; | 123 | 1.09M | } | 124 | 1.38M | } | 125 | | | 126 | 9.48M | return rf[0]; | 127 | 10.8M | } |
Unexecuted instantiation: mvref_common.c:av1_ref_frame_type Unexecuted instantiation: pred_common.c:av1_ref_frame_type Unexecuted instantiation: reconinter.c:av1_ref_frame_type |
128 | | |
129 | | // clang-format off |
130 | | static MV_REFERENCE_FRAME ref_frame_map[TOTAL_COMP_REFS][2] = { |
131 | | { LAST_FRAME, BWDREF_FRAME }, { LAST2_FRAME, BWDREF_FRAME }, |
132 | | { LAST3_FRAME, BWDREF_FRAME }, { GOLDEN_FRAME, BWDREF_FRAME }, |
133 | | |
134 | | { LAST_FRAME, ALTREF2_FRAME }, { LAST2_FRAME, ALTREF2_FRAME }, |
135 | | { LAST3_FRAME, ALTREF2_FRAME }, { GOLDEN_FRAME, ALTREF2_FRAME }, |
136 | | |
137 | | { LAST_FRAME, ALTREF_FRAME }, { LAST2_FRAME, ALTREF_FRAME }, |
138 | | { LAST3_FRAME, ALTREF_FRAME }, { GOLDEN_FRAME, ALTREF_FRAME }, |
139 | | |
140 | | { LAST_FRAME, LAST2_FRAME }, { LAST_FRAME, LAST3_FRAME }, |
141 | | { LAST_FRAME, GOLDEN_FRAME }, { BWDREF_FRAME, ALTREF_FRAME }, |
142 | | |
143 | | // NOTE: Following reference frame pairs are not supported to be explicitly |
144 | | // signalled, but they are possibly chosen by the use of skip_mode, |
145 | | // which may use the most recent one-sided reference frame pair. |
146 | | { LAST2_FRAME, LAST3_FRAME }, { LAST2_FRAME, GOLDEN_FRAME }, |
147 | | { LAST3_FRAME, GOLDEN_FRAME }, {BWDREF_FRAME, ALTREF2_FRAME}, |
148 | | { ALTREF2_FRAME, ALTREF_FRAME } |
149 | | }; |
150 | | // clang-format on |
151 | | |
152 | | static inline void av1_set_ref_frame(MV_REFERENCE_FRAME *rf, |
153 | 6.92M | MV_REFERENCE_FRAME ref_frame_type) { |
154 | 6.92M | if (ref_frame_type >= REF_FRAMES) { |
155 | 2.03M | rf[0] = ref_frame_map[ref_frame_type - REF_FRAMES][0]; |
156 | 2.03M | rf[1] = ref_frame_map[ref_frame_type - REF_FRAMES][1]; |
157 | 4.88M | } else { |
158 | 4.88M | assert(ref_frame_type > NONE_FRAME); |
159 | 4.90M | rf[0] = ref_frame_type; |
160 | 4.90M | rf[1] = NONE_FRAME; |
161 | 4.90M | } |
162 | 6.92M | } Unexecuted instantiation: decodeframe.c:av1_set_ref_frame Unexecuted instantiation: decodemv.c:av1_set_ref_frame mvref_common.c:av1_set_ref_frame Line | Count | Source | 153 | 6.92M | MV_REFERENCE_FRAME ref_frame_type) { | 154 | 6.92M | if (ref_frame_type >= REF_FRAMES) { | 155 | 2.03M | rf[0] = ref_frame_map[ref_frame_type - REF_FRAMES][0]; | 156 | 2.03M | rf[1] = ref_frame_map[ref_frame_type - REF_FRAMES][1]; | 157 | 4.88M | } else { | 158 | 4.88M | assert(ref_frame_type > NONE_FRAME); | 159 | 4.90M | rf[0] = ref_frame_type; | 160 | 4.90M | rf[1] = NONE_FRAME; | 161 | 4.90M | } | 162 | 6.92M | } |
Unexecuted instantiation: pred_common.c:av1_set_ref_frame Unexecuted instantiation: reconinter.c:av1_set_ref_frame |
163 | | |
164 | | static uint16_t compound_mode_ctx_map[3][COMP_NEWMV_CTXS] = { |
165 | | { 0, 1, 1, 1, 1 }, |
166 | | { 1, 2, 3, 4, 4 }, |
167 | | { 4, 4, 5, 6, 7 }, |
168 | | }; |
169 | | |
170 | | static inline int16_t av1_mode_context_analyzer( |
171 | 3.85M | const int16_t *const mode_context, const MV_REFERENCE_FRAME *const rf) { |
172 | 3.85M | const int8_t ref_frame = av1_ref_frame_type(rf); |
173 | | |
174 | 3.85M | if (rf[1] <= INTRA_FRAME) return mode_context[ref_frame]; |
175 | | |
176 | 523k | const int16_t newmv_ctx = mode_context[ref_frame] & NEWMV_CTX_MASK; |
177 | 523k | const int16_t refmv_ctx = |
178 | 523k | (mode_context[ref_frame] >> REFMV_OFFSET) & REFMV_CTX_MASK; |
179 | | |
180 | 523k | const int16_t comp_ctx = compound_mode_ctx_map[refmv_ctx >> 1][AOMMIN( |
181 | 523k | newmv_ctx, COMP_NEWMV_CTXS - 1)]; |
182 | 523k | return comp_ctx; |
183 | 3.85M | } Unexecuted instantiation: decodeframe.c:av1_mode_context_analyzer decodemv.c:av1_mode_context_analyzer Line | Count | Source | 171 | 3.85M | const int16_t *const mode_context, const MV_REFERENCE_FRAME *const rf) { | 172 | 3.85M | const int8_t ref_frame = av1_ref_frame_type(rf); | 173 | | | 174 | 3.85M | if (rf[1] <= INTRA_FRAME) return mode_context[ref_frame]; | 175 | | | 176 | 523k | const int16_t newmv_ctx = mode_context[ref_frame] & NEWMV_CTX_MASK; | 177 | 523k | const int16_t refmv_ctx = | 178 | 523k | (mode_context[ref_frame] >> REFMV_OFFSET) & REFMV_CTX_MASK; | 179 | | | 180 | 523k | const int16_t comp_ctx = compound_mode_ctx_map[refmv_ctx >> 1][AOMMIN( | 181 | 523k | newmv_ctx, COMP_NEWMV_CTXS - 1)]; | 182 | 523k | return comp_ctx; | 183 | 3.85M | } |
Unexecuted instantiation: mvref_common.c:av1_mode_context_analyzer Unexecuted instantiation: pred_common.c:av1_mode_context_analyzer Unexecuted instantiation: reconinter.c:av1_mode_context_analyzer |
184 | | |
185 | 2.46M | static inline uint8_t av1_drl_ctx(const uint16_t *ref_mv_weight, int ref_idx) { |
186 | 2.46M | if (ref_mv_weight[ref_idx] >= REF_CAT_LEVEL && |
187 | 2.46M | ref_mv_weight[ref_idx + 1] >= REF_CAT_LEVEL) |
188 | 1.39M | return 0; |
189 | | |
190 | 1.07M | if (ref_mv_weight[ref_idx] >= REF_CAT_LEVEL && |
191 | 1.07M | ref_mv_weight[ref_idx + 1] < REF_CAT_LEVEL) |
192 | 854k | return 1; |
193 | | |
194 | 220k | if (ref_mv_weight[ref_idx] < REF_CAT_LEVEL && |
195 | 220k | ref_mv_weight[ref_idx + 1] < REF_CAT_LEVEL) |
196 | 220k | return 2; |
197 | | |
198 | 18.4E | return 0; |
199 | 220k | } Unexecuted instantiation: decodeframe.c:av1_drl_ctx Line | Count | Source | 185 | 2.46M | static inline uint8_t av1_drl_ctx(const uint16_t *ref_mv_weight, int ref_idx) { | 186 | 2.46M | if (ref_mv_weight[ref_idx] >= REF_CAT_LEVEL && | 187 | 2.46M | ref_mv_weight[ref_idx + 1] >= REF_CAT_LEVEL) | 188 | 1.39M | return 0; | 189 | | | 190 | 1.07M | if (ref_mv_weight[ref_idx] >= REF_CAT_LEVEL && | 191 | 1.07M | ref_mv_weight[ref_idx + 1] < REF_CAT_LEVEL) | 192 | 854k | return 1; | 193 | | | 194 | 220k | if (ref_mv_weight[ref_idx] < REF_CAT_LEVEL && | 195 | 220k | ref_mv_weight[ref_idx + 1] < REF_CAT_LEVEL) | 196 | 220k | return 2; | 197 | | | 198 | 18.4E | return 0; | 199 | 220k | } |
Unexecuted instantiation: mvref_common.c:av1_drl_ctx Unexecuted instantiation: pred_common.c:av1_drl_ctx Unexecuted instantiation: reconinter.c:av1_drl_ctx |
200 | | |
201 | | void av1_setup_frame_buf_refs(AV1_COMMON *cm); |
202 | | void av1_setup_frame_sign_bias(AV1_COMMON *cm); |
203 | | void av1_setup_skip_mode_allowed(AV1_COMMON *cm); |
204 | | void av1_calculate_ref_frame_side(AV1_COMMON *cm); |
205 | | void av1_setup_motion_field(AV1_COMMON *cm); |
206 | | void av1_set_frame_refs(AV1_COMMON *const cm, int *remapped_ref_idx, |
207 | | int lst_map_idx, int gld_map_idx); |
208 | | |
209 | 4.55M | static inline void av1_collect_neighbors_ref_counts(MACROBLOCKD *const xd) { |
210 | 4.55M | av1_zero(xd->neighbors_ref_counts); |
211 | | |
212 | 4.55M | uint8_t *const ref_counts = xd->neighbors_ref_counts; |
213 | | |
214 | 4.55M | const MB_MODE_INFO *const above_mbmi = xd->above_mbmi; |
215 | 4.55M | const MB_MODE_INFO *const left_mbmi = xd->left_mbmi; |
216 | 4.55M | const int above_in_image = xd->up_available; |
217 | 4.55M | const int left_in_image = xd->left_available; |
218 | | |
219 | | // Above neighbor |
220 | 4.55M | if (above_in_image && is_inter_block(above_mbmi)) { |
221 | 3.85M | ref_counts[above_mbmi->ref_frame[0]]++; |
222 | 3.85M | if (has_second_ref(above_mbmi)) { |
223 | 554k | ref_counts[above_mbmi->ref_frame[1]]++; |
224 | 554k | } |
225 | 3.85M | } |
226 | | |
227 | | // Left neighbor |
228 | 4.55M | if (left_in_image && is_inter_block(left_mbmi)) { |
229 | 3.91M | ref_counts[left_mbmi->ref_frame[0]]++; |
230 | 3.91M | if (has_second_ref(left_mbmi)) { |
231 | 605k | ref_counts[left_mbmi->ref_frame[1]]++; |
232 | 605k | } |
233 | 3.91M | } |
234 | 4.55M | } Unexecuted instantiation: decodeframe.c:av1_collect_neighbors_ref_counts decodemv.c:av1_collect_neighbors_ref_counts Line | Count | Source | 209 | 4.55M | static inline void av1_collect_neighbors_ref_counts(MACROBLOCKD *const xd) { | 210 | 4.55M | av1_zero(xd->neighbors_ref_counts); | 211 | | | 212 | 4.55M | uint8_t *const ref_counts = xd->neighbors_ref_counts; | 213 | | | 214 | 4.55M | const MB_MODE_INFO *const above_mbmi = xd->above_mbmi; | 215 | 4.55M | const MB_MODE_INFO *const left_mbmi = xd->left_mbmi; | 216 | 4.55M | const int above_in_image = xd->up_available; | 217 | 4.55M | const int left_in_image = xd->left_available; | 218 | | | 219 | | // Above neighbor | 220 | 4.55M | if (above_in_image && is_inter_block(above_mbmi)) { | 221 | 3.85M | ref_counts[above_mbmi->ref_frame[0]]++; | 222 | 3.85M | if (has_second_ref(above_mbmi)) { | 223 | 554k | ref_counts[above_mbmi->ref_frame[1]]++; | 224 | 554k | } | 225 | 3.85M | } | 226 | | | 227 | | // Left neighbor | 228 | 4.55M | if (left_in_image && is_inter_block(left_mbmi)) { | 229 | 3.91M | ref_counts[left_mbmi->ref_frame[0]]++; | 230 | 3.91M | if (has_second_ref(left_mbmi)) { | 231 | 605k | ref_counts[left_mbmi->ref_frame[1]]++; | 232 | 605k | } | 233 | 3.91M | } | 234 | 4.55M | } |
Unexecuted instantiation: mvref_common.c:av1_collect_neighbors_ref_counts Unexecuted instantiation: pred_common.c:av1_collect_neighbors_ref_counts Unexecuted instantiation: reconinter.c:av1_collect_neighbors_ref_counts |
235 | | |
236 | | void av1_get_mv_projection(MV *output, MV ref, int num, int den); |
237 | | |
238 | | void av1_copy_frame_mvs(const AV1_COMMON *const cm, |
239 | | const MB_MODE_INFO *const mi, int mi_row, int mi_col, |
240 | | int x_mis, int y_mis); |
241 | | |
242 | | // The global_mvs output parameter points to an array of REF_FRAMES elements. |
243 | | // The caller may pass a null global_mvs if it does not need the global_mvs |
244 | | // output. |
245 | | void av1_find_mv_refs(const AV1_COMMON *cm, const MACROBLOCKD *xd, |
246 | | MB_MODE_INFO *mi, MV_REFERENCE_FRAME ref_frame, |
247 | | uint8_t ref_mv_count[MODE_CTX_REF_FRAMES], |
248 | | CANDIDATE_MV ref_mv_stack[][MAX_REF_MV_STACK_SIZE], |
249 | | uint16_t ref_mv_weight[][MAX_REF_MV_STACK_SIZE], |
250 | | int_mv mv_ref_list[][MAX_MV_REF_CANDIDATES], |
251 | | int_mv *global_mvs, int16_t *mode_context); |
252 | | |
253 | | // check a list of motion vectors by sad score using a number rows of pixels |
254 | | // above and a number cols of pixels in the left to select the one with best |
255 | | // score to use as ref motion vector |
256 | | void av1_find_best_ref_mvs(int allow_hp, int_mv *mvlist, int_mv *nearest_mv, |
257 | | int_mv *near_mv, int is_integer); |
258 | | |
259 | | uint8_t av1_selectSamples(MV *mv, int *pts, int *pts_inref, int len, |
260 | | BLOCK_SIZE bsize); |
261 | | uint8_t av1_findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int *pts, |
262 | | int *pts_inref); |
263 | | |
264 | 184k | #define INTRABC_DELAY_PIXELS 256 // Delay of 256 pixels |
265 | 160k | #define INTRABC_DELAY_SB64 (INTRABC_DELAY_PIXELS / 64) |
266 | | |
267 | | static inline void av1_find_ref_dv(int_mv *ref_dv, const TileInfo *const tile, |
268 | 27.8k | int mib_size, int mi_row) { |
269 | 27.8k | if (mi_row - mib_size < tile->mi_row_start) { |
270 | 23.6k | ref_dv->as_fullmv.row = 0; |
271 | 23.6k | ref_dv->as_fullmv.col = -MI_SIZE * mib_size - INTRABC_DELAY_PIXELS; |
272 | 23.6k | } else { |
273 | 4.17k | ref_dv->as_fullmv.row = -MI_SIZE * mib_size; |
274 | 4.17k | ref_dv->as_fullmv.col = 0; |
275 | 4.17k | } |
276 | 27.8k | convert_fullmv_to_mv(ref_dv); |
277 | 27.8k | } Unexecuted instantiation: decodeframe.c:av1_find_ref_dv decodemv.c:av1_find_ref_dv Line | Count | Source | 268 | 27.8k | int mib_size, int mi_row) { | 269 | 27.8k | if (mi_row - mib_size < tile->mi_row_start) { | 270 | 23.6k | ref_dv->as_fullmv.row = 0; | 271 | 23.6k | ref_dv->as_fullmv.col = -MI_SIZE * mib_size - INTRABC_DELAY_PIXELS; | 272 | 23.6k | } else { | 273 | 4.17k | ref_dv->as_fullmv.row = -MI_SIZE * mib_size; | 274 | 4.17k | ref_dv->as_fullmv.col = 0; | 275 | 4.17k | } | 276 | 27.8k | convert_fullmv_to_mv(ref_dv); | 277 | 27.8k | } |
Unexecuted instantiation: mvref_common.c:av1_find_ref_dv Unexecuted instantiation: pred_common.c:av1_find_ref_dv Unexecuted instantiation: reconinter.c:av1_find_ref_dv |
278 | | |
279 | | static inline int av1_is_dv_valid(const MV dv, const AV1_COMMON *cm, |
280 | | const MACROBLOCKD *xd, int mi_row, int mi_col, |
281 | 60.0k | BLOCK_SIZE bsize, int mib_size_log2) { |
282 | 60.0k | const int bw = block_size_wide[bsize]; |
283 | 60.0k | const int bh = block_size_high[bsize]; |
284 | 60.0k | const int SCALE_PX_TO_MV = 8; |
285 | | // Disallow subpixel for now |
286 | | // SUBPEL_MASK is not the correct scale |
287 | 60.0k | if (((dv.row & (SCALE_PX_TO_MV - 1)) || (dv.col & (SCALE_PX_TO_MV - 1)))) |
288 | 0 | return 0; |
289 | | |
290 | 60.0k | const TileInfo *const tile = &xd->tile; |
291 | | // Is the source top-left inside the current tile? |
292 | 60.0k | const int src_top_edge = mi_row * MI_SIZE * SCALE_PX_TO_MV + dv.row; |
293 | 60.0k | const int tile_top_edge = tile->mi_row_start * MI_SIZE * SCALE_PX_TO_MV; |
294 | 60.0k | if (src_top_edge < tile_top_edge) return 0; |
295 | 58.8k | const int src_left_edge = mi_col * MI_SIZE * SCALE_PX_TO_MV + dv.col; |
296 | 58.8k | const int tile_left_edge = tile->mi_col_start * MI_SIZE * SCALE_PX_TO_MV; |
297 | 58.8k | if (src_left_edge < tile_left_edge) return 0; |
298 | | // Is the bottom right inside the current tile? |
299 | 53.8k | const int src_bottom_edge = (mi_row * MI_SIZE + bh) * SCALE_PX_TO_MV + dv.row; |
300 | 53.8k | const int tile_bottom_edge = tile->mi_row_end * MI_SIZE * SCALE_PX_TO_MV; |
301 | 53.8k | if (src_bottom_edge > tile_bottom_edge) return 0; |
302 | 53.7k | const int src_right_edge = (mi_col * MI_SIZE + bw) * SCALE_PX_TO_MV + dv.col; |
303 | 53.7k | const int tile_right_edge = tile->mi_col_end * MI_SIZE * SCALE_PX_TO_MV; |
304 | 53.7k | if (src_right_edge > tile_right_edge) return 0; |
305 | | |
306 | | // Special case for sub 8x8 chroma cases, to prevent referring to chroma |
307 | | // pixels outside current tile. |
308 | 53.6k | if (xd->is_chroma_ref && av1_num_planes(cm) > 1) { |
309 | 48.6k | const struct macroblockd_plane *const pd = &xd->plane[1]; |
310 | 48.6k | if (bw < 8 && pd->subsampling_x) |
311 | 716 | if (src_left_edge < tile_left_edge + 4 * SCALE_PX_TO_MV) return 0; |
312 | 48.6k | if (bh < 8 && pd->subsampling_y) |
313 | 1.39k | if (src_top_edge < tile_top_edge + 4 * SCALE_PX_TO_MV) return 0; |
314 | 48.6k | } |
315 | | |
316 | | // Is the bottom right within an already coded SB? Also consider additional |
317 | | // constraints to facilitate HW decoder. |
318 | 53.6k | const int max_mib_size = 1 << mib_size_log2; |
319 | 53.6k | const int active_sb_row = mi_row >> mib_size_log2; |
320 | 53.6k | const int active_sb64_col = (mi_col * MI_SIZE) >> 6; |
321 | 53.6k | const int sb_size = max_mib_size * MI_SIZE; |
322 | 53.6k | const int src_sb_row = ((src_bottom_edge >> 3) - 1) / sb_size; |
323 | 53.6k | const int src_sb64_col = ((src_right_edge >> 3) - 1) >> 6; |
324 | 53.6k | const int total_sb64_per_row = |
325 | 53.6k | ((tile->mi_col_end - tile->mi_col_start - 1) >> 4) + 1; |
326 | 53.6k | const int active_sb64 = active_sb_row * total_sb64_per_row + active_sb64_col; |
327 | 53.6k | const int src_sb64 = src_sb_row * total_sb64_per_row + src_sb64_col; |
328 | 53.6k | if (src_sb64 >= active_sb64 - INTRABC_DELAY_SB64) return 0; |
329 | | |
330 | | // Wavefront constraint: use only top left area of frame for reference. |
331 | 53.4k | const int gradient = 1 + INTRABC_DELAY_SB64 + (sb_size > 64); |
332 | 53.4k | const int wf_offset = gradient * (active_sb_row - src_sb_row); |
333 | 53.4k | if (src_sb_row > active_sb_row || |
334 | 53.4k | src_sb64_col >= active_sb64_col - INTRABC_DELAY_SB64 + wf_offset) |
335 | 10 | return 0; |
336 | | |
337 | 53.4k | return 1; |
338 | 53.4k | } Unexecuted instantiation: decodeframe.c:av1_is_dv_valid decodemv.c:av1_is_dv_valid Line | Count | Source | 281 | 60.0k | BLOCK_SIZE bsize, int mib_size_log2) { | 282 | 60.0k | const int bw = block_size_wide[bsize]; | 283 | 60.0k | const int bh = block_size_high[bsize]; | 284 | 60.0k | const int SCALE_PX_TO_MV = 8; | 285 | | // Disallow subpixel for now | 286 | | // SUBPEL_MASK is not the correct scale | 287 | 60.0k | if (((dv.row & (SCALE_PX_TO_MV - 1)) || (dv.col & (SCALE_PX_TO_MV - 1)))) | 288 | 0 | return 0; | 289 | | | 290 | 60.0k | const TileInfo *const tile = &xd->tile; | 291 | | // Is the source top-left inside the current tile? | 292 | 60.0k | const int src_top_edge = mi_row * MI_SIZE * SCALE_PX_TO_MV + dv.row; | 293 | 60.0k | const int tile_top_edge = tile->mi_row_start * MI_SIZE * SCALE_PX_TO_MV; | 294 | 60.0k | if (src_top_edge < tile_top_edge) return 0; | 295 | 58.8k | const int src_left_edge = mi_col * MI_SIZE * SCALE_PX_TO_MV + dv.col; | 296 | 58.8k | const int tile_left_edge = tile->mi_col_start * MI_SIZE * SCALE_PX_TO_MV; | 297 | 58.8k | if (src_left_edge < tile_left_edge) return 0; | 298 | | // Is the bottom right inside the current tile? | 299 | 53.8k | const int src_bottom_edge = (mi_row * MI_SIZE + bh) * SCALE_PX_TO_MV + dv.row; | 300 | 53.8k | const int tile_bottom_edge = tile->mi_row_end * MI_SIZE * SCALE_PX_TO_MV; | 301 | 53.8k | if (src_bottom_edge > tile_bottom_edge) return 0; | 302 | 53.7k | const int src_right_edge = (mi_col * MI_SIZE + bw) * SCALE_PX_TO_MV + dv.col; | 303 | 53.7k | const int tile_right_edge = tile->mi_col_end * MI_SIZE * SCALE_PX_TO_MV; | 304 | 53.7k | if (src_right_edge > tile_right_edge) return 0; | 305 | | | 306 | | // Special case for sub 8x8 chroma cases, to prevent referring to chroma | 307 | | // pixels outside current tile. | 308 | 53.6k | if (xd->is_chroma_ref && av1_num_planes(cm) > 1) { | 309 | 48.6k | const struct macroblockd_plane *const pd = &xd->plane[1]; | 310 | 48.6k | if (bw < 8 && pd->subsampling_x) | 311 | 716 | if (src_left_edge < tile_left_edge + 4 * SCALE_PX_TO_MV) return 0; | 312 | 48.6k | if (bh < 8 && pd->subsampling_y) | 313 | 1.39k | if (src_top_edge < tile_top_edge + 4 * SCALE_PX_TO_MV) return 0; | 314 | 48.6k | } | 315 | | | 316 | | // Is the bottom right within an already coded SB? Also consider additional | 317 | | // constraints to facilitate HW decoder. | 318 | 53.6k | const int max_mib_size = 1 << mib_size_log2; | 319 | 53.6k | const int active_sb_row = mi_row >> mib_size_log2; | 320 | 53.6k | const int active_sb64_col = (mi_col * MI_SIZE) >> 6; | 321 | 53.6k | const int sb_size = max_mib_size * MI_SIZE; | 322 | 53.6k | const int src_sb_row = ((src_bottom_edge >> 3) - 1) / sb_size; | 323 | 53.6k | const int src_sb64_col = ((src_right_edge >> 3) - 1) >> 6; | 324 | 53.6k | const int total_sb64_per_row = | 325 | 53.6k | ((tile->mi_col_end - tile->mi_col_start - 1) >> 4) + 1; | 326 | 53.6k | const int active_sb64 = active_sb_row * total_sb64_per_row + active_sb64_col; | 327 | 53.6k | const int src_sb64 = src_sb_row * total_sb64_per_row + src_sb64_col; | 328 | 53.6k | if (src_sb64 >= active_sb64 - INTRABC_DELAY_SB64) return 0; | 329 | | | 330 | | // Wavefront constraint: use only top left area of frame for reference. | 331 | 53.4k | const int gradient = 1 + INTRABC_DELAY_SB64 + (sb_size > 64); | 332 | 53.4k | const int wf_offset = gradient * (active_sb_row - src_sb_row); | 333 | 53.4k | if (src_sb_row > active_sb_row || | 334 | 53.4k | src_sb64_col >= active_sb64_col - INTRABC_DELAY_SB64 + wf_offset) | 335 | 10 | return 0; | 336 | | | 337 | 53.4k | return 1; | 338 | 53.4k | } |
Unexecuted instantiation: mvref_common.c:av1_is_dv_valid Unexecuted instantiation: pred_common.c:av1_is_dv_valid Unexecuted instantiation: reconinter.c:av1_is_dv_valid |
339 | | |
340 | | #ifdef __cplusplus |
341 | | } // extern "C" |
342 | | #endif |
343 | | |
344 | | #endif // AOM_AV1_COMMON_MVREF_COMMON_H_ |