../../../ffmpeg/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
733 / 836
87.7%
Branches:
502 / 632
79.4%
Functions:
14 / 14
100.0%

libavcodec/error_resilience.c
Line Branch Exec Source
1 /*
2 * Error resilience / concealment
3 *
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 /**
24 * @file
25 * Error resilience / concealment.
26 */
27
28 #include <limits.h>
29
30 #include "libavutil/avassert.h"
31 #include "libavutil/attributes.h"
32 #include "libavutil/mem.h"
33 #include "avcodec.h"
34 #include "error_resilience.h"
35 #include "mathops.h"
36 #include "me_cmp.h"
37 #include "mpegutils.h"
38 #include "mpegvideo.h"
39 #include "threadframe.h"
40 #include "threadprogress.h"
41
42 1414 av_cold int ff_er_init(ERContext *const s)
43 {
44 MECmpContext mecc;
45 1414 unsigned mb_array_size = s->mb_height * s->mb_stride;
46
47 1414 s->error_status_table = av_mallocz(mb_array_size);
48
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 1414 times.
1414 if (!s->error_status_table)
49 ✗ return AVERROR(ENOMEM);
50 1414 s->er_temp_buffer = av_malloc_array(mb_array_size, 4*sizeof(int) + 1);
51
1/2
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 1414 times.
1414 if (!s->er_temp_buffer)
52 ✗ return AVERROR(ENOMEM);
53
54 1414 ff_me_cmp_init(&mecc, s->avctx);
55 1414 s->sad = mecc.sad[0];
56
57 1414 return 0;
58 }
59
60 /**
61 * @param stride the number of MVs to get to the next row
62 * @param mv_step the number of MVs per row or column in a macroblock
63 */
64 294 static void set_mv_strides(ERContext *s, ptrdiff_t *mv_step, ptrdiff_t *stride)
65 {
66
2/2
✓ Branch 2 → 3 taken 119 times.
✓ Branch 2 → 7 taken 175 times.
294 if (s->avctx->codec_id == AV_CODEC_ID_H264) {
67
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 6 taken 119 times.
119 av_assert0(s->quarter_sample);
68 119 *mv_step = 4;
69 119 *stride = s->mb_width * 4;
70 } else {
71 175 *mv_step = 2;
72 175 *stride = s->b8_stride;
73 }
74 294 }
75
76 /**
77 * Replace the current MB with a flat dc-only version.
78 */
79 8269 static void put_dc(ERContext *s, uint8_t *dest_y, uint8_t *dest_cb,
80 uint8_t *dest_cr, int mb_x, int mb_y)
81 {
82 8269 int *linesize = s->cur_pic.f->linesize;
83 int dc, dcu, dcv, y, i;
84
2/2
✓ Branch 14 → 3 taken 33076 times.
✓ Branch 14 → 15 taken 8269 times.
41345 for (i = 0; i < 4; i++) {
85 33076 dc = s->dc_val[0][mb_x * 2 + (i & 1) + (mb_y * 2 + (i >> 1)) * s->b8_stride];
86
2/2
✓ Branch 3 → 4 taken 17 times.
✓ Branch 3 → 5 taken 33059 times.
33076 if (dc < 0)
87 17 dc = 0;
88
2/2
✓ Branch 5 → 6 taken 9 times.
✓ Branch 5 → 7 taken 33050 times.
33059 else if (dc > 2040)
89 9 dc = 2040;
90
2/2
✓ Branch 12 → 8 taken 264608 times.
✓ Branch 12 → 13 taken 33076 times.
297684 for (y = 0; y < 8; y++) {
91 int x;
92
2/2
✓ Branch 10 → 9 taken 2116864 times.
✓ Branch 10 → 11 taken 264608 times.
2381472 for (x = 0; x < 8; x++)
93 2116864 dest_y[x + (i & 1) * 8 + (y + (i >> 1) * 8) * linesize[0]] = dc / 8;
94 }
95 }
96 8269 dcu = s->dc_val[1][mb_x + mb_y * s->mb_stride];
97 8269 dcv = s->dc_val[2][mb_x + mb_y * s->mb_stride];
98
1/2
✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 8269 times.
8269 if (dcu < 0)
99 ✗ dcu = 0;
100
1/2
✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 8269 times.
8269 else if (dcu > 2040)
101 ✗ dcu = 2040;
102
1/2
✗ Branch 19 → 20 not taken.
✓ Branch 19 → 21 taken 8269 times.
8269 if (dcv < 0)
103 ✗ dcv = 0;
104
1/2
✗ Branch 21 → 22 not taken.
✓ Branch 21 → 23 taken 8269 times.
8269 else if (dcv > 2040)
105 ✗ dcv = 2040;
106
107
1/2
✓ Branch 23 → 24 taken 8269 times.
✗ Branch 23 → 30 not taken.
8269 if (dest_cr)
108
2/2
✓ Branch 29 → 25 taken 66152 times.
✓ Branch 29 → 30 taken 8269 times.
74421 for (y = 0; y < 8; y++) {
109 int x;
110
2/2
✓ Branch 27 → 26 taken 529216 times.
✓ Branch 27 → 28 taken 66152 times.
595368 for (x = 0; x < 8; x++) {
111 529216 dest_cb[x + y * linesize[1]] = dcu / 8;
112 529216 dest_cr[x + y * linesize[2]] = dcv / 8;
113 }
114 }
115 8269 }
116
117 42 static void filter181(int16_t *data, int width, int height, ptrdiff_t stride)
118 {
119 int x, y;
120
121 /* horizontal filter */
122
2/2
✓ Branch 7 → 3 taken 1238 times.
✓ Branch 7 → 8 taken 42 times.
1280 for (y = 1; y < height - 1; y++) {
123 1238 int prev_dc = data[0 + y * stride];
124
125
2/2
✓ Branch 5 → 4 taken 72788 times.
✓ Branch 5 → 6 taken 1238 times.
74026 for (x = 1; x < width - 1; x++) {
126 int dc;
127 72788 dc = -prev_dc +
128 72788 data[x + y * stride] * 8 -
129 72788 data[x + 1 + y * stride];
130 72788 dc = (av_clip(dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
131 72788 prev_dc = data[x + y * stride];
132 72788 data[x + y * stride] = dc;
133 }
134 }
135
136 /* vertical filter */
137
2/2
✓ Branch 13 → 9 taken 1622 times.
✓ Branch 13 → 14 taken 42 times.
1664 for (x = 1; x < width - 1; x++) {
138 1622 int prev_dc = data[x];
139
140
2/2
✓ Branch 11 → 10 taken 72788 times.
✓ Branch 11 → 12 taken 1622 times.
74410 for (y = 1; y < height - 1; y++) {
141 int dc;
142
143 72788 dc = -prev_dc +
144 72788 data[x + y * stride] * 8 -
145 72788 data[x + (y + 1) * stride];
146 72788 dc = (av_clip(dc, INT_MIN/10923, INT_MAX/10923 - 32768) * 10923 + 32768) >> 16;
147 72788 prev_dc = data[x + y * stride];
148 72788 data[x + y * stride] = dc;
149 }
150 }
151 42 }
152
153 /**
154 * guess the dc of blocks which do not have an undamaged dc
155 * @param w width in 8 pixel blocks
156 * @param h height in 8 pixel blocks
157 */
158 126 static void guess_dc(ERContext *s, int16_t *dc, int w,
159 int h, ptrdiff_t stride, int is_luma)
160 {
161 int b_x, b_y;
162 126 int16_t (*col )[4] = av_malloc_array(stride, h*sizeof( int16_t)*4);
163 126 uint32_t (*dist)[4] = av_malloc_array(stride, h*sizeof(uint32_t)*4);
164
165
2/4
✓ Branch 4 → 5 taken 126 times.
✗ Branch 4 → 6 not taken.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 8 taken 126 times.
126 if(!col || !dist) {
166 ✗ av_log(s->avctx, AV_LOG_ERROR, "guess_dc() is out of memory\n");
167 ✗ goto fail;
168 }
169
170
2/2
✓ Branch 28 → 9 taken 2644 times.
✓ Branch 28 → 29 taken 126 times.
2770 for(b_y=0; b_y<h; b_y++){
171 2644 int color= 1024;
172 2644 int distance= -1;
173
2/2
✓ Branch 17 → 10 taken 118014 times.
✓ Branch 17 → 18 taken 2644 times.
120658 for(b_x=0; b_x<w; b_x++){
174 118014 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
175 118014 int error_j= s->error_status_table[mb_index_j];
176 118014 int intra_j = IS_INTRA(s->cur_pic.mb_type[mb_index_j]);
177
4/4
✓ Branch 10 → 11 taken 72804 times.
✓ Branch 10 → 12 taken 45210 times.
✓ Branch 11 → 12 taken 23190 times.
✓ Branch 11 → 13 taken 49614 times.
118014 if(intra_j==0 || !(error_j&ER_DC_ERROR)){
178 68400 color= dc[b_x + b_y*stride];
179 68400 distance= b_x;
180 }
181 118014 col [b_x + b_y*stride][1]= color;
182
2/2
✓ Branch 13 → 14 taken 69018 times.
✓ Branch 13 → 15 taken 48996 times.
118014 dist[b_x + b_y*stride][1]= distance >= 0 ? b_x-distance : 9999;
183 }
184 2644 color= 1024;
185 2644 distance= -1;
186
2/2
✓ Branch 26 → 19 taken 118014 times.
✓ Branch 26 → 27 taken 2644 times.
120658 for(b_x=w-1; b_x>=0; b_x--){
187 118014 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
188 118014 int error_j= s->error_status_table[mb_index_j];
189 118014 int intra_j = IS_INTRA(s->cur_pic.mb_type[mb_index_j]);
190
4/4
✓ Branch 19 → 20 taken 72804 times.
✓ Branch 19 → 21 taken 45210 times.
✓ Branch 20 → 21 taken 23190 times.
✓ Branch 20 → 22 taken 49614 times.
118014 if(intra_j==0 || !(error_j&ER_DC_ERROR)){
191 68400 color= dc[b_x + b_y*stride];
192 68400 distance= b_x;
193 }
194 118014 col [b_x + b_y*stride][0]= color;
195
2/2
✓ Branch 22 → 23 taken 68412 times.
✓ Branch 22 → 24 taken 49602 times.
118014 dist[b_x + b_y*stride][0]= distance >= 0 ? distance-b_x : 9999;
196 }
197 }
198
2/2
✓ Branch 49 → 30 taken 3412 times.
✓ Branch 49 → 50 taken 126 times.
3538 for(b_x=0; b_x<w; b_x++){
199 3412 int color= 1024;
200 3412 int distance= -1;
201
2/2
✓ Branch 38 → 31 taken 118014 times.
✓ Branch 38 → 39 taken 3412 times.
121426 for(b_y=0; b_y<h; b_y++){
202 118014 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
203 118014 int error_j= s->error_status_table[mb_index_j];
204 118014 int intra_j = IS_INTRA(s->cur_pic.mb_type[mb_index_j]);
205
4/4
✓ Branch 31 → 32 taken 72804 times.
✓ Branch 31 → 33 taken 45210 times.
✓ Branch 32 → 33 taken 23190 times.
✓ Branch 32 → 34 taken 49614 times.
118014 if(intra_j==0 || !(error_j&ER_DC_ERROR)){
206 68400 color= dc[b_x + b_y*stride];
207 68400 distance= b_y;
208 }
209 118014 col [b_x + b_y*stride][3]= color;
210
2/2
✓ Branch 34 → 35 taken 86190 times.
✓ Branch 34 → 36 taken 31824 times.
118014 dist[b_x + b_y*stride][3]= distance >= 0 ? b_y-distance : 9999;
211 }
212 3412 color= 1024;
213 3412 distance= -1;
214
2/2
✓ Branch 47 → 40 taken 118014 times.
✓ Branch 47 → 48 taken 3412 times.
121426 for(b_y=h-1; b_y>=0; b_y--){
215 118014 int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride;
216 118014 int error_j= s->error_status_table[mb_index_j];
217 118014 int intra_j = IS_INTRA(s->cur_pic.mb_type[mb_index_j]);
218
4/4
✓ Branch 40 → 41 taken 72804 times.
✓ Branch 40 → 42 taken 45210 times.
✓ Branch 41 → 42 taken 23190 times.
✓ Branch 41 → 43 taken 49614 times.
118014 if(intra_j==0 || !(error_j&ER_DC_ERROR)){
219 68400 color= dc[b_x + b_y*stride];
220 68400 distance= b_y;
221 }
222 118014 col [b_x + b_y*stride][2]= color;
223
2/2
✓ Branch 43 → 44 taken 68712 times.
✓ Branch 43 → 45 taken 49302 times.
118014 dist[b_x + b_y*stride][2]= distance >= 0 ? distance-b_y : 9999;
224 }
225 }
226
227
2/2
✓ Branch 63 → 51 taken 2644 times.
✓ Branch 63 → 64 taken 126 times.
2770 for (b_y = 0; b_y < h; b_y++) {
228
2/2
✓ Branch 61 → 52 taken 118014 times.
✓ Branch 61 → 62 taken 2644 times.
120658 for (b_x = 0; b_x < w; b_x++) {
229 int mb_index, error, j;
230 int64_t guess, weight_sum;
231 118014 mb_index = (b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride;
232 118014 error = s->error_status_table[mb_index];
233
234
2/2
✓ Branch 52 → 53 taken 45210 times.
✓ Branch 52 → 54 taken 72804 times.
118014 if (IS_INTER(s->cur_pic.mb_type[mb_index]))
235 45210 continue; // inter
236
2/2
✓ Branch 54 → 55 taken 23190 times.
✓ Branch 54 → 56 taken 49614 times.
72804 if (!(error & ER_DC_ERROR))
237 23190 continue; // dc-ok
238
239 49614 weight_sum = 0;
240 49614 guess = 0;
241
2/2
✓ Branch 58 → 57 taken 198456 times.
✓ Branch 58 → 59 taken 49614 times.
248070 for (j = 0; j < 4; j++) {
242 198456 int64_t weight = 256 * 256 * 256 * 16 / FFMAX(dist[b_x + b_y*stride][j], 1);
243 198456 guess += weight*(int64_t)col[b_x + b_y*stride][j];
244 198456 weight_sum += weight;
245 }
246 49614 guess = (guess + weight_sum / 2) / weight_sum;
247 49614 dc[b_x + b_y * stride] = guess;
248 }
249 }
250
251 126 fail:
252 126 av_freep(&col);
253 126 av_freep(&dist);
254 126 }
255
256 /**
257 * simple horizontal deblocking filter used for error resilience
258 * @param w width in 8 pixel blocks
259 * @param h height in 8 pixel blocks
260 */
261 126 static void h_block_filter(ERContext *s, uint8_t *dst, int w,
262 int h, ptrdiff_t stride, int is_luma)
263 {
264 int b_x, b_y;
265 ptrdiff_t mvx_stride, mvy_stride;
266 126 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
267 126 set_mv_strides(s, &mvx_stride, &mvy_stride);
268 126 mvx_stride >>= is_luma;
269 126 mvy_stride *= mvx_stride;
270
271
2/2
✓ Branch 29 → 4 taken 2644 times.
✓ Branch 29 → 30 taken 126 times.
2770 for (b_y = 0; b_y < h; b_y++) {
272
2/2
✓ Branch 27 → 5 taken 115370 times.
✓ Branch 27 → 28 taken 2644 times.
118014 for (b_x = 0; b_x < w - 1; b_x++) {
273 int y;
274 115370 int left_status = s->error_status_table[( b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride];
275 115370 int right_status = s->error_status_table[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride];
276 115370 int left_intra = IS_INTRA(s->cur_pic.mb_type[( b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
277 115370 int right_intra = IS_INTRA(s->cur_pic.mb_type[((b_x + 1) >> is_luma) + (b_y >> is_luma) * s->mb_stride]);
278 115370 int left_damage = left_status & ER_MB_ERROR;
279 115370 int right_damage = right_status & ER_MB_ERROR;
280 115370 int offset = b_x * 8 + b_y * stride * 8;
281 115370 int16_t *left_mv = s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
282 115370 int16_t *right_mv = s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * (b_x + 1)];
283
4/4
✓ Branch 5 → 6 taken 42310 times.
✓ Branch 5 → 8 taken 73060 times.
✓ Branch 6 → 7 taken 42206 times.
✓ Branch 6 → 8 taken 104 times.
115370 if (!(left_damage || right_damage))
284 42206 continue; // both undamaged
285
4/4
✓ Branch 8 → 9 taken 23802 times.
✓ Branch 8 → 12 taken 49362 times.
✓ Branch 9 → 10 taken 23758 times.
✓ Branch 9 → 12 taken 44 times.
73164 if ((!left_intra) && (!right_intra) &&
286 23758 FFABS(left_mv[0] - right_mv[0]) +
287
2/2
✓ Branch 10 → 11 taken 9008 times.
✓ Branch 10 → 12 taken 14750 times.
23758 FFABS(left_mv[1] + right_mv[1]) < 2)
288 9008 continue;
289
290
2/2
✓ Branch 25 → 13 taken 513248 times.
✓ Branch 25 → 26 taken 64156 times.
577404 for (y = 0; y < 8; y++) {
291 int a, b, c, d;
292
293 513248 a = dst[offset + 7 + y * stride] - dst[offset + 6 + y * stride];
294 513248 b = dst[offset + 8 + y * stride] - dst[offset + 7 + y * stride];
295 513248 c = dst[offset + 9 + y * stride] - dst[offset + 8 + y * stride];
296
297 513248 d = FFABS(b) - ((FFABS(a) + FFABS(c) + 1) >> 1);
298 513248 d = FFMAX(d, 0);
299
2/2
✓ Branch 13 → 14 taken 74960 times.
✓ Branch 13 → 15 taken 438288 times.
513248 if (b < 0)
300 74960 d = -d;
301
302
2/2
✓ Branch 15 → 16 taken 417126 times.
✓ Branch 15 → 17 taken 96122 times.
513248 if (d == 0)
303 417126 continue;
304
305
4/4
✓ Branch 17 → 18 taken 95728 times.
✓ Branch 17 → 19 taken 394 times.
✓ Branch 18 → 19 taken 396 times.
✓ Branch 18 → 20 taken 95332 times.
96122 if (!(left_damage && right_damage))
306 790 d = d * 16 / 9;
307
308
2/2
✓ Branch 20 → 21 taken 95728 times.
✓ Branch 20 → 22 taken 394 times.
96122 if (left_damage) {
309 95728 dst[offset + 7 + y * stride] = cm[dst[offset + 7 + y * stride] + ((d * 7) >> 4)];
310 95728 dst[offset + 6 + y * stride] = cm[dst[offset + 6 + y * stride] + ((d * 5) >> 4)];
311 95728 dst[offset + 5 + y * stride] = cm[dst[offset + 5 + y * stride] + ((d * 3) >> 4)];
312 95728 dst[offset + 4 + y * stride] = cm[dst[offset + 4 + y * stride] + ((d * 1) >> 4)];
313 }
314
2/2
✓ Branch 22 → 23 taken 95726 times.
✓ Branch 22 → 24 taken 396 times.
96122 if (right_damage) {
315 95726 dst[offset + 8 + y * stride] = cm[dst[offset + 8 + y * stride] - ((d * 7) >> 4)];
316 95726 dst[offset + 9 + y * stride] = cm[dst[offset + 9 + y * stride] - ((d * 5) >> 4)];
317 95726 dst[offset + 10+ y * stride] = cm[dst[offset + 10 + y * stride] - ((d * 3) >> 4)];
318 95726 dst[offset + 11+ y * stride] = cm[dst[offset + 11 + y * stride] - ((d * 1) >> 4)];
319 }
320 }
321 }
322 }
323 126 }
324
325 /**
326 * simple vertical deblocking filter used for error resilience
327 * @param w width in 8 pixel blocks
328 * @param h height in 8 pixel blocks
329 */
330 126 static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h,
331 ptrdiff_t stride, int is_luma)
332 {
333 int b_x, b_y;
334 ptrdiff_t mvx_stride, mvy_stride;
335 126 const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
336 126 set_mv_strides(s, &mvx_stride, &mvy_stride);
337 126 mvx_stride >>= is_luma;
338 126 mvy_stride *= mvx_stride;
339
340
2/2
✓ Branch 29 → 4 taken 2518 times.
✓ Branch 29 → 30 taken 126 times.
2644 for (b_y = 0; b_y < h - 1; b_y++) {
341
2/2
✓ Branch 27 → 5 taken 114602 times.
✓ Branch 27 → 28 taken 2518 times.
117120 for (b_x = 0; b_x < w; b_x++) {
342 int x;
343 114602 int top_status = s->error_status_table[(b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride];
344 114602 int bottom_status = s->error_status_table[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride];
345 114602 int top_intra = IS_INTRA(s->cur_pic.mb_type[(b_x >> is_luma) + ( b_y >> is_luma) * s->mb_stride]);
346 114602 int bottom_intra = IS_INTRA(s->cur_pic.mb_type[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s->mb_stride]);
347 114602 int top_damage = top_status & ER_MB_ERROR;
348 114602 int bottom_damage = bottom_status & ER_MB_ERROR;
349 114602 int offset = b_x * 8 + b_y * stride * 8;
350
351 114602 int16_t *top_mv = s->cur_pic.motion_val[0][mvy_stride * b_y + mvx_stride * b_x];
352 114602 int16_t *bottom_mv = s->cur_pic.motion_val[0][mvy_stride * (b_y + 1) + mvx_stride * b_x];
353
354
4/4
✓ Branch 5 → 6 taken 41642 times.
✓ Branch 5 → 8 taken 72960 times.
✓ Branch 6 → 7 taken 39194 times.
✓ Branch 6 → 8 taken 2448 times.
114602 if (!(top_damage || bottom_damage))
355 39194 continue; // both undamaged
356
357
4/4
✓ Branch 8 → 9 taken 25058 times.
✓ Branch 8 → 12 taken 50350 times.
✓ Branch 9 → 10 taken 24218 times.
✓ Branch 9 → 12 taken 840 times.
75408 if ((!top_intra) && (!bottom_intra) &&
358 24218 FFABS(top_mv[0] - bottom_mv[0]) +
359
2/2
✓ Branch 10 → 11 taken 8786 times.
✓ Branch 10 → 12 taken 15432 times.
24218 FFABS(top_mv[1] + bottom_mv[1]) < 2)
360 8786 continue;
361
362
2/2
✓ Branch 25 → 13 taken 532976 times.
✓ Branch 25 → 26 taken 66622 times.
599598 for (x = 0; x < 8; x++) {
363 int a, b, c, d;
364
365 532976 a = dst[offset + x + 7 * stride] - dst[offset + x + 6 * stride];
366 532976 b = dst[offset + x + 8 * stride] - dst[offset + x + 7 * stride];
367 532976 c = dst[offset + x + 9 * stride] - dst[offset + x + 8 * stride];
368
369 532976 d = FFABS(b) - ((FFABS(a) + FFABS(c) + 1) >> 1);
370 532976 d = FFMAX(d, 0);
371
2/2
✓ Branch 13 → 14 taken 61337 times.
✓ Branch 13 → 15 taken 471639 times.
532976 if (b < 0)
372 61337 d = -d;
373
374
2/2
✓ Branch 15 → 16 taken 466993 times.
✓ Branch 15 → 17 taken 65983 times.
532976 if (d == 0)
375 466993 continue;
376
377
4/4
✓ Branch 17 → 18 taken 57197 times.
✓ Branch 17 → 19 taken 8786 times.
✓ Branch 18 → 19 taken 7197 times.
✓ Branch 18 → 20 taken 50000 times.
65983 if (!(top_damage && bottom_damage))
378 15983 d = d * 16 / 9;
379
380
2/2
✓ Branch 20 → 21 taken 57197 times.
✓ Branch 20 → 22 taken 8786 times.
65983 if (top_damage) {
381 57197 dst[offset + x + 7 * stride] = cm[dst[offset + x + 7 * stride] + ((d * 7) >> 4)];
382 57197 dst[offset + x + 6 * stride] = cm[dst[offset + x + 6 * stride] + ((d * 5) >> 4)];
383 57197 dst[offset + x + 5 * stride] = cm[dst[offset + x + 5 * stride] + ((d * 3) >> 4)];
384 57197 dst[offset + x + 4 * stride] = cm[dst[offset + x + 4 * stride] + ((d * 1) >> 4)];
385 }
386
2/2
✓ Branch 22 → 23 taken 58786 times.
✓ Branch 22 → 24 taken 7197 times.
65983 if (bottom_damage) {
387 58786 dst[offset + x + 8 * stride] = cm[dst[offset + x + 8 * stride] - ((d * 7) >> 4)];
388 58786 dst[offset + x + 9 * stride] = cm[dst[offset + x + 9 * stride] - ((d * 5) >> 4)];
389 58786 dst[offset + x + 10 * stride] = cm[dst[offset + x + 10 * stride] - ((d * 3) >> 4)];
390 58786 dst[offset + x + 11 * stride] = cm[dst[offset + x + 11 * stride] - ((d * 1) >> 4)];
391 }
392 }
393 }
394 }
395 126 }
396
397 #define MV_FROZEN 8
398 #define MV_CHANGED 4
399 #define MV_UNCHANGED 2
400 #define MV_LISTED 1
401 69490 static av_always_inline void add_blocklist(int (*blocklist)[2], int *blocklist_length, uint8_t *fixed, int mb_x, int mb_y, int mb_xy)
402 {
403
2/2
✓ Branch 2 → 3 taken 67068 times.
✓ Branch 2 → 4 taken 2422 times.
69490 if (fixed[mb_xy])
404 67068 return;
405 2422 fixed[mb_xy] = MV_LISTED;
406 2422 blocklist[ *blocklist_length ][0] = mb_x;
407 2422 blocklist[(*blocklist_length)++][1] = mb_y;
408 }
409
410 42 static void guess_mv(ERContext *s)
411 {
412 int (*blocklist)[2], (*next_blocklist)[2];
413 uint8_t *fixed;
414 42 const ptrdiff_t mb_stride = s->mb_stride;
415 42 const int mb_width = s->mb_width;
416 42 int mb_height = s->mb_height;
417 int i, num_avail;
418 int mb_x, mb_y;
419 ptrdiff_t mot_step, mot_stride;
420 int blocklist_length, next_blocklist_length;
421
422
3/4
✓ Branch 2 → 3 taken 39 times.
✓ Branch 2 → 5 taken 3 times.
✓ Branch 3 → 4 taken 39 times.
✗ Branch 3 → 5 not taken.
42 if (s->last_pic.f && s->last_pic.f->data[0])
423 39 mb_height = FFMIN(mb_height, (s->last_pic.f->height+15)>>4);
424
3/4
✓ Branch 5 → 6 taken 25 times.
✓ Branch 5 → 8 taken 17 times.
✓ Branch 6 → 7 taken 25 times.
✗ Branch 6 → 8 not taken.
42 if (s->next_pic.f && s->next_pic.f->data[0])
425 25 mb_height = FFMIN(mb_height, (s->next_pic.f->height+15)>>4);
426
427 42 blocklist = (int (*)[2])s->er_temp_buffer;
428 42 next_blocklist = blocklist + s->mb_stride * s->mb_height;
429 42 fixed = (uint8_t *)(next_blocklist + s->mb_stride * s->mb_height);
430
431 42 set_mv_strides(s, &mot_step, &mot_stride);
432
433 42 num_avail = 0;
434
2/2
✓ Branch 9 → 10 taken 39 times.
✓ Branch 9 → 13 taken 3 times.
42 if (s->last_pic.motion_val[0]) {
435
2/2
✓ Branch 10 → 11 taken 15 times.
✓ Branch 10 → 12 taken 24 times.
39 if (s->last_pic.tf)
436 15 ff_thread_await_progress(s->last_pic.tf, mb_height-1, 0);
437 else
438 24 ff_thread_progress_await(s->last_pic.progress, mb_height - 1);
439 }
440
2/2
✓ Branch 24 → 14 taken 19669 times.
✓ Branch 24 → 25 taken 42 times.
19711 for (i = 0; i < mb_width * mb_height; i++) {
441 19669 const int mb_xy = s->mb_index2xy[i];
442 19669 int f = 0;
443 19669 int error = s->error_status_table[mb_xy];
444
445
2/2
✓ Branch 14 → 15 taken 12134 times.
✓ Branch 14 → 16 taken 7535 times.
19669 if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))
446 12134 f = MV_FROZEN; // intra // FIXME check
447
2/2
✓ Branch 16 → 17 taken 7273 times.
✓ Branch 16 → 18 taken 12396 times.
19669 if (!(error & ER_MV_ERROR))
448 7273 f = MV_FROZEN; // inter with undamaged MV
449
450 19669 fixed[mb_xy] = f;
451
2/2
✓ Branch 18 → 19 taken 15542 times.
✓ Branch 18 → 20 taken 4127 times.
19669 if (f == MV_FROZEN)
452 15542 num_avail++;
453
2/4
✓ Branch 20 → 21 taken 4127 times.
✗ Branch 20 → 23 not taken.
✓ Branch 21 → 22 taken 4127 times.
✗ Branch 21 → 23 not taken.
4127 else if(s->last_pic.f->data[0] && s->last_pic.motion_val[0]){
454 4127 const int mb_y= mb_xy / s->mb_stride;
455 4127 const int mb_x= mb_xy % s->mb_stride;
456 4127 const int mot_index= (mb_x + mb_y*mot_stride) * mot_step;
457 4127 s->cur_pic.motion_val[0][mot_index][0]= s->last_pic.motion_val[0][mot_index][0];
458 4127 s->cur_pic.motion_val[0][mot_index][1]= s->last_pic.motion_val[0][mot_index][1];
459 4127 s->cur_pic.ref_index[0][4*mb_xy] = s->last_pic.ref_index[0][4*mb_xy];
460 }
461 }
462
463
1/2
✓ Branch 25 → 26 taken 42 times.
✗ Branch 25 → 27 not taken.
42 if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) ||
464
2/2
✓ Branch 26 → 27 taken 16 times.
✓ Branch 26 → 43 taken 26 times.
42 num_avail <= FFMAX(mb_width, mb_height) / 2) {
465
2/2
✓ Branch 41 → 28 taken 146 times.
✓ Branch 41 → 42 taken 16 times.
162 for (mb_y = 0; mb_y < mb_height; mb_y++) {
466
2/2
✓ Branch 39 → 29 taken 1705 times.
✓ Branch 39 → 40 taken 146 times.
1851 for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
467 1705 const int mb_xy = mb_x + mb_y * s->mb_stride;
468
2/4
✓ Branch 29 → 30 taken 1705 times.
✗ Branch 29 → 32 not taken.
✓ Branch 30 → 31 taken 1705 times.
✗ Branch 30 → 32 not taken.
1705 int mv_dir = (s->last_pic.f && s->last_pic.f->data[0]) ? MV_DIR_FORWARD : MV_DIR_BACKWARD;
469
470
1/2
✗ Branch 33 → 34 not taken.
✓ Branch 33 → 35 taken 1705 times.
1705 if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))
471 ✗ continue;
472
1/2
✗ Branch 35 → 36 not taken.
✓ Branch 35 → 37 taken 1705 times.
1705 if (!(s->error_status_table[mb_xy] & ER_MV_ERROR))
473 ✗ continue;
474
475 1705 s->mv[0][0][0] = 0;
476 1705 s->mv[0][0][1] = 0;
477 1705 s->decode_mb(s->opaque, 0, mv_dir, MV_TYPE_16X16, &s->mv,
478 mb_x, mb_y, 0, 0);
479 }
480 }
481 16 return;
482 }
483
484 26 blocklist_length = 0;
485
2/2
✓ Branch 57 → 44 taken 515 times.
✓ Branch 57 → 58 taken 26 times.
541 for (mb_y = 0; mb_y < mb_height; mb_y++) {
486
2/2
✓ Branch 55 → 45 taken 17964 times.
✓ Branch 55 → 56 taken 515 times.
18479 for (mb_x = 0; mb_x < mb_width; mb_x++) {
487 17964 const int mb_xy = mb_x + mb_y * mb_stride;
488
2/2
✓ Branch 45 → 46 taken 15542 times.
✓ Branch 45 → 54 taken 2422 times.
17964 if (fixed[mb_xy] == MV_FROZEN) {
489
2/2
✓ Branch 46 → 47 taken 15135 times.
✓ Branch 46 → 48 taken 407 times.
15542 if (mb_x) add_blocklist(blocklist, &blocklist_length, fixed, mb_x - 1, mb_y, mb_xy - 1);
490
2/2
✓ Branch 48 → 49 taken 14874 times.
✓ Branch 48 → 50 taken 668 times.
15542 if (mb_y) add_blocklist(blocklist, &blocklist_length, fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
491
2/2
✓ Branch 50 → 51 taken 15134 times.
✓ Branch 50 → 52 taken 408 times.
15542 if (mb_x+1 < mb_width) add_blocklist(blocklist, &blocklist_length, fixed, mb_x + 1, mb_y, mb_xy + 1);
492
2/2
✓ Branch 52 → 53 taken 14903 times.
✓ Branch 52 → 54 taken 639 times.
15542 if (mb_y+1 < mb_height) add_blocklist(blocklist, &blocklist_length, fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
493 }
494 }
495 }
496
497 64 for (;;) {
498 int changed, pass, none_left;
499 int blocklist_index;
500
501 90 none_left = 1;
502 90 changed = 1;
503
6/6
✓ Branch 149 → 150 taken 114 times.
✓ Branch 149 → 151 taken 486 times.
✓ Branch 150 → 151 taken 27 times.
✓ Branch 150 → 152 taken 87 times.
✓ Branch 151 → 60 taken 510 times.
✓ Branch 151 → 152 taken 3 times.
600 for (pass = 0; (changed || pass < 2) && pass < 10; pass++) {
504 510 changed = 0;
505
2/2
✓ Branch 147 → 61 taken 18035 times.
✓ Branch 147 → 148 taken 510 times.
18545 for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) {
506 18035 const int mb_x = blocklist[blocklist_index][0];
507 18035 const int mb_y = blocklist[blocklist_index][1];
508 18035 const int mb_xy = mb_x + mb_y * mb_stride;
509 int mv_predictor[8][2];
510 int ref[8];
511 int pred_count;
512 int j;
513 int best_score;
514 int best_pred;
515 int mot_index;
516 int prev_x, prev_y, prev_ref;
517
518
2/2
✓ Branch 61 → 62 taken 9026 times.
✓ Branch 61 → 63 taken 9009 times.
18035 if ((mb_x ^ mb_y ^ pass) & 1)
519 11206 continue;
520 av_assert2(fixed[mb_xy] != MV_FROZEN);
521
522
523 av_assert1(!IS_INTRA(s->cur_pic.mb_type[mb_xy]));
524 av_assert1(s->last_pic.f && s->last_pic.f->data[0]);
525
526 9009 j = 0;
527
2/2
✓ Branch 63 → 64 taken 8608 times.
✓ Branch 63 → 65 taken 401 times.
9009 if (mb_x > 0)
528 8608 j |= fixed[mb_xy - 1];
529
2/2
✓ Branch 65 → 66 taken 8608 times.
✓ Branch 65 → 67 taken 401 times.
9009 if (mb_x + 1 < mb_width)
530 8608 j |= fixed[mb_xy + 1];
531
1/2
✓ Branch 67 → 68 taken 9009 times.
✗ Branch 67 → 69 not taken.
9009 if (mb_y > 0)
532 9009 j |= fixed[mb_xy - mb_stride];
533
2/2
✓ Branch 69 → 70 taken 8932 times.
✓ Branch 69 → 71 taken 77 times.
9009 if (mb_y + 1 < mb_height)
534 8932 j |= fixed[mb_xy + mb_stride];
535
536 av_assert2(j & MV_FROZEN);
537
538
4/4
✓ Branch 71 → 72 taken 3608 times.
✓ Branch 71 → 74 taken 5401 times.
✓ Branch 72 → 73 taken 2180 times.
✓ Branch 72 → 74 taken 1428 times.
9009 if (!(j & MV_CHANGED) && pass > 1)
539 2180 continue;
540
541 6829 none_left = 0;
542 6829 pred_count = 0;
543 6829 mot_index = (mb_x + mb_y * mot_stride) * mot_step;
544
545
4/4
✓ Branch 74 → 75 taken 6576 times.
✓ Branch 74 → 77 taken 253 times.
✓ Branch 75 → 76 taken 5383 times.
✓ Branch 75 → 77 taken 1193 times.
6829 if (mb_x > 0 && fixed[mb_xy - 1] > 1) {
546 5383 mv_predictor[pred_count][0] =
547 5383 s->cur_pic.motion_val[0][mot_index - mot_step][0];
548 5383 mv_predictor[pred_count][1] =
549 5383 s->cur_pic.motion_val[0][mot_index - mot_step][1];
550 5383 ref[pred_count] =
551 5383 s->cur_pic.ref_index[0][4 * (mb_xy - 1)];
552 5383 pred_count++;
553 }
554
4/4
✓ Branch 77 → 78 taken 6574 times.
✓ Branch 77 → 80 taken 255 times.
✓ Branch 78 → 79 taken 5379 times.
✓ Branch 78 → 80 taken 1195 times.
6829 if (mb_x + 1 < mb_width && fixed[mb_xy + 1] > 1) {
555 5379 mv_predictor[pred_count][0] =
556 5379 s->cur_pic.motion_val[0][mot_index + mot_step][0];
557 5379 mv_predictor[pred_count][1] =
558 5379 s->cur_pic.motion_val[0][mot_index + mot_step][1];
559 5379 ref[pred_count] =
560 5379 s->cur_pic.ref_index[0][4 * (mb_xy + 1)];
561 5379 pred_count++;
562 }
563
3/4
✓ Branch 80 → 81 taken 6829 times.
✗ Branch 80 → 83 not taken.
✓ Branch 81 → 82 taken 4525 times.
✓ Branch 81 → 83 taken 2304 times.
6829 if (mb_y > 0 && fixed[mb_xy - mb_stride] > 1) {
564 4525 mv_predictor[pred_count][0] =
565 4525 s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][0];
566 4525 mv_predictor[pred_count][1] =
567 4525 s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][1];
568 4525 ref[pred_count] =
569 4525 s->cur_pic.ref_index[0][4 * (mb_xy - s->mb_stride)];
570 4525 pred_count++;
571 }
572
4/4
✓ Branch 83 → 84 taken 6760 times.
✓ Branch 83 → 86 taken 69 times.
✓ Branch 84 → 85 taken 4431 times.
✓ Branch 84 → 86 taken 2329 times.
6829 if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride] > 1) {
573 4431 mv_predictor[pred_count][0] =
574 4431 s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][0];
575 4431 mv_predictor[pred_count][1] =
576 4431 s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][1];
577 4431 ref[pred_count] =
578 4431 s->cur_pic.ref_index[0][4 * (mb_xy + s->mb_stride)];
579 4431 pred_count++;
580 }
581
1/2
✗ Branch 86 → 87 not taken.
✓ Branch 86 → 88 taken 6829 times.
6829 if (pred_count == 0)
582 ✗ continue;
583
584
2/2
✓ Branch 88 → 89 taken 1057 times.
✓ Branch 88 → 90 taken 5772 times.
6829 if (pred_count > 1) {
585 5772 int sum_x = 0, sum_y = 0, sum_r = 0;
586 int max_x, max_y, min_x, min_y, max_r, min_r;
587
588
2/2
✓ Branch 95 → 91 taken 18661 times.
✓ Branch 95 → 96 taken 5772 times.
24433 for (j = 0; j < pred_count; j++) {
589 18661 sum_x += mv_predictor[j][0];
590 18661 sum_y += mv_predictor[j][1];
591 18661 sum_r += ref[j];
592
3/4
✓ Branch 91 → 92 taken 12889 times.
✓ Branch 91 → 94 taken 5772 times.
✗ Branch 92 → 93 not taken.
✓ Branch 92 → 94 taken 12889 times.
18661 if (j && ref[j] != ref[j - 1])
593 ✗ goto skip_mean_and_median;
594 }
595
596 /* mean */
597 5772 mv_predictor[pred_count][0] = sum_x / j;
598 5772 mv_predictor[pred_count][1] = sum_y / j;
599 5772 ref[pred_count] = sum_r / j;
600
601 /* median */
602
2/2
✓ Branch 96 → 97 taken 5275 times.
✓ Branch 96 → 98 taken 497 times.
5772 if (pred_count >= 3) {
603 5275 min_y = min_x = min_r = 99999;
604 5275 max_y = max_x = max_r = -99999;
605 } else {
606 497 min_x = min_y = max_x = max_y = min_r = max_r = 0;
607 }
608
2/2
✓ Branch 101 → 100 taken 18661 times.
✓ Branch 101 → 102 taken 5772 times.
24433 for (j = 0; j < pred_count; j++) {
609 18661 max_x = FFMAX(max_x, mv_predictor[j][0]);
610 18661 max_y = FFMAX(max_y, mv_predictor[j][1]);
611 18661 max_r = FFMAX(max_r, ref[j]);
612 18661 min_x = FFMIN(min_x, mv_predictor[j][0]);
613 18661 min_y = FFMIN(min_y, mv_predictor[j][1]);
614 18661 min_r = FFMIN(min_r, ref[j]);
615 }
616 5772 mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;
617 5772 mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;
618 5772 ref[pred_count + 1] = sum_r - max_r - min_r;
619
620
2/2
✓ Branch 102 → 103 taken 1842 times.
✓ Branch 102 → 104 taken 3930 times.
5772 if (pred_count == 4) {
621 1842 mv_predictor[pred_count + 1][0] /= 2;
622 1842 mv_predictor[pred_count + 1][1] /= 2;
623 1842 ref[pred_count + 1] /= 2;
624 }
625 5772 pred_count += 2;
626 }
627
628 1057 skip_mean_and_median:
629 /* zero MV */
630 6829 mv_predictor[pred_count][0] =
631 6829 mv_predictor[pred_count][1] =
632 6829 ref[pred_count] = 0;
633 6829 pred_count++;
634
635 6829 prev_x = s->cur_pic.motion_val[0][mot_index][0];
636 6829 prev_y = s->cur_pic.motion_val[0][mot_index][1];
637 6829 prev_ref = s->cur_pic.ref_index[0][4 * mb_xy];
638
639 /* last MV */
640 6829 mv_predictor[pred_count][0] = prev_x;
641 6829 mv_predictor[pred_count][1] = prev_y;
642 6829 ref[pred_count] = prev_ref;
643 6829 pred_count++;
644
645 6829 best_pred = 0;
646 6829 best_score = 256 * 256 * 256 * 64;
647
2/2
✓ Branch 132 → 106 taken 44920 times.
✓ Branch 132 → 133 taken 6829 times.
51749 for (j = 0; j < pred_count; j++) {
648 44920 int *linesize = s->cur_pic.f->linesize;
649 44920 int score = 0;
650 44920 uint8_t *src = s->cur_pic.f->data[0] +
651 44920 mb_x * 16 + mb_y * 16 * linesize[0];
652
653 44920 s->cur_pic.motion_val[0][mot_index][0] =
654 44920 s->mv[0][0][0] = mv_predictor[j][0];
655 44920 s->cur_pic.motion_val[0][mot_index][1] =
656 44920 s->mv[0][0][1] = mv_predictor[j][1];
657
658 // predictor intra or otherwise not available
659
1/2
✗ Branch 106 → 107 not taken.
✓ Branch 106 → 108 taken 44920 times.
44920 if (ref[j] < 0)
660 ✗ continue;
661
662 44920 s->decode_mb(s->opaque, ref[j], MV_DIR_FORWARD,
663 MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0);
664
665
4/4
✓ Branch 109 → 110 taken 43474 times.
✓ Branch 109 → 114 taken 1446 times.
✓ Branch 110 → 111 taken 39322 times.
✓ Branch 110 → 114 taken 4152 times.
44920 if (mb_x > 0 && fixed[mb_xy - 1] > 1) {
666 int k;
667
2/2
✓ Branch 113 → 112 taken 629152 times.
✓ Branch 113 → 114 taken 39322 times.
668474 for (k = 0; k < 16; k++)
668 629152 score += FFABS(src[k * linesize[0] - 1] -
669 src[k * linesize[0]]);
670 }
671
4/4
✓ Branch 114 → 115 taken 43454 times.
✓ Branch 114 → 119 taken 1466 times.
✓ Branch 115 → 116 taken 39284 times.
✓ Branch 115 → 119 taken 4170 times.
44920 if (mb_x + 1 < mb_width && fixed[mb_xy + 1] > 1) {
672 int k;
673
2/2
✓ Branch 118 → 117 taken 628544 times.
✓ Branch 118 → 119 taken 39284 times.
667828 for (k = 0; k < 16; k++)
674 628544 score += FFABS(src[k * linesize[0] + 15] -
675 src[k * linesize[0] + 16]);
676 }
677
3/4
✓ Branch 119 → 120 taken 44920 times.
✗ Branch 119 → 124 not taken.
✓ Branch 120 → 121 taken 31056 times.
✓ Branch 120 → 124 taken 13864 times.
44920 if (mb_y > 0 && fixed[mb_xy - mb_stride] > 1) {
678 int k;
679
2/2
✓ Branch 123 → 122 taken 496896 times.
✓ Branch 123 → 124 taken 31056 times.
527952 for (k = 0; k < 16; k++)
680 496896 score += FFABS(src[k - linesize[0]] - src[k]);
681 }
682
4/4
✓ Branch 124 → 125 taken 44501 times.
✓ Branch 124 → 129 taken 419 times.
✓ Branch 125 → 126 taken 30510 times.
✓ Branch 125 → 129 taken 13991 times.
44920 if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] > 1) {
683 int k;
684
2/2
✓ Branch 128 → 127 taken 488160 times.
✓ Branch 128 → 129 taken 30510 times.
518670 for (k = 0; k < 16; k++)
685 488160 score += FFABS(src[k + linesize[0] * 15] -
686 src[k + linesize[0] * 16]);
687 }
688
689
2/2
✓ Branch 129 → 130 taken 22648 times.
✓ Branch 129 → 131 taken 22272 times.
44920 if (score <= best_score) { // <= will favor the last MV
690 22648 best_score = score;
691 22648 best_pred = j;
692 }
693 }
694 6829 s->mv[0][0][0] = mv_predictor[best_pred][0];
695 6829 s->mv[0][0][1] = mv_predictor[best_pred][1];
696
697
2/2
✓ Branch 138 → 134 taken 13658 times.
✓ Branch 138 → 139 taken 6829 times.
20487 for (i = 0; i < mot_step; i++)
698
2/2
✓ Branch 136 → 135 taken 27316 times.
✓ Branch 136 → 137 taken 13658 times.
40974 for (j = 0; j < mot_step; j++) {
699 27316 s->cur_pic.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0];
700 27316 s->cur_pic.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1];
701 }
702
703 6829 s->decode_mb(s->opaque, ref[best_pred], MV_DIR_FORWARD,
704 MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0);
705
706
707
4/4
✓ Branch 140 → 141 taken 4417 times.
✓ Branch 140 → 142 taken 2412 times.
✓ Branch 141 → 142 taken 530 times.
✓ Branch 141 → 143 taken 3887 times.
6829 if (s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y) {
708 2942 fixed[mb_xy] = MV_CHANGED;
709 2942 changed++;
710 } else
711 3887 fixed[mb_xy] = MV_UNCHANGED;
712 }
713 }
714
715
2/2
✓ Branch 152 → 153 taken 26 times.
✓ Branch 152 → 154 taken 64 times.
90 if (none_left)
716 26 return;
717
718 64 next_blocklist_length = 0;
719
720
2/2
✓ Branch 165 → 155 taken 2422 times.
✓ Branch 165 → 166 taken 64 times.
2486 for (blocklist_index = 0; blocklist_index < blocklist_length; blocklist_index++) {
721 2422 const int mb_x = blocklist[blocklist_index][0];
722 2422 const int mb_y = blocklist[blocklist_index][1];
723 2422 const int mb_xy = mb_x + mb_y * mb_stride;
724
725
1/2
✓ Branch 155 → 156 taken 2422 times.
✗ Branch 155 → 164 not taken.
2422 if (fixed[mb_xy] & (MV_CHANGED|MV_UNCHANGED|MV_FROZEN)) {
726 2422 fixed[mb_xy] = MV_FROZEN;
727
2/2
✓ Branch 156 → 157 taken 2314 times.
✓ Branch 156 → 158 taken 108 times.
2422 if (mb_x > 0)
728 2314 add_blocklist(next_blocklist, &next_blocklist_length, fixed, mb_x - 1, mb_y, mb_xy - 1);
729
1/2
✓ Branch 158 → 159 taken 2422 times.
✗ Branch 158 → 160 not taken.
2422 if (mb_y > 0)
730 2422 add_blocklist(next_blocklist, &next_blocklist_length, fixed, mb_x, mb_y - 1, mb_xy - mb_stride);
731
2/2
✓ Branch 160 → 161 taken 2315 times.
✓ Branch 160 → 162 taken 107 times.
2422 if (mb_x + 1 < mb_width)
732 2315 add_blocklist(next_blocklist, &next_blocklist_length, fixed, mb_x + 1, mb_y, mb_xy + 1);
733
2/2
✓ Branch 162 → 163 taken 2393 times.
✓ Branch 162 → 164 taken 29 times.
2422 if (mb_y + 1 < mb_height)
734 2393 add_blocklist(next_blocklist, &next_blocklist_length, fixed, mb_x, mb_y + 1, mb_xy + mb_stride);
735 }
736 }
737
1/2
✗ Branch 166 → 167 not taken.
✓ Branch 166 → 169 taken 64 times.
64 av_assert0(next_blocklist_length <= mb_height * mb_width);
738 64 FFSWAP(int , blocklist_length, next_blocklist_length);
739 64 FFSWAP(void*, blocklist, next_blocklist);
740 }
741 }
742
743 42 static int is_intra_more_likely(ERContext *s)
744 {
745 int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;
746
747
3/4
✓ Branch 2 → 3 taken 39 times.
✓ Branch 2 → 4 taken 3 times.
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 39 times.
42 if (!s->last_pic.f || !s->last_pic.f->data[0])
748 3 return 1; // no previous frame available -> use spatial prediction
749
750
1/2
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 39 times.
39 if (s->avctx->error_concealment & FF_EC_FAVOR_INTER)
751 ✗ return 0;
752
753 39 undamaged_count = 0;
754
2/2
✓ Branch 12 → 8 taken 10813 times.
✓ Branch 12 → 13 taken 39 times.
10852 for (i = 0; i < s->mb_num; i++) {
755 10813 const int mb_xy = s->mb_index2xy[i];
756 10813 const int error = s->error_status_table[mb_xy];
757
3/4
✓ Branch 8 → 9 taken 4127 times.
✓ Branch 8 → 10 taken 6686 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 4127 times.
10813 if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))
758 6686 undamaged_count++;
759 }
760
761
2/2
✓ Branch 13 → 14 taken 16 times.
✓ Branch 13 → 15 taken 23 times.
39 if (undamaged_count < 5)
762 16 return 0; // almost all MBs damaged -> use temporal prediction
763
764
1/2
✓ Branch 15 → 16 taken 23 times.
✗ Branch 15 → 17 not taken.
23 skip_amount = FFMAX(undamaged_count / 50, 1); // check only up to 50 MBs
765 23 is_intra_likely = 0;
766
767 23 j = 0;
768
2/2
✓ Branch 37 → 19 taken 391 times.
✓ Branch 37 → 38 taken 23 times.
414 for (mb_y = 0; mb_y < s->mb_height - 1; mb_y++) {
769
2/2
✓ Branch 35 → 20 taken 8602 times.
✓ Branch 35 → 36 taken 391 times.
8993 for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
770 int error;
771 8602 const int mb_xy = mb_x + mb_y * s->mb_stride;
772
773 8602 error = s->error_status_table[mb_xy];
774
3/4
✓ Branch 20 → 21 taken 2393 times.
✓ Branch 20 → 23 taken 6209 times.
✓ Branch 21 → 22 taken 2393 times.
✗ Branch 21 → 23 not taken.
8602 if ((error & ER_DC_ERROR) && (error & ER_MV_ERROR))
775 2393 continue; // skip damaged
776
777 6209 j++;
778 // skip a few to speed things up
779
2/2
✓ Branch 23 → 24 taken 5053 times.
✓ Branch 23 → 25 taken 1156 times.
6209 if ((j % skip_amount) != 0)
780 5053 continue;
781
782
2/2
✓ Branch 25 → 26 taken 450 times.
✓ Branch 25 → 31 taken 706 times.
1156 if (s->cur_pic.f->pict_type == AV_PICTURE_TYPE_I) {
783 450 int *linesize = s->cur_pic.f->linesize;
784 450 uint8_t *mb_ptr = s->cur_pic.f->data[0] +
785 450 mb_x * 16 + mb_y * 16 * linesize[0];
786 450 uint8_t *last_mb_ptr = s->last_pic.f->data[0] +
787 450 mb_x * 16 + mb_y * 16 * linesize[0];
788
789
1/2
✓ Branch 26 → 27 taken 450 times.
✗ Branch 26 → 28 not taken.
450 if (s->avctx->codec_id == AV_CODEC_ID_H264) {
790 // FIXME
791 } else {
792 450 ff_thread_progress_await(s->last_pic.progress, mb_y);
793 }
794 900 is_intra_likely += s->sad(NULL, last_mb_ptr, mb_ptr,
795 450 linesize[0], 16);
796 // FIXME need await_progress() here
797 450 is_intra_likely -= s->sad(NULL, last_mb_ptr,
798 450 last_mb_ptr + linesize[0] * 16,
799 450 linesize[0], 16);
800 } else {
801
2/2
✓ Branch 31 → 32 taken 32 times.
✓ Branch 31 → 33 taken 674 times.
706 if (IS_INTRA(s->cur_pic.mb_type[mb_xy]))
802 32 is_intra_likely++;
803 else
804 674 is_intra_likely--;
805 }
806 }
807 }
808 // av_log(NULL, AV_LOG_ERROR, "is_intra_likely: %d type:%d\n", is_intra_likely, s->pict_type);
809 23 return is_intra_likely > 0;
810 }
811
812 39707 void ff_er_frame_start(ERContext *s)
813 {
814
2/2
✓ Branch 2 → 3 taken 255 times.
✓ Branch 2 → 4 taken 39452 times.
39707 if (!s->avctx->error_concealment)
815 255 return;
816
817 39452 memset(s->error_status_table, ER_MB_ERROR | VP_START | ER_MB_END,
818 39452 s->mb_stride * s->mb_height * sizeof(uint8_t));
819 39452 atomic_init(&s->error_count, 3 * s->mb_num);
820 39452 s->error_occurred = 0;
821 }
822
823 122348 static int er_supported(ERContext *s)
824 {
825
1/2
✓ Branch 2 → 3 taken 122348 times.
✗ Branch 2 → 5 not taken.
122348 if (s->avctx->hwaccel ||
826
2/2
✓ Branch 3 → 4 taken 110425 times.
✓ Branch 3 → 5 taken 11923 times.
122348 !s->cur_pic.f ||
827
2/2
✓ Branch 4 → 5 taken 12574 times.
✓ Branch 4 → 6 taken 97851 times.
110425 s->cur_pic.field_picture
828 )
829 24497 return 0;
830 97851 return 1;
831 }
832
833 /**
834 * Add a slice.
835 * @param endx x component of the last macroblock, can be -1
836 * for the last of the previous line
837 * @param status the status at the end (ER_MV_END, ER_AC_ERROR, ...), it is
838 * assumed that no earlier end or error of the same type occurred
839 */
840 200574 void ff_er_add_slice(ERContext *s, int startx, int starty,
841 int endx, int endy, int status)
842 {
843 200574 const int start_i = av_clip(startx + starty * s->mb_width, 0, s->mb_num - 1);
844 200574 const int end_i = av_clip(endx + endy * s->mb_width, 0, s->mb_num);
845 200574 const int start_xy = s->mb_index2xy[start_i];
846 200574 const int end_xy = s->mb_index2xy[end_i];
847 200574 int mask = -1;
848
849
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 200574 times.
200574 if (s->avctx->hwaccel)
850 ✗ return;
851
852
2/4
✓ Branch 4 → 5 taken 200574 times.
✗ Branch 4 → 6 not taken.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 8 taken 200574 times.
200574 if (start_i > end_i || start_xy > end_xy) {
853 ✗ av_log(s->avctx, AV_LOG_ERROR,
854 "internal error, slice end before start\n");
855 ✗ return;
856 }
857
858
2/2
✓ Branch 8 → 9 taken 12074 times.
✓ Branch 8 → 10 taken 188500 times.
200574 if (!s->avctx->error_concealment)
859 12074 return;
860
861 188500 mask &= ~VP_START;
862
2/2
✓ Branch 10 → 11 taken 185541 times.
✓ Branch 10 → 12 taken 2959 times.
188500 if (status & (ER_AC_ERROR | ER_AC_END)) {
863 185541 mask &= ~(ER_AC_ERROR | ER_AC_END);
864 185541 atomic_fetch_add(&s->error_count, start_i - end_i - 1);
865 }
866
2/2
✓ Branch 12 → 13 taken 185541 times.
✓ Branch 12 → 14 taken 2959 times.
188500 if (status & (ER_DC_ERROR | ER_DC_END)) {
867 185541 mask &= ~(ER_DC_ERROR | ER_DC_END);
868 185541 atomic_fetch_add(&s->error_count, start_i - end_i - 1);
869 }
870
2/2
✓ Branch 14 → 15 taken 185541 times.
✓ Branch 14 → 16 taken 2959 times.
188500 if (status & (ER_MV_ERROR | ER_MV_END)) {
871 185541 mask &= ~(ER_MV_ERROR | ER_MV_END);
872 185541 atomic_fetch_add(&s->error_count, start_i - end_i - 1);
873 }
874
875
2/2
✓ Branch 16 → 17 taken 22 times.
✓ Branch 16 → 18 taken 188478 times.
188500 if (status & ER_MB_ERROR) {
876 22 s->error_occurred = 1;
877 22 atomic_store(&s->error_count, INT_MAX);
878 }
879
880
2/2
✓ Branch 18 → 19 taken 183812 times.
✓ Branch 18 → 20 taken 4688 times.
188500 if (mask == ~0x7F) {
881 183812 memset(&s->error_status_table[start_xy], 0,
882 183812 (end_xy - start_xy) * sizeof(uint8_t));
883 } else {
884 int i;
885
2/2
✓ Branch 22 → 21 taken 411543 times.
✓ Branch 22 → 23 taken 4688 times.
416231 for (i = start_xy; i < end_xy; i++)
886 411543 s->error_status_table[i] &= mask;
887 }
888
889
2/2
✓ Branch 23 → 24 taken 3907 times.
✓ Branch 23 → 25 taken 184593 times.
188500 if (end_i == s->mb_num)
890 3907 atomic_store(&s->error_count, INT_MAX);
891 else {
892 184593 s->error_status_table[end_xy] &= mask;
893 184593 s->error_status_table[end_xy] |= status;
894 }
895
896 188500 s->error_status_table[start_xy] |= VP_START;
897
898
6/6
✓ Branch 26 → 27 taken 149195 times.
✓ Branch 26 → 33 taken 39305 times.
✓ Branch 27 → 28 taken 121819 times.
✓ Branch 27 → 33 taken 27376 times.
✓ Branch 29 → 30 taken 97809 times.
✓ Branch 29 → 33 taken 24010 times.
310319 if (start_xy > 0 && !(s->avctx->active_thread_type & FF_THREAD_SLICE) &&
899
1/2
✓ Branch 30 → 31 taken 97809 times.
✗ Branch 30 → 33 not taken.
219628 er_supported(s) && s->avctx->skip_top * s->mb_width < start_i) {
900 97809 int prev_status = s->error_status_table[s->mb_index2xy[start_i - 1]];
901
902 97809 prev_status &= ~ VP_START;
903
2/2
✓ Branch 31 → 32 taken 64 times.
✓ Branch 31 → 33 taken 97745 times.
97809 if (prev_status != (ER_MV_END | ER_DC_END | ER_AC_END)) {
904 64 s->error_occurred = 1;
905 64 atomic_store(&s->error_count, INT_MAX);
906 }
907 }
908 }
909
910 35120 void ff_er_frame_end(ERContext *s, int *decode_error_flags)
911 {
912 35120 int *linesize = NULL;
913 int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error;
914 int distance;
915 35120 int threshold_part[4] = { 100, 100, 100 };
916 35120 int threshold = 50;
917 int is_intra_likely;
918 35120 int size = s->b8_stride * 2 * s->mb_height;
919 int guessed_mb_type;
920
921 /* We do not support ER of field pictures yet,
922 * though it should not crash if enabled. */
923
4/4
✓ Branch 2 → 3 taken 34865 times.
✓ Branch 2 → 8 taken 255 times.
✓ Branch 3 → 4 taken 529 times.
✓ Branch 3 → 8 taken 34336 times.
35120 if (!s->avctx->error_concealment || !atomic_load(&s->error_count) ||
924
3/4
✓ Branch 4 → 5 taken 529 times.
✗ Branch 4 → 8 not taken.
✓ Branch 6 → 7 taken 42 times.
✓ Branch 6 → 8 taken 487 times.
1058 s->avctx->lowres ||
925 529 !er_supported(s) ||
926 42 atomic_load(&s->error_count) == 3 * s->mb_width *
927
1/2
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 42 times.
42 (s->avctx->skip_top + s->avctx->skip_bottom)) {
928 35078 return;
929 }
930 42 linesize = s->cur_pic.f->linesize;
931
932
1/2
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 20 taken 42 times.
42 if ( s->avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO
933
0/2
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 20 not taken.
✗ && (FFALIGN(s->avctx->height, 16)&16)
934
0/2
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 20 not taken.
✗ && atomic_load(&s->error_count) == 3 * s->mb_width * (s->avctx->skip_top + s->avctx->skip_bottom + 1)) {
935
0/2
✗ Branch 16 → 13 not taken.
✗ Branch 16 → 17 not taken.
✗ for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
936 ✗ int status = s->error_status_table[mb_x + (s->mb_height - 1) * s->mb_stride];
937
0/2
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 15 not taken.
✗ if (status != 0x7F)
938 ✗ break;
939 }
940
941
0/2
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 20 not taken.
✗ if (mb_x == s->mb_width) {
942 ✗ av_log(s->avctx, AV_LOG_DEBUG, "ignoring last missing slice\n");
943 ✗ return;
944 }
945 }
946
947
2/2
✓ Branch 20 → 21 taken 39 times.
✓ Branch 20 → 26 taken 3 times.
42 if (s->last_pic.f) {
948
1/2
✓ Branch 21 → 22 taken 39 times.
✗ Branch 21 → 24 not taken.
39 if (s->last_pic.f->width != s->cur_pic.f->width ||
949
1/2
✓ Branch 22 → 23 taken 39 times.
✗ Branch 22 → 24 not taken.
39 s->last_pic.f->height != s->cur_pic.f->height ||
950
1/2
✗ Branch 23 → 24 not taken.
✓ Branch 23 → 26 taken 39 times.
39 s->last_pic.f->format != s->cur_pic.f->format) {
951 ✗ av_log(s->avctx, AV_LOG_WARNING, "Cannot use previous picture in error concealment\n");
952 ✗ memset(&s->last_pic, 0, sizeof(s->last_pic));
953 }
954 }
955
2/2
✓ Branch 26 → 27 taken 25 times.
✓ Branch 26 → 32 taken 17 times.
42 if (s->next_pic.f) {
956
1/2
✓ Branch 27 → 28 taken 25 times.
✗ Branch 27 → 30 not taken.
25 if (s->next_pic.f->width != s->cur_pic.f->width ||
957
1/2
✓ Branch 28 → 29 taken 25 times.
✗ Branch 28 → 30 not taken.
25 s->next_pic.f->height != s->cur_pic.f->height ||
958
1/2
✗ Branch 29 → 30 not taken.
✓ Branch 29 → 32 taken 25 times.
25 s->next_pic.f->format != s->cur_pic.f->format) {
959 ✗ av_log(s->avctx, AV_LOG_WARNING, "Cannot use next picture in error concealment\n");
960 ✗ memset(&s->next_pic, 0, sizeof(s->next_pic));
961 }
962 }
963
964
2/4
✓ Branch 32 → 33 taken 42 times.
✗ Branch 32 → 34 not taken.
✗ Branch 33 → 34 not taken.
✓ Branch 33 → 43 taken 42 times.
42 if (!s->cur_pic.motion_val[0] || !s->cur_pic.ref_index[0]) {
965 ✗ av_log(s->avctx, AV_LOG_ERROR, "Warning MVs not available\n");
966
967
0/2
✗ Branch 42 → 36 not taken.
✗ Branch 42 → 43 not taken.
✗ for (i = 0; i < 2; i++) {
968 ✗ s->ref_index[i] = av_calloc(s->mb_stride * s->mb_height, 4 * sizeof(uint8_t));
969 ✗ s->motion_val_base[i] = av_calloc(size + 4, 2 * sizeof(uint16_t));
970
0/4
✗ Branch 38 → 39 not taken.
✗ Branch 38 → 40 not taken.
✗ Branch 39 → 40 not taken.
✗ Branch 39 → 41 not taken.
✗ if (!s->ref_index[i] || !s->motion_val_base[i])
971 ✗ goto cleanup;
972 ✗ s->cur_pic.ref_index[i] = s->ref_index[i];
973 ✗ s->cur_pic.motion_val[i] = s->motion_val_base[i] + 4;
974 }
975 }
976
977
1/2
✗ Branch 43 → 44 not taken.
✓ Branch 43 → 52 taken 42 times.
42 if (s->avctx->debug & FF_DEBUG_ER) {
978
0/2
✗ Branch 51 → 45 not taken.
✗ Branch 51 → 52 not taken.
✗ for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
979
0/2
✗ Branch 48 → 46 not taken.
✗ Branch 48 → 49 not taken.
✗ for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
980 ✗ int status = s->error_status_table[mb_x + mb_y * s->mb_stride];
981
982 ✗ av_log(s->avctx, AV_LOG_DEBUG, "%2X ", status);
983 }
984 ✗ av_log(s->avctx, AV_LOG_DEBUG, "\n");
985 }
986 }
987
988 #if 1
989 /* handle overlapping slices */
990
2/2
✓ Branch 65 → 53 taken 126 times.
✓ Branch 65 → 66 taken 42 times.
168 for (error_type = 1; error_type <= 3; error_type++) {
991 126 int end_ok = 0;
992
993
2/2
✓ Branch 63 → 54 taken 59007 times.
✓ Branch 63 → 64 taken 126 times.
59133 for (i = s->mb_num - 1; i >= 0; i--) {
994 59007 const int mb_xy = s->mb_index2xy[i];
995 59007 int error = s->error_status_table[mb_xy];
996
997
2/2
✓ Branch 54 → 55 taken 35841 times.
✓ Branch 54 → 56 taken 23166 times.
59007 if (error & (1 << error_type))
998 35841 end_ok = 1;
999
2/2
✓ Branch 56 → 57 taken 36153 times.
✓ Branch 56 → 58 taken 22854 times.
59007 if (error & (8 << error_type))
1000 36153 end_ok = 1;
1001
1002
1/2
✗ Branch 58 → 59 not taken.
✓ Branch 58 → 60 taken 59007 times.
59007 if (!end_ok)
1003 ✗ s->error_status_table[mb_xy] |= 1 << error_type;
1004
1005
2/2
✓ Branch 60 → 61 taken 36207 times.
✓ Branch 60 → 62 taken 22800 times.
59007 if (error & VP_START)
1006 36207 end_ok = 0;
1007 }
1008 }
1009 #endif
1010 #if 1
1011 /* handle slices with partitions of different length */
1012
2/2
✓ Branch 66 → 67 taken 24 times.
✓ Branch 66 → 80 taken 18 times.
42 if (s->partitioned_frame) {
1013 24 int end_ok = 0;
1014
1015
2/2
✓ Branch 79 → 68 taken 9504 times.
✓ Branch 79 → 80 taken 24 times.
9528 for (i = s->mb_num - 1; i >= 0; i--) {
1016 9504 const int mb_xy = s->mb_index2xy[i];
1017 9504 int error = s->error_status_table[mb_xy];
1018
1019
2/2
✓ Branch 68 → 69 taken 2596 times.
✓ Branch 68 → 70 taken 6908 times.
9504 if (error & ER_AC_END)
1020 2596 end_ok = 0;
1021
2/2
✓ Branch 70 → 71 taken 6908 times.
✓ Branch 70 → 73 taken 2596 times.
9504 if ((error & ER_MV_END) ||
1022
1/2
✓ Branch 71 → 72 taken 6908 times.
✗ Branch 71 → 73 not taken.
6908 (error & ER_DC_END) ||
1023
1/2
✗ Branch 72 → 73 not taken.
✓ Branch 72 → 74 taken 6908 times.
6908 (error & ER_AC_ERROR))
1024 2596 end_ok = 1;
1025
1026
1/2
✗ Branch 74 → 75 not taken.
✓ Branch 74 → 76 taken 9504 times.
9504 if (!end_ok)
1027 ✗ s->error_status_table[mb_xy]|= ER_AC_ERROR;
1028
1029
2/2
✓ Branch 76 → 77 taken 2596 times.
✓ Branch 76 → 78 taken 6908 times.
9504 if (error & VP_START)
1030 2596 end_ok = 0;
1031 }
1032 }
1033 #endif
1034 /* handle missing slices */
1035
1/2
✗ Branch 80 → 81 not taken.
✓ Branch 80 → 94 taken 42 times.
42 if (s->avctx->err_recognition & AV_EF_EXPLODE) {
1036 ✗ int end_ok = 1;
1037
1038 // FIXME + 100 hack
1039
0/2
✗ Branch 93 → 82 not taken.
✗ Branch 93 → 94 not taken.
✗ for (i = s->mb_num - 2; i >= s->mb_width + 100; i--) {
1040 ✗ const int mb_xy = s->mb_index2xy[i];
1041 ✗ int error1 = s->error_status_table[mb_xy];
1042 ✗ int error2 = s->error_status_table[s->mb_index2xy[i + 1]];
1043
1044
0/2
✗ Branch 82 → 83 not taken.
✗ Branch 82 → 84 not taken.
✗ if (error1 & VP_START)
1045 ✗ end_ok = 1;
1046
1047
0/4
✗ Branch 84 → 85 not taken.
✗ Branch 84 → 90 not taken.
✗ Branch 85 → 86 not taken.
✗ Branch 85 → 90 not taken.
✗ if (error2 == (VP_START | ER_MB_ERROR | ER_MB_END) &&
1048 ✗ error1 != (VP_START | ER_MB_ERROR | ER_MB_END) &&
1049
0/4
✗ Branch 86 → 87 not taken.
✗ Branch 86 → 89 not taken.
✗ Branch 87 → 88 not taken.
✗ Branch 87 → 89 not taken.
✗ ((error1 & ER_AC_END) || (error1 & ER_DC_END) ||
1050
0/2
✗ Branch 88 → 89 not taken.
✗ Branch 88 → 90 not taken.
✗ (error1 & ER_MV_END))) {
1051 // end & uninit
1052 ✗ end_ok = 0;
1053 }
1054
1055
0/2
✗ Branch 90 → 91 not taken.
✗ Branch 90 → 92 not taken.
✗ if (!end_ok)
1056 ✗ s->error_status_table[mb_xy] |= ER_MB_ERROR;
1057 }
1058 }
1059
1060 #if 1
1061 /* backward mark errors */
1062 42 distance = 9999999;
1063
2/2
✓ Branch 111 → 95 taken 126 times.
✓ Branch 111 → 112 taken 42 times.
168 for (error_type = 1; error_type <= 3; error_type++) {
1064
2/2
✓ Branch 109 → 96 taken 59007 times.
✓ Branch 109 → 110 taken 126 times.
59133 for (i = s->mb_num - 1; i >= 0; i--) {
1065 59007 const int mb_xy = s->mb_index2xy[i];
1066 59007 int error = s->error_status_table[mb_xy];
1067
1068
4/4
✓ Branch 96 → 97 taken 29172 times.
✓ Branch 96 → 98 taken 29835 times.
✓ Branch 97 → 98 taken 28977 times.
✓ Branch 97 → 99 taken 195 times.
59007 if (!s->mbskip_table || !s->mbskip_table[mb_xy]) // FIXME partition specific
1069 58812 distance++;
1070
2/2
✓ Branch 99 → 100 taken 35841 times.
✓ Branch 99 → 101 taken 23166 times.
59007 if (error & (1 << error_type))
1071 35841 distance = 0;
1072
1073
2/2
✓ Branch 101 → 102 taken 28512 times.
✓ Branch 101 → 104 taken 30495 times.
59007 if (s->partitioned_frame) {
1074
2/2
✓ Branch 102 → 103 taken 7422 times.
✓ Branch 102 → 106 taken 21090 times.
28512 if (distance < threshold_part[error_type - 1])
1075 7422 s->error_status_table[mb_xy] |= 1 << error_type;
1076 } else {
1077
2/2
✓ Branch 104 → 105 taken 29766 times.
✓ Branch 104 → 106 taken 729 times.
30495 if (distance < threshold)
1078 29766 s->error_status_table[mb_xy] |= 1 << error_type;
1079 }
1080
1081
2/2
✓ Branch 106 → 107 taken 36207 times.
✓ Branch 106 → 108 taken 22800 times.
59007 if (error & VP_START)
1082 36207 distance = 9999999;
1083 }
1084 }
1085 #endif
1086
1087 /* forward mark errors */
1088 42 error = 0;
1089
2/2
✓ Branch 117 → 113 taken 19669 times.
✓ Branch 117 → 118 taken 42 times.
19711 for (i = 0; i < s->mb_num; i++) {
1090 19669 const int mb_xy = s->mb_index2xy[i];
1091 19669 int old_error = s->error_status_table[mb_xy];
1092
1093
2/2
✓ Branch 113 → 114 taken 12069 times.
✓ Branch 113 → 115 taken 7600 times.
19669 if (old_error & VP_START) {
1094 12069 error = old_error & ER_MB_ERROR;
1095 } else {
1096 7600 error |= old_error & ER_MB_ERROR;
1097 7600 s->error_status_table[mb_xy] |= error;
1098 }
1099 }
1100 #if 1
1101 /* handle not partitioned case */
1102
2/2
✓ Branch 118 → 119 taken 18 times.
✓ Branch 118 → 124 taken 24 times.
42 if (!s->partitioned_frame) {
1103
2/2
✓ Branch 123 → 120 taken 10165 times.
✓ Branch 123 → 124 taken 18 times.
10183 for (i = 0; i < s->mb_num; i++) {
1104 10165 const int mb_xy = s->mb_index2xy[i];
1105 10165 int error = s->error_status_table[mb_xy];
1106
2/2
✓ Branch 120 → 121 taken 9922 times.
✓ Branch 120 → 122 taken 243 times.
10165 if (error & ER_MB_ERROR)
1107 9922 error |= ER_MB_ERROR;
1108 10165 s->error_status_table[mb_xy] = error;
1109 }
1110 }
1111 #endif
1112
1113 42 dc_error = ac_error = mv_error = 0;
1114
2/2
✓ Branch 132 → 125 taken 19669 times.
✓ Branch 132 → 133 taken 42 times.
19711 for (i = 0; i < s->mb_num; i++) {
1115 19669 const int mb_xy = s->mb_index2xy[i];
1116 19669 int error = s->error_status_table[mb_xy];
1117
2/2
✓ Branch 125 → 126 taken 12396 times.
✓ Branch 125 → 127 taken 7273 times.
19669 if (error & ER_DC_ERROR)
1118 12396 dc_error++;
1119
2/2
✓ Branch 127 → 128 taken 12396 times.
✓ Branch 127 → 129 taken 7273 times.
19669 if (error & ER_AC_ERROR)
1120 12396 ac_error++;
1121
2/2
✓ Branch 129 → 130 taken 12396 times.
✓ Branch 129 → 131 taken 7273 times.
19669 if (error & ER_MV_ERROR)
1122 12396 mv_error++;
1123 }
1124 42 av_log(s->avctx, AV_LOG_INFO, "concealing %d DC, %d AC, %d MV errors in %c frame\n",
1125 42 dc_error, ac_error, mv_error, av_get_picture_type_char(s->cur_pic.f->pict_type));
1126
1127
2/2
✓ Branch 135 → 136 taken 17 times.
✓ Branch 135 → 137 taken 25 times.
42 if (decode_error_flags)
1128 17 *decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
1129 else
1130 25 s->cur_pic.f->decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
1131
1132 42 is_intra_likely = is_intra_more_likely(s);
1133
1134 /* set unknown mb-type to most likely */
1135
2/2
✓ Branch 139 → 140 taken 39 times.
✓ Branch 139 → 143 taken 3 times.
81 guessed_mb_type = is_intra_likely ? MB_TYPE_INTRA4x4 :
1136
2/2
✓ Branch 140 → 141 taken 15 times.
✓ Branch 140 → 142 taken 24 times.
39 (MB_TYPE_16x16 | (s->avctx->codec_id == AV_CODEC_ID_H264 ? MB_TYPE_L0 : MB_TYPE_FORWARD_MV));
1137
2/2
✓ Branch 150 → 145 taken 19669 times.
✓ Branch 150 → 151 taken 42 times.
19711 for (i = 0; i < s->mb_num; i++) {
1138 19669 const int mb_xy = s->mb_index2xy[i];
1139 19669 int error = s->error_status_table[mb_xy];
1140
3/4
✓ Branch 145 → 146 taken 12396 times.
✓ Branch 145 → 147 taken 7273 times.
✗ Branch 146 → 147 not taken.
✓ Branch 146 → 148 taken 12396 times.
19669 if (!((error & ER_DC_ERROR) && (error & ER_MV_ERROR)))
1141 7273 continue;
1142
1143 12396 s->cur_pic.mb_type[mb_xy] = guessed_mb_type;
1144 }
1145
1146 // change inter to intra blocks if no reference frames are available
1147
3/4
✓ Branch 151 → 152 taken 39 times.
✓ Branch 151 → 153 taken 3 times.
✗ Branch 152 → 153 not taken.
✓ Branch 152 → 160 taken 39 times.
42 if (!(s->last_pic.f && s->last_pic.f->data[0]) &&
1148
3/4
✓ Branch 153 → 154 taken 1 time.
✓ Branch 153 → 155 taken 2 times.
✗ Branch 154 → 155 not taken.
✓ Branch 154 → 160 taken 1 time.
3 !(s->next_pic.f && s->next_pic.f->data[0]))
1149
2/2
✓ Branch 159 → 156 taken 8460 times.
✓ Branch 159 → 160 taken 2 times.
8462 for (i = 0; i < s->mb_num; i++) {
1150 8460 const int mb_xy = s->mb_index2xy[i];
1151
1/2
✗ Branch 156 → 157 not taken.
✓ Branch 156 → 158 taken 8460 times.
8460 if (!IS_INTRA(s->cur_pic.mb_type[mb_xy]))
1152 ✗ s->cur_pic.mb_type[mb_xy] = MB_TYPE_INTRA4x4;
1153 }
1154
1155 /* handle inter blocks with damaged AC */
1156
2/2
✓ Branch 184 → 161 taken 661 times.
✓ Branch 184 → 185 taken 42 times.
703 for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
1157
2/2
✓ Branch 182 → 162 taken 19669 times.
✓ Branch 182 → 183 taken 661 times.
20330 for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
1158 19669 const int mb_xy = mb_x + mb_y * s->mb_stride;
1159 19669 const int mb_type = s->cur_pic.mb_type[mb_xy];
1160
3/4
✓ Branch 162 → 163 taken 10813 times.
✓ Branch 162 → 164 taken 8856 times.
✗ Branch 163 → 164 not taken.
✓ Branch 163 → 165 taken 10813 times.
19669 const int dir = !(s->last_pic.f && s->last_pic.f->data[0]);
1161
2/2
✓ Branch 166 → 167 taken 8856 times.
✓ Branch 166 → 168 taken 10813 times.
19669 const int mv_dir = dir ? MV_DIR_BACKWARD : MV_DIR_FORWARD;
1162 int mv_type;
1163
1164 19669 int error = s->error_status_table[mb_xy];
1165
1166
2/2
✓ Branch 169 → 170 taken 12134 times.
✓ Branch 169 → 171 taken 7535 times.
19669 if (IS_INTRA(mb_type))
1167 12134 continue; // intra
1168
2/2
✓ Branch 171 → 172 taken 4127 times.
✓ Branch 171 → 173 taken 3408 times.
7535 if (error & ER_MV_ERROR)
1169 4127 continue; // inter with damaged MV
1170
1/2
✓ Branch 173 → 174 taken 3408 times.
✗ Branch 173 → 175 not taken.
3408 if (!(error & ER_AC_ERROR))
1171 3408 continue; // undamaged inter
1172
1173
0/2
✗ Branch 175 → 176 not taken.
✗ Branch 175 → 179 not taken.
✗ if (IS_8X8(mb_type)) {
1174 ✗ int mb_index = mb_x * 2 + mb_y * 2 * s->b8_stride;
1175 int j;
1176 ✗ mv_type = MV_TYPE_8X8;
1177
0/2
✗ Branch 178 → 177 not taken.
✗ Branch 178 → 180 not taken.
✗ for (j = 0; j < 4; j++) {
1178 ✗ s->mv[0][j][0] = s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][0];
1179 ✗ s->mv[0][j][1] = s->cur_pic.motion_val[dir][mb_index + (j & 1) + (j >> 1) * s->b8_stride][1];
1180 }
1181 } else {
1182 ✗ mv_type = MV_TYPE_16X16;
1183 ✗ s->mv[0][0][0] = s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][0];
1184 ✗ s->mv[0][0][1] = s->cur_pic.motion_val[dir][mb_x * 2 + mb_y * 2 * s->b8_stride][1];
1185 }
1186
1187 ✗ s->decode_mb(s->opaque, 0 /* FIXME H.264 partitioned slices need this set */,
1188 mv_dir, mv_type, &s->mv, mb_x, mb_y, 0, 0);
1189 }
1190 }
1191
1192 /* guess MVs */
1193
1/2
✗ Branch 185 → 186 not taken.
✓ Branch 185 → 212 taken 42 times.
42 if (s->cur_pic.f->pict_type == AV_PICTURE_TYPE_B) {
1194
0/2
✗ Branch 211 → 187 not taken.
✗ Branch 211 → 213 not taken.
✗ for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
1195
0/2
✗ Branch 209 → 188 not taken.
✗ Branch 209 → 210 not taken.
✗ for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
1196 ✗ int xy = mb_x * 2 + mb_y * 2 * s->b8_stride;
1197 ✗ const int mb_xy = mb_x + mb_y * s->mb_stride;
1198 ✗ const int mb_type = s->cur_pic.mb_type[mb_xy];
1199 ✗ int mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
1200
1201 ✗ int error = s->error_status_table[mb_xy];
1202
1203
0/2
✗ Branch 188 → 189 not taken.
✗ Branch 188 → 190 not taken.
✗ if (IS_INTRA(mb_type))
1204 ✗ continue;
1205
0/2
✗ Branch 190 → 191 not taken.
✗ Branch 190 → 192 not taken.
✗ if (!(error & ER_MV_ERROR))
1206 ✗ continue; // inter with undamaged MV
1207
0/2
✗ Branch 192 → 193 not taken.
✗ Branch 192 → 194 not taken.
✗ if (!(error & ER_AC_ERROR))
1208 ✗ continue; // undamaged inter
1209
1210
0/4
✗ Branch 194 → 195 not taken.
✗ Branch 194 → 196 not taken.
✗ Branch 195 → 196 not taken.
✗ Branch 195 → 197 not taken.
✗ if (!(s->last_pic.f && s->last_pic.f->data[0]))
1211 ✗ mv_dir &= ~MV_DIR_FORWARD;
1212
0/4
✗ Branch 197 → 198 not taken.
✗ Branch 197 → 199 not taken.
✗ Branch 198 → 199 not taken.
✗ Branch 198 → 200 not taken.
✗ if (!(s->next_pic.f && s->next_pic.f->data[0]))
1213 ✗ mv_dir &= ~MV_DIR_BACKWARD;
1214
1215
0/2
✗ Branch 200 → 201 not taken.
✗ Branch 200 → 206 not taken.
✗ if (s->pp_time) {
1216 ✗ int time_pp = s->pp_time;
1217 ✗ int time_pb = s->pb_time;
1218
1219
0/2
✗ Branch 201 → 202 not taken.
✗ Branch 201 → 204 not taken.
✗ av_assert0(s->avctx->codec_id != AV_CODEC_ID_H264);
1220 ✗ ff_thread_progress_await(s->next_pic.progress, mb_y);
1221
1222 ✗ s->mv[0][0][0] = s->next_pic.motion_val[0][xy][0] * time_pb / time_pp;
1223 ✗ s->mv[0][0][1] = s->next_pic.motion_val[0][xy][1] * time_pb / time_pp;
1224 ✗ s->mv[1][0][0] = s->next_pic.motion_val[0][xy][0] * (time_pb - time_pp) / time_pp;
1225 ✗ s->mv[1][0][1] = s->next_pic.motion_val[0][xy][1] * (time_pb - time_pp) / time_pp;
1226 } else {
1227 ✗ s->mv[0][0][0] = 0;
1228 ✗ s->mv[0][0][1] = 0;
1229 ✗ s->mv[1][0][0] = 0;
1230 ✗ s->mv[1][0][1] = 0;
1231 }
1232
1233 ✗ s->decode_mb(s->opaque, 0, mv_dir, MV_TYPE_16X16, &s->mv,
1234 mb_x, mb_y, 0, 0);
1235 }
1236 }
1237 } else
1238 42 guess_mv(s);
1239
1240 /* fill DC for inter blocks */
1241
2/2
✓ Branch 239 → 214 taken 661 times.
✓ Branch 239 → 240 taken 42 times.
703 for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
1242
2/2
✓ Branch 237 → 215 taken 19669 times.
✓ Branch 237 → 238 taken 661 times.
20330 for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
1243 int dc, dcu, dcv, y, n;
1244 int16_t *dc_ptr;
1245 uint8_t *dest_y, *dest_cb, *dest_cr;
1246 19669 const int mb_xy = mb_x + mb_y * s->mb_stride;
1247 19669 const int mb_type = s->cur_pic.mb_type[mb_xy];
1248
1249 // error = s->error_status_table[mb_xy];
1250
1251
4/4
✓ Branch 215 → 216 taken 12134 times.
✓ Branch 215 → 218 taken 7535 times.
✓ Branch 216 → 217 taken 3674 times.
✓ Branch 216 → 218 taken 8460 times.
19669 if (IS_INTRA(mb_type) && s->partitioned_frame)
1252 3674 continue;
1253 // if (error & ER_MV_ERROR)
1254 // continue; // inter data damaged FIXME is this good?
1255
1256 15995 dest_y = s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1257 15995 dest_cb = s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1258 15995 dest_cr = s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1259
1260 15995 dc_ptr = &s->dc_val[0][mb_x * 2 + mb_y * 2 * s->b8_stride];
1261
2/2
✓ Branch 226 → 219 taken 63980 times.
✓ Branch 226 → 227 taken 15995 times.
79975 for (n = 0; n < 4; n++) {
1262 63980 dc = 0;
1263
2/2
✓ Branch 224 → 220 taken 511840 times.
✓ Branch 224 → 225 taken 63980 times.
575820 for (y = 0; y < 8; y++) {
1264 int x;
1265
2/2
✓ Branch 222 → 221 taken 4094720 times.
✓ Branch 222 → 223 taken 511840 times.
4606560 for (x = 0; x < 8; x++)
1266 4094720 dc += dest_y[x + (n & 1) * 8 +
1267 4094720 (y + (n >> 1) * 8) * linesize[0]];
1268 }
1269 63980 dc_ptr[(n & 1) + (n >> 1) * s->b8_stride] = (dc + 4) >> 3;
1270 }
1271
1272
1/2
✗ Branch 227 → 228 not taken.
✓ Branch 227 → 229 taken 15995 times.
15995 if (!s->cur_pic.f->data[2])
1273 ✗ continue;
1274
1275 15995 dcu = dcv = 0;
1276
2/2
✓ Branch 234 → 230 taken 127960 times.
✓ Branch 234 → 235 taken 15995 times.
143955 for (y = 0; y < 8; y++) {
1277 int x;
1278
2/2
✓ Branch 232 → 231 taken 1023680 times.
✓ Branch 232 → 233 taken 127960 times.
1151640 for (x = 0; x < 8; x++) {
1279 1023680 dcu += dest_cb[x + y * linesize[1]];
1280 1023680 dcv += dest_cr[x + y * linesize[2]];
1281 }
1282 }
1283 15995 s->dc_val[1][mb_x + mb_y * s->mb_stride] = (dcu + 4) >> 3;
1284 15995 s->dc_val[2][mb_x + mb_y * s->mb_stride] = (dcv + 4) >> 3;
1285 }
1286 }
1287 #if 1
1288 /* guess DC for damaged blocks */
1289 42 guess_dc(s, s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride, 1);
1290 42 guess_dc(s, s->dc_val[1], s->mb_width , s->mb_height , s->mb_stride, 0);
1291 42 guess_dc(s, s->dc_val[2], s->mb_width , s->mb_height , s->mb_stride, 0);
1292 #endif
1293
1294 /* filter luma DC */
1295 42 filter181(s->dc_val[0], s->mb_width * 2, s->mb_height * 2, s->b8_stride);
1296
1297 #if 1
1298 /* render DC only intra */
1299
2/2
✓ Branch 256 → 245 taken 661 times.
✓ Branch 256 → 257 taken 42 times.
703 for (mb_y = 0; mb_y < s->mb_height; mb_y++) {
1300
2/2
✓ Branch 254 → 246 taken 19669 times.
✓ Branch 254 → 255 taken 661 times.
20330 for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
1301 uint8_t *dest_y, *dest_cb, *dest_cr;
1302 19669 const int mb_xy = mb_x + mb_y * s->mb_stride;
1303 19669 const int mb_type = s->cur_pic.mb_type[mb_xy];
1304
1305 19669 int error = s->error_status_table[mb_xy];
1306
1307
2/2
✓ Branch 246 → 247 taken 7535 times.
✓ Branch 246 → 248 taken 12134 times.
19669 if (IS_INTER(mb_type))
1308 7535 continue;
1309
2/2
✓ Branch 248 → 249 taken 3865 times.
✓ Branch 248 → 250 taken 8269 times.
12134 if (!(error & ER_AC_ERROR))
1310 3865 continue; // undamaged
1311
1312 8269 dest_y = s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0];
1313 8269 dest_cb = s->cur_pic.f->data[1] + mb_x * 8 + mb_y * 8 * linesize[1];
1314 8269 dest_cr = s->cur_pic.f->data[2] + mb_x * 8 + mb_y * 8 * linesize[2];
1315
1/2
✗ Branch 250 → 251 not taken.
✓ Branch 250 → 252 taken 8269 times.
8269 if (!s->cur_pic.f->data[2])
1316 ✗ dest_cb = dest_cr = NULL;
1317
1318 8269 put_dc(s, dest_y, dest_cb, dest_cr, mb_x, mb_y);
1319 }
1320 }
1321 #endif
1322
1323
1/2
✓ Branch 257 → 258 taken 42 times.
✗ Branch 257 → 265 not taken.
42 if (s->avctx->error_concealment & FF_EC_DEBLOCK) {
1324 /* filter horizontal block boundaries */
1325 42 h_block_filter(s, s->cur_pic.f->data[0], s->mb_width * 2,
1326 42 s->mb_height * 2, linesize[0], 1);
1327
1328 /* filter vertical block boundaries */
1329 42 v_block_filter(s, s->cur_pic.f->data[0], s->mb_width * 2,
1330 42 s->mb_height * 2, linesize[0], 1);
1331
1332
1/2
✓ Branch 260 → 261 taken 42 times.
✗ Branch 260 → 265 not taken.
42 if (s->cur_pic.f->data[2]) {
1333 42 h_block_filter(s, s->cur_pic.f->data[1], s->mb_width,
1334 42 s->mb_height, linesize[1], 0);
1335 42 h_block_filter(s, s->cur_pic.f->data[2], s->mb_width,
1336 42 s->mb_height, linesize[2], 0);
1337 42 v_block_filter(s, s->cur_pic.f->data[1], s->mb_width,
1338 42 s->mb_height, linesize[1], 0);
1339 42 v_block_filter(s, s->cur_pic.f->data[2], s->mb_width,
1340 42 s->mb_height, linesize[2], 0);
1341 }
1342 }
1343
1344 /* clean a few tables */
1345
2/2
✓ Branch 273 → 266 taken 19669 times.
✓ Branch 273 → 274 taken 42 times.
19711 for (i = 0; i < s->mb_num; i++) {
1346 19669 const int mb_xy = s->mb_index2xy[i];
1347 19669 int error = s->error_status_table[mb_xy];
1348
1349
3/4
✓ Branch 266 → 267 taken 9724 times.
✓ Branch 266 → 270 taken 9945 times.
✓ Branch 267 → 268 taken 9724 times.
✗ Branch 267 → 270 not taken.
19669 if (s->mbskip_table && s->cur_pic.f->pict_type != AV_PICTURE_TYPE_B &&
1350
2/2
✓ Branch 268 → 269 taken 2694 times.
✓ Branch 268 → 270 taken 7030 times.
9724 (error & (ER_DC_ERROR | ER_MV_ERROR | ER_AC_ERROR))) {
1351 2694 s->mbskip_table[mb_xy] = 0;
1352 }
1353
2/2
✓ Branch 270 → 271 taken 9724 times.
✓ Branch 270 → 272 taken 9945 times.
19669 if (s->mbintra_table)
1354 9724 s->mbintra_table[mb_xy] = 1;
1355 }
1356
1357 42 memset(&s->cur_pic, 0, sizeof(ERPicture));
1358 42 memset(&s->last_pic, 0, sizeof(ERPicture));
1359 42 memset(&s->next_pic, 0, sizeof(ERPicture));
1360
1361 42 cleanup:
1362
2/2
✓ Branch 279 → 276 taken 84 times.
✓ Branch 279 → 280 taken 42 times.
126 for (i = 0; i < 2; i++) {
1363 84 av_freep(&s->ref_index[i]);
1364 84 av_freep(&s->motion_val_base[i]);
1365 84 s->cur_pic.ref_index[i] = NULL;
1366 84 s->cur_pic.motion_val[i] = NULL;
1367 }
1368 }
1369