Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * VC-1 and WMV3 decoder | ||
3 | * Copyright (c) 2011 Mashiat Sarker Shakkhar | ||
4 | * Copyright (c) 2006-2007 Konstantin Shishkov | ||
5 | * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer | ||
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 | /** | ||
25 | * @file | ||
26 | * VC-1 and WMV3 block decoding routines | ||
27 | */ | ||
28 | |||
29 | #include "mathops.h" | ||
30 | #include "mpegutils.h" | ||
31 | #include "mpegvideo.h" | ||
32 | #include "vc1.h" | ||
33 | #include "vc1_pred.h" | ||
34 | #include "vc1data.h" | ||
35 | |||
36 | 34909 | static av_always_inline int scaleforsame_x(VC1Context *v, int n /* MV */, int dir) | |
37 | { | ||
38 | int scaledvalue, refdist; | ||
39 | int scalesame1, scalesame2; | ||
40 | int scalezone1_x, zone1offset_x; | ||
41 | 34909 | int table_index = dir ^ v->second_field; | |
42 | |||
43 |
2/2✓ Branch 0 taken 14268 times.
✓ Branch 1 taken 20641 times.
|
34909 | if (v->s.pict_type != AV_PICTURE_TYPE_B) |
44 | 14268 | refdist = v->refdist; | |
45 | else | ||
46 |
2/2✓ Branch 0 taken 7214 times.
✓ Branch 1 taken 13427 times.
|
20641 | refdist = dir ? v->brfd : v->frfd; |
47 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 34909 times.
|
34909 | if (refdist > 3) |
48 | ✗ | refdist = 3; | |
49 | 34909 | scalesame1 = ff_vc1_field_mvpred_scales[table_index][1][refdist]; | |
50 | 34909 | scalesame2 = ff_vc1_field_mvpred_scales[table_index][2][refdist]; | |
51 | 34909 | scalezone1_x = ff_vc1_field_mvpred_scales[table_index][3][refdist]; | |
52 | 34909 | zone1offset_x = ff_vc1_field_mvpred_scales[table_index][5][refdist]; | |
53 | |||
54 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 34896 times.
|
34909 | if (FFABS(n) > 255) |
55 | 13 | scaledvalue = n; | |
56 | else { | ||
57 |
2/2✓ Branch 0 taken 25948 times.
✓ Branch 1 taken 8948 times.
|
34896 | if (FFABS(n) < scalezone1_x) |
58 | 25948 | scaledvalue = (n * scalesame1) >> 8; | |
59 | else { | ||
60 |
2/2✓ Branch 0 taken 4487 times.
✓ Branch 1 taken 4461 times.
|
8948 | if (n < 0) |
61 | 4487 | scaledvalue = ((n * scalesame2) >> 8) - zone1offset_x; | |
62 | else | ||
63 | 4461 | scaledvalue = ((n * scalesame2) >> 8) + zone1offset_x; | |
64 | } | ||
65 | } | ||
66 | 34909 | return av_clip(scaledvalue, -v->range_x, v->range_x - 1); | |
67 | } | ||
68 | |||
69 | 34909 | static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n /* MV */, int dir) | |
70 | { | ||
71 | int scaledvalue, refdist; | ||
72 | int scalesame1, scalesame2; | ||
73 | int scalezone1_y, zone1offset_y; | ||
74 | 34909 | int table_index = dir ^ v->second_field; | |
75 | |||
76 |
2/2✓ Branch 0 taken 14268 times.
✓ Branch 1 taken 20641 times.
|
34909 | if (v->s.pict_type != AV_PICTURE_TYPE_B) |
77 | 14268 | refdist = v->refdist; | |
78 | else | ||
79 |
2/2✓ Branch 0 taken 7214 times.
✓ Branch 1 taken 13427 times.
|
20641 | refdist = dir ? v->brfd : v->frfd; |
80 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 34909 times.
|
34909 | if (refdist > 3) |
81 | ✗ | refdist = 3; | |
82 | 34909 | scalesame1 = ff_vc1_field_mvpred_scales[table_index][1][refdist]; | |
83 | 34909 | scalesame2 = ff_vc1_field_mvpred_scales[table_index][2][refdist]; | |
84 | 34909 | scalezone1_y = ff_vc1_field_mvpred_scales[table_index][4][refdist]; | |
85 | 34909 | zone1offset_y = ff_vc1_field_mvpred_scales[table_index][6][refdist]; | |
86 | |||
87 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 34909 times.
|
34909 | if (FFABS(n) > 63) |
88 | ✗ | scaledvalue = n; | |
89 | else { | ||
90 |
2/2✓ Branch 0 taken 27772 times.
✓ Branch 1 taken 7137 times.
|
34909 | if (FFABS(n) < scalezone1_y) |
91 | 27772 | scaledvalue = (n * scalesame1) >> 8; | |
92 | else { | ||
93 |
2/2✓ Branch 0 taken 3231 times.
✓ Branch 1 taken 3906 times.
|
7137 | if (n < 0) |
94 | 3231 | scaledvalue = ((n * scalesame2) >> 8) - zone1offset_y; | |
95 | else | ||
96 | 3906 | scaledvalue = ((n * scalesame2) >> 8) + zone1offset_y; | |
97 | } | ||
98 | } | ||
99 | |||
100 |
3/4✓ Branch 0 taken 18863 times.
✓ Branch 1 taken 16046 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18863 times.
|
34909 | if (v->cur_field_type && !v->ref_field_type[dir]) |
101 | ✗ | return av_clip(scaledvalue, -v->range_y / 2 + 1, v->range_y / 2); | |
102 | else | ||
103 | 34909 | return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1); | |
104 | } | ||
105 | |||
106 | 8428 | static av_always_inline int scaleforopp_x(VC1Context *v, int n /* MV */) | |
107 | { | ||
108 | int scalezone1_x, zone1offset_x; | ||
109 | int scaleopp1, scaleopp2, brfd; | ||
110 | int scaledvalue; | ||
111 | |||
112 | 8428 | brfd = FFMIN(v->brfd, 3); | |
113 | 8428 | scalezone1_x = ff_vc1_b_field_mvpred_scales[3][brfd]; | |
114 | 8428 | zone1offset_x = ff_vc1_b_field_mvpred_scales[5][brfd]; | |
115 | 8428 | scaleopp1 = ff_vc1_b_field_mvpred_scales[1][brfd]; | |
116 | 8428 | scaleopp2 = ff_vc1_b_field_mvpred_scales[2][brfd]; | |
117 | |||
118 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8428 times.
|
8428 | if (FFABS(n) > 255) |
119 | ✗ | scaledvalue = n; | |
120 | else { | ||
121 |
2/2✓ Branch 0 taken 6150 times.
✓ Branch 1 taken 2278 times.
|
8428 | if (FFABS(n) < scalezone1_x) |
122 | 6150 | scaledvalue = (n * scaleopp1) >> 8; | |
123 | else { | ||
124 |
2/2✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 1127 times.
|
2278 | if (n < 0) |
125 | 1151 | scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_x; | |
126 | else | ||
127 | 1127 | scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_x; | |
128 | } | ||
129 | } | ||
130 | 8428 | return av_clip(scaledvalue, -v->range_x, v->range_x - 1); | |
131 | } | ||
132 | |||
133 | 8428 | static av_always_inline int scaleforopp_y(VC1Context *v, int n /* MV */, int dir) | |
134 | { | ||
135 | int scalezone1_y, zone1offset_y; | ||
136 | int scaleopp1, scaleopp2, brfd; | ||
137 | int scaledvalue; | ||
138 | |||
139 | 8428 | brfd = FFMIN(v->brfd, 3); | |
140 | 8428 | scalezone1_y = ff_vc1_b_field_mvpred_scales[4][brfd]; | |
141 | 8428 | zone1offset_y = ff_vc1_b_field_mvpred_scales[6][brfd]; | |
142 | 8428 | scaleopp1 = ff_vc1_b_field_mvpred_scales[1][brfd]; | |
143 | 8428 | scaleopp2 = ff_vc1_b_field_mvpred_scales[2][brfd]; | |
144 | |||
145 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8428 times.
|
8428 | if (FFABS(n) > 63) |
146 | ✗ | scaledvalue = n; | |
147 | else { | ||
148 |
2/2✓ Branch 0 taken 6961 times.
✓ Branch 1 taken 1467 times.
|
8428 | if (FFABS(n) < scalezone1_y) |
149 | 6961 | scaledvalue = (n * scaleopp1) >> 8; | |
150 | else { | ||
151 |
2/2✓ Branch 0 taken 803 times.
✓ Branch 1 taken 664 times.
|
1467 | if (n < 0) |
152 | 803 | scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_y; | |
153 | else | ||
154 | 664 | scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_y; | |
155 | } | ||
156 | } | ||
157 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 8428 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
8428 | if (v->cur_field_type && !v->ref_field_type[dir]) { |
158 | ✗ | return av_clip(scaledvalue, -v->range_y / 2 + 1, v->range_y / 2); | |
159 | } else { | ||
160 | 8428 | return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1); | |
161 | } | ||
162 | } | ||
163 | |||
164 | 86724 | static av_always_inline int scaleforsame(VC1Context *v, int i, int n /* MV */, | |
165 | int dim, int dir) | ||
166 | { | ||
167 | int brfd, scalesame; | ||
168 | 86724 | int hpel = 1 - v->s.quarter_sample; | |
169 | |||
170 | 86724 | n >>= hpel; | |
171 |
6/6✓ Branch 0 taken 58188 times.
✓ Branch 1 taken 28536 times.
✓ Branch 2 taken 32076 times.
✓ Branch 3 taken 26112 times.
✓ Branch 4 taken 15170 times.
✓ Branch 5 taken 16906 times.
|
86724 | if (v->s.pict_type != AV_PICTURE_TYPE_B || v->second_field || !dir) { |
172 |
2/2✓ Branch 0 taken 34909 times.
✓ Branch 1 taken 34909 times.
|
69818 | if (dim) |
173 | 34909 | n = scaleforsame_y(v, i, n, dir) * (1 << hpel); | |
174 | else | ||
175 | 34909 | n = scaleforsame_x(v, n, dir) * (1 << hpel); | |
176 | 69818 | return n; | |
177 | } | ||
178 | 16906 | brfd = FFMIN(v->brfd, 3); | |
179 | 16906 | scalesame = ff_vc1_b_field_mvpred_scales[0][brfd]; | |
180 | |||
181 | 16906 | n = (n * scalesame >> 8) * (1 << hpel); | |
182 | 16906 | return n; | |
183 | } | ||
184 | |||
185 | 86000 | static av_always_inline int scaleforopp(VC1Context *v, int n /* MV */, | |
186 | int dim, int dir) | ||
187 | { | ||
188 | int refdist, scaleopp; | ||
189 | 86000 | int hpel = 1 - v->s.quarter_sample; | |
190 | |||
191 | 86000 | n >>= hpel; | |
192 |
6/6✓ Branch 0 taken 59182 times.
✓ Branch 1 taken 26818 times.
✓ Branch 2 taken 31814 times.
✓ Branch 3 taken 27368 times.
✓ Branch 4 taken 16856 times.
✓ Branch 5 taken 14958 times.
|
86000 | if (v->s.pict_type == AV_PICTURE_TYPE_B && !v->second_field && dir == 1) { |
193 |
2/2✓ Branch 0 taken 8428 times.
✓ Branch 1 taken 8428 times.
|
16856 | if (dim) |
194 | 8428 | n = scaleforopp_y(v, n, dir) * (1 << hpel); | |
195 | else | ||
196 | 8428 | n = scaleforopp_x(v, n) * (1 << hpel); | |
197 | 16856 | return n; | |
198 | } | ||
199 |
2/2✓ Branch 0 taken 26818 times.
✓ Branch 1 taken 42326 times.
|
69144 | if (v->s.pict_type != AV_PICTURE_TYPE_B) |
200 | 26818 | refdist = v->refdist; | |
201 | else | ||
202 |
2/2✓ Branch 0 taken 13008 times.
✓ Branch 1 taken 29318 times.
|
42326 | refdist = dir ? v->brfd : v->frfd; |
203 | 69144 | refdist = FFMIN(refdist, 3); | |
204 | 69144 | scaleopp = ff_vc1_field_mvpred_scales[dir ^ v->second_field][0][refdist]; | |
205 | |||
206 | 69144 | n = (n * scaleopp >> 8) * (1 << hpel); | |
207 | 69144 | return n; | |
208 | } | ||
209 | |||
210 | /** Predict and set motion vector | ||
211 | */ | ||
212 | 398903 | void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, | |
213 | int mv1, int r_x, int r_y, uint8_t* is_intra, | ||
214 | int pred_flag, int dir) | ||
215 | { | ||
216 | 398903 | MpegEncContext *s = &v->s; | |
217 | 398903 | int xy, wrap, off = 0; | |
218 | int16_t *A, *B, *C; | ||
219 | int px, py; | ||
220 | int sum; | ||
221 | 398903 | int mixedmv_pic, num_samefield = 0, num_oppfield = 0; | |
222 | int opposite, a_f, b_f, c_f; | ||
223 | int16_t field_predA[2]; | ||
224 | int16_t field_predB[2]; | ||
225 | int16_t field_predC[2]; | ||
226 | int a_valid, b_valid, c_valid; | ||
227 | 398903 | int hybridmv_thresh, y_bias = 0; | |
228 | |||
229 |
2/2✓ Branch 0 taken 147596 times.
✓ Branch 1 taken 251307 times.
|
398903 | if (v->mv_mode == MV_PMODE_MIXED_MV || |
230 |
3/4✓ Branch 0 taken 4620 times.
✓ Branch 1 taken 142976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4620 times.
|
147596 | ((v->mv_mode == MV_PMODE_INTENSITY_COMP) && (v->mv_mode2 == MV_PMODE_MIXED_MV))) |
231 | 251307 | mixedmv_pic = 1; | |
232 | else | ||
233 | 147596 | mixedmv_pic = 0; | |
234 | /* scale MV difference to be quad-pel */ | ||
235 |
2/2✓ Branch 0 taken 115752 times.
✓ Branch 1 taken 283151 times.
|
398903 | if (!s->quarter_sample) { |
236 | 115752 | dmv_x *= 2; | |
237 | 115752 | dmv_y *= 2; | |
238 | } | ||
239 | |||
240 | 398903 | wrap = s->b8_stride; | |
241 | 398903 | xy = s->block_index[n]; | |
242 | |||
243 |
2/2✓ Branch 0 taken 35551 times.
✓ Branch 1 taken 363352 times.
|
398903 | if (s->mb_intra) { |
244 | 35551 | s->mv[0][n][0] = s->current_picture.motion_val[0][xy + v->blocks_off][0] = 0; | |
245 | 35551 | s->mv[0][n][1] = s->current_picture.motion_val[0][xy + v->blocks_off][1] = 0; | |
246 | 35551 | s->current_picture.motion_val[1][xy + v->blocks_off][0] = 0; | |
247 | 35551 | s->current_picture.motion_val[1][xy + v->blocks_off][1] = 0; | |
248 |
2/2✓ Branch 0 taken 24987 times.
✓ Branch 1 taken 10564 times.
|
35551 | if (mv1) { /* duplicate motion data for 1-MV block */ |
249 | 24987 | s->current_picture.motion_val[0][xy + 1 + v->blocks_off][0] = 0; | |
250 | 24987 | s->current_picture.motion_val[0][xy + 1 + v->blocks_off][1] = 0; | |
251 | 24987 | s->current_picture.motion_val[0][xy + wrap + v->blocks_off][0] = 0; | |
252 | 24987 | s->current_picture.motion_val[0][xy + wrap + v->blocks_off][1] = 0; | |
253 | 24987 | s->current_picture.motion_val[0][xy + wrap + 1 + v->blocks_off][0] = 0; | |
254 | 24987 | s->current_picture.motion_val[0][xy + wrap + 1 + v->blocks_off][1] = 0; | |
255 | 24987 | v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; | |
256 | 24987 | s->current_picture.motion_val[1][xy + 1 + v->blocks_off][0] = 0; | |
257 | 24987 | s->current_picture.motion_val[1][xy + 1 + v->blocks_off][1] = 0; | |
258 | 24987 | s->current_picture.motion_val[1][xy + wrap + v->blocks_off][0] = 0; | |
259 | 24987 | s->current_picture.motion_val[1][xy + wrap + v->blocks_off][1] = 0; | |
260 | 24987 | s->current_picture.motion_val[1][xy + wrap + 1 + v->blocks_off][0] = 0; | |
261 | 24987 | s->current_picture.motion_val[1][xy + wrap + 1 + v->blocks_off][1] = 0; | |
262 | } | ||
263 | 35551 | return; | |
264 | } | ||
265 | |||
266 |
6/6✓ Branch 0 taken 56538 times.
✓ Branch 1 taken 306814 times.
✓ Branch 2 taken 46881 times.
✓ Branch 3 taken 9657 times.
✓ Branch 4 taken 9674 times.
✓ Branch 5 taken 37207 times.
|
363352 | a_valid = !s->first_slice_line || (n == 2 || n == 3); |
267 | 363352 | b_valid = a_valid; | |
268 |
6/6✓ Branch 0 taken 8510 times.
✓ Branch 1 taken 354842 times.
✓ Branch 2 taken 7475 times.
✓ Branch 3 taken 1035 times.
✓ Branch 4 taken 1029 times.
✓ Branch 5 taken 6446 times.
|
363352 | c_valid = s->mb_x || (n == 1 || n == 3); |
269 |
2/2✓ Branch 0 taken 201708 times.
✓ Branch 1 taken 161644 times.
|
363352 | if (mv1) { |
270 |
4/4✓ Branch 0 taken 100663 times.
✓ Branch 1 taken 101045 times.
✓ Branch 2 taken 26211 times.
✓ Branch 3 taken 74452 times.
|
201708 | if (v->field_mode && mixedmv_pic) |
271 |
2/2✓ Branch 0 taken 470 times.
✓ Branch 1 taken 25741 times.
|
26211 | off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; |
272 | else | ||
273 |
2/2✓ Branch 0 taken 3853 times.
✓ Branch 1 taken 171644 times.
|
175497 | off = (s->mb_x == (s->mb_width - 1)) ? -1 : 2; |
274 |
3/4✓ Branch 0 taken 183816 times.
✓ Branch 1 taken 17892 times.
✓ Branch 2 taken 183816 times.
✗ Branch 3 not taken.
|
201708 | b_valid = b_valid && s->mb_width > 1; |
275 | } else { | ||
276 | //in 4-MV mode different blocks have different B predictor position | ||
277 |
4/5✓ Branch 0 taken 40502 times.
✓ Branch 1 taken 40397 times.
✓ Branch 2 taken 40382 times.
✓ Branch 3 taken 40363 times.
✗ Branch 4 not taken.
|
161644 | switch (n) { |
278 | 40502 | case 0: | |
279 |
1/2✓ Branch 0 taken 40502 times.
✗ Branch 1 not taken.
|
40502 | if (v->res_rtm_flag) |
280 |
2/2✓ Branch 0 taken 39495 times.
✓ Branch 1 taken 1007 times.
|
40502 | off = s->mb_x ? -1 : 1; |
281 | else | ||
282 | ✗ | off = s->mb_x ? -1 : 2 * s->mb_width - wrap - 1; | |
283 | 40502 | break; | |
284 | 40397 | case 1: | |
285 |
2/2✓ Branch 0 taken 913 times.
✓ Branch 1 taken 39484 times.
|
40397 | off = (s->mb_x == (s->mb_width - 1)) ? -1 : 1; |
286 | 40397 | break; | |
287 | 40382 | case 2: | |
288 | 40382 | off = 1; | |
289 | 40382 | break; | |
290 | 40363 | case 3: | |
291 | 40363 | off = -1; | |
292 | } | ||
293 |
3/4✓ Branch 0 taken 65904 times.
✓ Branch 1 taken 95740 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 65904 times.
|
161644 | if (v->field_mode && s->mb_width == 1) |
294 | ✗ | b_valid = b_valid && c_valid; | |
295 | } | ||
296 | |||
297 |
2/2✓ Branch 0 taken 166567 times.
✓ Branch 1 taken 196785 times.
|
363352 | if (v->field_mode) { |
298 |
4/4✓ Branch 0 taken 160625 times.
✓ Branch 1 taken 5942 times.
✓ Branch 2 taken 153049 times.
✓ Branch 3 taken 7576 times.
|
166567 | a_valid = a_valid && !is_intra[xy - wrap]; |
299 |
4/4✓ Branch 0 taken 160625 times.
✓ Branch 1 taken 5942 times.
✓ Branch 2 taken 152892 times.
✓ Branch 3 taken 7733 times.
|
166567 | b_valid = b_valid && !is_intra[xy - wrap + off]; |
300 |
4/4✓ Branch 0 taken 164660 times.
✓ Branch 1 taken 1907 times.
✓ Branch 2 taken 156923 times.
✓ Branch 3 taken 7737 times.
|
166567 | c_valid = c_valid && !is_intra[xy - 1]; |
301 | } | ||
302 | |||
303 |
2/2✓ Branch 0 taken 318569 times.
✓ Branch 1 taken 44783 times.
|
363352 | if (a_valid) { |
304 | 318569 | A = s->current_picture.motion_val[dir][xy - wrap + v->blocks_off]; | |
305 | 318569 | a_f = v->mv_f[dir][xy - wrap + v->blocks_off]; | |
306 | 318569 | num_oppfield += a_f; | |
307 | 318569 | num_samefield += 1 - a_f; | |
308 | 318569 | field_predA[0] = A[0]; | |
309 | 318569 | field_predA[1] = A[1]; | |
310 | } else { | ||
311 | 44783 | field_predA[0] = field_predA[1] = 0; | |
312 | 44783 | a_f = 0; | |
313 | } | ||
314 |
2/2✓ Branch 0 taken 318412 times.
✓ Branch 1 taken 44940 times.
|
363352 | if (b_valid) { |
315 | 318412 | B = s->current_picture.motion_val[dir][xy - wrap + off + v->blocks_off]; | |
316 | 318412 | b_f = v->mv_f[dir][xy - wrap + off + v->blocks_off]; | |
317 | 318412 | num_oppfield += b_f; | |
318 | 318412 | num_samefield += 1 - b_f; | |
319 | 318412 | field_predB[0] = B[0]; | |
320 | 318412 | field_predB[1] = B[1]; | |
321 | } else { | ||
322 | 44940 | field_predB[0] = field_predB[1] = 0; | |
323 | 44940 | b_f = 0; | |
324 | } | ||
325 |
2/2✓ Branch 0 taken 349169 times.
✓ Branch 1 taken 14183 times.
|
363352 | if (c_valid) { |
326 | 349169 | C = s->current_picture.motion_val[dir][xy - 1 + v->blocks_off]; | |
327 | 349169 | c_f = v->mv_f[dir][xy - 1 + v->blocks_off]; | |
328 | 349169 | num_oppfield += c_f; | |
329 | 349169 | num_samefield += 1 - c_f; | |
330 | 349169 | field_predC[0] = C[0]; | |
331 | 349169 | field_predC[1] = C[1]; | |
332 | } else { | ||
333 | 14183 | field_predC[0] = field_predC[1] = 0; | |
334 | 14183 | c_f = 0; | |
335 | } | ||
336 | |||
337 |
2/2✓ Branch 0 taken 166567 times.
✓ Branch 1 taken 196785 times.
|
363352 | if (v->field_mode) { |
338 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 166567 times.
|
166567 | if (!v->numref) |
339 | // REFFIELD determines if the last field or the second-last field is | ||
340 | // to be used as reference | ||
341 | ✗ | opposite = 1 - v->reffield; | |
342 | else { | ||
343 |
2/2✓ Branch 0 taken 91071 times.
✓ Branch 1 taken 75496 times.
|
166567 | if (num_samefield <= num_oppfield) |
344 | 91071 | opposite = 1 - pred_flag; | |
345 | else | ||
346 | 75496 | opposite = pred_flag; | |
347 | } | ||
348 | } else | ||
349 | 196785 | opposite = 0; | |
350 |
2/2✓ Branch 0 taken 89197 times.
✓ Branch 1 taken 274155 times.
|
363352 | if (opposite) { |
351 | 89197 | v->mv_f[dir][xy + v->blocks_off] = 1; | |
352 | 89197 | v->ref_field_type[dir] = !v->cur_field_type; | |
353 |
4/4✓ Branch 0 taken 81172 times.
✓ Branch 1 taken 8025 times.
✓ Branch 2 taken 13504 times.
✓ Branch 3 taken 67668 times.
|
89197 | if (a_valid && !a_f) { |
354 | 13504 | field_predA[0] = scaleforopp(v, field_predA[0], 0, dir); | |
355 | 13504 | field_predA[1] = scaleforopp(v, field_predA[1], 1, dir); | |
356 | } | ||
357 |
4/4✓ Branch 0 taken 81065 times.
✓ Branch 1 taken 8132 times.
✓ Branch 2 taken 15275 times.
✓ Branch 3 taken 65790 times.
|
89197 | if (b_valid && !b_f) { |
358 | 15275 | field_predB[0] = scaleforopp(v, field_predB[0], 0, dir); | |
359 | 15275 | field_predB[1] = scaleforopp(v, field_predB[1], 1, dir); | |
360 | } | ||
361 |
4/4✓ Branch 0 taken 83263 times.
✓ Branch 1 taken 5934 times.
✓ Branch 2 taken 14221 times.
✓ Branch 3 taken 69042 times.
|
89197 | if (c_valid && !c_f) { |
362 | 14221 | field_predC[0] = scaleforopp(v, field_predC[0], 0, dir); | |
363 | 14221 | field_predC[1] = scaleforopp(v, field_predC[1], 1, dir); | |
364 | } | ||
365 | } else { | ||
366 | 274155 | v->mv_f[dir][xy + v->blocks_off] = 0; | |
367 | 274155 | v->ref_field_type[dir] = v->cur_field_type; | |
368 |
4/4✓ Branch 0 taken 237397 times.
✓ Branch 1 taken 36758 times.
✓ Branch 2 taken 13995 times.
✓ Branch 3 taken 223402 times.
|
274155 | if (a_valid && a_f) { |
369 | 13995 | field_predA[0] = scaleforsame(v, n, field_predA[0], 0, dir); | |
370 | 13995 | field_predA[1] = scaleforsame(v, n, field_predA[1], 1, dir); | |
371 | } | ||
372 |
4/4✓ Branch 0 taken 237347 times.
✓ Branch 1 taken 36808 times.
✓ Branch 2 taken 15661 times.
✓ Branch 3 taken 221686 times.
|
274155 | if (b_valid && b_f) { |
373 | 15661 | field_predB[0] = scaleforsame(v, n, field_predB[0], 0, dir); | |
374 | 15661 | field_predB[1] = scaleforsame(v, n, field_predB[1], 1, dir); | |
375 | } | ||
376 |
4/4✓ Branch 0 taken 265906 times.
✓ Branch 1 taken 8249 times.
✓ Branch 2 taken 13706 times.
✓ Branch 3 taken 252200 times.
|
274155 | if (c_valid && c_f) { |
377 | 13706 | field_predC[0] = scaleforsame(v, n, field_predC[0], 0, dir); | |
378 | 13706 | field_predC[1] = scaleforsame(v, n, field_predC[1], 1, dir); | |
379 | } | ||
380 | } | ||
381 | |||
382 |
2/2✓ Branch 0 taken 318569 times.
✓ Branch 1 taken 44783 times.
|
363352 | if (a_valid) { |
383 | 318569 | px = field_predA[0]; | |
384 | 318569 | py = field_predA[1]; | |
385 |
2/2✓ Branch 0 taken 41920 times.
✓ Branch 1 taken 2863 times.
|
44783 | } else if (c_valid) { |
386 | 41920 | px = field_predC[0]; | |
387 | 41920 | py = field_predC[1]; | |
388 |
2/2✓ Branch 0 taken 1143 times.
✓ Branch 1 taken 1720 times.
|
2863 | } else if (b_valid) { |
389 | 1143 | px = field_predB[0]; | |
390 | 1143 | py = field_predB[1]; | |
391 | } else { | ||
392 | 1720 | px = 0; | |
393 | 1720 | py = 0; | |
394 | } | ||
395 | |||
396 |
2/2✓ Branch 0 taken 321003 times.
✓ Branch 1 taken 42349 times.
|
363352 | if (num_samefield + num_oppfield > 1) { |
397 | 321003 | px = mid_pred(field_predA[0], field_predB[0], field_predC[0]); | |
398 | 321003 | py = mid_pred(field_predA[1], field_predB[1], field_predC[1]); | |
399 | } | ||
400 | |||
401 | /* Pullback MV as specified in 8.3.5.3.4 */ | ||
402 |
2/2✓ Branch 0 taken 196785 times.
✓ Branch 1 taken 166567 times.
|
363352 | if (!v->field_mode) { |
403 | int qx, qy, X, Y; | ||
404 |
2/2✓ Branch 0 taken 101045 times.
✓ Branch 1 taken 95740 times.
|
196785 | int MV = mv1 ? -60 : -28; |
405 |
4/4✓ Branch 0 taken 172864 times.
✓ Branch 1 taken 23921 times.
✓ Branch 2 taken 23887 times.
✓ Branch 3 taken 148977 times.
|
196785 | qx = (s->mb_x << 6) + ((n == 1 || n == 3) ? 32 : 0); |
406 |
4/4✓ Branch 0 taken 172879 times.
✓ Branch 1 taken 23906 times.
✓ Branch 2 taken 23887 times.
✓ Branch 3 taken 148992 times.
|
196785 | qy = (s->mb_y << 6) + ((n == 2 || n == 3) ? 32 : 0); |
407 | 196785 | X = (s->mb_width << 6) - 4; | |
408 | 196785 | Y = (s->mb_height << 6) - 4; | |
409 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 196784 times.
|
196785 | if (qx + px < MV) px = MV - qx; |
410 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 196776 times.
|
196785 | if (qy + py < MV) py = MV - qy; |
411 |
2/2✓ Branch 0 taken 341 times.
✓ Branch 1 taken 196444 times.
|
196785 | if (qx + px > X) px = X - qx; |
412 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 196734 times.
|
196785 | if (qy + py > Y) py = Y - qy; |
413 | } | ||
414 | |||
415 |
4/4✓ Branch 0 taken 166567 times.
✓ Branch 1 taken 196785 times.
✓ Branch 2 taken 48899 times.
✓ Branch 3 taken 117668 times.
|
363352 | if (!v->field_mode || s->pict_type != AV_PICTURE_TYPE_B) { |
416 | /* Calculate hybrid prediction as specified in 8.3.5.3.5 (also 10.3.5.4.3.5) */ | ||
417 | 245684 | hybridmv_thresh = 32; | |
418 |
4/4✓ Branch 0 taken 205159 times.
✓ Branch 1 taken 40525 times.
✓ Branch 2 taken 195137 times.
✓ Branch 3 taken 10022 times.
|
245684 | if (a_valid && c_valid) { |
419 |
2/2✓ Branch 0 taken 16134 times.
✓ Branch 1 taken 179003 times.
|
195137 | if (is_intra[xy - wrap]) |
420 | 16134 | sum = FFABS(px) + FFABS(py); | |
421 | else | ||
422 | 179003 | sum = FFABS(px - field_predA[0]) + FFABS(py - field_predA[1]); | |
423 |
2/2✓ Branch 0 taken 12499 times.
✓ Branch 1 taken 182638 times.
|
195137 | if (sum > hybridmv_thresh) { |
424 |
2/2✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 7363 times.
|
12499 | if (get_bits1(&s->gb)) { // read HYBRIDPRED bit |
425 | 5136 | px = field_predA[0]; | |
426 | 5136 | py = field_predA[1]; | |
427 | } else { | ||
428 | 7363 | px = field_predC[0]; | |
429 | 7363 | py = field_predC[1]; | |
430 | } | ||
431 | } else { | ||
432 |
2/2✓ Branch 0 taken 16322 times.
✓ Branch 1 taken 166316 times.
|
182638 | if (is_intra[xy - 1]) |
433 | 16322 | sum = FFABS(px) + FFABS(py); | |
434 | else | ||
435 | 166316 | sum = FFABS(px - field_predC[0]) + FFABS(py - field_predC[1]); | |
436 |
2/2✓ Branch 0 taken 16743 times.
✓ Branch 1 taken 165895 times.
|
182638 | if (sum > hybridmv_thresh) { |
437 |
2/2✓ Branch 1 taken 8856 times.
✓ Branch 2 taken 7887 times.
|
16743 | if (get_bits1(&s->gb)) { |
438 | 8856 | px = field_predA[0]; | |
439 | 8856 | py = field_predA[1]; | |
440 | } else { | ||
441 | 7887 | px = field_predC[0]; | |
442 | 7887 | py = field_predC[1]; | |
443 | } | ||
444 | } | ||
445 | } | ||
446 | } | ||
447 | } | ||
448 | |||
449 |
3/4✓ Branch 0 taken 166567 times.
✓ Branch 1 taken 196785 times.
✓ Branch 2 taken 166567 times.
✗ Branch 3 not taken.
|
363352 | if (v->field_mode && v->numref) |
450 | 166567 | r_y >>= 1; | |
451 |
6/6✓ Branch 0 taken 166567 times.
✓ Branch 1 taken 196785 times.
✓ Branch 2 taken 84551 times.
✓ Branch 3 taken 82016 times.
✓ Branch 4 taken 59202 times.
✓ Branch 5 taken 25349 times.
|
363352 | if (v->field_mode && v->cur_field_type && v->ref_field_type[dir] == 0) |
452 | 59202 | y_bias = 1; | |
453 | /* store MV using signed modulus of MV range defined in 4.11 */ | ||
454 | 363352 | s->mv[dir][n][0] = s->current_picture.motion_val[dir][xy + v->blocks_off][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x; | |
455 | 363352 | s->mv[dir][n][1] = s->current_picture.motion_val[dir][xy + v->blocks_off][1] = ((py + dmv_y + r_y - y_bias) & ((r_y << 1) - 1)) - r_y + y_bias; | |
456 |
2/2✓ Branch 0 taken 201708 times.
✓ Branch 1 taken 161644 times.
|
363352 | if (mv1) { /* duplicate motion data for 1-MV block */ |
457 | 201708 | s->current_picture.motion_val[dir][xy + 1 + v->blocks_off][0] = s->current_picture.motion_val[dir][xy + v->blocks_off][0]; | |
458 | 201708 | s->current_picture.motion_val[dir][xy + 1 + v->blocks_off][1] = s->current_picture.motion_val[dir][xy + v->blocks_off][1]; | |
459 | 201708 | s->current_picture.motion_val[dir][xy + wrap + v->blocks_off][0] = s->current_picture.motion_val[dir][xy + v->blocks_off][0]; | |
460 | 201708 | s->current_picture.motion_val[dir][xy + wrap + v->blocks_off][1] = s->current_picture.motion_val[dir][xy + v->blocks_off][1]; | |
461 | 201708 | s->current_picture.motion_val[dir][xy + wrap + 1 + v->blocks_off][0] = s->current_picture.motion_val[dir][xy + v->blocks_off][0]; | |
462 | 201708 | s->current_picture.motion_val[dir][xy + wrap + 1 + v->blocks_off][1] = s->current_picture.motion_val[dir][xy + v->blocks_off][1]; | |
463 | 201708 | v->mv_f[dir][xy + 1 + v->blocks_off] = v->mv_f[dir][xy + v->blocks_off]; | |
464 | 201708 | v->mv_f[dir][xy + wrap + v->blocks_off] = v->mv_f[dir][xy + wrap + 1 + v->blocks_off] = v->mv_f[dir][xy + v->blocks_off]; | |
465 | } | ||
466 | } | ||
467 | |||
468 | /** Predict and set motion vector for interlaced frame picture MBs | ||
469 | */ | ||
470 | 87401 | void ff_vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y, | |
471 | int mvn, int r_x, int r_y, int dir) | ||
472 | { | ||
473 | 87401 | MpegEncContext *s = &v->s; | |
474 | 87401 | int xy, wrap, off = 0; | |
475 | int A[2], B[2], C[2]; | ||
476 | 87401 | int px = 0, py = 0; | |
477 | 87401 | int a_valid = 0, b_valid = 0, c_valid = 0; | |
478 | int field_a, field_b, field_c; // 0: same, 1: opposite | ||
479 | int total_valid, num_samefield, num_oppfield; | ||
480 | int pos_c, pos_b, n_adj; | ||
481 | |||
482 | 87401 | wrap = s->b8_stride; | |
483 | 87401 | xy = s->block_index[n]; | |
484 | |||
485 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 87401 times.
|
87401 | if (s->mb_intra) { |
486 | ✗ | s->mv[0][n][0] = s->current_picture.motion_val[0][xy][0] = 0; | |
487 | ✗ | s->mv[0][n][1] = s->current_picture.motion_val[0][xy][1] = 0; | |
488 | ✗ | s->current_picture.motion_val[1][xy][0] = 0; | |
489 | ✗ | s->current_picture.motion_val[1][xy][1] = 0; | |
490 | ✗ | if (mvn == 1) { /* duplicate motion data for 1-MV block */ | |
491 | ✗ | s->current_picture.motion_val[0][xy + 1][0] = 0; | |
492 | ✗ | s->current_picture.motion_val[0][xy + 1][1] = 0; | |
493 | ✗ | s->current_picture.motion_val[0][xy + wrap][0] = 0; | |
494 | ✗ | s->current_picture.motion_val[0][xy + wrap][1] = 0; | |
495 | ✗ | s->current_picture.motion_val[0][xy + wrap + 1][0] = 0; | |
496 | ✗ | s->current_picture.motion_val[0][xy + wrap + 1][1] = 0; | |
497 | ✗ | v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; | |
498 | ✗ | s->current_picture.motion_val[1][xy + 1][0] = 0; | |
499 | ✗ | s->current_picture.motion_val[1][xy + 1][1] = 0; | |
500 | ✗ | s->current_picture.motion_val[1][xy + wrap][0] = 0; | |
501 | ✗ | s->current_picture.motion_val[1][xy + wrap][1] = 0; | |
502 | ✗ | s->current_picture.motion_val[1][xy + wrap + 1][0] = 0; | |
503 | ✗ | s->current_picture.motion_val[1][xy + wrap + 1][1] = 0; | |
504 | } | ||
505 | ✗ | return; | |
506 | } | ||
507 | |||
508 |
4/4✓ Branch 0 taken 30480 times.
✓ Branch 1 taken 56921 times.
✓ Branch 2 taken 1788 times.
✓ Branch 3 taken 28692 times.
|
87401 | off = ((n == 0) || (n == 1)) ? 1 : -1; |
509 | /* predict A */ | ||
510 |
6/6✓ Branch 0 taken 832 times.
✓ Branch 1 taken 86569 times.
✓ Branch 2 taken 823 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 814 times.
|
87401 | if (s->mb_x || (n == 1) || (n == 3)) { |
511 |
2/2✓ Branch 0 taken 24418 times.
✓ Branch 1 taken 62169 times.
|
86587 | if ((v->blk_mv_type[xy]) // current block (MB) has a field MV |
512 |
3/4✓ Branch 0 taken 24418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11588 times.
✓ Branch 3 taken 12830 times.
|
24418 | || (!v->blk_mv_type[xy] && !v->blk_mv_type[xy - 1])) { // or both have frame MV |
513 | 73757 | A[0] = s->current_picture.motion_val[dir][xy - 1][0]; | |
514 | 73757 | A[1] = s->current_picture.motion_val[dir][xy - 1][1]; | |
515 | 73757 | a_valid = 1; | |
516 | } else { // current block has frame mv and cand. has field MV (so average) | ||
517 | 12830 | A[0] = (s->current_picture.motion_val[dir][xy - 1][0] | |
518 | 12830 | + s->current_picture.motion_val[dir][xy - 1 + off * wrap][0] + 1) >> 1; | |
519 | 12830 | A[1] = (s->current_picture.motion_val[dir][xy - 1][1] | |
520 | 12830 | + s->current_picture.motion_val[dir][xy - 1 + off * wrap][1] + 1) >> 1; | |
521 | 12830 | a_valid = 1; | |
522 | } | ||
523 |
4/4✓ Branch 0 taken 83011 times.
✓ Branch 1 taken 3576 times.
✓ Branch 2 taken 830 times.
✓ Branch 3 taken 82181 times.
|
86587 | if (!(n & 1) && v->is_intra[s->mb_x - 1]) { |
524 | 830 | a_valid = 0; | |
525 | 830 | A[0] = A[1] = 0; | |
526 | } | ||
527 | } else | ||
528 | 814 | A[0] = A[1] = 0; | |
529 | /* Predict B and C */ | ||
530 | 87401 | B[0] = B[1] = C[0] = C[1] = 0; | |
531 |
6/6✓ Branch 0 taken 30480 times.
✓ Branch 1 taken 56921 times.
✓ Branch 2 taken 28692 times.
✓ Branch 3 taken 1788 times.
✓ Branch 4 taken 27284 times.
✓ Branch 5 taken 1408 times.
|
87401 | if (n == 0 || n == 1 || v->blk_mv_type[xy]) { |
532 |
2/2✓ Branch 0 taken 84676 times.
✓ Branch 1 taken 1317 times.
|
85993 | if (!s->first_slice_line) { |
533 |
2/2✓ Branch 0 taken 83692 times.
✓ Branch 1 taken 984 times.
|
84676 | if (!v->is_intra[s->mb_x - s->mb_stride]) { |
534 | 83692 | b_valid = 1; | |
535 | 83692 | n_adj = n | 2; | |
536 | 83692 | pos_b = s->block_index[n_adj] - 2 * wrap; | |
537 |
4/4✓ Branch 0 taken 61316 times.
✓ Branch 1 taken 22376 times.
✓ Branch 2 taken 48511 times.
✓ Branch 3 taken 12805 times.
|
83692 | if (v->blk_mv_type[pos_b] && v->blk_mv_type[xy]) { |
538 | 48511 | n_adj = (n & 2) | (n & 1); | |
539 | } | ||
540 | 83692 | B[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap][0]; | |
541 | 83692 | B[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap][1]; | |
542 |
4/4✓ Branch 0 taken 61316 times.
✓ Branch 1 taken 22376 times.
✓ Branch 2 taken 12805 times.
✓ Branch 3 taken 48511 times.
|
83692 | if (v->blk_mv_type[pos_b] && !v->blk_mv_type[xy]) { |
543 | 12805 | B[0] = (B[0] + s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap][0] + 1) >> 1; | |
544 | 12805 | B[1] = (B[1] + s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap][1] + 1) >> 1; | |
545 | } | ||
546 | } | ||
547 |
1/2✓ Branch 0 taken 84676 times.
✗ Branch 1 not taken.
|
84676 | if (s->mb_width > 1) { |
548 |
2/2✓ Branch 0 taken 83548 times.
✓ Branch 1 taken 1128 times.
|
84676 | if (!v->is_intra[s->mb_x - s->mb_stride + 1]) { |
549 | 83548 | c_valid = 1; | |
550 | 83548 | n_adj = 2; | |
551 | 83548 | pos_c = s->block_index[2] - 2 * wrap + 2; | |
552 |
4/4✓ Branch 0 taken 60020 times.
✓ Branch 1 taken 23528 times.
✓ Branch 2 taken 47104 times.
✓ Branch 3 taken 12916 times.
|
83548 | if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) { |
553 | 47104 | n_adj = n & 2; | |
554 | } | ||
555 | 83548 | C[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap + 2][0]; | |
556 | 83548 | C[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap + 2][1]; | |
557 |
4/4✓ Branch 0 taken 60020 times.
✓ Branch 1 taken 23528 times.
✓ Branch 2 taken 12916 times.
✓ Branch 3 taken 47104 times.
|
83548 | if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) { |
558 | 12916 | C[0] = (1 + C[0] + (s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap + 2][0])) >> 1; | |
559 | 12916 | C[1] = (1 + C[1] + (s->current_picture.motion_val[dir][s->block_index[n_adj ^ 2] - 2 * wrap + 2][1])) >> 1; | |
560 | } | ||
561 |
2/2✓ Branch 0 taken 802 times.
✓ Branch 1 taken 82746 times.
|
83548 | if (s->mb_x == s->mb_width - 1) { |
562 |
2/2✓ Branch 0 taken 782 times.
✓ Branch 1 taken 20 times.
|
802 | if (!v->is_intra[s->mb_x - s->mb_stride - 1]) { |
563 | 782 | c_valid = 1; | |
564 | 782 | n_adj = 3; | |
565 | 782 | pos_c = s->block_index[3] - 2 * wrap - 2; | |
566 |
4/4✓ Branch 0 taken 643 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 551 times.
✓ Branch 3 taken 92 times.
|
782 | if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) { |
567 | 551 | n_adj = n | 1; | |
568 | } | ||
569 | 782 | C[0] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap - 2][0]; | |
570 | 782 | C[1] = s->current_picture.motion_val[dir][s->block_index[n_adj] - 2 * wrap - 2][1]; | |
571 |
4/4✓ Branch 0 taken 643 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 92 times.
✓ Branch 3 taken 551 times.
|
782 | if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) { |
572 | 92 | C[0] = (1 + C[0] + s->current_picture.motion_val[dir][s->block_index[1] - 2 * wrap - 2][0]) >> 1; | |
573 | 92 | C[1] = (1 + C[1] + s->current_picture.motion_val[dir][s->block_index[1] - 2 * wrap - 2][1]) >> 1; | |
574 | } | ||
575 | } else | ||
576 | 20 | c_valid = 0; | |
577 | } | ||
578 | } | ||
579 | } | ||
580 | } | ||
581 | } else { | ||
582 | 1408 | pos_b = s->block_index[1]; | |
583 | 1408 | b_valid = 1; | |
584 | 1408 | B[0] = s->current_picture.motion_val[dir][pos_b][0]; | |
585 | 1408 | B[1] = s->current_picture.motion_val[dir][pos_b][1]; | |
586 | 1408 | pos_c = s->block_index[0]; | |
587 | 1408 | c_valid = 1; | |
588 | 1408 | C[0] = s->current_picture.motion_val[dir][pos_c][0]; | |
589 | 1408 | C[1] = s->current_picture.motion_val[dir][pos_c][1]; | |
590 | } | ||
591 | |||
592 | 87401 | total_valid = a_valid + b_valid + c_valid; | |
593 | // check if predictor A is out of bounds | ||
594 |
6/6✓ Branch 0 taken 832 times.
✓ Branch 1 taken 86569 times.
✓ Branch 2 taken 823 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 814 times.
✓ Branch 5 taken 9 times.
|
87401 | if (!s->mb_x && !(n == 1 || n == 3)) { |
595 | 814 | A[0] = A[1] = 0; | |
596 | } | ||
597 | // check if predictor B is out of bounds | ||
598 |
8/8✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 86072 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 1009 times.
✓ Branch 4 taken 320 times.
✓ Branch 5 taken 86072 times.
✓ Branch 6 taken 308 times.
✓ Branch 7 taken 12 times.
|
87401 | if ((s->first_slice_line && v->blk_mv_type[xy]) || (s->first_slice_line && !(n & 2))) { |
599 | 1317 | B[0] = B[1] = C[0] = C[1] = 0; | |
600 | } | ||
601 |
2/2✓ Branch 0 taken 24624 times.
✓ Branch 1 taken 62777 times.
|
87401 | if (!v->blk_mv_type[xy]) { |
602 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 24624 times.
|
24624 | if (s->mb_width == 1) { |
603 | ✗ | px = B[0]; | |
604 | ✗ | py = B[1]; | |
605 | } else { | ||
606 |
2/2✓ Branch 0 taken 24202 times.
✓ Branch 1 taken 422 times.
|
24624 | if (total_valid >= 2) { |
607 | 24202 | px = mid_pred(A[0], B[0], C[0]); | |
608 | 24202 | py = mid_pred(A[1], B[1], C[1]); | |
609 |
2/2✓ Branch 0 taken 395 times.
✓ Branch 1 taken 27 times.
|
422 | } else if (total_valid) { |
610 |
2/2✓ Branch 0 taken 356 times.
✓ Branch 1 taken 39 times.
|
395 | if (a_valid) { px = A[0]; py = A[1]; } |
611 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 21 times.
|
39 | else if (b_valid) { px = B[0]; py = B[1]; } |
612 | 21 | else { px = C[0]; py = C[1]; } | |
613 | } | ||
614 | } | ||
615 | } else { | ||
616 |
2/2✓ Branch 0 taken 61492 times.
✓ Branch 1 taken 1285 times.
|
62777 | if (a_valid) |
617 | 61492 | field_a = (A[1] & 4) ? 1 : 0; | |
618 | else | ||
619 | 1285 | field_a = 0; | |
620 |
2/2✓ Branch 0 taken 60944 times.
✓ Branch 1 taken 1833 times.
|
62777 | if (b_valid) |
621 | 60944 | field_b = (B[1] & 4) ? 1 : 0; | |
622 | else | ||
623 | 1833 | field_b = 0; | |
624 |
2/2✓ Branch 0 taken 60819 times.
✓ Branch 1 taken 1958 times.
|
62777 | if (c_valid) |
625 | 60819 | field_c = (C[1] & 4) ? 1 : 0; | |
626 | else | ||
627 | 1958 | field_c = 0; | |
628 | |||
629 | 62777 | num_oppfield = field_a + field_b + field_c; | |
630 | 62777 | num_samefield = total_valid - num_oppfield; | |
631 |
2/2✓ Branch 0 taken 59358 times.
✓ Branch 1 taken 3419 times.
|
62777 | if (total_valid == 3) { |
632 |
4/4✓ Branch 0 taken 45017 times.
✓ Branch 1 taken 14341 times.
✓ Branch 2 taken 13487 times.
✓ Branch 3 taken 31530 times.
|
59358 | if ((num_samefield == 3) || (num_oppfield == 3)) { |
633 | 27828 | px = mid_pred(A[0], B[0], C[0]); | |
634 | 27828 | py = mid_pred(A[1], B[1], C[1]); | |
635 |
2/2✓ Branch 0 taken 15698 times.
✓ Branch 1 taken 15832 times.
|
31530 | } else if (num_samefield >= num_oppfield) { |
636 | /* take one MV from same field set depending on priority | ||
637 | the check for B may not be necessary */ | ||
638 |
2/2✓ Branch 0 taken 9839 times.
✓ Branch 1 taken 5859 times.
|
15698 | px = !field_a ? A[0] : B[0]; |
639 |
2/2✓ Branch 0 taken 9839 times.
✓ Branch 1 taken 5859 times.
|
15698 | py = !field_a ? A[1] : B[1]; |
640 | } else { | ||
641 |
2/2✓ Branch 0 taken 9939 times.
✓ Branch 1 taken 5893 times.
|
15832 | px = field_a ? A[0] : B[0]; |
642 |
2/2✓ Branch 0 taken 9939 times.
✓ Branch 1 taken 5893 times.
|
15832 | py = field_a ? A[1] : B[1]; |
643 | } | ||
644 |
2/2✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 1549 times.
|
3419 | } else if (total_valid == 2) { |
645 |
2/2✓ Branch 0 taken 1250 times.
✓ Branch 1 taken 620 times.
|
1870 | if (num_samefield >= num_oppfield) { |
646 |
4/4✓ Branch 0 taken 1167 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 455 times.
✓ Branch 3 taken 712 times.
|
1250 | if (!field_a && a_valid) { |
647 | 455 | px = A[0]; | |
648 | 455 | py = A[1]; | |
649 |
4/4✓ Branch 0 taken 646 times.
✓ Branch 1 taken 149 times.
✓ Branch 2 taken 605 times.
✓ Branch 3 taken 41 times.
|
795 | } else if (!field_b && b_valid) { |
650 | 605 | px = B[0]; | |
651 | 605 | py = B[1]; | |
652 | } else /*if (c_valid)*/ { | ||
653 | av_assert1(c_valid); | ||
654 | 190 | px = C[0]; | |
655 | 190 | py = C[1]; | |
656 | } | ||
657 | } else { | ||
658 |
3/4✓ Branch 0 taken 303 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 303 times.
✗ Branch 3 not taken.
|
620 | if (field_a && a_valid) { |
659 | 303 | px = A[0]; | |
660 | 303 | py = A[1]; | |
661 | } else /*if (field_b && b_valid)*/ { | ||
662 | av_assert1(field_b && b_valid); | ||
663 | 317 | px = B[0]; | |
664 | 317 | py = B[1]; | |
665 | } | ||
666 | } | ||
667 |
2/2✓ Branch 0 taken 1441 times.
✓ Branch 1 taken 108 times.
|
1549 | } else if (total_valid == 1) { |
668 |
4/4✓ Branch 0 taken 1293 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 90 times.
|
1441 | px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]); |
669 |
4/4✓ Branch 0 taken 1293 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 90 times.
|
1441 | py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]); |
670 | } | ||
671 | } | ||
672 | |||
673 | /* store MV using signed modulus of MV range defined in 4.11 */ | ||
674 | 87401 | s->mv[dir][n][0] = s->current_picture.motion_val[dir][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x; | |
675 | 87401 | s->mv[dir][n][1] = s->current_picture.motion_val[dir][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y; | |
676 |
2/2✓ Branch 0 taken 21808 times.
✓ Branch 1 taken 65593 times.
|
87401 | if (mvn == 1) { /* duplicate motion data for 1-MV block */ |
677 | 21808 | s->current_picture.motion_val[dir][xy + 1 ][0] = s->current_picture.motion_val[dir][xy][0]; | |
678 | 21808 | s->current_picture.motion_val[dir][xy + 1 ][1] = s->current_picture.motion_val[dir][xy][1]; | |
679 | 21808 | s->current_picture.motion_val[dir][xy + wrap ][0] = s->current_picture.motion_val[dir][xy][0]; | |
680 | 21808 | s->current_picture.motion_val[dir][xy + wrap ][1] = s->current_picture.motion_val[dir][xy][1]; | |
681 | 21808 | s->current_picture.motion_val[dir][xy + wrap + 1][0] = s->current_picture.motion_val[dir][xy][0]; | |
682 | 21808 | s->current_picture.motion_val[dir][xy + wrap + 1][1] = s->current_picture.motion_val[dir][xy][1]; | |
683 |
2/2✓ Branch 0 taken 58441 times.
✓ Branch 1 taken 7152 times.
|
65593 | } else if (mvn == 2) { /* duplicate motion data for 2-Field MV block */ |
684 | 58441 | s->current_picture.motion_val[dir][xy + 1][0] = s->current_picture.motion_val[dir][xy][0]; | |
685 | 58441 | s->current_picture.motion_val[dir][xy + 1][1] = s->current_picture.motion_val[dir][xy][1]; | |
686 | 58441 | s->mv[dir][n + 1][0] = s->mv[dir][n][0]; | |
687 | 58441 | s->mv[dir][n + 1][1] = s->mv[dir][n][1]; | |
688 | } | ||
689 | } | ||
690 | |||
691 | 20940 | void ff_vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], | |
692 | int direct, int mvtype) | ||
693 | { | ||
694 | 20940 | MpegEncContext *s = &v->s; | |
695 | 20940 | int xy, wrap, off = 0; | |
696 | int16_t *A, *B, *C; | ||
697 | int px, py; | ||
698 | int sum; | ||
699 | int r_x, r_y; | ||
700 | 20940 | const uint8_t *is_intra = v->mb_type[0]; | |
701 | |||
702 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20940 times.
|
20940 | av_assert0(!v->field_mode); |
703 | |||
704 | 20940 | r_x = v->range_x; | |
705 | 20940 | r_y = v->range_y; | |
706 | /* scale MV difference to be quad-pel */ | ||
707 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20940 times.
|
20940 | if (!s->quarter_sample) { |
708 | ✗ | dmv_x[0] *= 2; | |
709 | ✗ | dmv_y[0] *= 2; | |
710 | ✗ | dmv_x[1] *= 2; | |
711 | ✗ | dmv_y[1] *= 2; | |
712 | } | ||
713 | |||
714 | 20940 | wrap = s->b8_stride; | |
715 | 20940 | xy = s->block_index[0]; | |
716 | |||
717 |
2/2✓ Branch 0 taken 170 times.
✓ Branch 1 taken 20770 times.
|
20940 | if (s->mb_intra) { |
718 | 170 | s->current_picture.motion_val[0][xy][0] = | |
719 | 170 | s->current_picture.motion_val[0][xy][1] = | |
720 | 170 | s->current_picture.motion_val[1][xy][0] = | |
721 | 170 | s->current_picture.motion_val[1][xy][1] = 0; | |
722 | 170 | return; | |
723 | } | ||
724 |
3/4✓ Branch 0 taken 2569 times.
✓ Branch 1 taken 18201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2569 times.
|
20770 | if (direct && s->next_picture_ptr->field_picture) |
725 | ✗ | av_log(s->avctx, AV_LOG_WARNING, "Mixed frame/field direct mode not supported\n"); | |
726 | |||
727 | 20770 | s->mv[0][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample); | |
728 | 20770 | s->mv[0][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample); | |
729 | 20770 | s->mv[1][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample); | |
730 | 20770 | s->mv[1][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 1, s->quarter_sample); | |
731 | |||
732 | /* Pullback predicted motion vectors as specified in 8.4.5.4 */ | ||
733 | 20770 | s->mv[0][0][0] = av_clip(s->mv[0][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); | |
734 | 20770 | s->mv[0][0][1] = av_clip(s->mv[0][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); | |
735 | 20770 | s->mv[1][0][0] = av_clip(s->mv[1][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); | |
736 | 20770 | s->mv[1][0][1] = av_clip(s->mv[1][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); | |
737 |
2/2✓ Branch 0 taken 2569 times.
✓ Branch 1 taken 18201 times.
|
20770 | if (direct) { |
738 | 2569 | s->current_picture.motion_val[0][xy][0] = s->mv[0][0][0]; | |
739 | 2569 | s->current_picture.motion_val[0][xy][1] = s->mv[0][0][1]; | |
740 | 2569 | s->current_picture.motion_val[1][xy][0] = s->mv[1][0][0]; | |
741 | 2569 | s->current_picture.motion_val[1][xy][1] = s->mv[1][0][1]; | |
742 | 2569 | return; | |
743 | } | ||
744 | |||
745 |
4/4✓ Branch 0 taken 14178 times.
✓ Branch 1 taken 4023 times.
✓ Branch 2 taken 6157 times.
✓ Branch 3 taken 8021 times.
|
18201 | if ((mvtype == BMV_TYPE_FORWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { |
746 | 10180 | C = s->current_picture.motion_val[0][xy - 2]; | |
747 | 10180 | A = s->current_picture.motion_val[0][xy - wrap * 2]; | |
748 |
2/2✓ Branch 0 taken 226 times.
✓ Branch 1 taken 9954 times.
|
10180 | off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; |
749 | 10180 | B = s->current_picture.motion_val[0][xy - wrap * 2 + off]; | |
750 | |||
751 |
2/2✓ Branch 0 taken 319 times.
✓ Branch 1 taken 9861 times.
|
10180 | if (!s->mb_x) C[0] = C[1] = 0; |
752 |
2/2✓ Branch 0 taken 9675 times.
✓ Branch 1 taken 505 times.
|
10180 | if (!s->first_slice_line) { // predictor A is not out of bounds |
753 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9675 times.
|
9675 | if (s->mb_width == 1) { |
754 | ✗ | px = A[0]; | |
755 | ✗ | py = A[1]; | |
756 | } else { | ||
757 | 9675 | px = mid_pred(A[0], B[0], C[0]); | |
758 | 9675 | py = mid_pred(A[1], B[1], C[1]); | |
759 | } | ||
760 |
2/2✓ Branch 0 taken 489 times.
✓ Branch 1 taken 16 times.
|
505 | } else if (s->mb_x) { // predictor C is not out of bounds |
761 | 489 | px = C[0]; | |
762 | 489 | py = C[1]; | |
763 | } else { | ||
764 | 16 | px = py = 0; | |
765 | } | ||
766 | /* Pullback MV as specified in 8.3.5.3.4 */ | ||
767 | { | ||
768 | int qx, qy, X, Y; | ||
769 |
2/2✓ Branch 0 taken 7513 times.
✓ Branch 1 taken 2667 times.
|
10180 | int sh = v->profile < PROFILE_ADVANCED ? 5 : 6; |
770 | 10180 | int MV = 4 - (1 << sh); | |
771 | 10180 | qx = (s->mb_x << sh); | |
772 | 10180 | qy = (s->mb_y << sh); | |
773 | 10180 | X = (s->mb_width << sh) - 4; | |
774 | 10180 | Y = (s->mb_height << sh) - 4; | |
775 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10180 times.
|
10180 | if (qx + px < MV) px = MV - qx; |
776 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10180 times.
|
10180 | if (qy + py < MV) py = MV - qy; |
777 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 10165 times.
|
10180 | if (qx + px > X) px = X - qx; |
778 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10180 times.
|
10180 | if (qy + py > Y) py = Y - qy; |
779 | } | ||
780 | /* Calculate hybrid prediction as specified in 8.3.5.3.5 */ | ||
781 | if (0 && !s->first_slice_line && s->mb_x) { | ||
782 | if (is_intra[xy - wrap]) | ||
783 | sum = FFABS(px) + FFABS(py); | ||
784 | else | ||
785 | sum = FFABS(px - A[0]) + FFABS(py - A[1]); | ||
786 | if (sum > 32) { | ||
787 | if (get_bits1(&s->gb)) { | ||
788 | px = A[0]; | ||
789 | py = A[1]; | ||
790 | } else { | ||
791 | px = C[0]; | ||
792 | py = C[1]; | ||
793 | } | ||
794 | } else { | ||
795 | if (is_intra[xy - 2]) | ||
796 | sum = FFABS(px) + FFABS(py); | ||
797 | else | ||
798 | sum = FFABS(px - C[0]) + FFABS(py - C[1]); | ||
799 | if (sum > 32) { | ||
800 | if (get_bits1(&s->gb)) { | ||
801 | px = A[0]; | ||
802 | py = A[1]; | ||
803 | } else { | ||
804 | px = C[0]; | ||
805 | py = C[1]; | ||
806 | } | ||
807 | } | ||
808 | } | ||
809 | } | ||
810 | /* store MV using signed modulus of MV range defined in 4.11 */ | ||
811 | 10180 | s->mv[0][0][0] = ((px + dmv_x[0] + r_x) & ((r_x << 1) - 1)) - r_x; | |
812 | 10180 | s->mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y; | |
813 | } | ||
814 |
4/4✓ Branch 0 taken 10180 times.
✓ Branch 1 taken 8021 times.
✓ Branch 2 taken 6157 times.
✓ Branch 3 taken 4023 times.
|
18201 | if ((mvtype == BMV_TYPE_BACKWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { |
815 | 14178 | C = s->current_picture.motion_val[1][xy - 2]; | |
816 | 14178 | A = s->current_picture.motion_val[1][xy - wrap * 2]; | |
817 |
2/2✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13629 times.
|
14178 | off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; |
818 | 14178 | B = s->current_picture.motion_val[1][xy - wrap * 2 + off]; | |
819 | |||
820 |
2/2✓ Branch 0 taken 389 times.
✓ Branch 1 taken 13789 times.
|
14178 | if (!s->mb_x) |
821 | 389 | C[0] = C[1] = 0; | |
822 |
2/2✓ Branch 0 taken 13334 times.
✓ Branch 1 taken 844 times.
|
14178 | if (!s->first_slice_line) { // predictor A is not out of bounds |
823 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 13334 times.
|
13334 | if (s->mb_width == 1) { |
824 | ✗ | px = A[0]; | |
825 | ✗ | py = A[1]; | |
826 | } else { | ||
827 | 13334 | px = mid_pred(A[0], B[0], C[0]); | |
828 | 13334 | py = mid_pred(A[1], B[1], C[1]); | |
829 | } | ||
830 |
2/2✓ Branch 0 taken 813 times.
✓ Branch 1 taken 31 times.
|
844 | } else if (s->mb_x) { // predictor C is not out of bounds |
831 | 813 | px = C[0]; | |
832 | 813 | py = C[1]; | |
833 | } else { | ||
834 | 31 | px = py = 0; | |
835 | } | ||
836 | /* Pullback MV as specified in 8.3.5.3.4 */ | ||
837 | { | ||
838 | int qx, qy, X, Y; | ||
839 |
2/2✓ Branch 0 taken 10397 times.
✓ Branch 1 taken 3781 times.
|
14178 | int sh = v->profile < PROFILE_ADVANCED ? 5 : 6; |
840 | 14178 | int MV = 4 - (1 << sh); | |
841 | 14178 | qx = (s->mb_x << sh); | |
842 | 14178 | qy = (s->mb_y << sh); | |
843 | 14178 | X = (s->mb_width << sh) - 4; | |
844 | 14178 | Y = (s->mb_height << sh) - 4; | |
845 |
2/2✓ Branch 0 taken 23 times.
✓ Branch 1 taken 14155 times.
|
14178 | if (qx + px < MV) px = MV - qx; |
846 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 14174 times.
|
14178 | if (qy + py < MV) py = MV - qy; |
847 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14178 times.
|
14178 | if (qx + px > X) px = X - qx; |
848 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 14172 times.
|
14178 | if (qy + py > Y) py = Y - qy; |
849 | } | ||
850 | /* Calculate hybrid prediction as specified in 8.3.5.3.5 */ | ||
851 | if (0 && !s->first_slice_line && s->mb_x) { | ||
852 | if (is_intra[xy - wrap]) | ||
853 | sum = FFABS(px) + FFABS(py); | ||
854 | else | ||
855 | sum = FFABS(px - A[0]) + FFABS(py - A[1]); | ||
856 | if (sum > 32) { | ||
857 | if (get_bits1(&s->gb)) { | ||
858 | px = A[0]; | ||
859 | py = A[1]; | ||
860 | } else { | ||
861 | px = C[0]; | ||
862 | py = C[1]; | ||
863 | } | ||
864 | } else { | ||
865 | if (is_intra[xy - 2]) | ||
866 | sum = FFABS(px) + FFABS(py); | ||
867 | else | ||
868 | sum = FFABS(px - C[0]) + FFABS(py - C[1]); | ||
869 | if (sum > 32) { | ||
870 | if (get_bits1(&s->gb)) { | ||
871 | px = A[0]; | ||
872 | py = A[1]; | ||
873 | } else { | ||
874 | px = C[0]; | ||
875 | py = C[1]; | ||
876 | } | ||
877 | } | ||
878 | } | ||
879 | } | ||
880 | /* store MV using signed modulus of MV range defined in 4.11 */ | ||
881 | |||
882 | 14178 | s->mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x; | |
883 | 14178 | s->mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y; | |
884 | } | ||
885 | 18201 | s->current_picture.motion_val[0][xy][0] = s->mv[0][0][0]; | |
886 | 18201 | s->current_picture.motion_val[0][xy][1] = s->mv[0][0][1]; | |
887 | 18201 | s->current_picture.motion_val[1][xy][0] = s->mv[1][0][0]; | |
888 | 18201 | s->current_picture.motion_val[1][xy][1] = s->mv[1][0][1]; | |
889 | } | ||
890 | |||
891 | 79716 | void ff_vc1_pred_b_mv_intfi(VC1Context *v, int n, int *dmv_x, int *dmv_y, | |
892 | int mv1, int *pred_flag) | ||
893 | { | ||
894 | 79716 | int dir = (v->bmvtype == BMV_TYPE_BACKWARD) ? 1 : 0; | |
895 | 79716 | MpegEncContext *s = &v->s; | |
896 | 79716 | int mb_pos = s->mb_x + s->mb_y * s->mb_stride; | |
897 | |||
898 |
2/2✓ Branch 0 taken 6770 times.
✓ Branch 1 taken 72946 times.
|
79716 | if (v->bmvtype == BMV_TYPE_DIRECT) { |
899 | int total_opp, k, f; | ||
900 |
2/2✓ Branch 0 taken 4903 times.
✓ Branch 1 taken 1867 times.
|
6770 | if (s->next_picture.mb_type[mb_pos + v->mb_off] != MB_TYPE_INTRA) { |
901 | 9806 | s->mv[0][0][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[0] + v->blocks_off][0], | |
902 | 4903 | v->bfraction, 0, s->quarter_sample); | |
903 | 9806 | s->mv[0][0][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[0] + v->blocks_off][1], | |
904 | 4903 | v->bfraction, 0, s->quarter_sample); | |
905 | 9806 | s->mv[1][0][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[0] + v->blocks_off][0], | |
906 | 4903 | v->bfraction, 1, s->quarter_sample); | |
907 | 9806 | s->mv[1][0][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[0] + v->blocks_off][1], | |
908 | 4903 | v->bfraction, 1, s->quarter_sample); | |
909 | |||
910 | 4903 | total_opp = v->mv_f_next[0][s->block_index[0] + v->blocks_off] | |
911 | 4903 | + v->mv_f_next[0][s->block_index[1] + v->blocks_off] | |
912 | 4903 | + v->mv_f_next[0][s->block_index[2] + v->blocks_off] | |
913 | 4903 | + v->mv_f_next[0][s->block_index[3] + v->blocks_off]; | |
914 | 4903 | f = (total_opp > 2) ? 1 : 0; | |
915 | } else { | ||
916 | 1867 | s->mv[0][0][0] = s->mv[0][0][1] = 0; | |
917 | 1867 | s->mv[1][0][0] = s->mv[1][0][1] = 0; | |
918 | 1867 | f = 0; | |
919 | } | ||
920 | 6770 | v->ref_field_type[0] = v->ref_field_type[1] = v->cur_field_type ^ f; | |
921 |
2/2✓ Branch 0 taken 27080 times.
✓ Branch 1 taken 6770 times.
|
33850 | for (k = 0; k < 4; k++) { |
922 | 27080 | s->current_picture.motion_val[0][s->block_index[k] + v->blocks_off][0] = s->mv[0][0][0]; | |
923 | 27080 | s->current_picture.motion_val[0][s->block_index[k] + v->blocks_off][1] = s->mv[0][0][1]; | |
924 | 27080 | s->current_picture.motion_val[1][s->block_index[k] + v->blocks_off][0] = s->mv[1][0][0]; | |
925 | 27080 | s->current_picture.motion_val[1][s->block_index[k] + v->blocks_off][1] = s->mv[1][0][1]; | |
926 | 27080 | v->mv_f[0][s->block_index[k] + v->blocks_off] = f; | |
927 | 27080 | v->mv_f[1][s->block_index[k] + v->blocks_off] = f; | |
928 | } | ||
929 | 6770 | return; | |
930 | } | ||
931 |
2/2✓ Branch 0 taken 5886 times.
✓ Branch 1 taken 67060 times.
|
72946 | if (v->bmvtype == BMV_TYPE_INTERPOLATED) { |
932 | 5886 | ff_vc1_pred_mv(v, 0, dmv_x[0], dmv_y[0], 1, v->range_x, v->range_y, v->mb_type[0], pred_flag[0], 0); | |
933 | 5886 | ff_vc1_pred_mv(v, 0, dmv_x[1], dmv_y[1], 1, v->range_x, v->range_y, v->mb_type[0], pred_flag[1], 1); | |
934 | 5886 | return; | |
935 | } | ||
936 |
2/2✓ Branch 0 taken 31989 times.
✓ Branch 1 taken 35071 times.
|
67060 | if (dir) { // backward |
937 | 31989 | ff_vc1_pred_mv(v, n, dmv_x[1], dmv_y[1], mv1, v->range_x, v->range_y, v->mb_type[0], pred_flag[1], 1); | |
938 |
4/4✓ Branch 0 taken 27473 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 13925 times.
✓ Branch 3 taken 13548 times.
|
31989 | if (n == 3 || mv1) { |
939 | 18441 | ff_vc1_pred_mv(v, 0, dmv_x[0], dmv_y[0], 1, v->range_x, v->range_y, v->mb_type[0], 0, 0); | |
940 | } | ||
941 | } else { // forward | ||
942 | 35071 | ff_vc1_pred_mv(v, n, dmv_x[0], dmv_y[0], mv1, v->range_x, v->range_y, v->mb_type[0], pred_flag[0], 0); | |
943 |
4/4✓ Branch 0 taken 30179 times.
✓ Branch 1 taken 4892 times.
✓ Branch 2 taken 15503 times.
✓ Branch 3 taken 14676 times.
|
35071 | if (n == 3 || mv1) { |
944 | 20395 | ff_vc1_pred_mv(v, 0, dmv_x[1], dmv_y[1], 1, v->range_x, v->range_y, v->mb_type[0], 0, 1); | |
945 | } | ||
946 | } | ||
947 | } | ||
948 |