FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/hevc/mvs.c
Date: 2024-07-16 12:46:59
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 28064556 void ff_hevc_set_neighbour_available(HEVCLocalContext *lc, int x0, int y0,
44 int nPbW, int nPbH, int log2_ctb_size)
45 {
46 28064556 int x0b = av_zero_extend(x0, log2_ctb_size);
47 28064556 int y0b = av_zero_extend(y0, log2_ctb_size);
48
49
4/4
✓ Branch 0 taken 4520926 times.
✓ Branch 1 taken 23543630 times.
✓ Branch 2 taken 3698418 times.
✓ Branch 3 taken 822508 times.
28064556 lc->na.cand_up = (lc->ctb_up_flag || y0b);
50
4/4
✓ Branch 0 taken 2311347 times.
✓ Branch 1 taken 25753209 times.
✓ Branch 2 taken 1887396 times.
✓ Branch 3 taken 423951 times.
28064556 lc->na.cand_left = (lc->ctb_left_flag || x0b);
51
8/8
✓ Branch 0 taken 5343566 times.
✓ Branch 1 taken 22720990 times.
✓ Branch 2 taken 3510039 times.
✓ Branch 3 taken 1833527 times.
✓ Branch 4 taken 25952862 times.
✓ Branch 5 taken 278167 times.
✓ Branch 6 taken 25412705 times.
✓ Branch 7 taken 540157 times.
28064556 lc->na.cand_up_left = (x0b || y0b) ? lc->na.cand_left && lc->na.cand_up : lc->ctb_up_left_flag;
52 28064556 lc->na.cand_up_right_sap =
53 28064556 (x0b + nPbW == 1 << log2_ctb_size) ?
54
6/6
✓ Branch 0 taken 5259215 times.
✓ Branch 1 taken 22805341 times.
✓ Branch 2 taken 4334248 times.
✓ Branch 3 taken 924967 times.
✓ Branch 4 taken 1485501 times.
✓ Branch 5 taken 2848747 times.
28064556 lc->ctb_up_right_flag && !y0b : lc->na.cand_up;
55 28064556 lc->na.cand_up_right =
56 28064556 lc->na.cand_up_right_sap
57
4/4
✓ Branch 0 taken 23742681 times.
✓ Branch 1 taken 4321875 times.
✓ Branch 2 taken 23621234 times.
✓ Branch 3 taken 121447 times.
28064556 && (x0 + nPbW) < lc->end_of_tiles_x;
58
2/2
✓ Branch 0 taken 22517297 times.
✓ Branch 1 taken 5547259 times.
28064556 lc->na.cand_bottom_left = ((y0 + nPbH) >= lc->end_of_tiles_y) ? 0 : lc->na.cand_left;
59 28064556 }
60
61 /*
62 * 6.4.1 Derivation process for z-scan order block availability
63 */
64 static av_always_inline int
65 5299962 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 5299962 int xCurr_ctb = xCurr >> sps->log2_ctb_size;
72 5299962 int yCurr_ctb = yCurr >> sps->log2_ctb_size;
73 5299962 int xN_ctb = xN >> sps->log2_ctb_size;
74 5299962 int yN_ctb = yN >> sps->log2_ctb_size;
75
4/4
✓ Branch 0 taken 4415455 times.
✓ Branch 1 taken 884507 times.
✓ Branch 2 taken 517152 times.
✓ Branch 3 taken 3898303 times.
5299962 if( yN_ctb < yCurr_ctb || xN_ctb < xCurr_ctb )
76 1401659 return 1;
77 else {
78 3898303 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 3898303 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 3898303 return N <= Curr;
83 }
84 }
85
86 //check if the two luma locations belong to the same motion estimation region
87 11129533 static av_always_inline int is_diff_mer(const HEVCPPS *pps, int xN, int yN, int xP, int yP)
88 {
89 11129533 uint8_t plevel = pps->log2_parallel_merge_level;
90
91
2/2
✓ Branch 0 taken 755253 times.
✓ Branch 1 taken 10374280 times.
11884786 return xN >> plevel == xP >> plevel &&
92
2/2
✓ Branch 0 taken 421308 times.
✓ Branch 1 taken 333945 times.
755253 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 4418492 static av_always_inline int compare_mv_ref_idx(struct MvField A, struct MvField B)
100 {
101 4418492 int a_pf = A.pred_flag;
102 4418492 int b_pf = B.pred_flag;
103
2/2
✓ Branch 0 taken 3289238 times.
✓ Branch 1 taken 1129254 times.
4418492 if (a_pf == b_pf) {
104
2/2
✓ Branch 0 taken 1773606 times.
✓ Branch 1 taken 1515632 times.
3289238 if (a_pf == PF_BI) {
105
2/2
✓ Branch 0 taken 908631 times.
✓ Branch 1 taken 695368 times.
1603999 return MATCH(ref_idx[0]) && MATCH_MV(mv[0]) &&
106
6/6
✓ Branch 0 taken 1603999 times.
✓ Branch 1 taken 169607 times.
✓ Branch 2 taken 889521 times.
✓ Branch 3 taken 19110 times.
✓ Branch 4 taken 812986 times.
✓ Branch 5 taken 76535 times.
3377605 MATCH(ref_idx[1]) && MATCH_MV(mv[1]);
107
2/2
✓ Branch 0 taken 1333655 times.
✓ Branch 1 taken 181977 times.
1515632 } else if (a_pf == PF_L0) {
108
4/4
✓ Branch 0 taken 1045144 times.
✓ Branch 1 taken 288511 times.
✓ Branch 2 taken 505370 times.
✓ Branch 3 taken 539774 times.
1333655 return MATCH(ref_idx[0]) && MATCH_MV(mv[0]);
109
1/2
✓ Branch 0 taken 181977 times.
✗ Branch 1 not taken.
181977 } else if (a_pf == PF_L1) {
110
4/4
✓ Branch 0 taken 174400 times.
✓ Branch 1 taken 7577 times.
✓ Branch 2 taken 105501 times.
✓ Branch 3 taken 68899 times.
181977 return MATCH(ref_idx[1]) && MATCH_MV(mv[1]);
111 }
112 }
113 1129254 return 0;
114 }
115
116 2294437 static av_always_inline void mv_scale(Mv *dst, const Mv *src, int td, int tb)
117 {
118 int tx, scale_factor;
119
120 2294437 td = av_clip_int8(td);
121 2294437 tb = av_clip_int8(tb);
122 2294437 tx = (0x4000 + abs(td / 2)) / td;
123 2294437 scale_factor = av_clip_intp2((tb * tx + 32) >> 6, 12);
124 2294437 dst->x = av_clip_int16((scale_factor * src->x + 127 +
125 2294437 (scale_factor * src->x < 0)) >> 8);
126 2294437 dst->y = av_clip_int16((scale_factor * src->y + 127 +
127 2294437 (scale_factor * src->y < 0)) >> 8);
128 2294437 }
129
130 1786330 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 1786330 int cur_lt = refPicList[X].isLongTerm[refIdxLx];
136 1786330 int col_lt = refPicList_col[listCol].isLongTerm[refidxCol];
137 int col_poc_diff, cur_poc_diff;
138
139
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 1784890 times.
1786330 if (cur_lt != col_lt) {
140 1440 mvLXCol->x = 0;
141 1440 mvLXCol->y = 0;
142 1440 return 0;
143 }
144
145 1784890 col_poc_diff = colPic - refPicList_col[listCol].list[refidxCol];
146 1784890 cur_poc_diff = poc - refPicList[X].list[refIdxLx];
147
148
5/6
✓ Branch 0 taken 1783795 times.
✓ Branch 1 taken 1095 times.
✓ Branch 2 taken 1451627 times.
✓ Branch 3 taken 332168 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1451627 times.
1784890 if (cur_lt || col_poc_diff == cur_poc_diff || !col_poc_diff) {
149 333263 mvLXCol->x = mvCol->x;
150 333263 mvLXCol->y = mvCol->y;
151 } else {
152 1451627 mv_scale(mvLXCol, mvCol, col_poc_diff, cur_poc_diff);
153 }
154 1784890 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 2231062 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 2231062 const RefPicList *refPicList = s->cur_frame->refPicList;
169
170
2/2
✓ Branch 0 taken 444732 times.
✓ Branch 1 taken 1786330 times.
2231062 if (temp_col.pred_flag == PF_INTRA)
171 444732 return 0;
172
173
2/2
✓ Branch 0 taken 210994 times.
✓ Branch 1 taken 1575336 times.
1786330 if (!(temp_col.pred_flag & PF_L0))
174 210994 return CHECK_MVSET(1);
175
2/2
✓ Branch 0 taken 748992 times.
✓ Branch 1 taken 826344 times.
1575336 else if (temp_col.pred_flag == PF_L0)
176 748992 return CHECK_MVSET(0);
177
1/2
✓ Branch 0 taken 826344 times.
✗ Branch 1 not taken.
826344 else if (temp_col.pred_flag == PF_BI) {
178 826344 int check_diffpicount = 0;
179 int i, j;
180
2/2
✓ Branch 0 taken 1652688 times.
✓ Branch 1 taken 826344 times.
2479032 for (j = 0; j < 2; j++) {
181
2/2
✓ Branch 0 taken 3539979 times.
✓ Branch 1 taken 921783 times.
4461762 for (i = 0; i < refPicList[j].nb_refs; i++) {
182
2/2
✓ Branch 0 taken 730905 times.
✓ Branch 1 taken 2809074 times.
3539979 if (refPicList[j].list[i] > s->poc) {
183 730905 check_diffpicount++;
184 730905 break;
185 }
186 }
187 }
188
2/2
✓ Branch 0 taken 237536 times.
✓ Branch 1 taken 588808 times.
826344 if (!check_diffpicount) {
189
2/2
✓ Branch 0 taken 133677 times.
✓ Branch 1 taken 103859 times.
237536 if (X==0)
190 133677 return CHECK_MVSET(0);
191 else
192 103859 return CHECK_MVSET(1);
193 } else {
194
2/2
✓ Branch 0 taken 327399 times.
✓ Branch 1 taken 261409 times.
588808 if (s->sh.collocated_list == L1)
195 327399 return CHECK_MVSET(0);
196 else
197 261409 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(s, ref, x, y))
215
216 /*
217 * 8.5.3.1.7 temporal luma motion vector prediction
218 */
219 2000681 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 2000681 int min_pu_width = sps->min_pu_width;
228 2000681 int availableFlagLXCol = 0;
229 int colPic;
230
231 2000681 const HEVCFrame *ref = s->collocated_ref;
232
233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2000681 times.
2000681 if (!ref) {
234 memset(mvLXCol, 0, sizeof(*mvLXCol));
235 return 0;
236 }
237
238 2000681 tab_mvf = ref->tab_mvf;
239 2000681 colPic = ref->poc;
240
241 //bottom right collocated motion vector
242 2000681 x = x0 + nPbW;
243 2000681 y = y0 + nPbH;
244
245
1/2
✓ Branch 0 taken 2000681 times.
✗ Branch 1 not taken.
2000681 if (tab_mvf &&
246
2/2
✓ Branch 0 taken 1434522 times.
✓ Branch 1 taken 566159 times.
2000681 (y0 >> sps->log2_ctb_size) == (y >> sps->log2_ctb_size) &&
247
2/2
✓ Branch 0 taken 1387860 times.
✓ Branch 1 taken 46662 times.
1434522 y < sps->height &&
248
2/2
✓ Branch 0 taken 1365898 times.
✓ Branch 1 taken 21962 times.
1387860 x < sps->width) {
249 1365898 x &= ~15;
250 1365898 y &= ~15;
251
2/2
✓ Branch 0 taken 1443 times.
✓ Branch 1 taken 1364455 times.
1365898 if (s->avctx->active_thread_type == FF_THREAD_FRAME)
252 1443 ff_progress_frame_await(&ref->tf, y);
253 1365898 x_pu = x >> sps->log2_min_pu_size;
254 1365898 y_pu = y >> sps->log2_min_pu_size;
255 1365898 temp_col = TAB_MVF(x_pu, y_pu);
256 1365898 availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;
257 }
258
259 // derive center collocated motion vector
260
3/4
✓ Branch 0 taken 2000681 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865164 times.
✓ Branch 3 taken 1135517 times.
2000681 if (tab_mvf && !availableFlagLXCol) {
261 865164 x = x0 + (nPbW >> 1);
262 865164 y = y0 + (nPbH >> 1);
263 865164 x &= ~15;
264 865164 y &= ~15;
265
2/2
✓ Branch 0 taken 1167 times.
✓ Branch 1 taken 863997 times.
865164 if (s->avctx->active_thread_type == FF_THREAD_FRAME)
266 1167 ff_progress_frame_await(&ref->tf, y);
267 865164 x_pu = x >> sps->log2_min_pu_size;
268 865164 y_pu = y >> sps->log2_min_pu_size;
269 865164 temp_col = TAB_MVF(x_pu, y_pu);
270 865164 availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;
271 }
272 2000681 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 6232300 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 6232300 const RefPicList *refPicList = s->cur_frame->refPicList;
297 6232300 const MvField *tab_mvf = s->cur_frame->tab_mvf;
298
299 6232300 const int min_pu_width = sps->min_pu_width;
300
301 6232300 const int cand_bottom_left = lc->na.cand_bottom_left;
302 6232300 const int cand_left = lc->na.cand_left;
303 6232300 const int cand_up_left = lc->na.cand_up_left;
304 6232300 const int cand_up = lc->na.cand_up;
305 6232300 const int cand_up_right = lc->na.cand_up_right_sap;
306
307 6232300 const int xA1 = x0 - 1;
308 6232300 const int yA1 = y0 + nPbH - 1;
309
310 6232300 const int xB1 = x0 + nPbW - 1;
311 6232300 const int yB1 = y0 - 1;
312
313 6232300 const int xB0 = x0 + nPbW;
314 6232300 const int yB0 = y0 - 1;
315
316 6232300 const int xA0 = x0 - 1;
317 6232300 const int yA0 = y0 + nPbH;
318
319 6232300 const int xB2 = x0 - 1;
320 6232300 const int yB2 = y0 - 1;
321
322 12464600 const int nb_refs = (s->sh.slice_type == HEVC_SLICE_P) ?
323
2/2
✓ Branch 0 taken 1404085 times.
✓ Branch 1 taken 4828215 times.
6232300 s->sh.nb_refs[0] : FFMIN(s->sh.nb_refs[0], s->sh.nb_refs[1]);
324
325 6232300 int zero_idx = 0;
326
327 6232300 int nb_merge_cand = 0;
328 6232300 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 6017665 times.
✓ Branch 1 taken 214635 times.
✓ Branch 2 taken 668749 times.
✓ Branch 3 taken 5348916 times.
6232300 if (!singleMCLFlag && part_idx == 1 &&
338
2/2
✓ Branch 0 taken 404624 times.
✓ Branch 1 taken 264125 times.
668749 (lc->cu.part_mode == PART_Nx2N ||
339
2/2
✓ Branch 0 taken 358427 times.
✓ Branch 1 taken 46197 times.
404624 lc->cu.part_mode == PART_nLx2N ||
340
4/4
✓ Branch 0 taken 308969 times.
✓ Branch 1 taken 49458 times.
✓ Branch 2 taken 138388 times.
✓ Branch 3 taken 5734132 times.
6230947 lc->cu.part_mode == PART_nRx2N) ||
341 5872520 is_diff_mer(pps, xA1, yA1, x0, y0)) {
342 498168 is_available_a1 = 0;
343 } else {
344
4/4
✓ Branch 0 taken 5608248 times.
✓ Branch 1 taken 125884 times.
✓ Branch 2 taken 5359477 times.
✓ Branch 3 taken 248771 times.
5734132 is_available_a1 = AVAILABLE(cand_left, A1);
345
2/2
✓ Branch 0 taken 5359477 times.
✓ Branch 1 taken 374655 times.
5734132 if (is_available_a1) {
346 5359477 mergecandlist[nb_merge_cand] = TAB_MVF_PU(A1);
347
2/2
✓ Branch 0 taken 3190394 times.
✓ Branch 1 taken 2169083 times.
5359477 if (merge_idx == 0)
348 3190394 return;
349 2169083 nb_merge_cand++;
350 }
351 }
352
353
4/4
✓ Branch 0 taken 2863314 times.
✓ Branch 1 taken 178592 times.
✓ Branch 2 taken 521112 times.
✓ Branch 3 taken 2342202 times.
3041906 if (!singleMCLFlag && part_idx == 1 &&
354
2/2
✓ Branch 0 taken 428403 times.
✓ Branch 1 taken 92709 times.
521112 (lc->cu.part_mode == PART_2NxN ||
355
2/2
✓ Branch 0 taken 412700 times.
✓ Branch 1 taken 15703 times.
428403 lc->cu.part_mode == PART_2NxnU ||
356
4/4
✓ Branch 0 taken 395605 times.
✓ Branch 1 taken 17095 times.
✓ Branch 2 taken 127861 times.
✓ Branch 3 taken 2788538 times.
3329099 lc->cu.part_mode == PART_2NxnD) ||
357 2916399 is_diff_mer(pps, xB1, yB1, x0, y0)) {
358 253368 is_available_b1 = 0;
359 } else {
360
4/4
✓ Branch 0 taken 2674777 times.
✓ Branch 1 taken 113761 times.
✓ Branch 2 taken 2548772 times.
✓ Branch 3 taken 126005 times.
2788538 is_available_b1 = AVAILABLE(cand_up, B1);
361
4/4
✓ Branch 0 taken 2548772 times.
✓ Branch 1 taken 239766 times.
✓ Branch 2 taken 1916911 times.
✓ Branch 3 taken 631861 times.
2788538 if (is_available_b1 &&
362
2/2
✓ Branch 1 taken 1596430 times.
✓ Branch 2 taken 320481 times.
1916911 !(is_available_a1 && COMPARE_MV_REFIDX(B1, A1))) {
363 2228291 mergecandlist[nb_merge_cand] = TAB_MVF_PU(B1);
364
2/2
✓ Branch 0 taken 1370501 times.
✓ Branch 1 taken 857790 times.
2228291 if (merge_idx == nb_merge_cand)
365 1370501 return;
366 857790 nb_merge_cand++;
367 }
368 }
369
370 // above right spatial merge candidate
371
2/2
✓ Branch 0 taken 1168766 times.
✓ Branch 1 taken 157724 times.
1326490 is_available_b0 = AVAILABLE(cand_up_right, B0) &&
372
4/4
✓ Branch 0 taken 1160297 times.
✓ Branch 1 taken 8469 times.
✓ Branch 2 taken 963759 times.
✓ Branch 3 taken 196538 times.
2329063 xB0 < sps->width &&
373
4/4
✓ Branch 0 taken 1326490 times.
✓ Branch 1 taken 344915 times.
✓ Branch 3 taken 909354 times.
✓ Branch 4 taken 54405 times.
4158192 PRED_BLOCK_AVAILABLE(B0) &&
374 963759 !is_diff_mer(pps, xB0, yB0, x0, y0);
375
376
4/4
✓ Branch 0 taken 909354 times.
✓ Branch 1 taken 762051 times.
✓ Branch 2 taken 856577 times.
✓ Branch 3 taken 52777 times.
1671405 if (is_available_b0 &&
377
2/2
✓ Branch 1 taken 488158 times.
✓ Branch 2 taken 368419 times.
856577 !(is_available_b1 && COMPARE_MV_REFIDX(B0, B1))) {
378 540935 mergecandlist[nb_merge_cand] = TAB_MVF_PU(B0);
379
2/2
✓ Branch 0 taken 308128 times.
✓ Branch 1 taken 232807 times.
540935 if (merge_idx == nb_merge_cand)
380 308128 return;
381 232807 nb_merge_cand++;
382 }
383
384 // left bottom spatial merge candidate
385
2/2
✓ Branch 0 taken 783869 times.
✓ Branch 1 taken 187033 times.
970902 is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
386
3/4
✓ Branch 0 taken 783869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 344150 times.
✓ Branch 3 taken 439719 times.
1567738 yA0 < sps->height &&
387
4/4
✓ Branch 0 taken 970902 times.
✓ Branch 1 taken 392375 times.
✓ Branch 3 taken 325682 times.
✓ Branch 4 taken 18468 times.
3118048 PRED_BLOCK_AVAILABLE(A0) &&
388 344150 !is_diff_mer(pps, xA0, yA0, x0, y0);
389
390
4/4
✓ Branch 0 taken 325682 times.
✓ Branch 1 taken 1037595 times.
✓ Branch 2 taken 312264 times.
✓ Branch 3 taken 13418 times.
1363277 if (is_available_a0 &&
391
2/2
✓ Branch 1 taken 132511 times.
✓ Branch 2 taken 179753 times.
312264 !(is_available_a1 && COMPARE_MV_REFIDX(A0, A1))) {
392 145929 mergecandlist[nb_merge_cand] = TAB_MVF_PU(A0);
393
2/2
✓ Branch 0 taken 80522 times.
✓ Branch 1 taken 65407 times.
145929 if (merge_idx == nb_merge_cand)
394 80522 return;
395 65407 nb_merge_cand++;
396 }
397
398 // above left spatial merge candidate
399
6/6
✓ Branch 0 taken 1150614 times.
✓ Branch 1 taken 132141 times.
✓ Branch 2 taken 1032705 times.
✓ Branch 3 taken 117909 times.
✓ Branch 4 taken 950519 times.
✓ Branch 5 taken 82186 times.
2315460 is_available_b2 = AVAILABLE(cand_up_left, B2) &&
400 1032705 !is_diff_mer(pps, xB2, yB2, x0, y0);
401
402
4/4
✓ Branch 0 taken 950519 times.
✓ Branch 1 taken 332236 times.
✓ Branch 2 taken 796456 times.
✓ Branch 3 taken 154063 times.
1282755 if (is_available_b2 &&
403
4/4
✓ Branch 1 taken 450928 times.
✓ Branch 2 taken 345528 times.
✓ Branch 3 taken 536284 times.
✓ Branch 4 taken 68707 times.
950519 !(is_available_a1 && COMPARE_MV_REFIDX(B2, A1)) &&
404
4/4
✓ Branch 1 taken 326608 times.
✓ Branch 2 taken 209676 times.
✓ Branch 3 taken 390997 times.
✓ Branch 4 taken 4318 times.
604991 !(is_available_b1 && COMPARE_MV_REFIDX(B2, B1)) &&
405 nb_merge_cand != 4) {
406 390997 mergecandlist[nb_merge_cand] = TAB_MVF_PU(B2);
407
2/2
✓ Branch 0 taken 192081 times.
✓ Branch 1 taken 198916 times.
390997 if (merge_idx == nb_merge_cand)
408 192081 return;
409 198916 nb_merge_cand++;
410 }
411
412 // temporal motion vector candidate
413
2/2
✓ Branch 0 taken 851129 times.
✓ Branch 1 taken 239545 times.
1090674 if (s->sh.slice_temporal_mvp_enabled_flag &&
414
1/2
✓ Branch 0 taken 851129 times.
✗ Branch 1 not taken.
851129 nb_merge_cand < s->sh.max_num_merge_cand) {
415 851129 Mv mv_l0_col = { 0 }, mv_l1_col = { 0 };
416 851129 int available_l0 = temporal_luma_motion_vector(s, sps, x0, y0, nPbW, nPbH,
417 0, &mv_l0_col, 0);
418 1702258 int available_l1 = (s->sh.slice_type == HEVC_SLICE_B) ?
419 759850 temporal_luma_motion_vector(s, sps, x0, y0, nPbW, nPbH,
420
2/2
✓ Branch 0 taken 759850 times.
✓ Branch 1 taken 91279 times.
851129 0, &mv_l1_col, 1) : 0;
421
422
4/4
✓ Branch 0 taken 76206 times.
✓ Branch 1 taken 774923 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 76169 times.
851129 if (available_l0 || available_l1) {
423 774960 mergecandlist[nb_merge_cand].pred_flag = available_l0 + (available_l1 << 1);
424 774960 AV_ZERO16(mergecandlist[nb_merge_cand].ref_idx);
425 774960 mergecandlist[nb_merge_cand].mv[0] = mv_l0_col;
426 774960 mergecandlist[nb_merge_cand].mv[1] = mv_l1_col;
427
428
2/2
✓ Branch 0 taken 485671 times.
✓ Branch 1 taken 289289 times.
774960 if (merge_idx == nb_merge_cand)
429 485671 return;
430 289289 nb_merge_cand++;
431 }
432 }
433
434 605003 nb_orig_merge_cand = nb_merge_cand;
435
436 // combined bi-predictive merge candidates (applies for B slices)
437
4/4
✓ Branch 0 taken 494068 times.
✓ Branch 1 taken 110935 times.
✓ Branch 2 taken 331343 times.
✓ Branch 3 taken 162725 times.
605003 if (s->sh.slice_type == HEVC_SLICE_B && nb_orig_merge_cand > 1 &&
438
1/2
✓ Branch 0 taken 331343 times.
✗ Branch 1 not taken.
331343 nb_orig_merge_cand < s->sh.max_num_merge_cand) {
439 331343 int comb_idx = 0;
440
441
1/2
✓ Branch 0 taken 699036 times.
✗ Branch 1 not taken.
699036 for (comb_idx = 0; nb_merge_cand < s->sh.max_num_merge_cand &&
442
2/2
✓ Branch 0 taken 650667 times.
✓ Branch 1 taken 48369 times.
1066729 comb_idx < nb_orig_merge_cand * (nb_orig_merge_cand - 1); comb_idx++) {
443 650667 int l0_cand_idx = l0_l1_cand_idx[comb_idx][0];
444 650667 int l1_cand_idx = l0_l1_cand_idx[comb_idx][1];
445 650667 MvField l0_cand = mergecandlist[l0_cand_idx];
446 650667 MvField l1_cand = mergecandlist[l1_cand_idx];
447
448
4/4
✓ Branch 0 taken 581736 times.
✓ Branch 1 taken 68931 times.
✓ Branch 2 taken 432651 times.
✓ Branch 3 taken 149085 times.
650667 if ((l0_cand.pred_flag & PF_L0) && (l1_cand.pred_flag & PF_L1) &&
449 432651 (refPicList[0].list[l0_cand.ref_idx[0]] !=
450
2/2
✓ Branch 0 taken 108522 times.
✓ Branch 1 taken 324129 times.
432651 refPicList[1].list[l1_cand.ref_idx[1]] ||
451
2/2
✓ Branch 0 taken 94306 times.
✓ Branch 1 taken 14216 times.
108522 AV_RN32A(&l0_cand.mv[0]) != AV_RN32A(&l1_cand.mv[1]))) {
452 418435 mergecandlist[nb_merge_cand].ref_idx[0] = l0_cand.ref_idx[0];
453 418435 mergecandlist[nb_merge_cand].ref_idx[1] = l1_cand.ref_idx[1];
454 418435 mergecandlist[nb_merge_cand].pred_flag = PF_BI;
455 418435 AV_COPY32(&mergecandlist[nb_merge_cand].mv[0], &l0_cand.mv[0]);
456 418435 AV_COPY32(&mergecandlist[nb_merge_cand].mv[1], &l1_cand.mv[1]);
457
2/2
✓ Branch 0 taken 282974 times.
✓ Branch 1 taken 135461 times.
418435 if (merge_idx == nb_merge_cand)
458 282974 return;
459 135461 nb_merge_cand++;
460 }
461 }
462 }
463
464 // append Zero motion vector candidates
465
1/2
✓ Branch 0 taken 534128 times.
✗ Branch 1 not taken.
534128 while (nb_merge_cand < s->sh.max_num_merge_cand) {
466
2/2
✓ Branch 0 taken 357802 times.
✓ Branch 1 taken 176326 times.
534128 mergecandlist[nb_merge_cand].pred_flag = PF_L0 + ((s->sh.slice_type == HEVC_SLICE_B) << 1);
467 534128 AV_ZERO32(mergecandlist[nb_merge_cand].mv + 0);
468 534128 AV_ZERO32(mergecandlist[nb_merge_cand].mv + 1);
469
2/2
✓ Branch 0 taken 485371 times.
✓ Branch 1 taken 48757 times.
534128 mergecandlist[nb_merge_cand].ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0;
470
2/2
✓ Branch 0 taken 485371 times.
✓ Branch 1 taken 48757 times.
534128 mergecandlist[nb_merge_cand].ref_idx[1] = zero_idx < nb_refs ? zero_idx : 0;
471
472
2/2
✓ Branch 0 taken 322029 times.
✓ Branch 1 taken 212099 times.
534128 if (merge_idx == nb_merge_cand)
473 322029 return;
474 212099 nb_merge_cand++;
475 212099 zero_idx++;
476 }
477 }
478
479 /*
480 * 8.5.3.1.1 Derivation process of luma Mvs for merge mode
481 */
482 6232300 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 6232300 const HEVCSPS *const sps = pps->sps;
488 6232300 const HEVCContext *const s = lc->parent;
489 6232300 int singleMCLFlag = 0;
490 6232300 int nCS = 1 << log2_cb_size;
491 MvField mergecand_list[MRG_MAX_NUM_CANDS];
492 6232300 int nPbW2 = nPbW;
493 6232300 int nPbH2 = nPbH;
494
495
4/4
✓ Branch 0 taken 326043 times.
✓ Branch 1 taken 5906257 times.
✓ Branch 2 taken 214635 times.
✓ Branch 3 taken 111408 times.
6232300 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 6232300 ff_hevc_set_neighbour_available(lc, x0, y0, nPbW, nPbH, sps->log2_ctb_size);
505 6232300 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 3507585 times.
✓ Branch 1 taken 2724715 times.
6232300 if (mergecand_list[merge_idx].pred_flag == PF_BI &&
510
2/2
✓ Branch 0 taken 124136 times.
✓ Branch 1 taken 3383449 times.
3507585 (nPbW2 + nPbH2) == 12) {
511 124136 mergecand_list[merge_idx].pred_flag = PF_L0;
512 }
513
514 6232300 *mv = mergecand_list[merge_idx];
515 6232300 }
516
517 1000874 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 1000874 const RefPicList *refPicList = s->cur_frame->refPicList;
522 1000874 const MvField *tab_mvf = s->cur_frame->tab_mvf;
523 1000874 int ref_pic_elist = refPicList[elist].list[TAB_MVF(x, y).ref_idx[elist]];
524 1000874 int ref_pic_curr = refPicList[ref_idx_curr].list[ref_idx];
525
526
2/2
✓ Branch 0 taken 842810 times.
✓ Branch 1 taken 158064 times.
1000874 if (ref_pic_elist != ref_pic_curr) {
527 842810 int poc_diff = s->poc - ref_pic_elist;
528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 842810 times.
842810 if (!poc_diff)
529 poc_diff = 1;
530 842810 mv_scale(mv, mv, poc_diff, s->poc - ref_pic_curr);
531 }
532 1000874 }
533
534 9085557 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 9085557 const MvField *tab_mvf = s->cur_frame->tab_mvf;
539 9085557 int min_pu_width = sps->min_pu_width;
540
541 9085557 const RefPicList *refPicList = s->cur_frame->refPicList;
542
543
2/2
✓ Branch 0 taken 7054480 times.
✓ Branch 1 taken 2031077 times.
9085557 if (((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) &&
544
2/2
✓ Branch 0 taken 3728989 times.
✓ Branch 1 taken 3325491 times.
7054480 refPicList[pred_flag_index].list[TAB_MVF(x, y).ref_idx[pred_flag_index]] == refPicList[ref_idx_curr].list[ref_idx]) {
545 3728989 *mv = TAB_MVF(x, y).mv[pred_flag_index];
546 3728989 return 1;
547 }
548 5356568 return 0;
549 }
550
551 1271619 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 1271619 const MvField *tab_mvf = s->cur_frame->tab_mvf;
556 1271619 int min_pu_width = sps->min_pu_width;
557
558 1271619 const RefPicList *refPicList = s->cur_frame->refPicList;
559
560
2/2
✓ Branch 0 taken 1009931 times.
✓ Branch 1 taken 261688 times.
1271619 if ((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) {
561 1009931 int currIsLongTerm = refPicList[ref_idx_curr].isLongTerm[ref_idx];
562
563 1009931 int colIsLongTerm =
564 1009931 refPicList[pred_flag_index].isLongTerm[(TAB_MVF(x, y).ref_idx[pred_flag_index])];
565
566
2/2
✓ Branch 0 taken 1005214 times.
✓ Branch 1 taken 4717 times.
1009931 if (colIsLongTerm == currIsLongTerm) {
567 1005214 *mv = TAB_MVF(x, y).mv[pred_flag_index];
568
2/2
✓ Branch 0 taken 1000874 times.
✓ Branch 1 taken 4340 times.
1005214 if (!currIsLongTerm)
569 1000874 dist_scale(s, mv, min_pu_width, x, y,
570 pred_flag_index, ref_idx_curr, ref_idx);
571 1005214 return 1;
572 }
573 }
574 266405 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 2787978 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 2787978 const HEVCSPS *const sps = pps->sps;
596 2787978 const HEVCContext *const s = lc->parent;
597 2787978 const MvField *const tab_mvf = s->cur_frame->tab_mvf;
598 2787978 int isScaledFlag_L0 = 0;
599 2787978 int availableFlagLXA0 = 1;
600 2787978 int availableFlagLXB0 = 1;
601 2787978 int numMVPCandLX = 0;
602 2787978 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 2787978 Mv mvpcand_list[2] = { { 0 } };
616 Mv mxA;
617 Mv mxB;
618 int ref_idx_curr;
619 2787978 int ref_idx = 0;
620 int pred_flag_index_l0;
621 int pred_flag_index_l1;
622
623 2787978 const int cand_bottom_left = lc->na.cand_bottom_left;
624 2787978 const int cand_left = lc->na.cand_left;
625 2787978 const int cand_up_left = lc->na.cand_up_left;
626 2787978 const int cand_up = lc->na.cand_up;
627 2787978 const int cand_up_right = lc->na.cand_up_right_sap;
628 2787978 ref_idx_curr = LX;
629 2787978 ref_idx = mv->ref_idx[LX];
630 2787978 pred_flag_index_l0 = LX;
631 2787978 pred_flag_index_l1 = !LX;
632
633 // left bottom spatial candidate
634 2787978 xA0 = x0 - 1;
635 2787978 yA0 = y0 + nPbH;
636
637
2/2
✓ Branch 0 taken 1541995 times.
✓ Branch 1 taken 407573 times.
1949568 is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
638
5/6
✓ Branch 0 taken 1949568 times.
✓ Branch 1 taken 838410 times.
✓ Branch 2 taken 1541995 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 732607 times.
✓ Branch 5 taken 809388 times.
6279541 yA0 < sps->height &&
639 1541995 PRED_BLOCK_AVAILABLE(A0);
640
641 //left spatial merge candidate
642 2787978 xA1 = x0 - 1;
643 2787978 yA1 = y0 + nPbH - 1;
644
645
4/4
✓ Branch 0 taken 2707951 times.
✓ Branch 1 taken 80027 times.
✓ Branch 2 taken 2460327 times.
✓ Branch 3 taken 247624 times.
2787978 is_available_a1 = AVAILABLE(cand_left, A1);
646
4/4
✓ Branch 0 taken 2055371 times.
✓ Branch 1 taken 732607 times.
✓ Branch 2 taken 1752359 times.
✓ Branch 3 taken 303012 times.
2787978 if (is_available_a0 || is_available_a1)
647 2484966 isScaledFlag_L0 = 1;
648
649
2/2
✓ Branch 0 taken 732607 times.
✓ Branch 1 taken 2055371 times.
2787978 if (is_available_a0) {
650
2/2
✓ Branch 1 taken 446634 times.
✓ Branch 2 taken 285973 times.
732607 if (MP_MX(A0, pred_flag_index_l0, mxA)) {
651 446634 goto b_candidates;
652 }
653
2/2
✓ Branch 1 taken 47482 times.
✓ Branch 2 taken 238491 times.
285973 if (MP_MX(A0, pred_flag_index_l1, mxA)) {
654 47482 goto b_candidates;
655 }
656 }
657
658
2/2
✓ Branch 0 taken 1981527 times.
✓ Branch 1 taken 312335 times.
2293862 if (is_available_a1) {
659
2/2
✓ Branch 1 taken 1119770 times.
✓ Branch 2 taken 861757 times.
1981527 if (MP_MX(A1, pred_flag_index_l0, mxA)) {
660 1119770 goto b_candidates;
661 }
662
2/2
✓ Branch 1 taken 113885 times.
✓ Branch 2 taken 747872 times.
861757 if (MP_MX(A1, pred_flag_index_l1, mxA)) {
663 113885 goto b_candidates;
664 }
665 }
666
667
2/2
✓ Branch 0 taken 193620 times.
✓ Branch 1 taken 866587 times.
1060207 if (is_available_a0) {
668
2/2
✓ Branch 1 taken 141578 times.
✓ Branch 2 taken 52042 times.
193620 if (MP_MX_LT(A0, pred_flag_index_l0, mxA)) {
669 141578 goto b_candidates;
670 }
671
2/2
✓ Branch 1 taken 51220 times.
✓ Branch 2 taken 822 times.
52042 if (MP_MX_LT(A0, pred_flag_index_l1, mxA)) {
672 51220 goto b_candidates;
673 }
674 }
675
676
2/2
✓ Branch 0 taken 564179 times.
✓ Branch 1 taken 303230 times.
867409 if (is_available_a1) {
677
2/2
✓ Branch 1 taken 384860 times.
✓ Branch 2 taken 179319 times.
564179 if (MP_MX_LT(A1, pred_flag_index_l0, mxA)) {
678 384860 goto b_candidates;
679 }
680
2/2
✓ Branch 1 taken 176550 times.
✓ Branch 2 taken 2769 times.
179319 if (MP_MX_LT(A1, pred_flag_index_l1, mxA)) {
681 176550 goto b_candidates;
682 }
683 }
684 305999 availableFlagLXA0 = 0;
685
686 2787978 b_candidates:
687 // B candidates
688 // above right spatial merge candidate
689 2787978 xB0 = x0 + nPbW;
690 2787978 yB0 = y0 - 1;
691
692
2/2
✓ Branch 0 taken 1827946 times.
✓ Branch 1 taken 307473 times.
2135419 is_available_b0 = AVAILABLE(cand_up_right, B0) &&
693
6/6
✓ Branch 0 taken 2135419 times.
✓ Branch 1 taken 652559 times.
✓ Branch 2 taken 1813801 times.
✓ Branch 3 taken 14145 times.
✓ Branch 4 taken 1463443 times.
✓ Branch 5 taken 350358 times.
6737198 xB0 < sps->width &&
694 1813801 PRED_BLOCK_AVAILABLE(B0);
695
696 // above spatial merge candidate
697 2787978 xB1 = x0 + nPbW - 1;
698 2787978 yB1 = y0 - 1;
699
4/4
✓ Branch 0 taken 2596699 times.
✓ Branch 1 taken 191279 times.
✓ Branch 2 taken 2368263 times.
✓ Branch 3 taken 228436 times.
2787978 is_available_b1 = AVAILABLE(cand_up, B1);
700
701 // above left spatial merge candidate
702 2787978 xB2 = x0 - 1;
703 2787978 yB2 = y0 - 1;
704
4/4
✓ Branch 0 taken 2530126 times.
✓ Branch 1 taken 257852 times.
✓ Branch 2 taken 2253880 times.
✓ Branch 3 taken 276246 times.
2787978 is_available_b2 = AVAILABLE(cand_up_left, B2);
705
706 // above right spatial merge candidate
707
2/2
✓ Branch 0 taken 1463443 times.
✓ Branch 1 taken 1324535 times.
2787978 if (is_available_b0) {
708
2/2
✓ Branch 1 taken 911597 times.
✓ Branch 2 taken 551846 times.
1463443 if (MP_MX(B0, pred_flag_index_l0, mxB)) {
709 911597 goto scalef;
710 }
711
2/2
✓ Branch 1 taken 93879 times.
✓ Branch 2 taken 457967 times.
551846 if (MP_MX(B0, pred_flag_index_l1, mxB)) {
712 93879 goto scalef;
713 }
714 }
715
716 // above spatial merge candidate
717
2/2
✓ Branch 0 taken 1407985 times.
✓ Branch 1 taken 374517 times.
1782502 if (is_available_b1) {
718
2/2
✓ Branch 1 taken 713645 times.
✓ Branch 2 taken 694340 times.
1407985 if (MP_MX(B1, pred_flag_index_l0, mxB)) {
719 713645 goto scalef;
720 }
721
2/2
✓ Branch 1 taken 71087 times.
✓ Branch 2 taken 623253 times.
694340 if (MP_MX(B1, pred_flag_index_l1, mxB)) {
722 71087 goto scalef;
723 }
724 }
725
726 // above left spatial merge candidate
727
2/2
✓ Branch 0 taken 646625 times.
✓ Branch 1 taken 351145 times.
997770 if (is_available_b2) {
728
2/2
✓ Branch 1 taken 187171 times.
✓ Branch 2 taken 459454 times.
646625 if (MP_MX(B2, pred_flag_index_l0, mxB)) {
729 187171 goto scalef;
730 }
731
2/2
✓ Branch 1 taken 23839 times.
✓ Branch 2 taken 435615 times.
459454 if (MP_MX(B2, pred_flag_index_l1, mxB)) {
732 23839 goto scalef;
733 }
734 }
735 786760 availableFlagLXB0 = 0;
736
737 2787978 scalef:
738
2/2
✓ Branch 0 taken 303012 times.
✓ Branch 1 taken 2484966 times.
2787978 if (!isScaledFlag_L0) {
739
2/2
✓ Branch 0 taken 185880 times.
✓ Branch 1 taken 117132 times.
303012 if (availableFlagLXB0) {
740 185880 availableFlagLXA0 = 1;
741 185880 mxA = mxB;
742 }
743 303012 availableFlagLXB0 = 0;
744
745 // XB0 and L1
746
2/2
✓ Branch 0 taken 139284 times.
✓ Branch 1 taken 163728 times.
303012 if (is_available_b0) {
747 139284 availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l0, mxB);
748
2/2
✓ Branch 0 taken 16174 times.
✓ Branch 1 taken 123110 times.
139284 if (!availableFlagLXB0)
749 16174 availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l1, mxB);
750 }
751
752
4/4
✓ Branch 0 taken 220439 times.
✓ Branch 1 taken 82573 times.
✓ Branch 2 taken 98352 times.
✓ Branch 3 taken 122087 times.
303012 if (is_available_b1 && !availableFlagLXB0) {
753 98352 availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l0, mxB);
754
2/2
✓ Branch 0 taken 12533 times.
✓ Branch 1 taken 85819 times.
98352 if (!availableFlagLXB0)
755 12533 availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l1, mxB);
756 }
757
758
4/4
✓ Branch 0 taken 96589 times.
✓ Branch 1 taken 206423 times.
✓ Branch 2 taken 14403 times.
✓ Branch 3 taken 82186 times.
303012 if (is_available_b2 && !availableFlagLXB0) {
759 14403 availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l0, mxB);
760
2/2
✓ Branch 0 taken 1713 times.
✓ Branch 1 taken 12690 times.
14403 if (!availableFlagLXB0)
761 1713 availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l1, mxB);
762 }
763 }
764
765
2/2
✓ Branch 0 taken 2667859 times.
✓ Branch 1 taken 120119 times.
2787978 if (availableFlagLXA0)
766 2667859 mvpcand_list[numMVPCandLX++] = mxA;
767
768
8/8
✓ Branch 0 taken 2066344 times.
✓ Branch 1 taken 721634 times.
✓ Branch 2 taken 1999455 times.
✓ Branch 3 taken 66889 times.
✓ Branch 4 taken 686918 times.
✓ Branch 5 taken 1312537 times.
✓ Branch 6 taken 132526 times.
✓ Branch 7 taken 554392 times.
2787978 if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y))
769 1511952 mvpcand_list[numMVPCandLX++] = mxB;
770
771 //temporal motion vector prediction candidate
772
6/6
✓ Branch 0 taken 1342915 times.
✓ Branch 1 taken 1445063 times.
✓ Branch 2 taken 1093422 times.
✓ Branch 3 taken 249493 times.
✓ Branch 4 taken 389702 times.
✓ Branch 5 taken 703720 times.
2787978 if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag &&
773 mvp_lx_flag == numMVPCandLX) {
774 Mv mv_col;
775 389702 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 321190 times.
✓ Branch 1 taken 68512 times.
389702 if (available_col)
779 321190 mvpcand_list[numMVPCandLX++] = mv_col;
780 }
781
782 2787978 mv->mv[LX] = mvpcand_list[mvp_lx_flag];
783 2787978 }
784