FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/hevc/mvs.c
Date: 2024-10-04 17:46:48
Exec Total Coverage
Lines: 405 409 99.0%
Functions: 14 14 100.0%
Branches: 371 384 96.6%

Line Branch Exec Source
1 /*
2 * HEVC video decoder
3 *
4 * Copyright (C) 2012 - 2013 Guillaume Martres
5 * Copyright (C) 2013 Anand Meher Kotra
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #include "hevc.h"
25 #include "hevcdec.h"
26 #include "progressframe.h"
27
28 static const uint8_t l0_l1_cand_idx[12][2] = {
29 { 0, 1, },
30 { 1, 0, },
31 { 0, 2, },
32 { 2, 0, },
33 { 1, 2, },
34 { 2, 1, },
35 { 0, 3, },
36 { 3, 0, },
37 { 1, 3, },
38 { 3, 1, },
39 { 2, 3, },
40 { 3, 2, },
41 };
42
43 29543995 void ff_hevc_set_neighbour_available(HEVCLocalContext *lc, int x0, int y0,
44 int nPbW, int nPbH, int log2_ctb_size)
45 {
46 29543995 int x0b = av_zero_extend(x0, log2_ctb_size);
47 29543995 int y0b = av_zero_extend(y0, log2_ctb_size);
48
49
4/4
✓ Branch 0 taken 4569036 times.
✓ Branch 1 taken 24974959 times.
✓ Branch 2 taken 3725047 times.
✓ Branch 3 taken 843989 times.
29543995 lc->na.cand_up = (lc->ctb_up_flag || y0b);
50
4/4
✓ Branch 0 taken 2409848 times.
✓ Branch 1 taken 27134147 times.
✓ Branch 2 taken 1960643 times.
✓ Branch 3 taken 449205 times.
29543995 lc->na.cand_left = (lc->ctb_left_flag || x0b);
51
8/8
✓ Branch 0 taken 5757026 times.
✓ Branch 1 taken 23786969 times.
✓ Branch 2 taken 3717299 times.
✓ Branch 3 taken 2039727 times.
✓ Branch 4 taken 27211959 times.
✓ Branch 5 taken 292309 times.
✓ Branch 6 taken 26664983 times.
✓ Branch 7 taken 546976 times.
29543995 lc->na.cand_up_left = (x0b || y0b) ? lc->na.cand_left && lc->na.cand_up : lc->ctb_up_left_flag;
52 29543995 lc->na.cand_up_right_sap =
53 29543995 (x0b + nPbW == 1 << log2_ctb_size) ?
54
6/6
✓ Branch 0 taken 5673308 times.
✓ Branch 1 taken 23870687 times.
✓ Branch 2 taken 4726236 times.
✓ Branch 3 taken 947072 times.
✓ Branch 4 taken 1676444 times.
✓ Branch 5 taken 3049792 times.
29543995 lc->ctb_up_right_flag && !y0b : lc->na.cand_up;
55 29543995 lc->na.cand_up_right =
56 29543995 lc->na.cand_up_right_sap
57
4/4
✓ Branch 0 taken 24992187 times.
✓ Branch 1 taken 4551808 times.
✓ Branch 2 taken 24860447 times.
✓ Branch 3 taken 131740 times.
29543995 && (x0 + nPbW) < lc->end_of_tiles_x;
58
2/2
✓ Branch 0 taken 23571784 times.
✓ Branch 1 taken 5972211 times.
29543995 lc->na.cand_bottom_left = ((y0 + nPbH) >= lc->end_of_tiles_y) ? 0 : lc->na.cand_left;
59 29543995 }
60
61 /*
62 * 6.4.1 Derivation process for z-scan order block availability
63 */
64 static av_always_inline int
65 5548074 z_scan_block_avail(const HEVCPPS *pps, const HEVCSPS *sps,
66 int xCurr, int yCurr, int xN, int yN)
67 {
68 #define MIN_TB_ADDR_ZS(x, y) \
69 pps->min_tb_addr_zs[(y) * (sps->tb_mask+2) + (x)]
70
71 5548074 int xCurr_ctb = xCurr >> sps->log2_ctb_size;
72 5548074 int yCurr_ctb = yCurr >> sps->log2_ctb_size;
73 5548074 int xN_ctb = xN >> sps->log2_ctb_size;
74 5548074 int yN_ctb = yN >> sps->log2_ctb_size;
75
4/4
✓ Branch 0 taken 4586599 times.
✓ Branch 1 taken 961475 times.
✓ Branch 2 taken 536522 times.
✓ Branch 3 taken 4050077 times.
5548074 if( yN_ctb < yCurr_ctb || xN_ctb < xCurr_ctb )
76 1497997 return 1;
77 else {
78 4050077 int Curr = MIN_TB_ADDR_ZS((xCurr >> sps->log2_min_tb_size) & sps->tb_mask,
79 (yCurr >> sps->log2_min_tb_size) & sps->tb_mask);
80 4050077 int N = MIN_TB_ADDR_ZS((xN >> sps->log2_min_tb_size) & sps->tb_mask,
81 (yN >> sps->log2_min_tb_size) & sps->tb_mask);
82 4050077 return N <= Curr;
83 }
84 }
85
86 //check if the two luma locations belong to the same motion estimation region
87 11655431 static av_always_inline int is_diff_mer(const HEVCPPS *pps, int xN, int yN, int xP, int yP)
88 {
89 11655431 uint8_t plevel = pps->log2_parallel_merge_level;
90
91
2/2
✓ Branch 0 taken 762299 times.
✓ Branch 1 taken 10893132 times.
12417730 return xN >> plevel == xP >> plevel &&
92
2/2
✓ Branch 0 taken 421308 times.
✓ Branch 1 taken 340991 times.
762299 yN >> plevel == yP >> plevel;
93 }
94
95 #define MATCH_MV(x) (AV_RN32A(&A.x) == AV_RN32A(&B.x))
96 #define MATCH(x) (A.x == B.x)
97
98 // check if the mv's and refidx are the same between A and B
99 4602891 static av_always_inline int compare_mv_ref_idx(struct MvField A, struct MvField B)
100 {
101 4602891 int a_pf = A.pred_flag;
102 4602891 int b_pf = B.pred_flag;
103
2/2
✓ Branch 0 taken 3421817 times.
✓ Branch 1 taken 1181074 times.
4602891 if (a_pf == b_pf) {
104
2/2
✓ Branch 0 taken 1839572 times.
✓ Branch 1 taken 1582245 times.
3421817 if (a_pf == PF_BI) {
105
2/2
✓ Branch 0 taken 942351 times.
✓ Branch 1 taken 721131 times.
1663482 return MATCH(ref_idx[0]) && MATCH_MV(mv[0]) &&
106
6/6
✓ Branch 0 taken 1663482 times.
✓ Branch 1 taken 176090 times.
✓ Branch 2 taken 922698 times.
✓ Branch 3 taken 19653 times.
✓ Branch 4 taken 843116 times.
✓ Branch 5 taken 79582 times.
3503054 MATCH(ref_idx[1]) && MATCH_MV(mv[1]);
107
2/2
✓ Branch 0 taken 1389072 times.
✓ Branch 1 taken 193173 times.
1582245 } else if (a_pf == PF_L0) {
108
4/4
✓ Branch 0 taken 1094936 times.
✓ Branch 1 taken 294136 times.
✓ Branch 2 taken 521609 times.
✓ Branch 3 taken 573327 times.
1389072 return MATCH(ref_idx[0]) && MATCH_MV(mv[0]);
109
1/2
✓ Branch 0 taken 193173 times.
✗ Branch 1 not taken.
193173 } else if (a_pf == PF_L1) {
110
4/4
✓ Branch 0 taken 185438 times.
✓ Branch 1 taken 7735 times.
✓ Branch 2 taken 109572 times.
✓ Branch 3 taken 75866 times.
193173 return MATCH(ref_idx[1]) && MATCH_MV(mv[1]);
111 }
112 }
113 1181074 return 0;
114 }
115
116 2369976 static av_always_inline void mv_scale(Mv *dst, const Mv *src, int td, int tb)
117 {
118 int tx, scale_factor;
119
120 2369976 td = av_clip_int8(td);
121 2369976 tb = av_clip_int8(tb);
122 2369976 tx = (0x4000 + abs(td / 2)) / td;
123 2369976 scale_factor = av_clip_intp2((tb * tx + 32) >> 6, 12);
124 2369976 dst->x = av_clip_int16((scale_factor * src->x + 127 +
125 2369976 (scale_factor * src->x < 0)) >> 8);
126 2369976 dst->y = av_clip_int16((scale_factor * src->y + 127 +
127 2369976 (scale_factor * src->y < 0)) >> 8);
128 2369976 }
129
130 1852922 static int check_mvset(Mv *mvLXCol, const Mv *mvCol,
131 int colPic, int poc,
132 const RefPicList *refPicList, int X, int refIdxLx,
133 const RefPicList *refPicList_col, int listCol, int refidxCol)
134 {
135 1852922 int cur_lt = refPicList[X].isLongTerm[refIdxLx];
136 1852922 int col_lt = refPicList_col[listCol].isLongTerm[refidxCol];
137 int col_poc_diff, cur_poc_diff;
138
139
2/2
✓ Branch 0 taken 11053 times.
✓ Branch 1 taken 1841869 times.
1852922 if (cur_lt != col_lt) {
140 11053 mvLXCol->x = 0;
141 11053 mvLXCol->y = 0;
142 11053 return 0;
143 }
144
145 1841869 col_poc_diff = colPic - refPicList_col[listCol].list[refidxCol];
146 1841869 cur_poc_diff = poc - refPicList[X].list[refIdxLx];
147
148
5/6
✓ Branch 0 taken 1837101 times.
✓ Branch 1 taken 4768 times.
✓ Branch 2 taken 1500457 times.
✓ Branch 3 taken 336644 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1500457 times.
1841869 if (cur_lt || col_poc_diff == cur_poc_diff || !col_poc_diff) {
149 341412 mvLXCol->x = mvCol->x;
150 341412 mvLXCol->y = mvCol->y;
151 } else {
152 1500457 mv_scale(mvLXCol, mvCol, col_poc_diff, cur_poc_diff);
153 }
154 1841869 return 1;
155 }
156
157 #define CHECK_MVSET(l) \
158 check_mvset(mvLXCol, temp_col.mv + l, \
159 colPic, s->poc, \
160 refPicList, X, refIdxLx, \
161 refPicList_col, L ## l, temp_col.ref_idx[l])
162
163 // derive the motion vectors section 8.5.3.1.8
164 2316986 static int derive_temporal_colocated_mvs(const HEVCContext *s, MvField temp_col,
165 int refIdxLx, Mv *mvLXCol, int X,
166 int colPic, const RefPicList *refPicList_col)
167 {
168 2316986 const RefPicList *refPicList = s->cur_frame->refPicList;
169
170
2/2
✓ Branch 0 taken 464064 times.
✓ Branch 1 taken 1852922 times.
2316986 if (temp_col.pred_flag == PF_INTRA)
171 464064 return 0;
172
173
2/2
✓ Branch 0 taken 216579 times.
✓ Branch 1 taken 1636343 times.
1852922 if (!(temp_col.pred_flag & PF_L0))
174 216579 return CHECK_MVSET(1);
175
2/2
✓ Branch 0 taken 776309 times.
✓ Branch 1 taken 860034 times.
1636343 else if (temp_col.pred_flag == PF_L0)
176 776309 return CHECK_MVSET(0);
177
1/2
✓ Branch 0 taken 860034 times.
✗ Branch 1 not taken.
860034 else if (temp_col.pred_flag == PF_BI) {
178 860034 int check_diffpicount = 0;
179 int i, j;
180
2/2
✓ Branch 0 taken 1720068 times.
✓ Branch 1 taken 860034 times.
2580102 for (j = 0; j < 2; j++) {
181
2/2
✓ Branch 0 taken 3673824 times.
✓ Branch 1 taken 952296 times.
4626120 for (i = 0; i < refPicList[j].nb_refs; i++) {
182
2/2
✓ Branch 0 taken 767772 times.
✓ Branch 1 taken 2906052 times.
3673824 if (refPicList[j].list[i] > s->poc) {
183 767772 check_diffpicount++;
184 767772 break;
185 }
186 }
187 }
188
2/2
✓ Branch 0 taken 243486 times.
✓ Branch 1 taken 616548 times.
860034 if (!check_diffpicount) {
189
2/2
✓ Branch 0 taken 137027 times.
✓ Branch 1 taken 106459 times.
243486 if (X==0)
190 137027 return CHECK_MVSET(0);
191 else
192 106459 return CHECK_MVSET(1);
193 } else {
194
2/2
✓ Branch 0 taken 343733 times.
✓ Branch 1 taken 272815 times.
616548 if (s->sh.collocated_list == L1)
195 343733 return CHECK_MVSET(0);
196 else
197 272815 return CHECK_MVSET(1);
198 }
199 }
200
201 return 0;
202 }
203
204 #define TAB_MVF(x, y) \
205 tab_mvf[(y) * min_pu_width + x]
206
207 #define TAB_MVF_PU(v) \
208 TAB_MVF(((x ## v) >> sps->log2_min_pu_size), \
209 ((y ## v) >> sps->log2_min_pu_size))
210
211 #define DERIVE_TEMPORAL_COLOCATED_MVS \
212 derive_temporal_colocated_mvs(s, temp_col, \
213 refIdxLx, mvLXCol, X, colPic, \
214 ff_hevc_get_ref_list(ref, x, y))
215
216 /*
217 * 8.5.3.1.7 temporal luma motion vector prediction
218 */
219 2073720 static int temporal_luma_motion_vector(const HEVCContext *s, const HEVCSPS *sps,
220 int x0, int y0,
221 int nPbW, int nPbH, int refIdxLx,
222 Mv *mvLXCol, int X)
223 {
224 const MvField *tab_mvf;
225 MvField temp_col;
226 int x, y, x_pu, y_pu;
227 2073720 int min_pu_width = sps->min_pu_width;
228 2073720 int availableFlagLXCol = 0;
229 int colPic;
230
231 2073720 const HEVCFrame *ref = s->collocated_ref;
232
233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2073720 times.
2073720 if (!ref) {
234 memset(mvLXCol, 0, sizeof(*mvLXCol));
235 return 0;
236 }
237
238 2073720 tab_mvf = ref->tab_mvf;
239 2073720 colPic = ref->poc;
240
241 //bottom right collocated motion vector
242 2073720 x = x0 + nPbW;
243 2073720 y = y0 + nPbH;
244
245
1/2
✓ Branch 0 taken 2073720 times.
✗ Branch 1 not taken.
2073720 if (tab_mvf &&
246
2/2
✓ Branch 0 taken 1478153 times.
✓ Branch 1 taken 595567 times.
2073720 (y0 >> sps->log2_ctb_size) == (y >> sps->log2_ctb_size) &&
247
2/2
✓ Branch 0 taken 1430888 times.
✓ Branch 1 taken 47265 times.
1478153 y < sps->height &&
248
2/2
✓ Branch 0 taken 1408409 times.
✓ Branch 1 taken 22479 times.
1430888 x < sps->width) {
249 1408409 x &= ~15;
250 1408409 y &= ~15;
251
2/2
✓ Branch 0 taken 1443 times.
✓ Branch 1 taken 1406966 times.
1408409 if (s->avctx->active_thread_type == FF_THREAD_FRAME)
252 1443 ff_progress_frame_await(&ref->tf, y);
253 1408409 x_pu = x >> sps->log2_min_pu_size;
254 1408409 y_pu = y >> sps->log2_min_pu_size;
255 1408409 temp_col = TAB_MVF(x_pu, y_pu);
256 1408409 availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;
257 }
258
259 // derive center collocated motion vector
260
3/4
✓ Branch 0 taken 2073720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 908577 times.
✓ Branch 3 taken 1165143 times.
2073720 if (tab_mvf && !availableFlagLXCol) {
261 908577 x = x0 + (nPbW >> 1);
262 908577 y = y0 + (nPbH >> 1);
263 908577 x &= ~15;
264 908577 y &= ~15;
265
2/2
✓ Branch 0 taken 1167 times.
✓ Branch 1 taken 907410 times.
908577 if (s->avctx->active_thread_type == FF_THREAD_FRAME)
266 1167 ff_progress_frame_await(&ref->tf, y);
267 908577 x_pu = x >> sps->log2_min_pu_size;
268 908577 y_pu = y >> sps->log2_min_pu_size;
269 908577 temp_col = TAB_MVF(x_pu, y_pu);
270 908577 availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;
271 }
272 2073720 return availableFlagLXCol;
273 }
274
275 #define AVAILABLE(cand, v) \
276 (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
277
278 #define PRED_BLOCK_AVAILABLE(v) \
279 z_scan_block_avail(pps, sps, x0, y0, x ## v, y ## v)
280
281 #define COMPARE_MV_REFIDX(a, b) \
282 compare_mv_ref_idx(TAB_MVF_PU(a), TAB_MVF_PU(b))
283
284 /*
285 * 8.5.3.1.2 Derivation process for spatial merging candidates
286 */
287 6556947 static void derive_spatial_merge_candidates(HEVCLocalContext *lc, const HEVCContext *s,
288 const HEVCPPS *pps, const HEVCSPS *sps,
289 int x0, int y0,
290 int nPbW, int nPbH,
291 int log2_cb_size,
292 int singleMCLFlag, int part_idx,
293 int merge_idx,
294 struct MvField mergecandlist[])
295 {
296 6556947 const RefPicList *refPicList = s->cur_frame->refPicList;
297 6556947 const MvField *tab_mvf = s->cur_frame->tab_mvf;
298
299 6556947 const int min_pu_width = sps->min_pu_width;
300
301 6556947 const int cand_bottom_left = lc->na.cand_bottom_left;
302 6556947 const int cand_left = lc->na.cand_left;
303 6556947 const int cand_up_left = lc->na.cand_up_left;
304 6556947 const int cand_up = lc->na.cand_up;
305 6556947 const int cand_up_right = lc->na.cand_up_right_sap;
306
307 6556947 const int xA1 = x0 - 1;
308 6556947 const int yA1 = y0 + nPbH - 1;
309
310 6556947 const int xB1 = x0 + nPbW - 1;
311 6556947 const int yB1 = y0 - 1;
312
313 6556947 const int xB0 = x0 + nPbW;
314 6556947 const int yB0 = y0 - 1;
315
316 6556947 const int xA0 = x0 - 1;
317 6556947 const int yA0 = y0 + nPbH;
318
319 6556947 const int xB2 = x0 - 1;
320 6556947 const int yB2 = y0 - 1;
321
322 13113894 const int nb_refs = (s->sh.slice_type == HEVC_SLICE_P) ?
323
2/2
✓ Branch 0 taken 1469252 times.
✓ Branch 1 taken 5087695 times.
6556947 s->sh.nb_refs[0] : FFMIN(s->sh.nb_refs[0], s->sh.nb_refs[1]);
324
325 6556947 int zero_idx = 0;
326
327 6556947 int nb_merge_cand = 0;
328 6556947 int nb_orig_merge_cand = 0;
329
330 int is_available_a0;
331 int is_available_a1;
332 int is_available_b0;
333 int is_available_b1;
334 int is_available_b2;
335
336
337
4/4
✓ Branch 0 taken 6342312 times.
✓ Branch 1 taken 214635 times.
✓ Branch 2 taken 693777 times.
✓ Branch 3 taken 5648535 times.
6556947 if (!singleMCLFlag && part_idx == 1 &&
338
2/2
✓ Branch 0 taken 418414 times.
✓ Branch 1 taken 275363 times.
693777 (lc->cu.part_mode == PART_Nx2N ||
339
2/2
✓ Branch 0 taken 368457 times.
✓ Branch 1 taken 49957 times.
418414 lc->cu.part_mode == PART_nLx2N ||
340
4/4
✓ Branch 0 taken 315485 times.
✓ Branch 1 taken 52972 times.
✓ Branch 2 taken 138388 times.
✓ Branch 3 taken 6040267 times.
6547112 lc->cu.part_mode == PART_nRx2N) ||
341 6178655 is_diff_mer(pps, xA1, yA1, x0, y0)) {
342 516680 is_available_a1 = 0;
343 } else {
344
4/4
✓ Branch 0 taken 5907266 times.
✓ Branch 1 taken 133001 times.
✓ Branch 2 taken 5640889 times.
✓ Branch 3 taken 266377 times.
6040267 is_available_a1 = AVAILABLE(cand_left, A1);
345
2/2
✓ Branch 0 taken 5640889 times.
✓ Branch 1 taken 399378 times.
6040267 if (is_available_a1) {
346 5640889 mergecandlist[nb_merge_cand] = TAB_MVF_PU(A1);
347
2/2
✓ Branch 0 taken 3376134 times.
✓ Branch 1 taken 2264755 times.
5640889 if (merge_idx == 0)
348 3376134 return;
349 2264755 nb_merge_cand++;
350 }
351 }
352
353
4/4
✓ Branch 0 taken 3002221 times.
✓ Branch 1 taken 178592 times.
✓ Branch 2 taken 542287 times.
✓ Branch 3 taken 2459934 times.
3180813 if (!singleMCLFlag && part_idx == 1 &&
354
2/2
✓ Branch 0 taken 448058 times.
✓ Branch 1 taken 94229 times.
542287 (lc->cu.part_mode == PART_2NxN ||
355
2/2
✓ Branch 0 taken 431781 times.
✓ Branch 1 taken 16277 times.
448058 lc->cu.part_mode == PART_2NxnU ||
356
4/4
✓ Branch 0 taken 414117 times.
✓ Branch 1 taken 17664 times.
✓ Branch 2 taken 127861 times.
✓ Branch 3 taken 2924782 times.
3484424 lc->cu.part_mode == PART_2NxnD) ||
357 3052643 is_diff_mer(pps, xB1, yB1, x0, y0)) {
358 256031 is_available_b1 = 0;
359 } else {
360
4/4
✓ Branch 0 taken 2809617 times.
✓ Branch 1 taken 115165 times.
✓ Branch 2 taken 2677408 times.
✓ Branch 3 taken 132209 times.
2924782 is_available_b1 = AVAILABLE(cand_up, B1);
361
4/4
✓ Branch 0 taken 2677408 times.
✓ Branch 1 taken 247374 times.
✓ Branch 2 taken 2006771 times.
✓ Branch 3 taken 670637 times.
2924782 if (is_available_b1 &&
362
2/2
✓ Branch 1 taken 1675012 times.
✓ Branch 2 taken 331759 times.
2006771 !(is_available_a1 && COMPARE_MV_REFIDX(B1, A1))) {
363 2345649 mergecandlist[nb_merge_cand] = TAB_MVF_PU(B1);
364
2/2
✓ Branch 0 taken 1451771 times.
✓ Branch 1 taken 893878 times.
2345649 if (merge_idx == nb_merge_cand)
365 1451771 return;
366 893878 nb_merge_cand++;
367 }
368 }
369
370 // above right spatial merge candidate
371
2/2
✓ Branch 0 taken 1212938 times.
✓ Branch 1 taken 162716 times.
1375654 is_available_b0 = AVAILABLE(cand_up_right, B0) &&
372
4/4
✓ Branch 0 taken 1204009 times.
✓ Branch 1 taken 8929 times.
✓ Branch 2 taken 1004433 times.
✓ Branch 3 taken 199576 times.
2416947 xB0 < sps->width &&
373
4/4
✓ Branch 0 taken 1375654 times.
✓ Branch 1 taken 353388 times.
✓ Branch 3 taken 950028 times.
✓ Branch 4 taken 54405 times.
4308705 PRED_BLOCK_AVAILABLE(B0) &&
374 1004433 !is_diff_mer(pps, xB0, yB0, x0, y0);
375
376
4/4
✓ Branch 0 taken 950028 times.
✓ Branch 1 taken 779014 times.
✓ Branch 2 taken 894222 times.
✓ Branch 3 taken 55806 times.
1729042 if (is_available_b0 &&
377
2/2
✓ Branch 1 taken 510353 times.
✓ Branch 2 taken 383869 times.
894222 !(is_available_b1 && COMPARE_MV_REFIDX(B0, B1))) {
378 566159 mergecandlist[nb_merge_cand] = TAB_MVF_PU(B0);
379
2/2
✓ Branch 0 taken 324014 times.
✓ Branch 1 taken 242145 times.
566159 if (merge_idx == nb_merge_cand)
380 324014 return;
381 242145 nb_merge_cand++;
382 }
383
384 // left bottom spatial merge candidate
385
2/2
✓ Branch 0 taken 801336 times.
✓ Branch 1 taken 192817 times.
994153 is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
386
3/4
✓ Branch 0 taken 801336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 353352 times.
✓ Branch 3 taken 447984 times.
1602672 yA0 < sps->height &&
387
4/4
✓ Branch 0 taken 994153 times.
✓ Branch 1 taken 410875 times.
✓ Branch 3 taken 334884 times.
✓ Branch 4 taken 18468 times.
3200517 PRED_BLOCK_AVAILABLE(A0) &&
388 353352 !is_diff_mer(pps, xA0, yA0, x0, y0);
389
390
4/4
✓ Branch 0 taken 334884 times.
✓ Branch 1 taken 1070144 times.
✓ Branch 2 taken 320898 times.
✓ Branch 3 taken 13986 times.
1405028 if (is_available_a0 &&
391
2/2
✓ Branch 1 taken 136071 times.
✓ Branch 2 taken 184827 times.
320898 !(is_available_a1 && COMPARE_MV_REFIDX(A0, A1))) {
392 150057 mergecandlist[nb_merge_cand] = TAB_MVF_PU(A0);
393
2/2
✓ Branch 0 taken 83124 times.
✓ Branch 1 taken 66933 times.
150057 if (merge_idx == nb_merge_cand)
394 83124 return;
395 66933 nb_merge_cand++;
396 }
397
398 // above left spatial merge candidate
399
6/6
✓ Branch 0 taken 1186854 times.
✓ Branch 1 taken 135050 times.
✓ Branch 2 taken 1066348 times.
✓ Branch 3 taken 120506 times.
✓ Branch 4 taken 984162 times.
✓ Branch 5 taken 82186 times.
2388252 is_available_b2 = AVAILABLE(cand_up_left, B2) &&
400 1066348 !is_diff_mer(pps, xB2, yB2, x0, y0);
401
402
4/4
✓ Branch 0 taken 984162 times.
✓ Branch 1 taken 337742 times.
✓ Branch 2 taken 824400 times.
✓ Branch 3 taken 159762 times.
1321904 if (is_available_b2 &&
403
4/4
✓ Branch 1 taken 467897 times.
✓ Branch 2 taken 356503 times.
✓ Branch 3 taken 556600 times.
✓ Branch 4 taken 71059 times.
984162 !(is_available_a1 && COMPARE_MV_REFIDX(B2, A1)) &&
404
4/4
✓ Branch 1 taken 339261 times.
✓ Branch 2 taken 217339 times.
✓ Branch 3 taken 405929 times.
✓ Branch 4 taken 4391 times.
627659 !(is_available_b1 && COMPARE_MV_REFIDX(B2, B1)) &&
405 nb_merge_cand != 4) {
406 405929 mergecandlist[nb_merge_cand] = TAB_MVF_PU(B2);
407
2/2
✓ Branch 0 taken 200839 times.
✓ Branch 1 taken 205090 times.
405929 if (merge_idx == nb_merge_cand)
408 200839 return;
409 205090 nb_merge_cand++;
410 }
411
412 // temporal motion vector candidate
413
2/2
✓ Branch 0 taken 879742 times.
✓ Branch 1 taken 241323 times.
1121065 if (s->sh.slice_temporal_mvp_enabled_flag &&
414
1/2
✓ Branch 0 taken 879742 times.
✗ Branch 1 not taken.
879742 nb_merge_cand < s->sh.max_num_merge_cand) {
415 879742 Mv mv_l0_col = { 0 }, mv_l1_col = { 0 };
416 879742 int available_l0 = temporal_luma_motion_vector(s, sps, x0, y0, nPbW, nPbH,
417 0, &mv_l0_col, 0);
418 1759484 int available_l1 = (s->sh.slice_type == HEVC_SLICE_B) ?
419 787198 temporal_luma_motion_vector(s, sps, x0, y0, nPbW, nPbH,
420
2/2
✓ Branch 0 taken 787198 times.
✓ Branch 1 taken 92544 times.
879742 0, &mv_l1_col, 1) : 0;
421
422
4/4
✓ Branch 0 taken 82776 times.
✓ Branch 1 taken 796966 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 82474 times.
879742 if (available_l0 || available_l1) {
423 797268 mergecandlist[nb_merge_cand].pred_flag = available_l0 + (available_l1 << 1);
424 797268 AV_ZERO16(mergecandlist[nb_merge_cand].ref_idx);
425 797268 mergecandlist[nb_merge_cand].mv[0] = mv_l0_col;
426 797268 mergecandlist[nb_merge_cand].mv[1] = mv_l1_col;
427
428
2/2
✓ Branch 0 taken 498410 times.
✓ Branch 1 taken 298858 times.
797268 if (merge_idx == nb_merge_cand)
429 498410 return;
430 298858 nb_merge_cand++;
431 }
432 }
433
434 622655 nb_orig_merge_cand = nb_merge_cand;
435
436 // combined bi-predictive merge candidates (applies for B slices)
437
4/4
✓ Branch 0 taken 510374 times.
✓ Branch 1 taken 112281 times.
✓ Branch 2 taken 345285 times.
✓ Branch 3 taken 165089 times.
622655 if (s->sh.slice_type == HEVC_SLICE_B && nb_orig_merge_cand > 1 &&
438
1/2
✓ Branch 0 taken 345285 times.
✗ Branch 1 not taken.
345285 nb_orig_merge_cand < s->sh.max_num_merge_cand) {
439 345285 int comb_idx = 0;
440
441
1/2
✓ Branch 0 taken 731068 times.
✗ Branch 1 not taken.
731068 for (comb_idx = 0; nb_merge_cand < s->sh.max_num_merge_cand &&
442
2/2
✓ Branch 0 taken 680211 times.
✓ Branch 1 taken 50857 times.
1116851 comb_idx < nb_orig_merge_cand * (nb_orig_merge_cand - 1); comb_idx++) {
443 680211 int l0_cand_idx = l0_l1_cand_idx[comb_idx][0];
444 680211 int l1_cand_idx = l0_l1_cand_idx[comb_idx][1];
445 680211 MvField l0_cand = mergecandlist[l0_cand_idx];
446 680211 MvField l1_cand = mergecandlist[l1_cand_idx];
447
448
4/4
✓ Branch 0 taken 606879 times.
✓ Branch 1 taken 73332 times.
✓ Branch 2 taken 450089 times.
✓ Branch 3 taken 156790 times.
680211 if ((l0_cand.pred_flag & PF_L0) && (l1_cand.pred_flag & PF_L1) &&
449 450089 (refPicList[0].list[l0_cand.ref_idx[0]] !=
450
2/2
✓ Branch 0 taken 112341 times.
✓ Branch 1 taken 337748 times.
450089 refPicList[1].list[l1_cand.ref_idx[1]] ||
451
2/2
✓ Branch 0 taken 97896 times.
✓ Branch 1 taken 14445 times.
112341 AV_RN32A(&l0_cand.mv[0]) != AV_RN32A(&l1_cand.mv[1]))) {
452 435644 mergecandlist[nb_merge_cand].ref_idx[0] = l0_cand.ref_idx[0];
453 435644 mergecandlist[nb_merge_cand].ref_idx[1] = l1_cand.ref_idx[1];
454 435644 mergecandlist[nb_merge_cand].pred_flag = PF_BI;
455 435644 AV_COPY32(&mergecandlist[nb_merge_cand].mv[0], &l0_cand.mv[0]);
456 435644 AV_COPY32(&mergecandlist[nb_merge_cand].mv[1], &l1_cand.mv[1]);
457
2/2
✓ Branch 0 taken 294428 times.
✓ Branch 1 taken 141216 times.
435644 if (merge_idx == nb_merge_cand)
458 294428 return;
459 141216 nb_merge_cand++;
460 }
461 }
462 }
463
464 // append Zero motion vector candidates
465
1/2
✓ Branch 0 taken 541465 times.
✗ Branch 1 not taken.
541465 while (nb_merge_cand < s->sh.max_num_merge_cand) {
466
2/2
✓ Branch 0 taken 363663 times.
✓ Branch 1 taken 177802 times.
541465 mergecandlist[nb_merge_cand].pred_flag = PF_L0 + ((s->sh.slice_type == HEVC_SLICE_B) << 1);
467 541465 AV_ZERO32(mergecandlist[nb_merge_cand].mv + 0);
468 541465 AV_ZERO32(mergecandlist[nb_merge_cand].mv + 1);
469
2/2
✓ Branch 0 taken 492708 times.
✓ Branch 1 taken 48757 times.
541465 mergecandlist[nb_merge_cand].ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0;
470
2/2
✓ Branch 0 taken 492708 times.
✓ Branch 1 taken 48757 times.
541465 mergecandlist[nb_merge_cand].ref_idx[1] = zero_idx < nb_refs ? zero_idx : 0;
471
472
2/2
✓ Branch 0 taken 328227 times.
✓ Branch 1 taken 213238 times.
541465 if (merge_idx == nb_merge_cand)
473 328227 return;
474 213238 nb_merge_cand++;
475 213238 zero_idx++;
476 }
477 }
478
479 /*
480 * 8.5.3.1.1 Derivation process of luma Mvs for merge mode
481 */
482 6556947 void ff_hevc_luma_mv_merge_mode(HEVCLocalContext *lc, const HEVCPPS *pps,
483 int x0, int y0, int nPbW,
484 int nPbH, int log2_cb_size, int part_idx,
485 int merge_idx, MvField *mv)
486 {
487 6556947 const HEVCSPS *const sps = pps->sps;
488 6556947 const HEVCContext *const s = lc->parent;
489 6556947 int singleMCLFlag = 0;
490 6556947 int nCS = 1 << log2_cb_size;
491 MvField mergecand_list[MRG_MAX_NUM_CANDS];
492 6556947 int nPbW2 = nPbW;
493 6556947 int nPbH2 = nPbH;
494
495
4/4
✓ Branch 0 taken 326043 times.
✓ Branch 1 taken 6230904 times.
✓ Branch 2 taken 214635 times.
✓ Branch 3 taken 111408 times.
6556947 if (pps->log2_parallel_merge_level > 2 && nCS == 8) {
496 214635 singleMCLFlag = 1;
497 214635 x0 = lc->cu.x;
498 214635 y0 = lc->cu.y;
499 214635 nPbW = nCS;
500 214635 nPbH = nCS;
501 214635 part_idx = 0;
502 }
503
504 6556947 ff_hevc_set_neighbour_available(lc, x0, y0, nPbW, nPbH, sps->log2_ctb_size);
505 6556947 derive_spatial_merge_candidates(lc, s, pps, sps, x0, y0, nPbW, nPbH, log2_cb_size,
506 singleMCLFlag, part_idx,
507 merge_idx, mergecand_list);
508
509
2/2
✓ Branch 0 taken 3666219 times.
✓ Branch 1 taken 2890728 times.
6556947 if (mergecand_list[merge_idx].pred_flag == PF_BI &&
510
2/2
✓ Branch 0 taken 128138 times.
✓ Branch 1 taken 3538081 times.
3666219 (nPbW2 + nPbH2) == 12) {
511 128138 mergecand_list[merge_idx].pred_flag = PF_L0;
512 }
513
514 6556947 *mv = mergecand_list[merge_idx];
515 6556947 }
516
517 1034357 static av_always_inline void dist_scale(const HEVCContext *s, Mv *mv,
518 int min_pu_width, int x, int y,
519 int elist, int ref_idx_curr, int ref_idx)
520 {
521 1034357 const RefPicList *refPicList = s->cur_frame->refPicList;
522 1034357 const MvField *tab_mvf = s->cur_frame->tab_mvf;
523 1034357 int ref_pic_elist = refPicList[elist].list[TAB_MVF(x, y).ref_idx[elist]];
524 1034357 int ref_pic_curr = refPicList[ref_idx_curr].list[ref_idx];
525
526
2/2
✓ Branch 0 taken 869519 times.
✓ Branch 1 taken 164838 times.
1034357 if (ref_pic_elist != ref_pic_curr) {
527 869519 int poc_diff = s->poc - ref_pic_elist;
528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 869519 times.
869519 if (!poc_diff)
529 poc_diff = 1;
530 869519 mv_scale(mv, mv, poc_diff, s->poc - ref_pic_curr);
531 }
532 1034357 }
533
534 9493610 static int mv_mp_mode_mx(const HEVCContext *s, const HEVCSPS *sps,
535 int x, int y, int pred_flag_index,
536 Mv *mv, int ref_idx_curr, int ref_idx)
537 {
538 9493610 const MvField *tab_mvf = s->cur_frame->tab_mvf;
539 9493610 int min_pu_width = sps->min_pu_width;
540
541 9493610 const RefPicList *refPicList = s->cur_frame->refPicList;
542
543
2/2
✓ Branch 0 taken 7382416 times.
✓ Branch 1 taken 2111194 times.
9493610 if (((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) &&
544
2/2
✓ Branch 0 taken 3928302 times.
✓ Branch 1 taken 3454114 times.
7382416 refPicList[pred_flag_index].list[TAB_MVF(x, y).ref_idx[pred_flag_index]] == refPicList[ref_idx_curr].list[ref_idx]) {
545 3928302 *mv = TAB_MVF(x, y).mv[pred_flag_index];
546 3928302 return 1;
547 }
548 5565308 return 0;
549 }
550
551 1336422 static int mv_mp_mode_mx_lt(const HEVCContext *s, const HEVCSPS *sps,
552 int x, int y, int pred_flag_index,
553 Mv *mv, int ref_idx_curr, int ref_idx)
554 {
555 1336422 const MvField *tab_mvf = s->cur_frame->tab_mvf;
556 1336422 int min_pu_width = sps->min_pu_width;
557
558 1336422 const RefPicList *refPicList = s->cur_frame->refPicList;
559
560
2/2
✓ Branch 0 taken 1055277 times.
✓ Branch 1 taken 281145 times.
1336422 if ((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) {
561 1055277 int currIsLongTerm = refPicList[ref_idx_curr].isLongTerm[ref_idx];
562
563 1055277 int colIsLongTerm =
564 1055277 refPicList[pred_flag_index].isLongTerm[(TAB_MVF(x, y).ref_idx[pred_flag_index])];
565
566
2/2
✓ Branch 0 taken 1040923 times.
✓ Branch 1 taken 14354 times.
1055277 if (colIsLongTerm == currIsLongTerm) {
567 1040923 *mv = TAB_MVF(x, y).mv[pred_flag_index];
568
2/2
✓ Branch 0 taken 1034357 times.
✓ Branch 1 taken 6566 times.
1040923 if (!currIsLongTerm)
569 1034357 dist_scale(s, mv, min_pu_width, x, y,
570 pred_flag_index, ref_idx_curr, ref_idx);
571 1040923 return 1;
572 }
573 }
574 295499 return 0;
575 }
576
577 #define MP_MX(v, pred, mx) \
578 mv_mp_mode_mx(s, sps, \
579 (x ## v) >> sps->log2_min_pu_size, \
580 (y ## v) >> sps->log2_min_pu_size, \
581 pred, &mx, ref_idx_curr, ref_idx)
582
583 #define MP_MX_LT(v, pred, mx) \
584 mv_mp_mode_mx_lt(s, sps, \
585 (x ## v) >> sps->log2_min_pu_size, \
586 (y ## v) >> sps->log2_min_pu_size, \
587 pred, &mx, ref_idx_curr, ref_idx)
588
589 2920914 void ff_hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, const HEVCPPS *pps,
590 int x0, int y0, int nPbW,
591 int nPbH, int log2_cb_size, int part_idx,
592 int merge_idx, MvField *mv,
593 int mvp_lx_flag, int LX)
594 {
595 2920914 const HEVCSPS *const sps = pps->sps;
596 2920914 const HEVCContext *const s = lc->parent;
597 2920914 const MvField *const tab_mvf = s->cur_frame->tab_mvf;
598 2920914 int isScaledFlag_L0 = 0;
599 2920914 int availableFlagLXA0 = 1;
600 2920914 int availableFlagLXB0 = 1;
601 2920914 int numMVPCandLX = 0;
602 2920914 int min_pu_width = sps->min_pu_width;
603
604 int xA0, yA0;
605 int is_available_a0;
606 int xA1, yA1;
607 int is_available_a1;
608 int xB0, yB0;
609 int is_available_b0;
610 int xB1, yB1;
611 int is_available_b1;
612 int xB2, yB2;
613 int is_available_b2;
614
615 2920914 Mv mvpcand_list[2] = { { 0 } };
616 Mv mxA;
617 Mv mxB;
618 int ref_idx_curr;
619 2920914 int ref_idx = 0;
620 int pred_flag_index_l0;
621 int pred_flag_index_l1;
622
623 2920914 const int cand_bottom_left = lc->na.cand_bottom_left;
624 2920914 const int cand_left = lc->na.cand_left;
625 2920914 const int cand_up_left = lc->na.cand_up_left;
626 2920914 const int cand_up = lc->na.cand_up;
627 2920914 const int cand_up_right = lc->na.cand_up_right_sap;
628 2920914 ref_idx_curr = LX;
629 2920914 ref_idx = mv->ref_idx[LX];
630 2920914 pred_flag_index_l0 = LX;
631 2920914 pred_flag_index_l1 = !LX;
632
633 // left bottom spatial candidate
634 2920914 xA0 = x0 - 1;
635 2920914 yA0 = y0 + nPbH;
636
637
2/2
✓ Branch 0 taken 1620536 times.
✓ Branch 1 taken 398552 times.
2019088 is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
638
5/6
✓ Branch 0 taken 2019088 times.
✓ Branch 1 taken 901826 times.
✓ Branch 2 taken 1620536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 757485 times.
✓ Branch 5 taken 863051 times.
6560538 yA0 < sps->height &&
639 1620536 PRED_BLOCK_AVAILABLE(A0);
640
641 //left spatial merge candidate
642 2920914 xA1 = x0 - 1;
643 2920914 yA1 = y0 + nPbH - 1;
644
645
4/4
✓ Branch 0 taken 2837004 times.
✓ Branch 1 taken 83910 times.
✓ Branch 2 taken 2578872 times.
✓ Branch 3 taken 258132 times.
2920914 is_available_a1 = AVAILABLE(cand_left, A1);
646
4/4
✓ Branch 0 taken 2163429 times.
✓ Branch 1 taken 757485 times.
✓ Branch 2 taken 1846969 times.
✓ Branch 3 taken 316460 times.
2920914 if (is_available_a0 || is_available_a1)
647 2604454 isScaledFlag_L0 = 1;
648
649
2/2
✓ Branch 0 taken 757485 times.
✓ Branch 1 taken 2163429 times.
2920914 if (is_available_a0) {
650
2/2
✓ Branch 1 taken 464048 times.
✓ Branch 2 taken 293437 times.
757485 if (MP_MX(A0, pred_flag_index_l0, mxA)) {
651 464048 goto b_candidates;
652 }
653
2/2
✓ Branch 1 taken 48997 times.
✓ Branch 2 taken 244440 times.
293437 if (MP_MX(A0, pred_flag_index_l1, mxA)) {
654 48997 goto b_candidates;
655 }
656 }
657
658
2/2
✓ Branch 0 taken 2081814 times.
✓ Branch 1 taken 326055 times.
2407869 if (is_available_a1) {
659
2/2
✓ Branch 1 taken 1186266 times.
✓ Branch 2 taken 895548 times.
2081814 if (MP_MX(A1, pred_flag_index_l0, mxA)) {
660 1186266 goto b_candidates;
661 }
662
2/2
✓ Branch 1 taken 118286 times.
✓ Branch 2 taken 777262 times.
895548 if (MP_MX(A1, pred_flag_index_l1, mxA)) {
663 118286 goto b_candidates;
664 }
665 }
666
667
2/2
✓ Branch 0 taken 198609 times.
✓ Branch 1 taken 904708 times.
1103317 if (is_available_a0) {
668
2/2
✓ Branch 1 taken 143739 times.
✓ Branch 2 taken 54870 times.
198609 if (MP_MX_LT(A0, pred_flag_index_l0, mxA)) {
669 143739 goto b_candidates;
670 }
671
2/2
✓ Branch 1 taken 52848 times.
✓ Branch 2 taken 2022 times.
54870 if (MP_MX_LT(A0, pred_flag_index_l1, mxA)) {
672 52848 goto b_candidates;
673 }
674 }
675
676
2/2
✓ Branch 0 taken 590028 times.
✓ Branch 1 taken 316702 times.
906730 if (is_available_a1) {
677
2/2
✓ Branch 1 taken 393110 times.
✓ Branch 2 taken 196918 times.
590028 if (MP_MX_LT(A1, pred_flag_index_l0, mxA)) {
678 393110 goto b_candidates;
679 }
680
2/2
✓ Branch 1 taken 188683 times.
✓ Branch 2 taken 8235 times.
196918 if (MP_MX_LT(A1, pred_flag_index_l1, mxA)) {
681 188683 goto b_candidates;
682 }
683 }
684 324937 availableFlagLXA0 = 0;
685
686 2920914 b_candidates:
687 // B candidates
688 // above right spatial merge candidate
689 2920914 xB0 = x0 + nPbW;
690 2920914 yB0 = y0 - 1;
691
692
2/2
✓ Branch 0 taken 1937147 times.
✓ Branch 1 taken 309954 times.
2247101 is_available_b0 = AVAILABLE(cand_up_right, B0) &&
693
6/6
✓ Branch 0 taken 2247101 times.
✓ Branch 1 taken 673813 times.
✓ Branch 2 taken 1922193 times.
✓ Branch 3 taken 14954 times.
✓ Branch 4 taken 1550407 times.
✓ Branch 5 taken 371786 times.
7090208 xB0 < sps->width &&
694 1922193 PRED_BLOCK_AVAILABLE(B0);
695
696 // above spatial merge candidate
697 2920914 xB1 = x0 + nPbW - 1;
698 2920914 yB1 = y0 - 1;
699
4/4
✓ Branch 0 taken 2728076 times.
✓ Branch 1 taken 192838 times.
✓ Branch 2 taken 2488612 times.
✓ Branch 3 taken 239464 times.
2920914 is_available_b1 = AVAILABLE(cand_up, B1);
700
701 // above left spatial merge candidate
702 2920914 xB2 = x0 - 1;
703 2920914 yB2 = y0 - 1;
704
4/4
✓ Branch 0 taken 2657769 times.
✓ Branch 1 taken 263145 times.
✓ Branch 2 taken 2370214 times.
✓ Branch 3 taken 287555 times.
2920914 is_available_b2 = AVAILABLE(cand_up_left, B2);
705
706 // above right spatial merge candidate
707
2/2
✓ Branch 0 taken 1550407 times.
✓ Branch 1 taken 1370507 times.
2920914 if (is_available_b0) {
708
2/2
✓ Branch 1 taken 971695 times.
✓ Branch 2 taken 578712 times.
1550407 if (MP_MX(B0, pred_flag_index_l0, mxB)) {
709 971695 goto scalef;
710 }
711
2/2
✓ Branch 1 taken 97830 times.
✓ Branch 2 taken 480882 times.
578712 if (MP_MX(B0, pred_flag_index_l1, mxB)) {
712 97830 goto scalef;
713 }
714 }
715
716 // above spatial merge candidate
717
2/2
✓ Branch 0 taken 1467081 times.
✓ Branch 1 taken 384308 times.
1851389 if (is_available_b1) {
718
2/2
✓ Branch 1 taken 746939 times.
✓ Branch 2 taken 720142 times.
1467081 if (MP_MX(B1, pred_flag_index_l0, mxB)) {
719 746939 goto scalef;
720 }
721
2/2
✓ Branch 1 taken 73606 times.
✓ Branch 2 taken 646536 times.
720142 if (MP_MX(B1, pred_flag_index_l1, mxB)) {
722 73606 goto scalef;
723 }
724 }
725
726 // above left spatial merge candidate
727
2/2
✓ Branch 0 taken 672472 times.
✓ Branch 1 taken 358372 times.
1030844 if (is_available_b2) {
728
2/2
✓ Branch 1 taken 195960 times.
✓ Branch 2 taken 476512 times.
672472 if (MP_MX(B2, pred_flag_index_l0, mxB)) {
729 195960 goto scalef;
730 }
731
2/2
✓ Branch 1 taken 24675 times.
✓ Branch 2 taken 451837 times.
476512 if (MP_MX(B2, pred_flag_index_l1, mxB)) {
732 24675 goto scalef;
733 }
734 }
735 810209 availableFlagLXB0 = 0;
736
737 2920914 scalef:
738
2/2
✓ Branch 0 taken 316460 times.
✓ Branch 1 taken 2604454 times.
2920914 if (!isScaledFlag_L0) {
739
2/2
✓ Branch 0 taken 195677 times.
✓ Branch 1 taken 120783 times.
316460 if (availableFlagLXB0) {
740 195677 availableFlagLXA0 = 1;
741 195677 mxA = mxB;
742 }
743 316460 availableFlagLXB0 = 0;
744
745 // XB0 and L1
746
2/2
✓ Branch 0 taken 146304 times.
✓ Branch 1 taken 170156 times.
316460 if (is_available_b0) {
747 146304 availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l0, mxB);
748
2/2
✓ Branch 0 taken 17071 times.
✓ Branch 1 taken 129233 times.
146304 if (!availableFlagLXB0)
749 17071 availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l1, mxB);
750 }
751
752
4/4
✓ Branch 0 taken 230759 times.
✓ Branch 1 taken 85701 times.
✓ Branch 2 taken 102645 times.
✓ Branch 3 taken 128114 times.
316460 if (is_available_b1 && !availableFlagLXB0) {
753 102645 availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l0, mxB);
754
2/2
✓ Branch 0 taken 13132 times.
✓ Branch 1 taken 89513 times.
102645 if (!availableFlagLXB0)
755 13132 availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l1, mxB);
756 }
757
758
4/4
✓ Branch 0 taken 101319 times.
✓ Branch 1 taken 215141 times.
✓ Branch 2 taken 14987 times.
✓ Branch 3 taken 86332 times.
316460 if (is_available_b2 && !availableFlagLXB0) {
759 14987 availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l0, mxB);
760
2/2
✓ Branch 0 taken 1858 times.
✓ Branch 1 taken 13129 times.
14987 if (!availableFlagLXB0)
761 1858 availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l1, mxB);
762 }
763 }
764
765
2/2
✓ Branch 0 taken 2791654 times.
✓ Branch 1 taken 129260 times.
2920914 if (availableFlagLXA0)
766 2791654 mvpcand_list[numMVPCandLX++] = mxA;
767
768
8/8
✓ Branch 0 taken 2177571 times.
✓ Branch 1 taken 743343 times.
✓ Branch 2 taken 2105950 times.
✓ Branch 3 taken 71621 times.
✓ Branch 4 taken 721209 times.
✓ Branch 5 taken 1384741 times.
✓ Branch 6 taken 138412 times.
✓ Branch 7 taken 582797 times.
2920914 if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y))
769 1594774 mvpcand_list[numMVPCandLX++] = mxB;
770
771 //temporal motion vector prediction candidate
772
6/6
✓ Branch 0 taken 1397761 times.
✓ Branch 1 taken 1523153 times.
✓ Branch 2 taken 1142681 times.
✓ Branch 3 taken 255080 times.
✓ Branch 4 taken 406780 times.
✓ Branch 5 taken 735901 times.
2920914 if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag &&
773 mvp_lx_flag == numMVPCandLX) {
774 Mv mv_col;
775 406780 int available_col = temporal_luma_motion_vector(s, sps, x0, y0, nPbW,
776 nPbH, ref_idx,
777 &mv_col, LX);
778
2/2
✓ Branch 0 taken 334482 times.
✓ Branch 1 taken 72298 times.
406780 if (available_col)
779 334482 mvpcand_list[numMVPCandLX++] = mv_col;
780 }
781
782 2920914 mv->mv[LX] = mvpcand_list[mvp_lx_flag];
783 2920914 }
784