FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/hevc_mvs.c
Date: 2022-07-04 19:11:22
Exec Total Coverage
Lines: 405 409 99.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 "threadframe.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 27893447 void ff_hevc_set_neighbour_available(HEVCContext *s, int x0, int y0,
44 int nPbW, int nPbH)
45 {
46 27893447 HEVCLocalContext *lc = s->HEVClc;
47 27893447 int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size);
48 27893447 int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size);
49
50
4/4
✓ Branch 0 taken 4498697 times.
✓ Branch 1 taken 23394750 times.
✓ Branch 2 taken 3679769 times.
✓ Branch 3 taken 818928 times.
27893447 lc->na.cand_up = (lc->ctb_up_flag || y0b);
51
4/4
✓ Branch 0 taken 2299578 times.
✓ Branch 1 taken 25593869 times.
✓ Branch 2 taken 1877464 times.
✓ Branch 3 taken 422114 times.
27893447 lc->na.cand_left = (lc->ctb_left_flag || x0b);
52
8/8
✓ Branch 0 taken 5305429 times.
✓ Branch 1 taken 22588018 times.
✓ Branch 2 taken 3488915 times.
✓ Branch 3 taken 1816514 times.
✓ Branch 4 taken 25799886 times.
✓ Branch 5 taken 277047 times.
✓ Branch 6 taken 25261990 times.
✓ Branch 7 taken 537896 times.
27893447 lc->na.cand_up_left = (x0b || y0b) ? lc->na.cand_left && lc->na.cand_up : lc->ctb_up_left_flag;
53 27893447 lc->na.cand_up_right_sap =
54 27893447 (x0b + nPbW == 1 << s->ps.sps->log2_ctb_size) ?
55
6/6
✓ Branch 0 taken 5221583 times.
✓ Branch 1 taken 22671864 times.
✓ Branch 2 taken 4300121 times.
✓ Branch 3 taken 921462 times.
✓ Branch 4 taken 1469943 times.
✓ Branch 5 taken 2830178 times.
27893447 lc->ctb_up_right_flag && !y0b : lc->na.cand_up;
56 27893447 lc->na.cand_up_right =
57 27893447 lc->na.cand_up_right_sap
58
4/4
✓ Branch 0 taken 23595960 times.
✓ Branch 1 taken 4297487 times.
✓ Branch 2 taken 23475907 times.
✓ Branch 3 taken 120053 times.
27893447 && (x0 + nPbW) < lc->end_of_tiles_x;
59
2/2
✓ Branch 0 taken 22388026 times.
✓ Branch 1 taken 5505421 times.
27893447 lc->na.cand_bottom_left = ((y0 + nPbH) >= lc->end_of_tiles_y) ? 0 : lc->na.cand_left;
60 27893447 }
61
62 /*
63 * 6.4.1 Derivation process for z-scan order block availability
64 */
65 5568802 static av_always_inline int z_scan_block_avail(HEVCContext *s, int xCurr, int yCurr,
66 int xN, int yN)
67 {
68 #define MIN_TB_ADDR_ZS(x, y) \
69 s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)]
70
71 5568802 int xCurr_ctb = xCurr >> s->ps.sps->log2_ctb_size;
72 5568802 int yCurr_ctb = yCurr >> s->ps.sps->log2_ctb_size;
73 5568802 int xN_ctb = xN >> s->ps.sps->log2_ctb_size;
74 5568802 int yN_ctb = yN >> s->ps.sps->log2_ctb_size;
75
4/4
✓ Branch 0 taken 4686540 times.
✓ Branch 1 taken 882262 times.
✓ Branch 2 taken 516431 times.
✓ Branch 3 taken 4170109 times.
5568802 if( yN_ctb < yCurr_ctb || xN_ctb < xCurr_ctb )
76 1398693 return 1;
77 else {
78 4170109 int Curr = MIN_TB_ADDR_ZS((xCurr >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask,
79 (yCurr >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask);
80 4170109 int N = MIN_TB_ADDR_ZS((xN >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask,
81 (yN >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask);
82 4170109 return N <= Curr;
83 }
84 }
85
86 //check if the two luma locations belong to the same motion estimation region
87 11092635 static av_always_inline int is_diff_mer(HEVCContext *s, int xN, int yN, int xP, int yP)
88 {
89 11092635 uint8_t plevel = s->ps.pps->log2_parallel_merge_level;
90
91
2/2
✓ Branch 0 taken 755074 times.
✓ Branch 1 taken 10337561 times.
11847709 return xN >> plevel == xP >> plevel &&
92
2/2
✓ Branch 0 taken 421308 times.
✓ Branch 1 taken 333766 times.
755074 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 4411525 static av_always_inline int compare_mv_ref_idx(struct MvField A, struct MvField B)
100 {
101 4411525 int a_pf = A.pred_flag;
102 4411525 int b_pf = B.pred_flag;
103
2/2
✓ Branch 0 taken 3283177 times.
✓ Branch 1 taken 1128348 times.
4411525 if (a_pf == b_pf) {
104
2/2
✓ Branch 0 taken 1772692 times.
✓ Branch 1 taken 1510485 times.
3283177 if (a_pf == PF_BI) {
105
2/2
✓ Branch 0 taken 908246 times.
✓ Branch 1 taken 694841 times.
1603087 return MATCH(ref_idx[0]) && MATCH_MV(mv[0]) &&
106
6/6
✓ Branch 0 taken 1603087 times.
✓ Branch 1 taken 169605 times.
✓ Branch 2 taken 889136 times.
✓ Branch 3 taken 19110 times.
✓ Branch 4 taken 812646 times.
✓ Branch 5 taken 76490 times.
3375779 MATCH(ref_idx[1]) && MATCH_MV(mv[1]);
107
2/2
✓ Branch 0 taken 1328705 times.
✓ Branch 1 taken 181780 times.
1510485 } else if (a_pf == PF_L0) {
108
4/4
✓ Branch 0 taken 1040546 times.
✓ Branch 1 taken 288159 times.
✓ Branch 2 taken 503762 times.
✓ Branch 3 taken 536784 times.
1328705 return MATCH(ref_idx[0]) && MATCH_MV(mv[0]);
109
1/2
✓ Branch 0 taken 181780 times.
✗ Branch 1 not taken.
181780 } else if (a_pf == PF_L1) {
110
4/4
✓ Branch 0 taken 174209 times.
✓ Branch 1 taken 7571 times.
✓ Branch 2 taken 105363 times.
✓ Branch 3 taken 68846 times.
181780 return MATCH(ref_idx[1]) && MATCH_MV(mv[1]);
111 }
112 }
113 1128348 return 0;
114 }
115
116 2293792 static av_always_inline void mv_scale(Mv *dst, Mv *src, int td, int tb)
117 {
118 int tx, scale_factor;
119
120 2293792 td = av_clip_int8(td);
121 2293792 tb = av_clip_int8(tb);
122 2293792 tx = (0x4000 + abs(td / 2)) / td;
123 2293792 scale_factor = av_clip_intp2((tb * tx + 32) >> 6, 12);
124 2293792 dst->x = av_clip_int16((scale_factor * src->x + 127 +
125 2293792 (scale_factor * src->x < 0)) >> 8);
126 2293792 dst->y = av_clip_int16((scale_factor * src->y + 127 +
127 2293792 (scale_factor * src->y < 0)) >> 8);
128 2293792 }
129
130 1785722 static int check_mvset(Mv *mvLXCol, Mv *mvCol,
131 int colPic, int poc,
132 RefPicList *refPicList, int X, int refIdxLx,
133 RefPicList *refPicList_col, int listCol, int refidxCol)
134 {
135 1785722 int cur_lt = refPicList[X].isLongTerm[refIdxLx];
136 1785722 int col_lt = refPicList_col[listCol].isLongTerm[refidxCol];
137 int col_poc_diff, cur_poc_diff;
138
139
2/2
✓ Branch 0 taken 1407 times.
✓ Branch 1 taken 1784315 times.
1785722 if (cur_lt != col_lt) {
140 1407 mvLXCol->x = 0;
141 1407 mvLXCol->y = 0;
142 1407 return 0;
143 }
144
145 1784315 col_poc_diff = colPic - refPicList_col[listCol].list[refidxCol];
146 1784315 cur_poc_diff = poc - refPicList[X].list[refIdxLx];
147
148
5/6
✓ Branch 0 taken 1783220 times.
✓ Branch 1 taken 1095 times.
✓ Branch 2 taken 1451324 times.
✓ Branch 3 taken 331896 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1451324 times.
1784315 if (cur_lt || col_poc_diff == cur_poc_diff || !col_poc_diff) {
149 332991 mvLXCol->x = mvCol->x;
150 332991 mvLXCol->y = mvCol->y;
151 } else {
152 1451324 mv_scale(mvLXCol, mvCol, col_poc_diff, cur_poc_diff);
153 }
154 1784315 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 2230189 static int derive_temporal_colocated_mvs(HEVCContext *s, MvField temp_col,
165 int refIdxLx, Mv *mvLXCol, int X,
166 int colPic, RefPicList *refPicList_col)
167 {
168 2230189 RefPicList *refPicList = s->ref->refPicList;
169
170
2/2
✓ Branch 0 taken 444467 times.
✓ Branch 1 taken 1785722 times.
2230189 if (temp_col.pred_flag == PF_INTRA)
171 444467 return 0;
172
173
2/2
✓ Branch 0 taken 210972 times.
✓ Branch 1 taken 1574750 times.
1785722 if (!(temp_col.pred_flag & PF_L0))
174 210972 return CHECK_MVSET(1);
175
2/2
✓ Branch 0 taken 748444 times.
✓ Branch 1 taken 826306 times.
1574750 else if (temp_col.pred_flag == PF_L0)
176 748444 return CHECK_MVSET(0);
177
1/2
✓ Branch 0 taken 826306 times.
✗ Branch 1 not taken.
826306 else if (temp_col.pred_flag == PF_BI) {
178 826306 int check_diffpicount = 0;
179 int i, j;
180
2/2
✓ Branch 0 taken 1652612 times.
✓ Branch 1 taken 826306 times.
2478918 for (j = 0; j < 2; j++) {
181
2/2
✓ Branch 0 taken 3539903 times.
✓ Branch 1 taken 921745 times.
4461648 for (i = 0; i < refPicList[j].nb_refs; i++) {
182
2/2
✓ Branch 0 taken 730867 times.
✓ Branch 1 taken 2809036 times.
3539903 if (refPicList[j].list[i] > s->poc) {
183 730867 check_diffpicount++;
184 730867 break;
185 }
186 }
187 }
188
2/2
✓ Branch 0 taken 237536 times.
✓ Branch 1 taken 588770 times.
826306 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 327361 times.
✓ Branch 1 taken 261409 times.
588770 if (s->sh.collocated_list == L1)
195 327361 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) >> s->ps.sps->log2_min_pu_size), \
209 ((y ## v) >> s->ps.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 1999934 static int temporal_luma_motion_vector(HEVCContext *s, int x0, int y0,
220 int nPbW, int nPbH, int refIdxLx,
221 Mv *mvLXCol, int X)
222 {
223 MvField *tab_mvf;
224 MvField temp_col;
225 int x, y, x_pu, y_pu;
226 1999934 int min_pu_width = s->ps.sps->min_pu_width;
227 1999934 int availableFlagLXCol = 0;
228 int colPic;
229
230 1999934 HEVCFrame *ref = s->ref->collocated_ref;
231
232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1999934 times.
1999934 if (!ref) {
233 memset(mvLXCol, 0, sizeof(*mvLXCol));
234 return 0;
235 }
236
237 1999934 tab_mvf = ref->tab_mvf;
238 1999934 colPic = ref->poc;
239
240 //bottom right collocated motion vector
241 1999934 x = x0 + nPbW;
242 1999934 y = y0 + nPbH;
243
244
1/2
✓ Branch 0 taken 1999934 times.
✗ Branch 1 not taken.
1999934 if (tab_mvf &&
245
2/2
✓ Branch 0 taken 1434079 times.
✓ Branch 1 taken 565855 times.
1999934 (y0 >> s->ps.sps->log2_ctb_size) == (y >> s->ps.sps->log2_ctb_size) &&
246
2/2
✓ Branch 0 taken 1387417 times.
✓ Branch 1 taken 46662 times.
1434079 y < s->ps.sps->height &&
247
2/2
✓ Branch 0 taken 1365465 times.
✓ Branch 1 taken 21952 times.
1387417 x < s->ps.sps->width) {
248 1365465 x &= ~15;
249 1365465 y &= ~15;
250
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 1364051 times.
1365465 if (s->threads_type == FF_THREAD_FRAME)
251 1414 ff_thread_await_progress(&ref->tf, y, 0);
252 1365465 x_pu = x >> s->ps.sps->log2_min_pu_size;
253 1365465 y_pu = y >> s->ps.sps->log2_min_pu_size;
254 1365465 temp_col = TAB_MVF(x_pu, y_pu);
255 1365465 availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;
256 }
257
258 // derive center collocated motion vector
259
3/4
✓ Branch 0 taken 1999934 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 864724 times.
✓ Branch 3 taken 1135210 times.
1999934 if (tab_mvf && !availableFlagLXCol) {
260 864724 x = x0 + (nPbW >> 1);
261 864724 y = y0 + (nPbH >> 1);
262 864724 x &= ~15;
263 864724 y &= ~15;
264
2/2
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 863594 times.
864724 if (s->threads_type == FF_THREAD_FRAME)
265 1130 ff_thread_await_progress(&ref->tf, y, 0);
266 864724 x_pu = x >> s->ps.sps->log2_min_pu_size;
267 864724 y_pu = y >> s->ps.sps->log2_min_pu_size;
268 864724 temp_col = TAB_MVF(x_pu, y_pu);
269 864724 availableFlagLXCol = DERIVE_TEMPORAL_COLOCATED_MVS;
270 }
271 1999934 return availableFlagLXCol;
272 }
273
274 #define AVAILABLE(cand, v) \
275 (cand && !(TAB_MVF_PU(v).pred_flag == PF_INTRA))
276
277 #define PRED_BLOCK_AVAILABLE(v) \
278 z_scan_block_avail(s, x0, y0, x ## v, y ## v)
279
280 #define COMPARE_MV_REFIDX(a, b) \
281 compare_mv_ref_idx(TAB_MVF_PU(a), TAB_MVF_PU(b))
282
283 /*
284 * 8.5.3.1.2 Derivation process for spatial merging candidates
285 */
286 6204617 static void derive_spatial_merge_candidates(HEVCContext *s, int x0, int y0,
287 int nPbW, int nPbH,
288 int log2_cb_size,
289 int singleMCLFlag, int part_idx,
290 int merge_idx,
291 struct MvField mergecandlist[])
292 {
293 6204617 HEVCLocalContext *lc = s->HEVClc;
294 6204617 RefPicList *refPicList = s->ref->refPicList;
295 6204617 MvField *tab_mvf = s->ref->tab_mvf;
296
297 6204617 const int min_pu_width = s->ps.sps->min_pu_width;
298
299 6204617 const int cand_bottom_left = lc->na.cand_bottom_left;
300 6204617 const int cand_left = lc->na.cand_left;
301 6204617 const int cand_up_left = lc->na.cand_up_left;
302 6204617 const int cand_up = lc->na.cand_up;
303 6204617 const int cand_up_right = lc->na.cand_up_right_sap;
304
305 6204617 const int xA1 = x0 - 1;
306 6204617 const int yA1 = y0 + nPbH - 1;
307
308 6204617 const int xB1 = x0 + nPbW - 1;
309 6204617 const int yB1 = y0 - 1;
310
311 6204617 const int xB0 = x0 + nPbW;
312 6204617 const int yB0 = y0 - 1;
313
314 6204617 const int xA0 = x0 - 1;
315 6204617 const int yA0 = y0 + nPbH;
316
317 6204617 const int xB2 = x0 - 1;
318 6204617 const int yB2 = y0 - 1;
319
320 12409234 const int nb_refs = (s->sh.slice_type == HEVC_SLICE_P) ?
321
2/2
✓ Branch 0 taken 1391917 times.
✓ Branch 1 taken 4812700 times.
6204617 s->sh.nb_refs[0] : FFMIN(s->sh.nb_refs[0], s->sh.nb_refs[1]);
322
323 6204617 int zero_idx = 0;
324
325 6204617 int nb_merge_cand = 0;
326 6204617 int nb_orig_merge_cand = 0;
327
328 int is_available_a0;
329 int is_available_a1;
330 int is_available_b0;
331 int is_available_b1;
332 int is_available_b2;
333
334
335
4/4
✓ Branch 0 taken 5989982 times.
✓ Branch 1 taken 214635 times.
✓ Branch 2 taken 668386 times.
✓ Branch 3 taken 5321596 times.
6204617 if (!singleMCLFlag && part_idx == 1 &&
336
2/2
✓ Branch 0 taken 404415 times.
✓ Branch 1 taken 263971 times.
668386 (lc->cu.part_mode == PART_Nx2N ||
337
2/2
✓ Branch 0 taken 358254 times.
✓ Branch 1 taken 46161 times.
404415 lc->cu.part_mode == PART_nLx2N ||
338
4/4
✓ Branch 0 taken 308823 times.
✓ Branch 1 taken 49431 times.
✓ Branch 2 taken 138388 times.
✓ Branch 3 taken 5706666 times.
6203308 lc->cu.part_mode == PART_nRx2N) ||
339 5845054 is_diff_mer(s, xA1, yA1, x0, y0)) {
340 497951 is_available_a1 = 0;
341 } else {
342
4/4
✓ Branch 0 taken 5581324 times.
✓ Branch 1 taken 125342 times.
✓ Branch 2 taken 5333919 times.
✓ Branch 3 taken 247405 times.
5706666 is_available_a1 = AVAILABLE(cand_left, A1);
343
2/2
✓ Branch 0 taken 5333919 times.
✓ Branch 1 taken 372747 times.
5706666 if (is_available_a1) {
344 5333919 mergecandlist[nb_merge_cand] = TAB_MVF_PU(A1);
345
2/2
✓ Branch 0 taken 3169076 times.
✓ Branch 1 taken 2164843 times.
5333919 if (merge_idx == 0)
346 3169076 return;
347 2164843 nb_merge_cand++;
348 }
349 }
350
351
4/4
✓ Branch 0 taken 2856949 times.
✓ Branch 1 taken 178592 times.
✓ Branch 2 taken 520827 times.
✓ Branch 3 taken 2336122 times.
3035541 if (!singleMCLFlag && part_idx == 1 &&
352
2/2
✓ Branch 0 taken 428163 times.
✓ Branch 1 taken 92664 times.
520827 (lc->cu.part_mode == PART_2NxN ||
353
2/2
✓ Branch 0 taken 412470 times.
✓ Branch 1 taken 15693 times.
428163 lc->cu.part_mode == PART_2NxnU ||
354
4/4
✓ Branch 0 taken 395388 times.
✓ Branch 1 taken 17082 times.
✓ Branch 2 taken 127861 times.
✓ Branch 3 taken 2782241 times.
3322572 lc->cu.part_mode == PART_2NxnD) ||
355 2910102 is_diff_mer(s, xB1, yB1, x0, y0)) {
356 253300 is_available_b1 = 0;
357 } else {
358
4/4
✓ Branch 0 taken 2668626 times.
✓ Branch 1 taken 113615 times.
✓ Branch 2 taken 2543279 times.
✓ Branch 3 taken 125347 times.
2782241 is_available_b1 = AVAILABLE(cand_up, B1);
359
4/4
✓ Branch 0 taken 2543279 times.
✓ Branch 1 taken 238962 times.
✓ Branch 2 taken 1913076 times.
✓ Branch 3 taken 630203 times.
2782241 if (is_available_b1 &&
360
2/2
✓ Branch 1 taken 1593287 times.
✓ Branch 2 taken 319789 times.
1913076 !(is_available_a1 && COMPARE_MV_REFIDX(B1, A1))) {
361 2223490 mergecandlist[nb_merge_cand] = TAB_MVF_PU(B1);
362
2/2
✓ Branch 0 taken 1366680 times.
✓ Branch 1 taken 856810 times.
2223490 if (merge_idx == nb_merge_cand)
363 1366680 return;
364 856810 nb_merge_cand++;
365 }
366 }
367
368 // above right spatial merge candidate
369
2/2
✓ Branch 0 taken 1200405 times.
✓ Branch 1 taken 123988 times.
1324393 is_available_b0 = AVAILABLE(cand_up_right, B0) &&
370
4/4
✓ Branch 0 taken 1191948 times.
✓ Branch 1 taken 8457 times.
✓ Branch 2 taken 962190 times.
✓ Branch 3 taken 229758 times.
2392353 xB0 < s->ps.sps->width &&
371
4/4
✓ Branch 0 taken 1324393 times.
✓ Branch 1 taken 344468 times.
✓ Branch 3 taken 907785 times.
✓ Branch 4 taken 54405 times.
4185202 PRED_BLOCK_AVAILABLE(B0) &&
372 962190 !is_diff_mer(s, xB0, yB0, x0, y0);
373
374
4/4
✓ Branch 0 taken 907785 times.
✓ Branch 1 taken 761076 times.
✓ Branch 2 taken 855281 times.
✓ Branch 3 taken 52504 times.
1668861 if (is_available_b0 &&
375
2/2
✓ Branch 1 taken 487475 times.
✓ Branch 2 taken 367806 times.
855281 !(is_available_b1 && COMPARE_MV_REFIDX(B0, B1))) {
376 539979 mergecandlist[nb_merge_cand] = TAB_MVF_PU(B0);
377
2/2
✓ Branch 0 taken 307370 times.
✓ Branch 1 taken 232609 times.
539979 if (merge_idx == nb_merge_cand)
378 307370 return;
379 232609 nb_merge_cand++;
380 }
381
382 // left bottom spatial merge candidate
383
2/2
✓ Branch 0 taken 858526 times.
✓ Branch 1 taken 111331 times.
969857 is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
384
3/4
✓ Branch 0 taken 858526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 343768 times.
✓ Branch 3 taken 514758 times.
1717052 yA0 < s->ps.sps->height &&
385
4/4
✓ Branch 0 taken 969857 times.
✓ Branch 1 taken 391634 times.
✓ Branch 3 taken 325300 times.
✓ Branch 4 taken 18468 times.
3189874 PRED_BLOCK_AVAILABLE(A0) &&
386 343768 !is_diff_mer(s, xA0, yA0, x0, y0);
387
388
4/4
✓ Branch 0 taken 325300 times.
✓ Branch 1 taken 1036191 times.
✓ Branch 2 taken 311927 times.
✓ Branch 3 taken 13373 times.
1361491 if (is_available_a0 &&
389
2/2
✓ Branch 1 taken 132352 times.
✓ Branch 2 taken 179575 times.
311927 !(is_available_a1 && COMPARE_MV_REFIDX(A0, A1))) {
390 145725 mergecandlist[nb_merge_cand] = TAB_MVF_PU(A0);
391
2/2
✓ Branch 0 taken 80361 times.
✓ Branch 1 taken 65364 times.
145725 if (merge_idx == nb_merge_cand)
392 80361 return;
393 65364 nb_merge_cand++;
394 }
395
396 // above left spatial merge candidate
397
6/6
✓ Branch 0 taken 1149165 times.
✓ Branch 1 taken 131965 times.
✓ Branch 2 taken 1031521 times.
✓ Branch 3 taken 117644 times.
✓ Branch 4 taken 949335 times.
✓ Branch 5 taken 82186 times.
2312651 is_available_b2 = AVAILABLE(cand_up_left, B2) &&
398 1031521 !is_diff_mer(s, xB2, yB2, x0, y0);
399
400
4/4
✓ Branch 0 taken 949335 times.
✓ Branch 1 taken 331795 times.
✓ Branch 2 taken 795520 times.
✓ Branch 3 taken 153815 times.
1281130 if (is_available_b2 &&
401
4/4
✓ Branch 1 taken 450426 times.
✓ Branch 2 taken 345094 times.
✓ Branch 3 taken 535721 times.
✓ Branch 4 taken 68520 times.
949335 !(is_available_a1 && COMPARE_MV_REFIDX(B2, A1)) &&
402
4/4
✓ Branch 1 taken 326214 times.
✓ Branch 2 taken 209507 times.
✓ Branch 3 taken 390417 times.
✓ Branch 4 taken 4317 times.
604241 !(is_available_b1 && COMPARE_MV_REFIDX(B2, B1)) &&
403 nb_merge_cand != 4) {
404 390417 mergecandlist[nb_merge_cand] = TAB_MVF_PU(B2);
405
2/2
✓ Branch 0 taken 191619 times.
✓ Branch 1 taken 198798 times.
390417 if (merge_idx == nb_merge_cand)
406 191619 return;
407 198798 nb_merge_cand++;
408 }
409
410 // temporal motion vector candidate
411
2/2
✓ Branch 0 taken 850638 times.
✓ Branch 1 taken 238873 times.
1089511 if (s->sh.slice_temporal_mvp_enabled_flag &&
412
1/2
✓ Branch 0 taken 850638 times.
✗ Branch 1 not taken.
850638 nb_merge_cand < s->sh.max_num_merge_cand) {
413 850638 Mv mv_l0_col = { 0 }, mv_l1_col = { 0 };
414 850638 int available_l0 = temporal_luma_motion_vector(s, x0, y0, nPbW, nPbH,
415 0, &mv_l0_col, 0);
416 1701276 int available_l1 = (s->sh.slice_type == HEVC_SLICE_B) ?
417 759738 temporal_luma_motion_vector(s, x0, y0, nPbW, nPbH,
418
2/2
✓ Branch 0 taken 759738 times.
✓ Branch 1 taken 90900 times.
850638 0, &mv_l1_col, 1) : 0;
419
420
4/4
✓ Branch 0 taken 76075 times.
✓ Branch 1 taken 774563 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 76038 times.
850638 if (available_l0 || available_l1) {
421 774600 mergecandlist[nb_merge_cand].pred_flag = available_l0 + (available_l1 << 1);
422 774600 AV_ZERO16(mergecandlist[nb_merge_cand].ref_idx);
423 774600 mergecandlist[nb_merge_cand].mv[0] = mv_l0_col;
424 774600 mergecandlist[nb_merge_cand].mv[1] = mv_l1_col;
425
426
2/2
✓ Branch 0 taken 485409 times.
✓ Branch 1 taken 289191 times.
774600 if (merge_idx == nb_merge_cand)
427 485409 return;
428 289191 nb_merge_cand++;
429 }
430 }
431
432 604102 nb_orig_merge_cand = nb_merge_cand;
433
434 // combined bi-predictive merge candidates (applies for B slices)
435
4/4
✓ Branch 0 taken 493829 times.
✓ Branch 1 taken 110273 times.
✓ Branch 2 taken 331237 times.
✓ Branch 3 taken 162592 times.
604102 if (s->sh.slice_type == HEVC_SLICE_B && nb_orig_merge_cand > 1 &&
436
1/2
✓ Branch 0 taken 331237 times.
✗ Branch 1 not taken.
331237 nb_orig_merge_cand < s->sh.max_num_merge_cand) {
437 331237 int comb_idx = 0;
438
439
1/2
✓ Branch 0 taken 698876 times.
✗ Branch 1 not taken.
698876 for (comb_idx = 0; nb_merge_cand < s->sh.max_num_merge_cand &&
440
2/2
✓ Branch 0 taken 650515 times.
✓ Branch 1 taken 48361 times.
1066515 comb_idx < nb_orig_merge_cand * (nb_orig_merge_cand - 1); comb_idx++) {
441 650515 int l0_cand_idx = l0_l1_cand_idx[comb_idx][0];
442 650515 int l1_cand_idx = l0_l1_cand_idx[comb_idx][1];
443 650515 MvField l0_cand = mergecandlist[l0_cand_idx];
444 650515 MvField l1_cand = mergecandlist[l1_cand_idx];
445
446
4/4
✓ Branch 0 taken 581613 times.
✓ Branch 1 taken 68902 times.
✓ Branch 2 taken 432547 times.
✓ Branch 3 taken 149066 times.
650515 if ((l0_cand.pred_flag & PF_L0) && (l1_cand.pred_flag & PF_L1) &&
447 432547 (refPicList[0].list[l0_cand.ref_idx[0]] !=
448
2/2
✓ Branch 0 taken 108522 times.
✓ Branch 1 taken 324025 times.
432547 refPicList[1].list[l1_cand.ref_idx[1]] ||
449
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]))) {
450 418331 mergecandlist[nb_merge_cand].ref_idx[0] = l0_cand.ref_idx[0];
451 418331 mergecandlist[nb_merge_cand].ref_idx[1] = l1_cand.ref_idx[1];
452 418331 mergecandlist[nb_merge_cand].pred_flag = PF_BI;
453 418331 AV_COPY32(&mergecandlist[nb_merge_cand].mv[0], &l0_cand.mv[0]);
454 418331 AV_COPY32(&mergecandlist[nb_merge_cand].mv[1], &l1_cand.mv[1]);
455
2/2
✓ Branch 0 taken 282876 times.
✓ Branch 1 taken 135455 times.
418331 if (merge_idx == nb_merge_cand)
456 282876 return;
457 135455 nb_merge_cand++;
458 }
459 }
460 }
461
462 // append Zero motion vector candidates
463
1/2
✓ Branch 0 taken 533292 times.
✗ Branch 1 not taken.
533292 while (nb_merge_cand < s->sh.max_num_merge_cand) {
464
2/2
✓ Branch 0 taken 357659 times.
✓ Branch 1 taken 175633 times.
533292 mergecandlist[nb_merge_cand].pred_flag = PF_L0 + ((s->sh.slice_type == HEVC_SLICE_B) << 1);
465 533292 AV_ZERO32(mergecandlist[nb_merge_cand].mv + 0);
466 533292 AV_ZERO32(mergecandlist[nb_merge_cand].mv + 1);
467
2/2
✓ Branch 0 taken 484536 times.
✓ Branch 1 taken 48756 times.
533292 mergecandlist[nb_merge_cand].ref_idx[0] = zero_idx < nb_refs ? zero_idx : 0;
468
2/2
✓ Branch 0 taken 484536 times.
✓ Branch 1 taken 48756 times.
533292 mergecandlist[nb_merge_cand].ref_idx[1] = zero_idx < nb_refs ? zero_idx : 0;
469
470
2/2
✓ Branch 0 taken 321226 times.
✓ Branch 1 taken 212066 times.
533292 if (merge_idx == nb_merge_cand)
471 321226 return;
472 212066 nb_merge_cand++;
473 212066 zero_idx++;
474 }
475 }
476
477 /*
478 * 8.5.3.1.1 Derivation process of luma Mvs for merge mode
479 */
480 6204617 void ff_hevc_luma_mv_merge_mode(HEVCContext *s, int x0, int y0, int nPbW,
481 int nPbH, int log2_cb_size, int part_idx,
482 int merge_idx, MvField *mv)
483 {
484 6204617 int singleMCLFlag = 0;
485 6204617 int nCS = 1 << log2_cb_size;
486 MvField mergecand_list[MRG_MAX_NUM_CANDS];
487 6204617 int nPbW2 = nPbW;
488 6204617 int nPbH2 = nPbH;
489 6204617 HEVCLocalContext *lc = s->HEVClc;
490
491
4/4
✓ Branch 0 taken 326043 times.
✓ Branch 1 taken 5878574 times.
✓ Branch 2 taken 214635 times.
✓ Branch 3 taken 111408 times.
6204617 if (s->ps.pps->log2_parallel_merge_level > 2 && nCS == 8) {
492 214635 singleMCLFlag = 1;
493 214635 x0 = lc->cu.x;
494 214635 y0 = lc->cu.y;
495 214635 nPbW = nCS;
496 214635 nPbH = nCS;
497 214635 part_idx = 0;
498 }
499
500 6204617 ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH);
501 6204617 derive_spatial_merge_candidates(s, x0, y0, nPbW, nPbH, log2_cb_size,
502 singleMCLFlag, part_idx,
503 merge_idx, mergecand_list);
504
505
2/2
✓ Branch 0 taken 3501583 times.
✓ Branch 1 taken 2703034 times.
6204617 if (mergecand_list[merge_idx].pred_flag == PF_BI &&
506
2/2
✓ Branch 0 taken 124136 times.
✓ Branch 1 taken 3377447 times.
3501583 (nPbW2 + nPbH2) == 12) {
507 124136 mergecand_list[merge_idx].pred_flag = PF_L0;
508 }
509
510 6204617 *mv = mergecand_list[merge_idx];
511 6204617 }
512
513 1000001 static av_always_inline void dist_scale(HEVCContext *s, Mv *mv,
514 int min_pu_width, int x, int y,
515 int elist, int ref_idx_curr, int ref_idx)
516 {
517 1000001 RefPicList *refPicList = s->ref->refPicList;
518 1000001 MvField *tab_mvf = s->ref->tab_mvf;
519 1000001 int ref_pic_elist = refPicList[elist].list[TAB_MVF(x, y).ref_idx[elist]];
520 1000001 int ref_pic_curr = refPicList[ref_idx_curr].list[ref_idx];
521
522
2/2
✓ Branch 0 taken 842468 times.
✓ Branch 1 taken 157533 times.
1000001 if (ref_pic_elist != ref_pic_curr) {
523 842468 int poc_diff = s->poc - ref_pic_elist;
524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 842468 times.
842468 if (!poc_diff)
525 poc_diff = 1;
526 842468 mv_scale(mv, mv, poc_diff, s->poc - ref_pic_curr);
527 }
528 1000001 }
529
530 9075896 static int mv_mp_mode_mx(HEVCContext *s, int x, int y, int pred_flag_index,
531 Mv *mv, int ref_idx_curr, int ref_idx)
532 {
533 9075896 MvField *tab_mvf = s->ref->tab_mvf;
534 9075896 int min_pu_width = s->ps.sps->min_pu_width;
535
536 9075896 RefPicList *refPicList = s->ref->refPicList;
537
538
2/2
✓ Branch 0 taken 7045871 times.
✓ Branch 1 taken 2030025 times.
9075896 if (((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) &&
539
2/2
✓ Branch 0 taken 3721492 times.
✓ Branch 1 taken 3324379 times.
7045871 refPicList[pred_flag_index].list[TAB_MVF(x, y).ref_idx[pred_flag_index]] == refPicList[ref_idx_curr].list[ref_idx]) {
540 3721492 *mv = TAB_MVF(x, y).mv[pred_flag_index];
541 3721492 return 1;
542 }
543 5354404 return 0;
544 }
545
546 1270631 static int mv_mp_mode_mx_lt(HEVCContext *s, int x, int y, int pred_flag_index,
547 Mv *mv, int ref_idx_curr, int ref_idx)
548 {
549 1270631 MvField *tab_mvf = s->ref->tab_mvf;
550 1270631 int min_pu_width = s->ps.sps->min_pu_width;
551
552 1270631 RefPicList *refPicList = s->ref->refPicList;
553
554
2/2
✓ Branch 0 taken 1009037 times.
✓ Branch 1 taken 261594 times.
1270631 if ((TAB_MVF(x, y).pred_flag) & (1 << pred_flag_index)) {
555 1009037 int currIsLongTerm = refPicList[ref_idx_curr].isLongTerm[ref_idx];
556
557 1009037 int colIsLongTerm =
558 1009037 refPicList[pred_flag_index].isLongTerm[(TAB_MVF(x, y).ref_idx[pred_flag_index])];
559
560
2/2
✓ Branch 0 taken 1004320 times.
✓ Branch 1 taken 4717 times.
1009037 if (colIsLongTerm == currIsLongTerm) {
561 1004320 *mv = TAB_MVF(x, y).mv[pred_flag_index];
562
2/2
✓ Branch 0 taken 1000001 times.
✓ Branch 1 taken 4319 times.
1004320 if (!currIsLongTerm)
563 1000001 dist_scale(s, mv, min_pu_width, x, y,
564 pred_flag_index, ref_idx_curr, ref_idx);
565 1004320 return 1;
566 }
567 }
568 266311 return 0;
569 }
570
571 #define MP_MX(v, pred, mx) \
572 mv_mp_mode_mx(s, \
573 (x ## v) >> s->ps.sps->log2_min_pu_size, \
574 (y ## v) >> s->ps.sps->log2_min_pu_size, \
575 pred, &mx, ref_idx_curr, ref_idx)
576
577 #define MP_MX_LT(v, pred, mx) \
578 mv_mp_mode_mx_lt(s, \
579 (x ## v) >> s->ps.sps->log2_min_pu_size, \
580 (y ## v) >> s->ps.sps->log2_min_pu_size, \
581 pred, &mx, ref_idx_curr, ref_idx)
582
583 2783351 void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
584 int nPbH, int log2_cb_size, int part_idx,
585 int merge_idx, MvField *mv,
586 int mvp_lx_flag, int LX)
587 {
588 2783351 HEVCLocalContext *lc = s->HEVClc;
589 2783351 MvField *tab_mvf = s->ref->tab_mvf;
590 2783351 int isScaledFlag_L0 = 0;
591 2783351 int availableFlagLXA0 = 1;
592 2783351 int availableFlagLXB0 = 1;
593 2783351 int numMVPCandLX = 0;
594 2783351 int min_pu_width = s->ps.sps->min_pu_width;
595
596 int xA0, yA0;
597 int is_available_a0;
598 int xA1, yA1;
599 int is_available_a1;
600 int xB0, yB0;
601 int is_available_b0;
602 int xB1, yB1;
603 int is_available_b1;
604 int xB2, yB2;
605 int is_available_b2;
606
607 2783351 Mv mvpcand_list[2] = { { 0 } };
608 Mv mxA;
609 Mv mxB;
610 int ref_idx_curr;
611 2783351 int ref_idx = 0;
612 int pred_flag_index_l0;
613 int pred_flag_index_l1;
614
615 2783351 const int cand_bottom_left = lc->na.cand_bottom_left;
616 2783351 const int cand_left = lc->na.cand_left;
617 2783351 const int cand_up_left = lc->na.cand_up_left;
618 2783351 const int cand_up = lc->na.cand_up;
619 2783351 const int cand_up_right = lc->na.cand_up_right_sap;
620 2783351 ref_idx_curr = LX;
621 2783351 ref_idx = mv->ref_idx[LX];
622 2783351 pred_flag_index_l0 = LX;
623 2783351 pred_flag_index_l1 = !LX;
624
625 // left bottom spatial candidate
626 2783351 xA0 = x0 - 1;
627 2783351 yA0 = y0 + nPbH;
628
629
2/2
✓ Branch 0 taken 1656098 times.
✓ Branch 1 taken 290933 times.
1947031 is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
630
5/6
✓ Branch 0 taken 1947031 times.
✓ Branch 1 taken 836320 times.
✓ Branch 2 taken 1656098 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 731769 times.
✓ Branch 5 taken 924329 times.
6386480 yA0 < s->ps.sps->height &&
631 1656098 PRED_BLOCK_AVAILABLE(A0);
632
633 //left spatial merge candidate
634 2783351 xA1 = x0 - 1;
635 2783351 yA1 = y0 + nPbH - 1;
636
637
4/4
✓ Branch 0 taken 2703401 times.
✓ Branch 1 taken 79950 times.
✓ Branch 2 taken 2456521 times.
✓ Branch 3 taken 246880 times.
2783351 is_available_a1 = AVAILABLE(cand_left, A1);
638
4/4
✓ Branch 0 taken 2051582 times.
✓ Branch 1 taken 731769 times.
✓ Branch 2 taken 1749328 times.
✓ Branch 3 taken 302254 times.
2783351 if (is_available_a0 || is_available_a1)
639 2481097 isScaledFlag_L0 = 1;
640
641
2/2
✓ Branch 0 taken 731769 times.
✓ Branch 1 taken 2051582 times.
2783351 if (is_available_a0) {
642
2/2
✓ Branch 1 taken 445876 times.
✓ Branch 2 taken 285893 times.
731769 if (MP_MX(A0, pred_flag_index_l0, mxA)) {
643 445876 goto b_candidates;
644 }
645
2/2
✓ Branch 1 taken 47482 times.
✓ Branch 2 taken 238411 times.
285893 if (MP_MX(A0, pred_flag_index_l1, mxA)) {
646 47482 goto b_candidates;
647 }
648 }
649
650
2/2
✓ Branch 0 taken 1978419 times.
✓ Branch 1 taken 311574 times.
2289993 if (is_available_a1) {
651
2/2
✓ Branch 1 taken 1116988 times.
✓ Branch 2 taken 861431 times.
1978419 if (MP_MX(A1, pred_flag_index_l0, mxA)) {
652 1116988 goto b_candidates;
653 }
654
2/2
✓ Branch 1 taken 113885 times.
✓ Branch 2 taken 747546 times.
861431 if (MP_MX(A1, pred_flag_index_l1, mxA)) {
655 113885 goto b_candidates;
656 }
657 }
658
659
2/2
✓ Branch 0 taken 193548 times.
✓ Branch 1 taken 865572 times.
1059120 if (is_available_a0) {
660
2/2
✓ Branch 1 taken 141520 times.
✓ Branch 2 taken 52028 times.
193548 if (MP_MX_LT(A0, pred_flag_index_l0, mxA)) {
661 141520 goto b_candidates;
662 }
663
2/2
✓ Branch 1 taken 51206 times.
✓ Branch 2 taken 822 times.
52028 if (MP_MX_LT(A0, pred_flag_index_l1, mxA)) {
664 51206 goto b_candidates;
665 }
666 }
667
668
2/2
✓ Branch 0 taken 563922 times.
✓ Branch 1 taken 302472 times.
866394 if (is_available_a1) {
669
2/2
✓ Branch 1 taken 384680 times.
✓ Branch 2 taken 179242 times.
563922 if (MP_MX_LT(A1, pred_flag_index_l0, mxA)) {
670 384680 goto b_candidates;
671 }
672
2/2
✓ Branch 1 taken 176473 times.
✓ Branch 2 taken 2769 times.
179242 if (MP_MX_LT(A1, pred_flag_index_l1, mxA)) {
673 176473 goto b_candidates;
674 }
675 }
676 305241 availableFlagLXA0 = 0;
677
678 2783351 b_candidates:
679 // B candidates
680 // above right spatial merge candidate
681 2783351 xB0 = x0 + nPbW;
682 2783351 yB0 = y0 - 1;
683
684
2/2
✓ Branch 0 taken 1876352 times.
✓ Branch 1 taken 255289 times.
2131641 is_available_b0 = AVAILABLE(cand_up_right, B0) &&
685
6/6
✓ Branch 0 taken 2131641 times.
✓ Branch 1 taken 651710 times.
✓ Branch 2 taken 1862230 times.
✓ Branch 3 taken 14122 times.
✓ Branch 4 taken 1460702 times.
✓ Branch 5 taken 401528 times.
6777222 xB0 < s->ps.sps->width &&
686 1862230 PRED_BLOCK_AVAILABLE(B0);
687
688 // above spatial merge candidate
689 2783351 xB1 = x0 + nPbW - 1;
690 2783351 yB1 = y0 - 1;
691
4/4
✓ Branch 0 taken 2592191 times.
✓ Branch 1 taken 191160 times.
✓ Branch 2 taken 2364536 times.
✓ Branch 3 taken 227655 times.
2783351 is_available_b1 = AVAILABLE(cand_up, B1);
692
693 // above left spatial merge candidate
694 2783351 xB2 = x0 - 1;
695 2783351 yB2 = y0 - 1;
696
4/4
✓ Branch 0 taken 2525689 times.
✓ Branch 1 taken 257662 times.
✓ Branch 2 taken 2250242 times.
✓ Branch 3 taken 275447 times.
2783351 is_available_b2 = AVAILABLE(cand_up_left, B2);
697
698 // above right spatial merge candidate
699
2/2
✓ Branch 0 taken 1460702 times.
✓ Branch 1 taken 1322649 times.
2783351 if (is_available_b0) {
700
2/2
✓ Branch 1 taken 909090 times.
✓ Branch 2 taken 551612 times.
1460702 if (MP_MX(B0, pred_flag_index_l0, mxB)) {
701 909090 goto scalef;
702 }
703
2/2
✓ Branch 1 taken 93879 times.
✓ Branch 2 taken 457733 times.
551612 if (MP_MX(B0, pred_flag_index_l1, mxB)) {
704 93879 goto scalef;
705 }
706 }
707
708 // above spatial merge candidate
709
2/2
✓ Branch 0 taken 1406546 times.
✓ Branch 1 taken 373836 times.
1780382 if (is_available_b1) {
710
2/2
✓ Branch 1 taken 712458 times.
✓ Branch 2 taken 694088 times.
1406546 if (MP_MX(B1, pred_flag_index_l0, mxB)) {
711 712458 goto scalef;
712 }
713
2/2
✓ Branch 1 taken 71087 times.
✓ Branch 2 taken 623001 times.
694088 if (MP_MX(B1, pred_flag_index_l1, mxB)) {
714 71087 goto scalef;
715 }
716 }
717
718 // above left spatial merge candidate
719
2/2
✓ Branch 0 taken 646172 times.
✓ Branch 1 taken 350665 times.
996837 if (is_available_b2) {
720
2/2
✓ Branch 1 taken 186908 times.
✓ Branch 2 taken 459264 times.
646172 if (MP_MX(B2, pred_flag_index_l0, mxB)) {
721 186908 goto scalef;
722 }
723
2/2
✓ Branch 1 taken 23839 times.
✓ Branch 2 taken 435425 times.
459264 if (MP_MX(B2, pred_flag_index_l1, mxB)) {
724 23839 goto scalef;
725 }
726 }
727 786090 availableFlagLXB0 = 0;
728
729 2783351 scalef:
730
2/2
✓ Branch 0 taken 302254 times.
✓ Branch 1 taken 2481097 times.
2783351 if (!isScaledFlag_L0) {
731
2/2
✓ Branch 0 taken 185324 times.
✓ Branch 1 taken 116930 times.
302254 if (availableFlagLXB0) {
732 185324 availableFlagLXA0 = 1;
733 185324 mxA = mxB;
734 }
735 302254 availableFlagLXB0 = 0;
736
737 // XB0 and L1
738
2/2
✓ Branch 0 taken 138981 times.
✓ Branch 1 taken 163273 times.
302254 if (is_available_b0) {
739 138981 availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l0, mxB);
740
2/2
✓ Branch 0 taken 16172 times.
✓ Branch 1 taken 122809 times.
138981 if (!availableFlagLXB0)
741 16172 availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l1, mxB);
742 }
743
744
4/4
✓ Branch 0 taken 219998 times.
✓ Branch 1 taken 82256 times.
✓ Branch 2 taken 98140 times.
✓ Branch 3 taken 121858 times.
302254 if (is_available_b1 && !availableFlagLXB0) {
745 98140 availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l0, mxB);
746
2/2
✓ Branch 0 taken 12532 times.
✓ Branch 1 taken 85608 times.
98140 if (!availableFlagLXB0)
747 12532 availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l1, mxB);
748 }
749
750
4/4
✓ Branch 0 taken 96302 times.
✓ Branch 1 taken 205952 times.
✓ Branch 2 taken 14353 times.
✓ Branch 3 taken 81949 times.
302254 if (is_available_b2 && !availableFlagLXB0) {
751 14353 availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l0, mxB);
752
2/2
✓ Branch 0 taken 1713 times.
✓ Branch 1 taken 12640 times.
14353 if (!availableFlagLXB0)
753 1713 availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l1, mxB);
754 }
755 }
756
757
2/2
✓ Branch 0 taken 2663434 times.
✓ Branch 1 taken 119917 times.
2783351 if (availableFlagLXA0)
758 2663434 mvpcand_list[numMVPCandLX++] = mxA;
759
760
8/8
✓ Branch 0 taken 2062378 times.
✓ Branch 1 taken 720973 times.
✓ Branch 2 taken 1995498 times.
✓ Branch 3 taken 66880 times.
✓ Branch 4 taken 685113 times.
✓ Branch 5 taken 1310385 times.
✓ Branch 6 taken 132306 times.
✓ Branch 7 taken 552807 times.
2783351 if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y))
761 1509571 mvpcand_list[numMVPCandLX++] = mxB;
762
763 //temporal motion vector prediction candidate
764
6/6
✓ Branch 0 taken 1340660 times.
✓ Branch 1 taken 1442691 times.
✓ Branch 2 taken 1092757 times.
✓ Branch 3 taken 247903 times.
✓ Branch 4 taken 389558 times.
✓ Branch 5 taken 703199 times.
2783351 if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag &&
765 mvp_lx_flag == numMVPCandLX) {
766 Mv mv_col;
767 389558 int available_col = temporal_luma_motion_vector(s, x0, y0, nPbW,
768 nPbH, ref_idx,
769 &mv_col, LX);
770
2/2
✓ Branch 0 taken 321087 times.
✓ Branch 1 taken 68471 times.
389558 if (available_col)
771 321087 mvpcand_list[numMVPCandLX++] = mv_col;
772 }
773
774 2783351 mv->mv[LX] = mvpcand_list[mvp_lx_flag];
775 2783351 }
776