Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * H.26L/H.264/AVC/JVT/14496-10/... motion vector prediction | ||
3 | * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at> | ||
4 | * | ||
5 | * This file is part of FFmpeg. | ||
6 | * | ||
7 | * FFmpeg is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * FFmpeg is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with FFmpeg; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * @file | ||
24 | * H.264 / AVC / MPEG-4 part10 motion vector prediction. | ||
25 | * @author Michael Niedermayer <michaelni@gmx.at> | ||
26 | */ | ||
27 | |||
28 | #ifndef AVCODEC_H264_MVPRED_H | ||
29 | #define AVCODEC_H264_MVPRED_H | ||
30 | |||
31 | #include "h264dec.h" | ||
32 | #include "mpegutils.h" | ||
33 | #include "rectangle.h" | ||
34 | |||
35 | #include "libavutil/avassert.h" | ||
36 | #include "libavutil/mem_internal.h" | ||
37 | |||
38 | |||
39 | /** | ||
40 | * Get the predicted intra4x4 prediction mode. | ||
41 | */ | ||
42 | 30581136 | static av_always_inline int pred_intra_mode(const H264Context *h, | |
43 | H264SliceContext *sl, int n) | ||
44 | { | ||
45 | 30581136 | const int index8 = scan8[n]; | |
46 | 30581136 | const int left = sl->intra4x4_pred_mode_cache[index8 - 1]; | |
47 | 30581136 | const int top = sl->intra4x4_pred_mode_cache[index8 - 8]; | |
48 | 30581136 | const int min = FFMIN(left, top); | |
49 | |||
50 | ff_tlog(h->avctx, "mode:%d %d min:%d\n", left, top, min); | ||
51 | |||
52 |
2/2✓ Branch 0 taken 857516 times.
✓ Branch 1 taken 29723620 times.
|
30581136 | if (min < 0) |
53 | 857516 | return DC_PRED; | |
54 | else | ||
55 | 29723620 | return min; | |
56 | } | ||
57 | |||
58 | 3064023 | static av_always_inline void write_back_intra_pred_mode(const H264Context *h, | |
59 | H264SliceContext *sl) | ||
60 | { | ||
61 | 3064023 | int8_t *i4x4 = sl->intra4x4_pred_mode + h->mb2br_xy[sl->mb_xy]; | |
62 | 3064023 | int8_t *i4x4_cache = sl->intra4x4_pred_mode_cache; | |
63 | |||
64 | 3064023 | AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4); | |
65 | 3064023 | i4x4[4] = i4x4_cache[7 + 8 * 3]; | |
66 | 3064023 | i4x4[5] = i4x4_cache[7 + 8 * 2]; | |
67 | 3064023 | i4x4[6] = i4x4_cache[7 + 8 * 1]; | |
68 | 3064023 | } | |
69 | |||
70 | 10871085 | static av_always_inline void write_back_non_zero_count(const H264Context *h, | |
71 | H264SliceContext *sl) | ||
72 | { | ||
73 | 10871085 | const int mb_xy = sl->mb_xy; | |
74 | 10871085 | uint8_t *nnz = h->non_zero_count[mb_xy]; | |
75 | 10871085 | uint8_t *nnz_cache = sl->non_zero_count_cache; | |
76 | |||
77 | 10871085 | AV_COPY32(&nnz[ 0], &nnz_cache[4 + 8 * 1]); | |
78 | 10871085 | AV_COPY32(&nnz[ 4], &nnz_cache[4 + 8 * 2]); | |
79 | 10871085 | AV_COPY32(&nnz[ 8], &nnz_cache[4 + 8 * 3]); | |
80 | 10871085 | AV_COPY32(&nnz[12], &nnz_cache[4 + 8 * 4]); | |
81 | 10871085 | AV_COPY32(&nnz[16], &nnz_cache[4 + 8 * 6]); | |
82 | 10871085 | AV_COPY32(&nnz[20], &nnz_cache[4 + 8 * 7]); | |
83 | 10871085 | AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]); | |
84 | 10871085 | AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]); | |
85 | |||
86 |
2/2✓ Branch 0 taken 971539 times.
✓ Branch 1 taken 9899546 times.
|
10871085 | if (!h->chroma_y_shift) { |
87 | 971539 | AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]); | |
88 | 971539 | AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]); | |
89 | 971539 | AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]); | |
90 | 971539 | AV_COPY32(&nnz[44], &nnz_cache[4 + 8 * 14]); | |
91 | } | ||
92 | 10871085 | } | |
93 | |||
94 | 14819762 | static av_always_inline void write_back_motion_list(const H264Context *h, | |
95 | H264SliceContext *sl, | ||
96 | int b_stride, | ||
97 | int b_xy, int b8_xy, | ||
98 | int mb_type, int list) | ||
99 | { | ||
100 | 14819762 | int16_t(*mv_dst)[2] = &h->cur_pic.motion_val[list][b_xy]; | |
101 | 14819762 | int16_t(*mv_src)[2] = &sl->mv_cache[list][scan8[0]]; | |
102 | 14819762 | AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0); | |
103 | 14819762 | AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1); | |
104 | 14819762 | AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2); | |
105 | 14819762 | AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3); | |
106 | if (CABAC(h)) { | ||
107 | 10785349 | uint8_t (*mvd_dst)[2] = &sl->mvd_table[list][FMO ? 8 * sl->mb_xy | |
108 | 10785349 | : h->mb2br_xy[sl->mb_xy]]; | |
109 | 10785349 | uint8_t(*mvd_src)[2] = &sl->mvd_cache[list][scan8[0]]; | |
110 |
2/2✓ Branch 0 taken 5003672 times.
✓ Branch 1 taken 5781677 times.
|
10785349 | if (IS_SKIP(mb_type)) { |
111 | 5003672 | AV_ZERO128(mvd_dst); | |
112 | } else { | ||
113 | 5781677 | AV_COPY64(mvd_dst, mvd_src + 8 * 3); | |
114 | 5781677 | AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8 * 0); | |
115 | 5781677 | AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8 * 1); | |
116 | 5781677 | AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8 * 2); | |
117 | } | ||
118 | } | ||
119 | |||
120 | { | ||
121 | 14819762 | int8_t *ref_index = &h->cur_pic.ref_index[list][b8_xy]; | |
122 | 14819762 | int8_t *ref_cache = sl->ref_cache[list]; | |
123 | 14819762 | ref_index[0 + 0 * 2] = ref_cache[scan8[0]]; | |
124 | 14819762 | ref_index[1 + 0 * 2] = ref_cache[scan8[4]]; | |
125 | 14819762 | ref_index[0 + 1 * 2] = ref_cache[scan8[8]]; | |
126 | 14819762 | ref_index[1 + 1 * 2] = ref_cache[scan8[12]]; | |
127 | } | ||
128 | 14819762 | } | |
129 | |||
130 | 11041143 | static av_always_inline void write_back_motion(const H264Context *h, | |
131 | H264SliceContext *sl, | ||
132 | int mb_type) | ||
133 | { | ||
134 | 11041143 | const int b_stride = h->b_stride; | |
135 | 11041143 | const int b_xy = 4 * sl->mb_x + 4 * sl->mb_y * h->b_stride; // try mb2b(8)_xy | |
136 | 11041143 | const int b8_xy = 4 * sl->mb_xy; | |
137 | |||
138 |
2/2✓ Branch 0 taken 10231064 times.
✓ Branch 1 taken 810079 times.
|
11041143 | if (USES_LIST(mb_type, 0)) { |
139 | 10231064 | write_back_motion_list(h, sl, b_stride, b_xy, b8_xy, mb_type, 0); | |
140 | } else { | ||
141 | 810079 | fill_rectangle(&h->cur_pic.ref_index[0][b8_xy], | |
142 | 2, 2, 2, (uint8_t)LIST_NOT_USED, 1); | ||
143 | } | ||
144 |
2/2✓ Branch 0 taken 4588698 times.
✓ Branch 1 taken 6452445 times.
|
11041143 | if (USES_LIST(mb_type, 1)) |
145 | 4588698 | write_back_motion_list(h, sl, b_stride, b_xy, b8_xy, mb_type, 1); | |
146 | |||
147 |
2/2✓ Branch 0 taken 4539128 times.
✓ Branch 1 taken 3147890 times.
|
7687018 | if (sl->slice_type_nos == AV_PICTURE_TYPE_B && CABAC(h)) { |
148 |
2/2✓ Branch 0 taken 423281 times.
✓ Branch 1 taken 4115847 times.
|
4539128 | if (IS_8X8(mb_type)) { |
149 | 423281 | uint8_t *direct_table = &h->direct_table[4 * sl->mb_xy]; | |
150 | 423281 | direct_table[1] = sl->sub_mb_type[1] >> 1; | |
151 | 423281 | direct_table[2] = sl->sub_mb_type[2] >> 1; | |
152 | 423281 | direct_table[3] = sl->sub_mb_type[3] >> 1; | |
153 | } | ||
154 | } | ||
155 | 11041143 | } | |
156 | |||
157 | 295507 | static av_always_inline int get_dct8x8_allowed(const H264Context *h, H264SliceContext *sl) | |
158 | { | ||
159 |
2/2✓ Branch 0 taken 290630 times.
✓ Branch 1 taken 4877 times.
|
295507 | if (h->ps.sps->direct_8x8_inference_flag) |
160 | 290630 | return !(AV_RN64A(sl->sub_mb_type) & | |
161 | ((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8) * | ||
162 | 0x0001000100010001ULL)); | ||
163 | else | ||
164 | 4877 | return !(AV_RN64A(sl->sub_mb_type) & | |
165 | ((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8 | MB_TYPE_DIRECT2) * | ||
166 | 0x0001000100010001ULL)); | ||
167 | } | ||
168 | |||
169 | 18375920 | static av_always_inline int fetch_diagonal_mv(const H264Context *h, H264SliceContext *sl, | |
170 | const int16_t **C, | ||
171 | int i, int list, int part_width) | ||
172 | { | ||
173 | 18375920 | const int topright_ref = sl->ref_cache[list][i - 8 + part_width]; | |
174 | |||
175 | /* there is no consistent mapping of mvs to neighboring locations that will | ||
176 | * make mbaff happy, so we can't move all this logic to fill_caches */ | ||
177 |
2/2✓ Branch 0 taken 2971673 times.
✓ Branch 1 taken 15404247 times.
|
18375920 | if (FRAME_MBAFF(h)) { |
178 | #define SET_DIAG_MV(MV_OP, REF_OP, XY, Y4) \ | ||
179 | const int xy = XY, y4 = Y4; \ | ||
180 | const int mb_type = mb_types[xy + (y4 >> 2) * h->mb_stride]; \ | ||
181 | if (!USES_LIST(mb_type, list)) \ | ||
182 | return LIST_NOT_USED; \ | ||
183 | mv = h->cur_pic_ptr->motion_val[list][h->mb2b_xy[xy] + 3 + y4 * h->b_stride]; \ | ||
184 | sl->mv_cache[list][scan8[0] - 2][0] = mv[0]; \ | ||
185 | sl->mv_cache[list][scan8[0] - 2][1] = mv[1] MV_OP; \ | ||
186 | return h->cur_pic_ptr->ref_index[list][4 * xy + 1 + (y4 & ~1)] REF_OP; | ||
187 | |||
188 |
2/2✓ Branch 0 taken 1302510 times.
✓ Branch 1 taken 1669163 times.
|
2971673 | if (topright_ref == PART_NOT_AVAILABLE |
189 |
4/4✓ Branch 0 taken 807187 times.
✓ Branch 1 taken 495323 times.
✓ Branch 2 taken 199035 times.
✓ Branch 3 taken 608152 times.
|
1302510 | && i >= scan8[0] + 8 && (i & 7) == 4 |
190 |
2/2✓ Branch 0 taken 190862 times.
✓ Branch 1 taken 8173 times.
|
199035 | && sl->ref_cache[list][scan8[0] - 1] != PART_NOT_AVAILABLE) { |
191 | 190862 | const uint32_t *mb_types = h->cur_pic_ptr->mb_type; | |
192 | const int16_t *mv; | ||
193 | 190862 | AV_ZERO32(sl->mv_cache[list][scan8[0] - 2]); | |
194 | 190862 | *C = sl->mv_cache[list][scan8[0] - 2]; | |
195 | |||
196 |
4/4✓ Branch 0 taken 94066 times.
✓ Branch 1 taken 96796 times.
✓ Branch 2 taken 26751 times.
✓ Branch 3 taken 67315 times.
|
190862 | if (!MB_FIELD(sl) && IS_INTERLACED(sl->left_type[0])) { |
197 |
2/2✓ Branch 0 taken 2849 times.
✓ Branch 1 taken 23902 times.
|
26751 | SET_DIAG_MV(* 2, >> 1, sl->left_mb_xy[0] + h->mb_stride, |
198 | (sl->mb_y & 1) * 2 + (i >> 5)); | ||
199 | } | ||
200 |
4/4✓ Branch 0 taken 96796 times.
✓ Branch 1 taken 67315 times.
✓ Branch 2 taken 36130 times.
✓ Branch 3 taken 60666 times.
|
164111 | if (MB_FIELD(sl) && !IS_INTERLACED(sl->left_type[0])) { |
201 | // left shift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's OK. | ||
202 |
2/2✓ Branch 0 taken 5750 times.
✓ Branch 1 taken 30380 times.
|
36130 | SET_DIAG_MV(/ 2, *2, sl->left_mb_xy[i >= 36], ((i >> 2)) & 3); |
203 | } | ||
204 | } | ||
205 | #undef SET_DIAG_MV | ||
206 | } | ||
207 | |||
208 |
2/2✓ Branch 0 taken 11661009 times.
✓ Branch 1 taken 6652030 times.
|
18313039 | if (topright_ref != PART_NOT_AVAILABLE) { |
209 | 11661009 | *C = sl->mv_cache[list][i - 8 + part_width]; | |
210 | 11661009 | return topright_ref; | |
211 | } else { | ||
212 | ff_tlog(h->avctx, "topright MV not available\n"); | ||
213 | |||
214 | 6652030 | *C = sl->mv_cache[list][i - 8 - 1]; | |
215 | 6652030 | return sl->ref_cache[list][i - 8 - 1]; | |
216 | } | ||
217 | } | ||
218 | |||
219 | /** | ||
220 | * Get the predicted MV. | ||
221 | * @param n the block index | ||
222 | * @param part_width the width of the partition (4, 8,16) -> (1, 2, 4) | ||
223 | * @param mx the x component of the predicted motion vector | ||
224 | * @param my the y component of the predicted motion vector | ||
225 | */ | ||
226 | 17734565 | static av_always_inline void pred_motion(const H264Context *const h, | |
227 | H264SliceContext *sl, | ||
228 | int n, | ||
229 | int part_width, int list, int ref, | ||
230 | int *const mx, int *const my) | ||
231 | { | ||
232 | 17734565 | const int index8 = scan8[n]; | |
233 | 17734565 | const int top_ref = sl->ref_cache[list][index8 - 8]; | |
234 | 17734565 | const int left_ref = sl->ref_cache[list][index8 - 1]; | |
235 | 17734565 | const int16_t *const A = sl->mv_cache[list][index8 - 1]; | |
236 | 17734565 | const int16_t *const B = sl->mv_cache[list][index8 - 8]; | |
237 | const int16_t *C; | ||
238 | int diagonal_ref, match_count; | ||
239 | |||
240 | av_assert2(part_width == 1 || part_width == 2 || part_width == 4); | ||
241 | |||
242 | /* mv_cache | ||
243 | * B . . A T T T T | ||
244 | * U . . L . . , . | ||
245 | * U . . L . . . . | ||
246 | * U . . L . . , . | ||
247 | * . . . L . . . . | ||
248 | */ | ||
249 | |||
250 | 17734565 | diagonal_ref = fetch_diagonal_mv(h, sl, &C, index8, list, part_width); | |
251 | 17734565 | match_count = (diagonal_ref == ref) + (top_ref == ref) + (left_ref == ref); | |
252 | ff_tlog(h->avctx, "pred_motion match_count=%d\n", match_count); | ||
253 |
2/2✓ Branch 0 taken 13138850 times.
✓ Branch 1 taken 4595715 times.
|
17734565 | if (match_count > 1) { //most common |
254 | 13138850 | *mx = mid_pred(A[0], B[0], C[0]); | |
255 | 13138850 | *my = mid_pred(A[1], B[1], C[1]); | |
256 |
2/2✓ Branch 0 taken 3116540 times.
✓ Branch 1 taken 1479175 times.
|
4595715 | } else if (match_count == 1) { |
257 |
2/2✓ Branch 0 taken 1967693 times.
✓ Branch 1 taken 1148847 times.
|
3116540 | if (left_ref == ref) { |
258 | 1967693 | *mx = A[0]; | |
259 | 1967693 | *my = A[1]; | |
260 |
2/2✓ Branch 0 taken 823086 times.
✓ Branch 1 taken 325761 times.
|
1148847 | } else if (top_ref == ref) { |
261 | 823086 | *mx = B[0]; | |
262 | 823086 | *my = B[1]; | |
263 | } else { | ||
264 | 325761 | *mx = C[0]; | |
265 | 325761 | *my = C[1]; | |
266 | } | ||
267 | } else { | ||
268 |
4/4✓ Branch 0 taken 244144 times.
✓ Branch 1 taken 1235031 times.
✓ Branch 2 taken 243731 times.
✓ Branch 3 taken 413 times.
|
1479175 | if (top_ref == PART_NOT_AVAILABLE && |
269 |
2/2✓ Branch 0 taken 218256 times.
✓ Branch 1 taken 25475 times.
|
243731 | diagonal_ref == PART_NOT_AVAILABLE && |
270 | left_ref != PART_NOT_AVAILABLE) { | ||
271 | 218256 | *mx = A[0]; | |
272 | 218256 | *my = A[1]; | |
273 | } else { | ||
274 | 1260919 | *mx = mid_pred(A[0], B[0], C[0]); | |
275 | 1260919 | *my = mid_pred(A[1], B[1], C[1]); | |
276 | } | ||
277 | } | ||
278 | |||
279 | ff_tlog(h->avctx, | ||
280 | "pred_motion (%2d %2d %2d) (%2d %2d %2d) (%2d %2d %2d) -> (%2d %2d %2d) at %2d %2d %d list %d\n", | ||
281 | top_ref, B[0], B[1], diagonal_ref, C[0], C[1], left_ref, | ||
282 | A[0], A[1], ref, *mx, *my, sl->mb_x, sl->mb_y, n, list); | ||
283 | 17734565 | } | |
284 | |||
285 | /** | ||
286 | * Get the directionally predicted 16x8 MV. | ||
287 | * @param n the block index | ||
288 | * @param mx the x component of the predicted motion vector | ||
289 | * @param my the y component of the predicted motion vector | ||
290 | */ | ||
291 | 1439462 | static av_always_inline void pred_16x8_motion(const H264Context *const h, | |
292 | H264SliceContext *sl, | ||
293 | int n, int list, int ref, | ||
294 | int *const mx, int *const my) | ||
295 | { | ||
296 |
2/2✓ Branch 0 taken 718828 times.
✓ Branch 1 taken 720634 times.
|
1439462 | if (n == 0) { |
297 | 718828 | const int top_ref = sl->ref_cache[list][scan8[0] - 8]; | |
298 | 718828 | const int16_t *const B = sl->mv_cache[list][scan8[0] - 8]; | |
299 | |||
300 | ff_tlog(h->avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", | ||
301 | top_ref, B[0], B[1], sl->mb_x, sl->mb_y, n, list); | ||
302 | |||
303 |
2/2✓ Branch 0 taken 416140 times.
✓ Branch 1 taken 302688 times.
|
718828 | if (top_ref == ref) { |
304 | 416140 | *mx = B[0]; | |
305 | 416140 | *my = B[1]; | |
306 | 416140 | return; | |
307 | } | ||
308 | } else { | ||
309 | 720634 | const int left_ref = sl->ref_cache[list][scan8[8] - 1]; | |
310 | 720634 | const int16_t *const A = sl->mv_cache[list][scan8[8] - 1]; | |
311 | |||
312 | ff_tlog(h->avctx, "pred_16x8: (%2d %2d %2d) at %2d %2d %d list %d\n", | ||
313 | left_ref, A[0], A[1], sl->mb_x, sl->mb_y, n, list); | ||
314 | |||
315 |
2/2✓ Branch 0 taken 489081 times.
✓ Branch 1 taken 231553 times.
|
720634 | if (left_ref == ref) { |
316 | 489081 | *mx = A[0]; | |
317 | 489081 | *my = A[1]; | |
318 | 489081 | return; | |
319 | } | ||
320 | } | ||
321 | |||
322 | //RARE | ||
323 | 534241 | pred_motion(h, sl, n, 4, list, ref, mx, my); | |
324 | } | ||
325 | |||
326 | /** | ||
327 | * Get the directionally predicted 8x16 MV. | ||
328 | * @param n the block index | ||
329 | * @param mx the x component of the predicted motion vector | ||
330 | * @param my the y component of the predicted motion vector | ||
331 | */ | ||
332 | 1284000 | static av_always_inline void pred_8x16_motion(const H264Context *const h, | |
333 | H264SliceContext *sl, | ||
334 | int n, int list, int ref, | ||
335 | int *const mx, int *const my) | ||
336 | { | ||
337 |
2/2✓ Branch 0 taken 642645 times.
✓ Branch 1 taken 641355 times.
|
1284000 | if (n == 0) { |
338 | 642645 | const int left_ref = sl->ref_cache[list][scan8[0] - 1]; | |
339 | 642645 | const int16_t *const A = sl->mv_cache[list][scan8[0] - 1]; | |
340 | |||
341 | ff_tlog(h->avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", | ||
342 | left_ref, A[0], A[1], sl->mb_x, sl->mb_y, n, list); | ||
343 | |||
344 |
2/2✓ Branch 0 taken 411126 times.
✓ Branch 1 taken 231519 times.
|
642645 | if (left_ref == ref) { |
345 | 411126 | *mx = A[0]; | |
346 | 411126 | *my = A[1]; | |
347 | 411126 | return; | |
348 | } | ||
349 | } else { | ||
350 | const int16_t *C; | ||
351 | int diagonal_ref; | ||
352 | |||
353 | 641355 | diagonal_ref = fetch_diagonal_mv(h, sl, &C, scan8[4], list, 2); | |
354 | |||
355 | ff_tlog(h->avctx, "pred_8x16: (%2d %2d %2d) at %2d %2d %d list %d\n", | ||
356 | diagonal_ref, C[0], C[1], sl->mb_x, sl->mb_y, n, list); | ||
357 | |||
358 |
2/2✓ Branch 0 taken 377917 times.
✓ Branch 1 taken 263438 times.
|
641355 | if (diagonal_ref == ref) { |
359 | 377917 | *mx = C[0]; | |
360 | 377917 | *my = C[1]; | |
361 | 377917 | return; | |
362 | } | ||
363 | } | ||
364 | |||
365 | //RARE | ||
366 | 494957 | pred_motion(h, sl, n, 2, list, ref, mx, my); | |
367 | } | ||
368 | |||
369 | #define FIX_MV_MBAFF(type, refn, mvn, idx) \ | ||
370 | if (FRAME_MBAFF(h)) { \ | ||
371 | if (MB_FIELD(sl)) { \ | ||
372 | if (!IS_INTERLACED(type)) { \ | ||
373 | refn <<= 1; \ | ||
374 | AV_COPY32(mvbuf[idx], mvn); \ | ||
375 | mvbuf[idx][1] /= 2; \ | ||
376 | mvn = mvbuf[idx]; \ | ||
377 | } \ | ||
378 | } else { \ | ||
379 | if (IS_INTERLACED(type)) { \ | ||
380 | refn >>= 1; \ | ||
381 | AV_COPY32(mvbuf[idx], mvn); \ | ||
382 | mvbuf[idx][1] *= 2; \ | ||
383 | mvn = mvbuf[idx]; \ | ||
384 | } \ | ||
385 | } \ | ||
386 | } | ||
387 | |||
388 | 1790778 | static av_always_inline void pred_pskip_motion(const H264Context *const h, | |
389 | H264SliceContext *sl) | ||
390 | { | ||
391 | DECLARE_ALIGNED(4, static const int16_t, zeromv)[2] = { 0 }; | ||
392 | DECLARE_ALIGNED(4, int16_t, mvbuf)[3][2]; | ||
393 | 1790778 | int8_t *ref = h->cur_pic.ref_index[0]; | |
394 | 1790778 | int16_t(*mv)[2] = h->cur_pic.motion_val[0]; | |
395 | int top_ref, left_ref, diagonal_ref, match_count, mx, my; | ||
396 | const int16_t *A, *B, *C; | ||
397 | 1790778 | int b_stride = h->b_stride; | |
398 | |||
399 | 1790778 | fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1); | |
400 | |||
401 | /* To avoid doing an entire fill_decode_caches, we inline the relevant | ||
402 | * parts here. | ||
403 | * FIXME: this is a partial duplicate of the logic in fill_decode_caches, | ||
404 | * but it's faster this way. Is there a way to avoid this duplication? | ||
405 | */ | ||
406 |
2/2✓ Branch 0 taken 1695889 times.
✓ Branch 1 taken 94889 times.
|
1790778 | if (USES_LIST(sl->left_type[LTOP], 0)) { |
407 | 1695889 | left_ref = ref[4 * sl->left_mb_xy[LTOP] + 1 + (sl->left_block[0] & ~1)]; | |
408 | 1695889 | A = mv[h->mb2b_xy[sl->left_mb_xy[LTOP]] + 3 + b_stride * sl->left_block[0]]; | |
409 |
8/8✓ Branch 0 taken 45498 times.
✓ Branch 1 taken 1650391 times.
✓ Branch 2 taken 7113 times.
✓ Branch 3 taken 38385 times.
✓ Branch 4 taken 1136 times.
✓ Branch 5 taken 5977 times.
✓ Branch 6 taken 1812 times.
✓ Branch 7 taken 36573 times.
|
1695889 | FIX_MV_MBAFF(sl->left_type[LTOP], left_ref, A, 0); |
410 |
2/2✓ Branch 0 taken 1361041 times.
✓ Branch 1 taken 334848 times.
|
1695889 | if (!(left_ref | AV_RN32A(A))) |
411 | 1361041 | goto zeromv; | |
412 |
2/2✓ Branch 0 taken 37018 times.
✓ Branch 1 taken 57871 times.
|
94889 | } else if (sl->left_type[LTOP]) { |
413 | 37018 | left_ref = LIST_NOT_USED; | |
414 | 37018 | A = zeromv; | |
415 | } else { | ||
416 | 57871 | goto zeromv; | |
417 | } | ||
418 | |||
419 |
2/2✓ Branch 0 taken 340431 times.
✓ Branch 1 taken 31435 times.
|
371866 | if (USES_LIST(sl->top_type, 0)) { |
420 | 340431 | top_ref = ref[4 * sl->top_mb_xy + 2]; | |
421 | 340431 | B = mv[h->mb2b_xy[sl->top_mb_xy] + 3 * b_stride]; | |
422 |
8/8✓ Branch 0 taken 19990 times.
✓ Branch 1 taken 320441 times.
✓ Branch 2 taken 2277 times.
✓ Branch 3 taken 17713 times.
✓ Branch 4 taken 1243 times.
✓ Branch 5 taken 1034 times.
✓ Branch 6 taken 1009 times.
✓ Branch 7 taken 16704 times.
|
340431 | FIX_MV_MBAFF(sl->top_type, top_ref, B, 1); |
423 |
2/2✓ Branch 0 taken 60927 times.
✓ Branch 1 taken 279504 times.
|
340431 | if (!(top_ref | AV_RN32A(B))) |
424 | 60927 | goto zeromv; | |
425 |
2/2✓ Branch 0 taken 20505 times.
✓ Branch 1 taken 10930 times.
|
31435 | } else if (sl->top_type) { |
426 | 20505 | top_ref = LIST_NOT_USED; | |
427 | 20505 | B = zeromv; | |
428 | } else { | ||
429 | 10930 | goto zeromv; | |
430 | } | ||
431 | |||
432 | ff_tlog(h->avctx, "pred_pskip: (%d) (%d) at %2d %2d\n", | ||
433 | top_ref, left_ref, sl->mb_x, sl->mb_y); | ||
434 | |||
435 |
2/2✓ Branch 0 taken 257472 times.
✓ Branch 1 taken 42537 times.
|
300009 | if (USES_LIST(sl->topright_type, 0)) { |
436 | 257472 | diagonal_ref = ref[4 * sl->topright_mb_xy + 2]; | |
437 | 257472 | C = mv[h->mb2b_xy[sl->topright_mb_xy] + 3 * b_stride]; | |
438 |
8/8✓ Branch 0 taken 8074 times.
✓ Branch 1 taken 249398 times.
✓ Branch 2 taken 1882 times.
✓ Branch 3 taken 6192 times.
✓ Branch 4 taken 908 times.
✓ Branch 5 taken 974 times.
✓ Branch 6 taken 835 times.
✓ Branch 7 taken 5357 times.
|
257472 | FIX_MV_MBAFF(sl->topright_type, diagonal_ref, C, 2); |
439 |
2/2✓ Branch 0 taken 20198 times.
✓ Branch 1 taken 22339 times.
|
42537 | } else if (sl->topright_type) { |
440 | 20198 | diagonal_ref = LIST_NOT_USED; | |
441 | 20198 | C = zeromv; | |
442 | } else { | ||
443 |
2/2✓ Branch 0 taken 21263 times.
✓ Branch 1 taken 1076 times.
|
22339 | if (USES_LIST(sl->topleft_type, 0)) { |
444 | 21263 | diagonal_ref = ref[4 * sl->topleft_mb_xy + 1 + | |
445 | 21263 | (sl->topleft_partition & 2)]; | |
446 | 21263 | C = mv[h->mb2b_xy[sl->topleft_mb_xy] + 3 + b_stride + | |
447 | 21263 | (sl->topleft_partition & 2 * b_stride)]; | |
448 |
8/8✓ Branch 0 taken 9013 times.
✓ Branch 1 taken 12250 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 8960 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 44 times.
✓ Branch 6 taken 478 times.
✓ Branch 7 taken 8482 times.
|
21263 | FIX_MV_MBAFF(sl->topleft_type, diagonal_ref, C, 2); |
449 |
1/2✓ Branch 0 taken 1076 times.
✗ Branch 1 not taken.
|
1076 | } else if (sl->topleft_type) { |
450 | 1076 | diagonal_ref = LIST_NOT_USED; | |
451 | 1076 | C = zeromv; | |
452 | } else { | ||
453 | ✗ | diagonal_ref = PART_NOT_AVAILABLE; | |
454 | ✗ | C = zeromv; | |
455 | } | ||
456 | } | ||
457 | |||
458 | 300009 | match_count = !diagonal_ref + !top_ref + !left_ref; | |
459 | ff_tlog(h->avctx, "pred_pskip_motion match_count=%d\n", match_count); | ||
460 |
2/2✓ Branch 0 taken 256087 times.
✓ Branch 1 taken 43922 times.
|
300009 | if (match_count > 1) { |
461 | 256087 | mx = mid_pred(A[0], B[0], C[0]); | |
462 | 256087 | my = mid_pred(A[1], B[1], C[1]); | |
463 |
2/2✓ Branch 0 taken 37466 times.
✓ Branch 1 taken 6456 times.
|
43922 | } else if (match_count == 1) { |
464 |
2/2✓ Branch 0 taken 18168 times.
✓ Branch 1 taken 19298 times.
|
37466 | if (!left_ref) { |
465 | 18168 | mx = A[0]; | |
466 | 18168 | my = A[1]; | |
467 |
2/2✓ Branch 0 taken 8321 times.
✓ Branch 1 taken 10977 times.
|
19298 | } else if (!top_ref) { |
468 | 8321 | mx = B[0]; | |
469 | 8321 | my = B[1]; | |
470 | } else { | ||
471 | 10977 | mx = C[0]; | |
472 | 10977 | my = C[1]; | |
473 | } | ||
474 | } else { | ||
475 | 6456 | mx = mid_pred(A[0], B[0], C[0]); | |
476 | 6456 | my = mid_pred(A[1], B[1], C[1]); | |
477 | } | ||
478 | |||
479 | 300009 | fill_rectangle(sl->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx, my), 4); | |
480 | 300009 | return; | |
481 | |||
482 | 1490769 | zeromv: | |
483 | 1490769 | fill_rectangle(sl->mv_cache[0][scan8[0]], 4, 4, 8, 0, 4); | |
484 | 1490769 | return; | |
485 | } | ||
486 | |||
487 | 14976995 | static void fill_decode_neighbors(const H264Context *h, H264SliceContext *sl, int mb_type) | |
488 | { | ||
489 | 14976995 | const int mb_xy = sl->mb_xy; | |
490 | int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; | ||
491 | static const uint8_t left_block_options[4][32] = { | ||
492 | { 0, 1, 2, 3, 7, 10, 8, 11, 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 5 * 4, 1 + 9 * 4 }, | ||
493 | { 2, 2, 3, 3, 8, 11, 8, 11, 3 + 2 * 4, 3 + 2 * 4, 3 + 3 * 4, 3 + 3 * 4, 1 + 5 * 4, 1 + 9 * 4, 1 + 5 * 4, 1 + 9 * 4 }, | ||
494 | { 0, 0, 1, 1, 7, 10, 7, 10, 3 + 0 * 4, 3 + 0 * 4, 3 + 1 * 4, 3 + 1 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 }, | ||
495 | { 0, 2, 0, 2, 7, 10, 7, 10, 3 + 0 * 4, 3 + 2 * 4, 3 + 0 * 4, 3 + 2 * 4, 1 + 4 * 4, 1 + 8 * 4, 1 + 4 * 4, 1 + 8 * 4 } | ||
496 | }; | ||
497 | |||
498 | 14976995 | sl->topleft_partition = -1; | |
499 | |||
500 | 14976995 | top_xy = mb_xy - (h->mb_stride << MB_FIELD(sl)); | |
501 | |||
502 | /* Wow, what a mess, why didn't they simplify the interlacing & intra | ||
503 | * stuff, I can't imagine that these complex rules are worth it. */ | ||
504 | |||
505 | 14976995 | topleft_xy = top_xy - 1; | |
506 | 14976995 | topright_xy = top_xy + 1; | |
507 | 14976995 | left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1; | |
508 | 14976995 | sl->left_block = left_block_options[0]; | |
509 |
2/2✓ Branch 0 taken 2303692 times.
✓ Branch 1 taken 12673303 times.
|
14976995 | if (FRAME_MBAFF(h)) { |
510 | 2303692 | const int left_mb_field_flag = IS_INTERLACED(h->cur_pic.mb_type[mb_xy - 1]); | |
511 | 2303692 | const int curr_mb_field_flag = IS_INTERLACED(mb_type); | |
512 |
2/2✓ Branch 0 taken 1151737 times.
✓ Branch 1 taken 1151955 times.
|
2303692 | if (sl->mb_y & 1) { |
513 |
2/2✓ Branch 0 taken 263647 times.
✓ Branch 1 taken 888090 times.
|
1151737 | if (left_mb_field_flag != curr_mb_field_flag) { |
514 | 263647 | left_xy[LBOT] = left_xy[LTOP] = mb_xy - h->mb_stride - 1; | |
515 |
2/2✓ Branch 0 taken 135938 times.
✓ Branch 1 taken 127709 times.
|
263647 | if (curr_mb_field_flag) { |
516 | 135938 | left_xy[LBOT] += h->mb_stride; | |
517 | 135938 | sl->left_block = left_block_options[3]; | |
518 | } else { | ||
519 | 127709 | topleft_xy += h->mb_stride; | |
520 | /* take top left mv from the middle of the mb, as opposed | ||
521 | * to all other modes which use the bottom right partition */ | ||
522 | 127709 | sl->topleft_partition = 0; | |
523 | 127709 | sl->left_block = left_block_options[1]; | |
524 | } | ||
525 | } | ||
526 | } else { | ||
527 |
2/2✓ Branch 0 taken 327048 times.
✓ Branch 1 taken 824907 times.
|
1151955 | if (curr_mb_field_flag) { |
528 | 327048 | topleft_xy += h->mb_stride & (((h->cur_pic.mb_type[top_xy - 1] >> 7) & 1) - 1); | |
529 | 327048 | topright_xy += h->mb_stride & (((h->cur_pic.mb_type[top_xy + 1] >> 7) & 1) - 1); | |
530 | 327048 | top_xy += h->mb_stride & (((h->cur_pic.mb_type[top_xy] >> 7) & 1) - 1); | |
531 | } | ||
532 |
2/2✓ Branch 0 taken 263818 times.
✓ Branch 1 taken 888137 times.
|
1151955 | if (left_mb_field_flag != curr_mb_field_flag) { |
533 |
2/2✓ Branch 0 taken 135909 times.
✓ Branch 1 taken 127909 times.
|
263818 | if (curr_mb_field_flag) { |
534 | 135909 | left_xy[LBOT] += h->mb_stride; | |
535 | 135909 | sl->left_block = left_block_options[3]; | |
536 | } else { | ||
537 | 127909 | sl->left_block = left_block_options[2]; | |
538 | } | ||
539 | } | ||
540 | } | ||
541 | } | ||
542 | |||
543 | 14976995 | sl->topleft_mb_xy = topleft_xy; | |
544 | 14976995 | sl->top_mb_xy = top_xy; | |
545 | 14976995 | sl->topright_mb_xy = topright_xy; | |
546 | 14976995 | sl->left_mb_xy[LTOP] = left_xy[LTOP]; | |
547 | 14976995 | sl->left_mb_xy[LBOT] = left_xy[LBOT]; | |
548 | //FIXME do we need all in the context? | ||
549 | |||
550 | 14976995 | sl->topleft_type = h->cur_pic.mb_type[topleft_xy]; | |
551 | 14976995 | sl->top_type = h->cur_pic.mb_type[top_xy]; | |
552 | 14976995 | sl->topright_type = h->cur_pic.mb_type[topright_xy]; | |
553 | 14976995 | sl->left_type[LTOP] = h->cur_pic.mb_type[left_xy[LTOP]]; | |
554 | 14976995 | sl->left_type[LBOT] = h->cur_pic.mb_type[left_xy[LBOT]]; | |
555 | |||
556 | if (FMO) { | ||
557 | if (h->slice_table[topleft_xy] != sl->slice_num) | ||
558 | sl->topleft_type = 0; | ||
559 | if (h->slice_table[top_xy] != sl->slice_num) | ||
560 | sl->top_type = 0; | ||
561 | if (h->slice_table[left_xy[LTOP]] != sl->slice_num) | ||
562 | sl->left_type[LTOP] = sl->left_type[LBOT] = 0; | ||
563 | } else { | ||
564 |
2/2✓ Branch 0 taken 1532294 times.
✓ Branch 1 taken 13444701 times.
|
14976995 | if (h->slice_table[topleft_xy] != sl->slice_num) { |
565 | 1532294 | sl->topleft_type = 0; | |
566 |
2/2✓ Branch 0 taken 1150671 times.
✓ Branch 1 taken 381623 times.
|
1532294 | if (h->slice_table[top_xy] != sl->slice_num) |
567 | 1150671 | sl->top_type = 0; | |
568 |
2/2✓ Branch 0 taken 418756 times.
✓ Branch 1 taken 1113538 times.
|
1532294 | if (h->slice_table[left_xy[LTOP]] != sl->slice_num) |
569 | 418756 | sl->left_type[LTOP] = sl->left_type[LBOT] = 0; | |
570 | } | ||
571 | } | ||
572 |
2/2✓ Branch 0 taken 2334235 times.
✓ Branch 1 taken 12642760 times.
|
14976995 | if (h->slice_table[topright_xy] != sl->slice_num) |
573 | 2334235 | sl->topright_type = 0; | |
574 | 14976995 | } | |
575 | |||
576 | 13180558 | static void fill_decode_caches(const H264Context *h, H264SliceContext *sl, int mb_type) | |
577 | { | ||
578 | int topleft_xy, top_xy, topright_xy, left_xy[LEFT_MBS]; | ||
579 | int topleft_type, top_type, topright_type, left_type[LEFT_MBS]; | ||
580 | 13180558 | const uint8_t *left_block = sl->left_block; | |
581 | int i; | ||
582 | uint8_t *nnz; | ||
583 | uint8_t *nnz_cache; | ||
584 | |||
585 | 13180558 | topleft_xy = sl->topleft_mb_xy; | |
586 | 13180558 | top_xy = sl->top_mb_xy; | |
587 | 13180558 | topright_xy = sl->topright_mb_xy; | |
588 | 13180558 | left_xy[LTOP] = sl->left_mb_xy[LTOP]; | |
589 | 13180558 | left_xy[LBOT] = sl->left_mb_xy[LBOT]; | |
590 | 13180558 | topleft_type = sl->topleft_type; | |
591 | 13180558 | top_type = sl->top_type; | |
592 | 13180558 | topright_type = sl->topright_type; | |
593 | 13180558 | left_type[LTOP] = sl->left_type[LTOP]; | |
594 | 13180558 | left_type[LBOT] = sl->left_type[LBOT]; | |
595 | |||
596 |
2/2✓ Branch 0 taken 10871086 times.
✓ Branch 1 taken 2309472 times.
|
13180558 | if (!IS_SKIP(mb_type)) { |
597 |
2/2✓ Branch 0 taken 4066391 times.
✓ Branch 1 taken 6804695 times.
|
10871086 | if (IS_INTRA(mb_type)) { |
598 |
2/2✓ Branch 0 taken 9021 times.
✓ Branch 1 taken 4057370 times.
|
4066391 | int type_mask = h->ps.pps->constrained_intra_pred ? IS_INTRA(-1) : -1; |
599 | 4066391 | sl->topleft_samples_available = | |
600 | 4066391 | sl->top_samples_available = | |
601 | 4066391 | sl->left_samples_available = 0xFFFF; | |
602 | 4066391 | sl->topright_samples_available = 0xEEEA; | |
603 | |||
604 |
2/2✓ Branch 0 taken 299791 times.
✓ Branch 1 taken 3766600 times.
|
4066391 | if (!(top_type & type_mask)) { |
605 | 299791 | sl->topleft_samples_available = 0xB3FF; | |
606 | 299791 | sl->top_samples_available = 0x33FF; | |
607 | 299791 | sl->topright_samples_available = 0x26EA; | |
608 | } | ||
609 |
2/2✓ Branch 0 taken 219535 times.
✓ Branch 1 taken 3846856 times.
|
4066391 | if (IS_INTERLACED(mb_type) != IS_INTERLACED(left_type[LTOP])) { |
610 |
2/2✓ Branch 0 taken 114180 times.
✓ Branch 1 taken 105355 times.
|
219535 | if (IS_INTERLACED(mb_type)) { |
611 |
2/2✓ Branch 0 taken 16676 times.
✓ Branch 1 taken 97504 times.
|
114180 | if (!(left_type[LTOP] & type_mask)) { |
612 | 16676 | sl->topleft_samples_available &= 0xDFFF; | |
613 | 16676 | sl->left_samples_available &= 0x5FFF; | |
614 | } | ||
615 |
2/2✓ Branch 0 taken 16681 times.
✓ Branch 1 taken 97499 times.
|
114180 | if (!(left_type[LBOT] & type_mask)) { |
616 | 16681 | sl->topleft_samples_available &= 0xFF5F; | |
617 | 16681 | sl->left_samples_available &= 0xFF5F; | |
618 | } | ||
619 | } else { | ||
620 | 105355 | int left_typei = h->cur_pic.mb_type[left_xy[LTOP] + h->mb_stride]; | |
621 | |||
622 | av_assert2(left_xy[LTOP] == left_xy[LBOT]); | ||
623 |
4/4✓ Branch 0 taken 105310 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 105302 times.
|
105355 | if (!((left_typei & type_mask) && (left_type[LTOP] & type_mask))) { |
624 | 53 | sl->topleft_samples_available &= 0xDF5F; | |
625 | 53 | sl->left_samples_available &= 0x5F5F; | |
626 | } | ||
627 | } | ||
628 | } else { | ||
629 |
2/2✓ Branch 0 taken 67823 times.
✓ Branch 1 taken 3779033 times.
|
3846856 | if (!(left_type[LTOP] & type_mask)) { |
630 | 67823 | sl->topleft_samples_available &= 0xDF5F; | |
631 | 67823 | sl->left_samples_available &= 0x5F5F; | |
632 | } | ||
633 | } | ||
634 | |||
635 |
2/2✓ Branch 0 taken 374832 times.
✓ Branch 1 taken 3691559 times.
|
4066391 | if (!(topleft_type & type_mask)) |
636 | 374832 | sl->topleft_samples_available &= 0x7FFF; | |
637 | |||
638 |
2/2✓ Branch 0 taken 771175 times.
✓ Branch 1 taken 3295216 times.
|
4066391 | if (!(topright_type & type_mask)) |
639 | 771175 | sl->topright_samples_available &= 0xFBFF; | |
640 | |||
641 |
2/2✓ Branch 0 taken 3064023 times.
✓ Branch 1 taken 1002368 times.
|
4066391 | if (IS_INTRA4x4(mb_type)) { |
642 |
2/2✓ Branch 0 taken 2295184 times.
✓ Branch 1 taken 768839 times.
|
3064023 | if (IS_INTRA4x4(top_type)) { |
643 | 2295184 | AV_COPY32(sl->intra4x4_pred_mode_cache + 4 + 8 * 0, sl->intra4x4_pred_mode + h->mb2br_xy[top_xy]); | |
644 | } else { | ||
645 | 768839 | sl->intra4x4_pred_mode_cache[4 + 8 * 0] = | |
646 | 768839 | sl->intra4x4_pred_mode_cache[5 + 8 * 0] = | |
647 | 768839 | sl->intra4x4_pred_mode_cache[6 + 8 * 0] = | |
648 |
2/2✓ Branch 0 taken 211703 times.
✓ Branch 1 taken 557136 times.
|
768839 | sl->intra4x4_pred_mode_cache[7 + 8 * 0] = 2 - 3 * !(top_type & type_mask); |
649 | } | ||
650 |
2/2✓ Branch 0 taken 6128046 times.
✓ Branch 1 taken 3064023 times.
|
9192069 | for (i = 0; i < 2; i++) { |
651 |
2/2✓ Branch 0 taken 4919529 times.
✓ Branch 1 taken 1208517 times.
|
6128046 | if (IS_INTRA4x4(left_type[LEFT(i)])) { |
652 | 4919529 | int8_t *mode = sl->intra4x4_pred_mode + h->mb2br_xy[left_xy[LEFT(i)]]; | |
653 | 4919529 | sl->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = mode[6 - left_block[0 + 2 * i]]; | |
654 | 4919529 | sl->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = mode[6 - left_block[1 + 2 * i]]; | |
655 | } else { | ||
656 | 1208517 | sl->intra4x4_pred_mode_cache[3 + 8 * 1 + 2 * 8 * i] = | |
657 |
2/2✓ Branch 0 taken 128591 times.
✓ Branch 1 taken 1079926 times.
|
1208517 | sl->intra4x4_pred_mode_cache[3 + 8 * 2 + 2 * 8 * i] = 2 - 3 * !(left_type[LEFT(i)] & type_mask); |
658 | } | ||
659 | } | ||
660 | } | ||
661 | } | ||
662 | |||
663 | /* | ||
664 | * 0 . T T. T T T T | ||
665 | * 1 L . .L . . . . | ||
666 | * 2 L . .L . . . . | ||
667 | * 3 . T TL . . . . | ||
668 | * 4 L . .L . . . . | ||
669 | * 5 L . .. . . . . | ||
670 | */ | ||
671 | /* FIXME: constraint_intra_pred & partitioning & nnz | ||
672 | * (let us hope this is just a typo in the spec) */ | ||
673 | 10871086 | nnz_cache = sl->non_zero_count_cache; | |
674 |
2/2✓ Branch 0 taken 9992621 times.
✓ Branch 1 taken 878465 times.
|
10871086 | if (top_type) { |
675 | 9992621 | nnz = h->non_zero_count[top_xy]; | |
676 | 9992621 | AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[4 * 3]); | |
677 |
2/2✓ Branch 0 taken 907099 times.
✓ Branch 1 taken 9085522 times.
|
9992621 | if (!h->chroma_y_shift) { |
678 | 907099 | AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 7]); | |
679 | 907099 | AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 11]); | |
680 | } else { | ||
681 | 9085522 | AV_COPY32(&nnz_cache[4 + 8 * 5], &nnz[4 * 5]); | |
682 | 9085522 | AV_COPY32(&nnz_cache[4 + 8 * 10], &nnz[4 * 9]); | |
683 | } | ||
684 | } else { | ||
685 |
2/2✓ Branch 0 taken 333844 times.
✓ Branch 1 taken 174506 times.
|
878465 | uint32_t top_empty = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 0x40404040; |
686 | 878465 | AV_WN32A(&nnz_cache[4 + 8 * 0], top_empty); | |
687 | 878465 | AV_WN32A(&nnz_cache[4 + 8 * 5], top_empty); | |
688 | 878465 | AV_WN32A(&nnz_cache[4 + 8 * 10], top_empty); | |
689 | } | ||
690 | |||
691 |
2/2✓ Branch 0 taken 21742172 times.
✓ Branch 1 taken 10871086 times.
|
32613258 | for (i = 0; i < 2; i++) { |
692 |
2/2✓ Branch 0 taken 21115224 times.
✓ Branch 1 taken 626948 times.
|
21742172 | if (left_type[LEFT(i)]) { |
693 | 21115224 | nnz = h->non_zero_count[left_xy[LEFT(i)]]; | |
694 | 21115224 | nnz_cache[3 + 8 * 1 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i]]; | |
695 | 21115224 | nnz_cache[3 + 8 * 2 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i]]; | |
696 |
2/2✓ Branch 0 taken 295798 times.
✓ Branch 1 taken 20819426 times.
|
21115224 | if (CHROMA444(h)) { |
697 | 295798 | nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 4 * 4]; | |
698 | 295798 | nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 4 * 4]; | |
699 | 295798 | nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] + 8 * 4]; | |
700 | 295798 | nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] + 8 * 4]; | |
701 |
2/2✓ Branch 0 taken 1619188 times.
✓ Branch 1 taken 19200238 times.
|
20819426 | } else if (CHROMA422(h)) { |
702 | 1619188 | nnz_cache[3 + 8 * 6 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 4 * 4]; | |
703 | 1619188 | nnz_cache[3 + 8 * 7 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 4 * 4]; | |
704 | 1619188 | nnz_cache[3 + 8 * 11 + 2 * 8 * i] = nnz[left_block[8 + 0 + 2 * i] - 2 + 8 * 4]; | |
705 | 1619188 | nnz_cache[3 + 8 * 12 + 2 * 8 * i] = nnz[left_block[8 + 1 + 2 * i] - 2 + 8 * 4]; | |
706 | } else { | ||
707 | 19200238 | nnz_cache[3 + 8 * 6 + 8 * i] = nnz[left_block[8 + 4 + 2 * i]]; | |
708 | 19200238 | nnz_cache[3 + 8 * 11 + 8 * i] = nnz[left_block[8 + 5 + 2 * i]]; | |
709 | } | ||
710 | } else { | ||
711 | 626948 | nnz_cache[3 + 8 * 1 + 2 * 8 * i] = | |
712 | 626948 | nnz_cache[3 + 8 * 2 + 2 * 8 * i] = | |
713 | 626948 | nnz_cache[3 + 8 * 6 + 2 * 8 * i] = | |
714 | 626948 | nnz_cache[3 + 8 * 7 + 2 * 8 * i] = | |
715 | 626948 | nnz_cache[3 + 8 * 11 + 2 * 8 * i] = | |
716 |
2/2✓ Branch 0 taken 264972 times.
✓ Branch 1 taken 102248 times.
|
626948 | nnz_cache[3 + 8 * 12 + 2 * 8 * i] = CABAC(h) && !IS_INTRA(mb_type) ? 0 : 64; |
717 | } | ||
718 | } | ||
719 | |||
720 | if (CABAC(h)) { | ||
721 | // top_cbp | ||
722 |
2/2✓ Branch 0 taken 6660174 times.
✓ Branch 1 taken 508350 times.
|
7168524 | if (top_type) |
723 | 6660174 | sl->top_cbp = h->cbp_table[top_xy]; | |
724 | else | ||
725 |
2/2✓ Branch 0 taken 174506 times.
✓ Branch 1 taken 333844 times.
|
508350 | sl->top_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; |
726 | // left_cbp | ||
727 |
2/2✓ Branch 0 taken 6984914 times.
✓ Branch 1 taken 183610 times.
|
7168524 | if (left_type[LTOP]) { |
728 | 6984914 | sl->left_cbp = (h->cbp_table[left_xy[LTOP]] & 0x7F0) | | |
729 | 6984914 | ((h->cbp_table[left_xy[LTOP]] >> (left_block[0] & (~1))) & 2) | | |
730 | 6984914 | (((h->cbp_table[left_xy[LBOT]] >> (left_block[2] & (~1))) & 2) << 2); | |
731 | } else { | ||
732 |
2/2✓ Branch 0 taken 51124 times.
✓ Branch 1 taken 132486 times.
|
183610 | sl->left_cbp = IS_INTRA(mb_type) ? 0x7CF : 0x00F; |
733 | } | ||
734 | } | ||
735 | } | ||
736 | |||
737 |
6/6✓ Branch 0 taken 7023025 times.
✓ Branch 1 taken 6157533 times.
✓ Branch 2 taken 2956634 times.
✓ Branch 3 taken 4066391 times.
✓ Branch 4 taken 2892432 times.
✓ Branch 5 taken 64202 times.
|
13180558 | if (IS_INTER(mb_type) || (IS_DIRECT(mb_type) && sl->direct_spatial_mv_pred)) { |
738 | int list; | ||
739 | 9049965 | int b_stride = h->b_stride; | |
740 |
2/2✓ Branch 0 taken 14452162 times.
✓ Branch 1 taken 9049965 times.
|
23502127 | for (list = 0; list < sl->list_count; list++) { |
741 | 14452162 | int8_t *ref_cache = &sl->ref_cache[list][scan8[0]]; | |
742 | 14452162 | int8_t *ref = h->cur_pic.ref_index[list]; | |
743 | 14452162 | int16_t(*mv_cache)[2] = &sl->mv_cache[list][scan8[0]]; | |
744 | 14452162 | int16_t(*mv)[2] = h->cur_pic.motion_val[list]; | |
745 |
2/2✓ Branch 0 taken 1361872 times.
✓ Branch 1 taken 13090290 times.
|
14452162 | if (!USES_LIST(mb_type, list)) |
746 | 1361872 | continue; | |
747 | av_assert2(!(IS_DIRECT(mb_type) && !sl->direct_spatial_mv_pred)); | ||
748 | |||
749 |
2/2✓ Branch 0 taken 10554124 times.
✓ Branch 1 taken 2536166 times.
|
13090290 | if (USES_LIST(top_type, list)) { |
750 | 10554124 | const int b_xy = h->mb2b_xy[top_xy] + 3 * b_stride; | |
751 | 10554124 | AV_COPY128(mv_cache[0 - 1 * 8], mv[b_xy + 0]); | |
752 | 10554124 | ref_cache[0 - 1 * 8] = | |
753 | 10554124 | ref_cache[1 - 1 * 8] = ref[4 * top_xy + 2]; | |
754 | 10554124 | ref_cache[2 - 1 * 8] = | |
755 | 10554124 | ref_cache[3 - 1 * 8] = ref[4 * top_xy + 3]; | |
756 | } else { | ||
757 | 2536166 | AV_ZERO128(mv_cache[0 - 1 * 8]); | |
758 |
2/2✓ Branch 0 taken 1521617 times.
✓ Branch 1 taken 1014549 times.
|
2536166 | AV_WN32A(&ref_cache[0 - 1 * 8], |
759 | ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE) & 0xFF) * 0x01010101u); | ||
760 | } | ||
761 | |||
762 |
2/2✓ Branch 0 taken 2819090 times.
✓ Branch 1 taken 10271200 times.
|
13090290 | if (mb_type & (MB_TYPE_16x8 | MB_TYPE_8x8)) { |
763 |
2/2✓ Branch 0 taken 5638180 times.
✓ Branch 1 taken 2819090 times.
|
8457270 | for (i = 0; i < 2; i++) { |
764 | 5638180 | int cache_idx = -1 + i * 2 * 8; | |
765 |
2/2✓ Branch 0 taken 4822167 times.
✓ Branch 1 taken 816013 times.
|
5638180 | if (USES_LIST(left_type[LEFT(i)], list)) { |
766 | 4822167 | const int b_xy = h->mb2b_xy[left_xy[LEFT(i)]] + 3; | |
767 | 4822167 | const int b8_xy = 4 * left_xy[LEFT(i)] + 1; | |
768 | 4822167 | AV_COPY32(mv_cache[cache_idx], | |
769 | mv[b_xy + b_stride * left_block[0 + i * 2]]); | ||
770 | 4822167 | AV_COPY32(mv_cache[cache_idx + 8], | |
771 | mv[b_xy + b_stride * left_block[1 + i * 2]]); | ||
772 | 4822167 | ref_cache[cache_idx] = ref[b8_xy + (left_block[0 + i * 2] & ~1)]; | |
773 | 4822167 | ref_cache[cache_idx + 8] = ref[b8_xy + (left_block[1 + i * 2] & ~1)]; | |
774 | } else { | ||
775 | 816013 | AV_ZERO32(mv_cache[cache_idx]); | |
776 | 816013 | AV_ZERO32(mv_cache[cache_idx + 8]); | |
777 | 816013 | ref_cache[cache_idx] = | |
778 |
2/2✓ Branch 0 taken 582121 times.
✓ Branch 1 taken 233892 times.
|
816013 | ref_cache[cache_idx + 8] = (left_type[LEFT(i)]) ? LIST_NOT_USED |
779 | : PART_NOT_AVAILABLE; | ||
780 | } | ||
781 | } | ||
782 | } else { | ||
783 |
2/2✓ Branch 0 taken 8809160 times.
✓ Branch 1 taken 1462040 times.
|
10271200 | if (USES_LIST(left_type[LTOP], list)) { |
784 | 8809160 | const int b_xy = h->mb2b_xy[left_xy[LTOP]] + 3; | |
785 | 8809160 | const int b8_xy = 4 * left_xy[LTOP] + 1; | |
786 | 8809160 | AV_COPY32(mv_cache[-1], mv[b_xy + b_stride * left_block[0]]); | |
787 | 8809160 | ref_cache[-1] = ref[b8_xy + (left_block[0] & ~1)]; | |
788 | } else { | ||
789 | 1462040 | AV_ZERO32(mv_cache[-1]); | |
790 |
2/2✓ Branch 0 taken 1200388 times.
✓ Branch 1 taken 261652 times.
|
1462040 | ref_cache[-1] = left_type[LTOP] ? LIST_NOT_USED |
791 | : PART_NOT_AVAILABLE; | ||
792 | } | ||
793 | } | ||
794 | |||
795 |
2/2✓ Branch 0 taken 9701144 times.
✓ Branch 1 taken 3389146 times.
|
13090290 | if (USES_LIST(topright_type, list)) { |
796 | 9701144 | const int b_xy = h->mb2b_xy[topright_xy] + 3 * b_stride; | |
797 | 9701144 | AV_COPY32(mv_cache[4 - 1 * 8], mv[b_xy]); | |
798 | 9701144 | ref_cache[4 - 1 * 8] = ref[4 * topright_xy + 2]; | |
799 | } else { | ||
800 | 3389146 | AV_ZERO32(mv_cache[4 - 1 * 8]); | |
801 |
2/2✓ Branch 0 taken 1470107 times.
✓ Branch 1 taken 1919039 times.
|
3389146 | ref_cache[4 - 1 * 8] = topright_type ? LIST_NOT_USED |
802 | : PART_NOT_AVAILABLE; | ||
803 | } | ||
804 |
4/4✓ Branch 0 taken 10353815 times.
✓ Branch 1 taken 2736475 times.
✓ Branch 2 taken 1363661 times.
✓ Branch 3 taken 8990154 times.
|
13090290 | if(ref_cache[2 - 1*8] < 0 || ref_cache[4 - 1 * 8] < 0) { |
805 |
2/2✓ Branch 0 taken 1841586 times.
✓ Branch 1 taken 2258550 times.
|
4100136 | if (USES_LIST(topleft_type, list)) { |
806 | 1841586 | const int b_xy = h->mb2b_xy[topleft_xy] + 3 + b_stride + | |
807 | 1841586 | (sl->topleft_partition & 2 * b_stride); | |
808 | 1841586 | const int b8_xy = 4 * topleft_xy + 1 + (sl->topleft_partition & 2); | |
809 | 1841586 | AV_COPY32(mv_cache[-1 - 1 * 8], mv[b_xy]); | |
810 | 1841586 | ref_cache[-1 - 1 * 8] = ref[b8_xy]; | |
811 | } else { | ||
812 | 2258550 | AV_ZERO32(mv_cache[-1 - 1 * 8]); | |
813 |
2/2✓ Branch 0 taken 1150201 times.
✓ Branch 1 taken 1108349 times.
|
2258550 | ref_cache[-1 - 1 * 8] = topleft_type ? LIST_NOT_USED |
814 | : PART_NOT_AVAILABLE; | ||
815 | } | ||
816 | } | ||
817 | |||
818 |
4/4✓ Branch 0 taken 5784864 times.
✓ Branch 1 taken 7305426 times.
✓ Branch 2 taken 5143680 times.
✓ Branch 3 taken 641184 times.
|
13090290 | if ((mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2)) && !FRAME_MBAFF(h)) |
819 | 5143680 | continue; | |
820 | |||
821 |
2/2✓ Branch 0 taken 7305426 times.
✓ Branch 1 taken 641184 times.
|
7946610 | if (!(mb_type & (MB_TYPE_SKIP | MB_TYPE_DIRECT2))) { |
822 | 7305426 | uint8_t(*mvd_cache)[2] = &sl->mvd_cache[list][scan8[0]]; | |
823 | 7305426 | uint8_t(*mvd)[2] = sl->mvd_table[list]; | |
824 | 7305426 | ref_cache[2 + 8 * 0] = | |
825 | 7305426 | ref_cache[2 + 8 * 2] = PART_NOT_AVAILABLE; | |
826 | 7305426 | AV_ZERO32(mv_cache[2 + 8 * 0]); | |
827 | 7305426 | AV_ZERO32(mv_cache[2 + 8 * 2]); | |
828 | |||
829 | if (CABAC(h)) { | ||
830 |
2/2✓ Branch 0 taken 3908082 times.
✓ Branch 1 taken 978731 times.
|
4886813 | if (USES_LIST(top_type, list)) { |
831 | 3908082 | const int b_xy = h->mb2br_xy[top_xy]; | |
832 | 3908082 | AV_COPY64(mvd_cache[0 - 1 * 8], mvd[b_xy + 0]); | |
833 | } else { | ||
834 | 978731 | AV_ZERO64(mvd_cache[0 - 1 * 8]); | |
835 | } | ||
836 |
2/2✓ Branch 0 taken 4135138 times.
✓ Branch 1 taken 751675 times.
|
4886813 | if (USES_LIST(left_type[LTOP], list)) { |
837 | 4135138 | const int b_xy = h->mb2br_xy[left_xy[LTOP]] + 6; | |
838 | 4135138 | AV_COPY16(mvd_cache[-1 + 0 * 8], mvd[b_xy - left_block[0]]); | |
839 | 4135138 | AV_COPY16(mvd_cache[-1 + 1 * 8], mvd[b_xy - left_block[1]]); | |
840 | } else { | ||
841 | 751675 | AV_ZERO16(mvd_cache[-1 + 0 * 8]); | |
842 | 751675 | AV_ZERO16(mvd_cache[-1 + 1 * 8]); | |
843 | } | ||
844 |
2/2✓ Branch 0 taken 4134622 times.
✓ Branch 1 taken 752191 times.
|
4886813 | if (USES_LIST(left_type[LBOT], list)) { |
845 | 4134622 | const int b_xy = h->mb2br_xy[left_xy[LBOT]] + 6; | |
846 | 4134622 | AV_COPY16(mvd_cache[-1 + 2 * 8], mvd[b_xy - left_block[2]]); | |
847 | 4134622 | AV_COPY16(mvd_cache[-1 + 3 * 8], mvd[b_xy - left_block[3]]); | |
848 | } else { | ||
849 | 752191 | AV_ZERO16(mvd_cache[-1 + 2 * 8]); | |
850 | 752191 | AV_ZERO16(mvd_cache[-1 + 3 * 8]); | |
851 | } | ||
852 | 4886813 | AV_ZERO16(mvd_cache[2 + 8 * 0]); | |
853 | 4886813 | AV_ZERO16(mvd_cache[2 + 8 * 2]); | |
854 |
2/2✓ Branch 0 taken 2706210 times.
✓ Branch 1 taken 2180603 times.
|
4886813 | if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { |
855 | 2706210 | uint8_t *direct_cache = &sl->direct_cache[scan8[0]]; | |
856 | 2706210 | uint8_t *direct_table = h->direct_table; | |
857 | 2706210 | fill_rectangle(direct_cache, 4, 4, 8, MB_TYPE_16x16 >> 1, 1); | |
858 | |||
859 |
2/2✓ Branch 0 taken 449769 times.
✓ Branch 1 taken 2256441 times.
|
2706210 | if (IS_DIRECT(top_type)) { |
860 | 449769 | AV_WN32A(&direct_cache[-1 * 8], | |
861 | 0x01010101u * (MB_TYPE_DIRECT2 >> 1)); | ||
862 |
2/2✓ Branch 0 taken 616446 times.
✓ Branch 1 taken 1639995 times.
|
2256441 | } else if (IS_8X8(top_type)) { |
863 | 616446 | int b8_xy = 4 * top_xy; | |
864 | 616446 | direct_cache[0 - 1 * 8] = direct_table[b8_xy + 2]; | |
865 | 616446 | direct_cache[2 - 1 * 8] = direct_table[b8_xy + 3]; | |
866 | } else { | ||
867 | 1639995 | AV_WN32A(&direct_cache[-1 * 8], | |
868 | 0x01010101 * (MB_TYPE_16x16 >> 1)); | ||
869 | } | ||
870 | |||
871 |
2/2✓ Branch 0 taken 440741 times.
✓ Branch 1 taken 2265469 times.
|
2706210 | if (IS_DIRECT(left_type[LTOP])) |
872 | 440741 | direct_cache[-1 + 0 * 8] = MB_TYPE_DIRECT2 >> 1; | |
873 |
2/2✓ Branch 0 taken 652830 times.
✓ Branch 1 taken 1612639 times.
|
2265469 | else if (IS_8X8(left_type[LTOP])) |
874 | 652830 | direct_cache[-1 + 0 * 8] = direct_table[4 * left_xy[LTOP] + 1 + (left_block[0] & ~1)]; | |
875 | else | ||
876 | 1612639 | direct_cache[-1 + 0 * 8] = MB_TYPE_16x16 >> 1; | |
877 | |||
878 |
2/2✓ Branch 0 taken 439770 times.
✓ Branch 1 taken 2266440 times.
|
2706210 | if (IS_DIRECT(left_type[LBOT])) |
879 | 439770 | direct_cache[-1 + 2 * 8] = MB_TYPE_DIRECT2 >> 1; | |
880 |
2/2✓ Branch 0 taken 654998 times.
✓ Branch 1 taken 1611442 times.
|
2266440 | else if (IS_8X8(left_type[LBOT])) |
881 | 654998 | direct_cache[-1 + 2 * 8] = direct_table[4 * left_xy[LBOT] + 1 + (left_block[2] & ~1)]; | |
882 | else | ||
883 | 1611442 | direct_cache[-1 + 2 * 8] = MB_TYPE_16x16 >> 1; | |
884 | } | ||
885 | } | ||
886 | } | ||
887 | |||
888 | #define MAP_MVS \ | ||
889 | MAP_F2F(scan8[0] - 1 - 1 * 8, topleft_type) \ | ||
890 | MAP_F2F(scan8[0] + 0 - 1 * 8, top_type) \ | ||
891 | MAP_F2F(scan8[0] + 1 - 1 * 8, top_type) \ | ||
892 | MAP_F2F(scan8[0] + 2 - 1 * 8, top_type) \ | ||
893 | MAP_F2F(scan8[0] + 3 - 1 * 8, top_type) \ | ||
894 | MAP_F2F(scan8[0] + 4 - 1 * 8, topright_type) \ | ||
895 | MAP_F2F(scan8[0] - 1 + 0 * 8, left_type[LTOP]) \ | ||
896 | MAP_F2F(scan8[0] - 1 + 1 * 8, left_type[LTOP]) \ | ||
897 | MAP_F2F(scan8[0] - 1 + 2 * 8, left_type[LBOT]) \ | ||
898 | MAP_F2F(scan8[0] - 1 + 3 * 8, left_type[LBOT]) | ||
899 | |||
900 |
2/2✓ Branch 0 taken 1796058 times.
✓ Branch 1 taken 6150552 times.
|
7946610 | if (FRAME_MBAFF(h)) { |
901 |
2/2✓ Branch 0 taken 592231 times.
✓ Branch 1 taken 1203827 times.
|
1796058 | if (MB_FIELD(sl)) { |
902 | |||
903 | #define MAP_F2F(idx, mb_type) \ | ||
904 | if (!IS_INTERLACED(mb_type) && sl->ref_cache[list][idx] >= 0) { \ | ||
905 | sl->ref_cache[list][idx] *= 2; \ | ||
906 | sl->mv_cache[list][idx][1] /= 2; \ | ||
907 | sl->mvd_cache[list][idx][1] >>= 1; \ | ||
908 | } | ||
909 | |||
910 |
40/40✓ Branch 0 taken 332414 times.
✓ Branch 1 taken 259817 times.
✓ Branch 2 taken 173051 times.
✓ Branch 3 taken 159363 times.
✓ Branch 4 taken 307863 times.
✓ Branch 5 taken 284368 times.
✓ Branch 6 taken 170840 times.
✓ Branch 7 taken 137023 times.
✓ Branch 8 taken 307863 times.
✓ Branch 9 taken 284368 times.
✓ Branch 10 taken 170840 times.
✓ Branch 11 taken 137023 times.
✓ Branch 12 taken 307863 times.
✓ Branch 13 taken 284368 times.
✓ Branch 14 taken 170873 times.
✓ Branch 15 taken 136990 times.
✓ Branch 16 taken 307863 times.
✓ Branch 17 taken 284368 times.
✓ Branch 18 taken 170873 times.
✓ Branch 19 taken 136990 times.
✓ Branch 20 taken 332361 times.
✓ Branch 21 taken 259870 times.
✓ Branch 22 taken 178772 times.
✓ Branch 23 taken 153589 times.
✓ Branch 24 taken 247826 times.
✓ Branch 25 taken 344405 times.
✓ Branch 26 taken 169886 times.
✓ Branch 27 taken 77940 times.
✓ Branch 28 taken 247826 times.
✓ Branch 29 taken 344405 times.
✓ Branch 30 taken 159734 times.
✓ Branch 31 taken 88092 times.
✓ Branch 32 taken 247826 times.
✓ Branch 33 taken 344405 times.
✓ Branch 34 taken 159515 times.
✓ Branch 35 taken 88311 times.
✓ Branch 36 taken 247826 times.
✓ Branch 37 taken 344405 times.
✓ Branch 38 taken 159521 times.
✓ Branch 39 taken 88305 times.
|
592231 | MAP_MVS |
911 | } else { | ||
912 | |||
913 | #undef MAP_F2F | ||
914 | #define MAP_F2F(idx, mb_type) \ | ||
915 | if (IS_INTERLACED(mb_type) && sl->ref_cache[list][idx] >= 0) { \ | ||
916 | sl->ref_cache[list][idx] >>= 1; \ | ||
917 | sl->mv_cache[list][idx][1] *= 2; \ | ||
918 | sl->mvd_cache[list][idx][1] <<= 1; \ | ||
919 | } | ||
920 | |||
921 |
40/40✓ Branch 0 taken 211555 times.
✓ Branch 1 taken 992272 times.
✓ Branch 2 taken 157101 times.
✓ Branch 3 taken 54454 times.
✓ Branch 4 taken 99998 times.
✓ Branch 5 taken 1103829 times.
✓ Branch 6 taken 77235 times.
✓ Branch 7 taken 22763 times.
✓ Branch 8 taken 99998 times.
✓ Branch 9 taken 1103829 times.
✓ Branch 10 taken 77235 times.
✓ Branch 11 taken 22763 times.
✓ Branch 12 taken 99998 times.
✓ Branch 13 taken 1103829 times.
✓ Branch 14 taken 77300 times.
✓ Branch 15 taken 22698 times.
✓ Branch 16 taken 99998 times.
✓ Branch 17 taken 1103829 times.
✓ Branch 18 taken 77300 times.
✓ Branch 19 taken 22698 times.
✓ Branch 20 taken 104651 times.
✓ Branch 21 taken 1099176 times.
✓ Branch 22 taken 81657 times.
✓ Branch 23 taken 22994 times.
✓ Branch 24 taken 213016 times.
✓ Branch 25 taken 990811 times.
✓ Branch 26 taken 165417 times.
✓ Branch 27 taken 47599 times.
✓ Branch 28 taken 213016 times.
✓ Branch 29 taken 990811 times.
✓ Branch 30 taken 145957 times.
✓ Branch 31 taken 67059 times.
✓ Branch 32 taken 213016 times.
✓ Branch 33 taken 990811 times.
✓ Branch 34 taken 145923 times.
✓ Branch 35 taken 67093 times.
✓ Branch 36 taken 213016 times.
✓ Branch 37 taken 990811 times.
✓ Branch 38 taken 145792 times.
✓ Branch 39 taken 67224 times.
|
1203827 | MAP_MVS |
922 | #undef MAP_F2F | ||
923 | } | ||
924 | } | ||
925 | } | ||
926 | } | ||
927 | |||
928 | 13180558 | sl->neighbor_transform_size = !!IS_8x8DCT(top_type) + !!IS_8x8DCT(left_type[LTOP]); | |
929 | 13180558 | } | |
930 | |||
931 | /** | ||
932 | * decodes a P_SKIP or B_SKIP macroblock | ||
933 | */ | ||
934 | 4236448 | static void av_unused decode_mb_skip(const H264Context *h, H264SliceContext *sl) | |
935 | { | ||
936 | 4236448 | const int mb_xy = sl->mb_xy; | |
937 | 4236448 | int mb_type = 0; | |
938 | |||
939 | 4236448 | memset(h->non_zero_count[mb_xy], 0, 48); | |
940 | |||
941 |
2/2✓ Branch 0 taken 1542807 times.
✓ Branch 1 taken 2693641 times.
|
4236448 | if (MB_FIELD(sl)) |
942 | 1542807 | mb_type |= MB_TYPE_INTERLACED; | |
943 | |||
944 |
2/2✓ Branch 0 taken 2445670 times.
✓ Branch 1 taken 1790778 times.
|
4236448 | if (sl->slice_type_nos == AV_PICTURE_TYPE_B) { |
945 | // just for fill_caches. pred_direct_motion will set the real mb_type | ||
946 | 2445670 | mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 | MB_TYPE_SKIP; | |
947 |
2/2✓ Branch 0 taken 2309472 times.
✓ Branch 1 taken 136198 times.
|
2445670 | if (sl->direct_spatial_mv_pred) { |
948 | 2309472 | fill_decode_neighbors(h, sl, mb_type); | |
949 | 2309472 | fill_decode_caches(h, sl, mb_type); //FIXME check what is needed and what not ... | |
950 | } | ||
951 | 2445670 | ff_h264_pred_direct_motion(h, sl, &mb_type); | |
952 | 2445670 | mb_type |= MB_TYPE_SKIP; | |
953 | } else { | ||
954 | 1790778 | mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_SKIP; | |
955 | |||
956 | 1790778 | fill_decode_neighbors(h, sl, mb_type); | |
957 | 1790778 | pred_pskip_motion(h, sl); | |
958 | } | ||
959 | |||
960 | 4236448 | write_back_motion(h, sl, mb_type); | |
961 | 4236448 | h->cur_pic.mb_type[mb_xy] = mb_type; | |
962 | 4236448 | h->cur_pic.qscale_table[mb_xy] = sl->qscale; | |
963 | 4236448 | h->slice_table[mb_xy] = sl->slice_num; | |
964 | 4236448 | sl->prev_mb_skipped = 1; | |
965 | 4236448 | } | |
966 | |||
967 | #endif /* AVCODEC_H264_MVPRED_H */ | ||
968 |