Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * H.26L/H.264/AVC/JVT/14496-10/... decoder | ||
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 | #include "h264dec.h" | ||
23 | |||
24 | #undef MCFUNC | ||
25 | |||
26 | #if CHROMA_IDC == 1 | ||
27 | # define MCFUNC(n) FUNC(n ## _420) | ||
28 | #elif CHROMA_IDC == 2 | ||
29 | # define MCFUNC(n) FUNC(n ## _422) | ||
30 | #elif CHROMA_IDC == 3 | ||
31 | # define MCFUNC(n) FUNC(n ## _444) | ||
32 | #endif | ||
33 | |||
34 | #undef mc_part | ||
35 | #define mc_part MCFUNC(mc_part) | ||
36 | |||
37 | 44238442 | static void mc_part(const H264Context *h, H264SliceContext *sl, | |
38 | int n, int square, | ||
39 | int height, int delta, | ||
40 | uint8_t *dest_y, uint8_t *dest_cb, | ||
41 | uint8_t *dest_cr, | ||
42 | int x_offset, int y_offset, | ||
43 | const qpel_mc_func *qpix_put, | ||
44 | h264_chroma_mc_func chroma_put, | ||
45 | const qpel_mc_func *qpix_avg, | ||
46 | h264_chroma_mc_func chroma_avg, | ||
47 | const h264_weight_func *weight_op, | ||
48 | const h264_biweight_func *weight_avg, | ||
49 | int list0, int list1) | ||
50 | { | ||
51 |
6/6✓ Branch 0 taken 1032946 times.
✓ Branch 1 taken 21086275 times.
✓ Branch 2 taken 802265 times.
✓ Branch 3 taken 230681 times.
✓ Branch 4 taken 660303 times.
✓ Branch 5 taken 141962 times.
|
44238442 | if ((sl->pwt.use_weight == 2 && list0 && list1 && |
52 |
2/2✓ Branch 0 taken 401824 times.
✓ Branch 1 taken 258479 times.
|
1320606 | (sl->pwt.implicit_weight[sl->ref_cache[0][scan8[n]]][sl->ref_cache[1][scan8[n]]][sl->mb_y & 1] != 32)) || |
53 |
2/2✓ Branch 0 taken 1331225 times.
✓ Branch 1 taken 20529517 times.
|
43721484 | sl->pwt.use_weight == 1) |
54 | 3179408 | mc_part_weighted(h, sl, n, square, height, delta, dest_y, dest_cb, dest_cr, | |
55 | x_offset, y_offset, qpix_put, chroma_put, | ||
56 | 3179408 | weight_op[0], weight_op[1], weight_avg[0], | |
57 | 3179408 | weight_avg[1], list0, list1, PIXEL_SHIFT, CHROMA_IDC); | |
58 | else | ||
59 | 41059034 | mc_part_std(h, sl, n, square, height, delta, dest_y, dest_cb, dest_cr, | |
60 | x_offset, y_offset, qpix_put, chroma_put, qpix_avg, | ||
61 | 18426256 | chroma_avg, list0, list1, PIXEL_SHIFT, CHROMA_IDC); | |
62 | 44238442 | } | |
63 | |||
64 | 22082286 | static void MCFUNC(hl_motion)(const H264Context *h, H264SliceContext *sl, | |
65 | uint8_t *dest_y, | ||
66 | uint8_t *dest_cb, uint8_t *dest_cr, | ||
67 | const qpel_mc_func(*qpix_put)[16], | ||
68 | const h264_chroma_mc_func(*chroma_put), | ||
69 | const qpel_mc_func(*qpix_avg)[16], | ||
70 | const h264_chroma_mc_func(*chroma_avg), | ||
71 | const h264_weight_func *weight_op, | ||
72 | const h264_biweight_func *weight_avg) | ||
73 | { | ||
74 | 22082286 | const int mb_xy = sl->mb_xy; | |
75 | 22082286 | const int mb_type = h->cur_pic.mb_type[mb_xy]; | |
76 | |||
77 | av_assert2(IS_INTER(mb_type)); | ||
78 | |||
79 |
2/2✓ Branch 0 taken 95468 times.
✓ Branch 1 taken 10945675 times.
|
22082286 | if (HAVE_THREADS && (h->avctx->active_thread_type & FF_THREAD_FRAME)) |
80 | 190936 | await_references(h, sl); | |
81 |
2/2✓ Branch 0 taken 10231064 times.
✓ Branch 1 taken 810079 times.
|
22082286 | if (USES_LIST(mb_type, 0)) |
82 | 20462128 | prefetch_motion(h, sl, 0, PIXEL_SHIFT, CHROMA_IDC); | |
83 | |||
84 |
2/2✓ Branch 0 taken 8304236 times.
✓ Branch 1 taken 2736907 times.
|
22082286 | if (IS_16X16(mb_type)) { |
85 | 16608472 | mc_part(h, sl, 0, 1, 16, 0, dest_y, dest_cb, dest_cr, 0, 0, | |
86 | qpix_put[0], chroma_put[0], qpix_avg[0], chroma_avg[0], | ||
87 | weight_op, weight_avg, | ||
88 | IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1)); | ||
89 |
2/2✓ Branch 0 taken 678170 times.
✓ Branch 1 taken 2058737 times.
|
5473814 | } else if (IS_16X8(mb_type)) { |
90 | 1356340 | mc_part(h, sl, 0, 0, 8, 8 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr, 0, 0, | |
91 | 1356340 | qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0], | |
92 | weight_op, weight_avg, | ||
93 | IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1)); | ||
94 | 1356340 | mc_part(h, sl, 8, 0, 8, 8 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr, 0, 4, | |
95 | 1356340 | qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0], | |
96 | weight_op, weight_avg, | ||
97 | IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1)); | ||
98 |
2/2✓ Branch 0 taken 605593 times.
✓ Branch 1 taken 1453144 times.
|
4117474 | } else if (IS_8X16(mb_type)) { |
99 | 1211186 | mc_part(h, sl, 0, 0, 16, 8 * sl->mb_linesize, dest_y, dest_cb, dest_cr, 0, 0, | |
100 | 1211186 | qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], | |
101 | &weight_op[1], &weight_avg[1], | ||
102 | IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1)); | ||
103 | 1211186 | mc_part(h, sl, 4, 0, 16, 8 * sl->mb_linesize, dest_y, dest_cb, dest_cr, 4, 0, | |
104 | 1211186 | qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], | |
105 | &weight_op[1], &weight_avg[1], | ||
106 | IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1)); | ||
107 | } else { | ||
108 | int i; | ||
109 | |||
110 | av_assert2(IS_8X8(mb_type)); | ||
111 | |||
112 |
2/2✓ Branch 0 taken 5812576 times.
✓ Branch 1 taken 1453144 times.
|
14531440 | for (i = 0; i < 4; i++) { |
113 | 11625152 | const int sub_mb_type = sl->sub_mb_type[i]; | |
114 | 11625152 | const int n = 4 * i; | |
115 | 11625152 | int x_offset = (i & 1) << 2; | |
116 | 11625152 | int y_offset = (i & 2) << 1; | |
117 | |||
118 |
2/2✓ Branch 0 taken 2653645 times.
✓ Branch 1 taken 3158931 times.
|
11625152 | if (IS_SUB_8X8(sub_mb_type)) { |
119 | 5307290 | mc_part(h, sl, n, 1, 8, 0, dest_y, dest_cb, dest_cr, | |
120 | x_offset, y_offset, | ||
121 | 5307290 | qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], | |
122 | &weight_op[1], &weight_avg[1], | ||
123 | IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); | ||
124 |
2/2✓ Branch 0 taken 1471614 times.
✓ Branch 1 taken 1687317 times.
|
6317862 | } else if (IS_SUB_8X4(sub_mb_type)) { |
125 | 2943228 | mc_part(h, sl, n, 0, 4, 4 << PIXEL_SHIFT, dest_y, dest_cb, dest_cr, | |
126 | x_offset, y_offset, | ||
127 | 2943228 | qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1], | |
128 | &weight_op[1], &weight_avg[1], | ||
129 | IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); | ||
130 | 2943228 | mc_part(h, sl, n + 2, 0, 4, 4 << PIXEL_SHIFT, | |
131 | dest_y, dest_cb, dest_cr, x_offset, y_offset + 2, | ||
132 | 2943228 | qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1], | |
133 | &weight_op[1], &weight_avg[1], | ||
134 | IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); | ||
135 |
2/2✓ Branch 0 taken 549341 times.
✓ Branch 1 taken 1137976 times.
|
3374634 | } else if (IS_SUB_4X8(sub_mb_type)) { |
136 | 1098682 | mc_part(h, sl, n, 0, 8, 4 * sl->mb_linesize, | |
137 | dest_y, dest_cb, dest_cr, x_offset, y_offset, | ||
138 | 1098682 | qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], | |
139 | &weight_op[2], &weight_avg[2], | ||
140 | IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); | ||
141 | 1098682 | mc_part(h, sl, n + 1, 0, 8, 4 * sl->mb_linesize, | |
142 | dest_y, dest_cb, dest_cr, x_offset + 2, y_offset, | ||
143 | 1098682 | qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], | |
144 | &weight_op[2], &weight_avg[2], | ||
145 | IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); | ||
146 | } else { | ||
147 | int j; | ||
148 | av_assert2(IS_SUB_4X4(sub_mb_type)); | ||
149 |
2/2✓ Branch 0 taken 4551904 times.
✓ Branch 1 taken 1137976 times.
|
11379760 | for (j = 0; j < 4; j++) { |
150 | 9103808 | int sub_x_offset = x_offset + 2 * (j & 1); | |
151 | 9103808 | int sub_y_offset = y_offset + (j & 2); | |
152 | 9103808 | mc_part(h, sl, n + j, 1, 4, 0, | |
153 | dest_y, dest_cb, dest_cr, sub_x_offset, sub_y_offset, | ||
154 | 9103808 | qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], | |
155 | &weight_op[2], &weight_avg[2], | ||
156 | IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1)); | ||
157 | } | ||
158 | } | ||
159 | } | ||
160 | } | ||
161 | |||
162 |
2/2✓ Branch 0 taken 4588698 times.
✓ Branch 1 taken 6452445 times.
|
22082286 | if (USES_LIST(mb_type, 1)) |
163 | 9177396 | prefetch_motion(h, sl, 1, PIXEL_SHIFT, CHROMA_IDC); | |
164 | 22082286 | } | |
165 | |||
166 |