FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vp8.c
Date: 2024-04-19 17:50:32
Exec Total Coverage
Lines: 1367 1591 85.9%
Functions: 77 84 91.7%
Branches: 816 1157 70.5%

Line Branch Exec Source
1 /*
2 * VP7/VP8 compatible video decoder
3 *
4 * Copyright (C) 2010 David Conrad
5 * Copyright (C) 2010 Ronald S. Bultje
6 * Copyright (C) 2010 Fiona Glaser
7 * Copyright (C) 2012 Daniel Kang
8 * Copyright (C) 2014 Peter Ross
9 *
10 * This file is part of FFmpeg.
11 *
12 * FFmpeg is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
16 *
17 * FFmpeg is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with FFmpeg; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 */
26
27 #include "config_components.h"
28
29 #include "libavutil/mem.h"
30 #include "libavutil/mem_internal.h"
31
32 #include "avcodec.h"
33 #include "codec_internal.h"
34 #include "decode.h"
35 #include "hwaccel_internal.h"
36 #include "hwconfig.h"
37 #include "mathops.h"
38 #include "progressframe.h"
39 #include "refstruct.h"
40 #include "thread.h"
41 #include "vp8.h"
42 #include "vp89_rac.h"
43 #include "vp8data.h"
44 #include "vpx_rac.h"
45
46 #if ARCH_ARM
47 # include "arm/vp8.h"
48 #endif
49
50 // fixme: add 1 bit to all the calls to this?
51 6139 static int vp8_rac_get_sint(VPXRangeCoder *c, int bits)
52 {
53 int v;
54
55
2/2
✓ Branch 1 taken 5389 times.
✓ Branch 2 taken 750 times.
6139 if (!vp89_rac_get(c))
56 5389 return 0;
57
58 750 v = vp89_rac_get_uint(c, bits);
59
60
2/2
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 652 times.
750 if (vp89_rac_get(c))
61 98 v = -v;
62
63 750 return v;
64 }
65
66 306 static int vp8_rac_get_nn(VPXRangeCoder *c)
67 {
68 306 int v = vp89_rac_get_uint(c, 7) << 1;
69 306 return v + !v;
70 }
71
72 // DCTextra
73 50926 static int vp8_rac_get_coeff(VPXRangeCoder *c, const uint8_t *prob)
74 {
75 50926 int v = 0;
76
77 do {
78 196061 v = (v<<1) + vpx_rac_get_prob(c, *prob++);
79
2/2
✓ Branch 0 taken 145135 times.
✓ Branch 1 taken 50926 times.
196061 } while (*prob);
80
81 50926 return v;
82 }
83
84 79 static void free_buffers(VP8Context *s)
85 {
86 int i;
87
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 39 times.
79 if (s->thread_data)
88
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 40 times.
360 for (i = 0; i < MAX_THREADS; i++) {
89 #if HAVE_THREADS
90 320 pthread_cond_destroy(&s->thread_data[i].cond);
91 320 pthread_mutex_destroy(&s->thread_data[i].lock);
92 #endif
93 320 av_freep(&s->thread_data[i].filter_strength);
94 }
95 79 av_freep(&s->thread_data);
96 79 av_freep(&s->macroblocks_base);
97 79 av_freep(&s->intra4x4_pred_mode_top);
98 79 av_freep(&s->top_nnz);
99 79 av_freep(&s->top_border);
100
101 79 s->macroblocks = NULL;
102 79 }
103
104 1150 static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int ref)
105 {
106 1150 int ret = ff_progress_frame_get_buffer(s->avctx, &f->tf,
107 ref ? AV_GET_BUFFER_FLAG_REF : 0);
108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1150 times.
1150 if (ret < 0)
109 return ret;
110
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1150 times.
1150 if (!(f->seg_map = ff_refstruct_allocz(s->mb_width * s->mb_height)))
111 goto fail;
112 1150 ret = ff_hwaccel_frame_priv_alloc(s->avctx, &f->hwaccel_picture_private);
113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1150 times.
1150 if (ret < 0)
114 goto fail;
115
116 1150 return 0;
117
118 fail:
119 ff_refstruct_unref(&f->seg_map);
120 ff_progress_frame_unref(&f->tf);
121 return ret;
122 }
123
124 1429 static void vp8_release_frame(VP8Frame *f)
125 {
126 1429 ff_refstruct_unref(&f->seg_map);
127 1429 ff_refstruct_unref(&f->hwaccel_picture_private);
128 1429 ff_progress_frame_unref(&f->tf);
129 1429 }
130
131 79 static av_cold void vp8_decode_flush_impl(AVCodecContext *avctx, int free_mem)
132 {
133 79 VP8Context *s = avctx->priv_data;
134 int i;
135
136
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 79 times.
474 for (i = 0; i < FF_ARRAY_ELEMS(s->frames); i++)
137 395 vp8_release_frame(&s->frames[i]);
138 79 memset(s->framep, 0, sizeof(s->framep));
139
140
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if (free_mem)
141 79 free_buffers(s);
142
143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
79 if (FF_HW_HAS_CB(avctx, flush))
144 FF_HW_SIMPLE_CALL(avctx, flush);
145 79 }
146
147 static av_cold void vp8_decode_flush(AVCodecContext *avctx)
148 {
149 vp8_decode_flush_impl(avctx, 0);
150 }
151
152 1150 static VP8Frame *vp8_find_free_buffer(VP8Context *s)
153 {
154 1150 VP8Frame *frame = NULL;
155 int i;
156
157 // find a free buffer
158
1/2
✓ Branch 0 taken 2808 times.
✗ Branch 1 not taken.
2808 for (i = 0; i < 5; i++)
159
2/2
✓ Branch 0 taken 2213 times.
✓ Branch 1 taken 595 times.
2808 if (&s->frames[i] != s->framep[VP8_FRAME_CURRENT] &&
160
2/2
✓ Branch 0 taken 2212 times.
✓ Branch 1 taken 1 times.
2213 &s->frames[i] != s->framep[VP8_FRAME_PREVIOUS] &&
161
2/2
✓ Branch 0 taken 1608 times.
✓ Branch 1 taken 604 times.
2212 &s->frames[i] != s->framep[VP8_FRAME_GOLDEN] &&
162
2/2
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 458 times.
1608 &s->frames[i] != s->framep[VP8_FRAME_ALTREF]) {
163 1150 frame = &s->frames[i];
164 1150 break;
165 }
166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1150 times.
1150 if (i == 5) {
167 av_log(s->avctx, AV_LOG_FATAL, "Ran out of free frames!\n");
168 abort();
169 }
170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1150 times.
1150 if (frame->tf.f)
171 vp8_release_frame(frame);
172
173 1150 return frame;
174 }
175
176 21 static enum AVPixelFormat get_pixel_format(VP8Context *s)
177 {
178 21 enum AVPixelFormat pix_fmts[] = {
179 #if CONFIG_VP8_VAAPI_HWACCEL
180 AV_PIX_FMT_VAAPI,
181 #endif
182 #if CONFIG_VP8_NVDEC_HWACCEL
183 AV_PIX_FMT_CUDA,
184 #endif
185 AV_PIX_FMT_YUV420P,
186 AV_PIX_FMT_NONE,
187 };
188
189 21 return ff_get_format(s->avctx, pix_fmts);
190 }
191
192 static av_always_inline
193 40 int update_dimensions(VP8Context *s, int width, int height, int is_vp7)
194 {
195 40 AVCodecContext *avctx = s->avctx;
196 40 int i, ret, dim_reset = 0;
197
198
7/8
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 6 times.
40 if (width != s->avctx->width || ((width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height) && s->macroblocks_base ||
199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 height != s->avctx->height) {
200 16 vp8_decode_flush_impl(s->avctx, 1);
201
202 16 ret = ff_set_dimensions(s->avctx, width, height);
203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (ret < 0)
204 return ret;
205
206 16 dim_reset = (s->macroblocks_base != NULL);
207 }
208
209
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
40 if ((s->pix_fmt == AV_PIX_FMT_NONE || dim_reset) &&
210
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 1 times.
28 !s->actually_webp && !is_vp7) {
211 21 s->pix_fmt = get_pixel_format(s);
212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (s->pix_fmt < 0)
213 return AVERROR(EINVAL);
214 21 avctx->pix_fmt = s->pix_fmt;
215 }
216
217 40 s->mb_width = (s->avctx->coded_width + 15) / 16;
218 40 s->mb_height = (s->avctx->coded_height + 15) / 16;
219
220
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
40 s->mb_layout = is_vp7 || avctx->active_thread_type == FF_THREAD_SLICE &&
221 avctx->thread_count > 1;
222
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 1 times.
40 if (!s->mb_layout) { // Frame threading and one thread
223 39 s->macroblocks_base = av_mallocz((s->mb_width + s->mb_height * 2 + 1) *
224 sizeof(*s->macroblocks));
225 39 s->intra4x4_pred_mode_top = av_mallocz(s->mb_width * 4);
226 } else // Sliced threading
227 1 s->macroblocks_base = av_mallocz((s->mb_width + 2) * (s->mb_height + 2) *
228 sizeof(*s->macroblocks));
229 40 s->top_nnz = av_mallocz(s->mb_width * sizeof(*s->top_nnz));
230 40 s->top_border = av_mallocz((s->mb_width + 1) * sizeof(*s->top_border));
231 40 s->thread_data = av_mallocz(MAX_THREADS * sizeof(VP8ThreadData));
232
233
3/6
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 40 times.
✗ Branch 5 not taken.
40 if (!s->macroblocks_base || !s->top_nnz || !s->top_border ||
234
4/6
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 39 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
40 !s->thread_data || (!s->intra4x4_pred_mode_top && !s->mb_layout)) {
235 free_buffers(s);
236 return AVERROR(ENOMEM);
237 }
238
239
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 40 times.
360 for (i = 0; i < MAX_THREADS; i++) {
240 640 s->thread_data[i].filter_strength =
241 320 av_mallocz(s->mb_width * sizeof(*s->thread_data[0].filter_strength));
242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
320 if (!s->thread_data[i].filter_strength) {
243 free_buffers(s);
244 return AVERROR(ENOMEM);
245 }
246 #if HAVE_THREADS
247 320 pthread_mutex_init(&s->thread_data[i].lock, NULL);
248 320 pthread_cond_init(&s->thread_data[i].cond, NULL);
249 #endif
250 }
251
252 40 s->macroblocks = s->macroblocks_base + 1;
253
254 40 return 0;
255 }
256
257 1 static int vp7_update_dimensions(VP8Context *s, int width, int height)
258 {
259 1 return update_dimensions(s, width, height, IS_VP7);
260 }
261
262 39 static int vp8_update_dimensions(VP8Context *s, int width, int height)
263 {
264 39 return update_dimensions(s, width, height, IS_VP8);
265 }
266
267
268 433 static void parse_segment_info(VP8Context *s)
269 {
270 433 VPXRangeCoder *c = &s->c;
271 int i;
272
273 433 s->segmentation.update_map = vp89_rac_get(c);
274 433 s->segmentation.update_feature_data = vp89_rac_get(c);
275
276
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 365 times.
433 if (s->segmentation.update_feature_data) {
277 68 s->segmentation.absolute_vals = vp89_rac_get(c);
278
279
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 68 times.
340 for (i = 0; i < 4; i++)
280 272 s->segmentation.base_quant[i] = vp8_rac_get_sint(c, 7);
281
282
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 68 times.
340 for (i = 0; i < 4; i++)
283 272 s->segmentation.filter_level[i] = vp8_rac_get_sint(c, 6);
284 }
285
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 365 times.
433 if (s->segmentation.update_map)
286
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 68 times.
272 for (i = 0; i < 3; i++)
287
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 180 times.
204 s->prob->segmentid[i] = vp89_rac_get(c) ? vp89_rac_get_uint(c, 8) : 255;
288 433 }
289
290 45 static void update_lf_deltas(VP8Context *s)
291 {
292 45 VPXRangeCoder *c = &s->c;
293 int i;
294
295
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 45 times.
225 for (i = 0; i < 4; i++) {
296
2/2
✓ Branch 1 taken 135 times.
✓ Branch 2 taken 45 times.
180 if (vp89_rac_get(c)) {
297 135 s->lf_delta.ref[i] = vp89_rac_get_uint(c, 6);
298
299
2/2
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 45 times.
135 if (vp89_rac_get(c))
300 90 s->lf_delta.ref[i] = -s->lf_delta.ref[i];
301 }
302 }
303
304
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 45 times.
225 for (i = MODE_I4x4; i <= VP8_MVMODE_SPLIT; i++) {
305
1/2
✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
180 if (vp89_rac_get(c)) {
306 180 s->lf_delta.mode[i] = vp89_rac_get_uint(c, 6);
307
308
2/2
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 135 times.
180 if (vp89_rac_get(c))
309 45 s->lf_delta.mode[i] = -s->lf_delta.mode[i];
310 }
311 }
312 45 }
313
314 1119 static int setup_partitions(VP8Context *s, const uint8_t *buf, int buf_size)
315 {
316 1119 const uint8_t *sizes = buf;
317 int i;
318 int ret;
319
320 1119 s->num_coeff_partitions = 1 << vp89_rac_get_uint(&s->c, 2);
321
322 1119 buf += 3 * (s->num_coeff_partitions - 1);
323 1119 buf_size -= 3 * (s->num_coeff_partitions - 1);
324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if (buf_size < 0)
325 return -1;
326
327
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 1119 times.
1458 for (i = 0; i < s->num_coeff_partitions - 1; i++) {
328 339 int size = AV_RL24(sizes + 3 * i);
329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if (buf_size - size < 0)
330 return -1;
331 339 s->coeff_partition_size[i] = size;
332
333 339 ret = ff_vpx_init_range_decoder(&s->coeff_partition[i], buf, size);
334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if (ret < 0)
335 return ret;
336 339 buf += size;
337 339 buf_size -= size;
338 }
339
340 1119 s->coeff_partition_size[i] = buf_size;
341 1119 ff_vpx_init_range_decoder(&s->coeff_partition[i], buf, buf_size);
342
343 1119 return 0;
344 }
345
346 31 static void vp7_get_quants(VP8Context *s)
347 {
348 31 VPXRangeCoder *c = &s->c;
349
350 31 int yac_qi = vp89_rac_get_uint(c, 7);
351
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
31 int ydc_qi = vp89_rac_get(c) ? vp89_rac_get_uint(c, 7) : yac_qi;
352
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
31 int y2dc_qi = vp89_rac_get(c) ? vp89_rac_get_uint(c, 7) : yac_qi;
353
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
31 int y2ac_qi = vp89_rac_get(c) ? vp89_rac_get_uint(c, 7) : yac_qi;
354
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
31 int uvdc_qi = vp89_rac_get(c) ? vp89_rac_get_uint(c, 7) : yac_qi;
355
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
31 int uvac_qi = vp89_rac_get(c) ? vp89_rac_get_uint(c, 7) : yac_qi;
356
357 31 s->qmat[0].luma_qmul[0] = vp7_ydc_qlookup[ydc_qi];
358 31 s->qmat[0].luma_qmul[1] = vp7_yac_qlookup[yac_qi];
359 31 s->qmat[0].luma_dc_qmul[0] = vp7_y2dc_qlookup[y2dc_qi];
360 31 s->qmat[0].luma_dc_qmul[1] = vp7_y2ac_qlookup[y2ac_qi];
361 31 s->qmat[0].chroma_qmul[0] = FFMIN(vp7_ydc_qlookup[uvdc_qi], 132);
362 31 s->qmat[0].chroma_qmul[1] = vp7_yac_qlookup[uvac_qi];
363 31 }
364
365 1119 static void vp8_get_quants(VP8Context *s)
366 {
367 1119 VPXRangeCoder *c = &s->c;
368 int i, base_qi;
369
370 1119 s->quant.yac_qi = vp89_rac_get_uint(c, 7);
371 1119 s->quant.ydc_delta = vp8_rac_get_sint(c, 4);
372 1119 s->quant.y2dc_delta = vp8_rac_get_sint(c, 4);
373 1119 s->quant.y2ac_delta = vp8_rac_get_sint(c, 4);
374 1119 s->quant.uvdc_delta = vp8_rac_get_sint(c, 4);
375 1119 s->quant.uvac_delta = vp8_rac_get_sint(c, 4);
376
377
2/2
✓ Branch 0 taken 4476 times.
✓ Branch 1 taken 1119 times.
5595 for (i = 0; i < 4; i++) {
378
2/2
✓ Branch 0 taken 1732 times.
✓ Branch 1 taken 2744 times.
4476 if (s->segmentation.enabled) {
379 1732 base_qi = s->segmentation.base_quant[i];
380
2/2
✓ Branch 0 taken 1608 times.
✓ Branch 1 taken 124 times.
1732 if (!s->segmentation.absolute_vals)
381 1608 base_qi += s->quant.yac_qi;
382 } else
383 2744 base_qi = s->quant.yac_qi;
384
385 4476 s->qmat[i].luma_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + s->quant.ydc_delta, 7)];
386 4476 s->qmat[i].luma_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi, 7)];
387 4476 s->qmat[i].luma_dc_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + s->quant.y2dc_delta, 7)] * 2;
388 /* 101581>>16 is equivalent to 155/100 */
389 4476 s->qmat[i].luma_dc_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi + s->quant.y2ac_delta, 7)] * 101581 >> 16;
390 4476 s->qmat[i].chroma_qmul[0] = vp8_dc_qlookup[av_clip_uintp2(base_qi + s->quant.uvdc_delta, 7)];
391 4476 s->qmat[i].chroma_qmul[1] = vp8_ac_qlookup[av_clip_uintp2(base_qi + s->quant.uvac_delta, 7)];
392
393 4476 s->qmat[i].luma_dc_qmul[1] = FFMAX(s->qmat[i].luma_dc_qmul[1], 8);
394 4476 s->qmat[i].chroma_qmul[0] = FFMIN(s->qmat[i].chroma_qmul[0], 132);
395 }
396 1119 }
397
398 /**
399 * Determine which buffers golden and altref should be updated with after this frame.
400 * The spec isn't clear here, so I'm going by my understanding of what libvpx does
401 *
402 * Intra frames update all 3 references
403 * Inter frames update VP8_FRAME_PREVIOUS if the update_last flag is set
404 * If the update (golden|altref) flag is set, it's updated with the current frame
405 * if update_last is set, and VP8_FRAME_PREVIOUS otherwise.
406 * If the flag is not set, the number read means:
407 * 0: no update
408 * 1: VP8_FRAME_PREVIOUS
409 * 2: update golden with altref, or update altref with golden
410 */
411 2136 static VP8FrameType ref_to_update(VP8Context *s, int update, VP8FrameType ref)
412 {
413 2136 VPXRangeCoder *c = &s->c;
414
415
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 2046 times.
2136 if (update)
416 90 return VP8_FRAME_CURRENT;
417
418
3/3
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 1931 times.
2046 switch (vp89_rac_get_uint(c, 2)) {
419 31 case 1:
420 31 return VP8_FRAME_PREVIOUS;
421 84 case 2:
422
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 81 times.
84 return (ref == VP8_FRAME_GOLDEN) ? VP8_FRAME_ALTREF : VP8_FRAME_GOLDEN;
423 }
424 1931 return VP8_FRAME_NONE;
425 }
426
427 52 static void vp78_reset_probability_tables(VP8Context *s)
428 {
429 int i, j;
430
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 52 times.
260 for (i = 0; i < 4; i++)
431
2/2
✓ Branch 0 taken 3328 times.
✓ Branch 1 taken 208 times.
3536 for (j = 0; j < 16; j++)
432 3328 memcpy(s->prob->token[i][j], vp8_token_default_probs[i][vp8_coeff_band[j]],
433 sizeof(s->prob->token[i][j]));
434 52 }
435
436 1150 static void vp78_update_probability_tables(VP8Context *s)
437 {
438 1150 VPXRangeCoder *c = &s->c;
439 int i, j, k, l, m;
440
441
2/2
✓ Branch 0 taken 4600 times.
✓ Branch 1 taken 1150 times.
5750 for (i = 0; i < 4; i++)
442
2/2
✓ Branch 0 taken 36800 times.
✓ Branch 1 taken 4600 times.
41400 for (j = 0; j < 8; j++)
443
2/2
✓ Branch 0 taken 110400 times.
✓ Branch 1 taken 36800 times.
147200 for (k = 0; k < 3; k++)
444
2/2
✓ Branch 0 taken 1214400 times.
✓ Branch 1 taken 110400 times.
1324800 for (l = 0; l < NUM_DCT_TOKENS-1; l++)
445
2/2
✓ Branch 1 taken 7790 times.
✓ Branch 2 taken 1206610 times.
1214400 if (vpx_rac_get_prob_branchy(c, ff_vp8_token_update_probs[i][j][k][l])) {
446 7790 int prob = vp89_rac_get_uint(c, 8);
447
2/2
✓ Branch 0 taken 18062 times.
✓ Branch 1 taken 7790 times.
25852 for (m = 0; vp8_coeff_band_indexes[j][m] >= 0; m++)
448 18062 s->prob->token[i][vp8_coeff_band_indexes[j][m]][k][l] = prob;
449 }
450 1150 }
451
452 #define VP7_MVC_SIZE 17
453 #define VP8_MVC_SIZE 19
454
455 1098 static void vp78_update_pred16x16_pred8x8_mvc_probabilities(VP8Context *s,
456 int mvc_size)
457 {
458 1098 VPXRangeCoder *c = &s->c;
459 int i, j;
460
461
2/2
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1096 times.
1098 if (vp89_rac_get(c))
462
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for (i = 0; i < 4; i++)
463 8 s->prob->pred16x16[i] = vp89_rac_get_uint(c, 8);
464
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1097 times.
1098 if (vp89_rac_get(c))
465
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for (i = 0; i < 3; i++)
466 3 s->prob->pred8x8c[i] = vp89_rac_get_uint(c, 8);
467
468 // 17.2 MV probability update
469
2/2
✓ Branch 0 taken 2196 times.
✓ Branch 1 taken 1098 times.
3294 for (i = 0; i < 2; i++)
470
2/2
✓ Branch 0 taken 41604 times.
✓ Branch 1 taken 2196 times.
43800 for (j = 0; j < mvc_size; j++)
471
2/2
✓ Branch 1 taken 306 times.
✓ Branch 2 taken 41298 times.
41604 if (vpx_rac_get_prob_branchy(c, vp8_mv_update_prob[i][j]))
472 306 s->prob->mvc[i][j] = vp8_rac_get_nn(c);
473 1098 }
474
475 1068 static void update_refs(VP8Context *s)
476 {
477 1068 VPXRangeCoder *c = &s->c;
478
479 1068 int update_golden = vp89_rac_get(c);
480 1068 int update_altref = vp89_rac_get(c);
481
482 1068 s->update_golden = ref_to_update(s, update_golden, VP8_FRAME_GOLDEN);
483 1068 s->update_altref = ref_to_update(s, update_altref, VP8_FRAME_ALTREF);
484 1068 }
485
486 static void copy_chroma(AVFrame *dst, const AVFrame *src, int width, int height)
487 {
488 int i, j;
489
490 for (j = 1; j < 3; j++) {
491 for (i = 0; i < height / 2; i++)
492 memcpy(dst->data[j] + i * dst->linesize[j],
493 src->data[j] + i * src->linesize[j], width / 2);
494 }
495 }
496
497 static void fade(uint8_t *dst, ptrdiff_t dst_linesize,
498 const uint8_t *src, ptrdiff_t src_linesize,
499 int width, int height,
500 int alpha, int beta)
501 {
502 int i, j;
503 for (j = 0; j < height; j++) {
504 const uint8_t *src2 = src + j * src_linesize;
505 uint8_t *dst2 = dst + j * dst_linesize;
506 for (i = 0; i < width; i++) {
507 uint8_t y = src2[i];
508 dst2[i] = av_clip_uint8(y + ((y * beta) >> 8) + alpha);
509 }
510 }
511 }
512
513 31 static int vp7_fade_frame(VP8Context *s, int alpha, int beta)
514 {
515 int ret;
516
517
4/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
31 if (!s->keyframe && (alpha || beta)) {
518 int width = s->mb_width * 16;
519 int height = s->mb_height * 16;
520 const AVFrame *src;
521 AVFrame *dst;
522
523 if (!s->framep[VP8_FRAME_PREVIOUS] ||
524 !s->framep[VP8_FRAME_GOLDEN]) {
525 av_log(s->avctx, AV_LOG_WARNING, "Discarding interframe without a prior keyframe!\n");
526 return AVERROR_INVALIDDATA;
527 }
528
529 src =
530 dst = s->framep[VP8_FRAME_PREVIOUS]->tf.f;
531
532 /* preserve the golden frame, write a new previous frame */
533 if (s->framep[VP8_FRAME_GOLDEN] == s->framep[VP8_FRAME_PREVIOUS]) {
534 s->framep[VP8_FRAME_PREVIOUS] = vp8_find_free_buffer(s);
535 if ((ret = vp8_alloc_frame(s, s->framep[VP8_FRAME_PREVIOUS], 1)) < 0)
536 return ret;
537
538 dst = s->framep[VP8_FRAME_PREVIOUS]->tf.f;
539
540 copy_chroma(dst, src, width, height);
541 }
542
543 fade(dst->data[0], dst->linesize[0],
544 src->data[0], src->linesize[0],
545 width, height, alpha, beta);
546 }
547
548 31 return 0;
549 }
550
551 31 static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
552 {
553 31 VPXRangeCoder *c = &s->c;
554 int part1_size, hscale, vscale, i, j, ret;
555 31 int width = s->avctx->width;
556 31 int height = s->avctx->height;
557 31 int alpha = 0;
558 31 int beta = 0;
559 31 int fade_present = 1;
560
561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (buf_size < 4) {
562 return AVERROR_INVALIDDATA;
563 }
564
565 31 s->profile = (buf[0] >> 1) & 7;
566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (s->profile > 1) {
567 avpriv_request_sample(s->avctx, "Unknown profile %d", s->profile);
568 return AVERROR_INVALIDDATA;
569 }
570
571 31 s->keyframe = !(buf[0] & 1);
572 31 s->invisible = 0;
573 31 part1_size = AV_RL24(buf) >> 4;
574
575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (buf_size < 4 - s->profile + part1_size) {
576 av_log(s->avctx, AV_LOG_ERROR, "Buffer size %d is too small, needed : %d\n", buf_size, 4 - s->profile + part1_size);
577 return AVERROR_INVALIDDATA;
578 }
579
580 31 buf += 4 - s->profile;
581 31 buf_size -= 4 - s->profile;
582
583 31 memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab));
584
585 31 ret = ff_vpx_init_range_decoder(c, buf, part1_size);
586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (ret < 0)
587 return ret;
588 31 buf += part1_size;
589 31 buf_size -= part1_size;
590
591 /* A. Dimension information (keyframes only) */
592
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 30 times.
31 if (s->keyframe) {
593 1 width = vp89_rac_get_uint(c, 12);
594 1 height = vp89_rac_get_uint(c, 12);
595 1 hscale = vp89_rac_get_uint(c, 2);
596 1 vscale = vp89_rac_get_uint(c, 2);
597
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if (hscale || vscale)
598 avpriv_request_sample(s->avctx, "Upscaling");
599
600 1 s->update_golden = s->update_altref = VP8_FRAME_CURRENT;
601 1 vp78_reset_probability_tables(s);
602 1 memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter,
603 sizeof(s->prob->pred16x16));
604 1 memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter,
605 sizeof(s->prob->pred8x8c));
606
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 for (i = 0; i < 2; i++)
607 2 memcpy(s->prob->mvc[i], vp7_mv_default_prob[i],
608 sizeof(vp7_mv_default_prob[i]));
609 1 memset(&s->segmentation, 0, sizeof(s->segmentation));
610 1 memset(&s->lf_delta, 0, sizeof(s->lf_delta));
611 1 memcpy(s->prob[0].scan, ff_zigzag_scan, sizeof(s->prob[0].scan));
612 }
613
614
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
31 if (s->keyframe || s->profile > 0)
615 1 memset(s->inter_dc_pred, 0 , sizeof(s->inter_dc_pred));
616
617 /* B. Decoding information for all four macroblock-level features */
618
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 31 times.
155 for (i = 0; i < 4; i++) {
619 124 s->feature_enabled[i] = vp89_rac_get(c);
620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if (s->feature_enabled[i]) {
621 s->feature_present_prob[i] = vp89_rac_get_uint(c, 8);
622
623 for (j = 0; j < 3; j++)
624 s->feature_index_prob[i][j] =
625 vp89_rac_get(c) ? vp89_rac_get_uint(c, 8) : 255;
626
627 if (vp7_feature_value_size[s->profile][i])
628 for (j = 0; j < 4; j++)
629 s->feature_value[i][j] =
630 vp89_rac_get(c) ? vp89_rac_get_uint(c, vp7_feature_value_size[s->profile][i]) : 0;
631 }
632 }
633
634 31 s->segmentation.enabled = 0;
635 31 s->segmentation.update_map = 0;
636 31 s->lf_delta.enabled = 0;
637
638 31 s->num_coeff_partitions = 1;
639 31 ret = ff_vpx_init_range_decoder(&s->coeff_partition[0], buf, buf_size);
640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (ret < 0)
641 return ret;
642
643
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1 times.
31 if (!s->macroblocks_base || /* first frame */
644
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 width != s->avctx->width || height != s->avctx->height ||
645
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
30 (width + 15) / 16 != s->mb_width || (height + 15) / 16 != s->mb_height) {
646
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
1 if ((ret = vp7_update_dimensions(s, width, height)) < 0)
647 return ret;
648 }
649
650 /* C. Dequantization indices */
651 31 vp7_get_quants(s);
652
653 /* D. Golden frame update flag (a Flag) for interframes only */
654
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1 times.
31 if (!s->keyframe) {
655
2/2
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 27 times.
30 s->update_golden = vp89_rac_get(c) ? VP8_FRAME_CURRENT : VP8_FRAME_NONE;
656 30 s->sign_bias[VP8_FRAME_GOLDEN] = 0;
657 }
658
659 31 s->update_last = 1;
660 31 s->update_probabilities = 1;
661
662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (s->profile > 0) {
663 s->update_probabilities = vp89_rac_get(c);
664 if (!s->update_probabilities)
665 s->prob[1] = s->prob[0];
666
667 if (!s->keyframe)
668 fade_present = vp89_rac_get(c);
669 }
670
671
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
31 if (vpx_rac_is_end(c))
672 return AVERROR_INVALIDDATA;
673 /* E. Fading information for previous frame */
674
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
31 if (fade_present && vp89_rac_get(c)) {
675 alpha = (int8_t) vp89_rac_get_uint(c, 8);
676 beta = (int8_t) vp89_rac_get_uint(c, 8);
677 }
678
679 /* F. Loop filter type */
680
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if (!s->profile)
681 31 s->filter.simple = vp89_rac_get(c);
682
683 /* G. DCT coefficient ordering specification */
684
2/2
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 18 times.
31 if (vp89_rac_get(c))
685
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 13 times.
208 for (i = 1; i < 16; i++)
686 195 s->prob[0].scan[i] = ff_zigzag_scan[vp89_rac_get_uint(c, 4)];
687
688 /* H. Loop filter levels */
689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (s->profile > 0)
690 s->filter.simple = vp89_rac_get(c);
691 31 s->filter.level = vp89_rac_get_uint(c, 6);
692 31 s->filter.sharpness = vp89_rac_get_uint(c, 3);
693
694 /* I. DCT coefficient probability update; 13.3 Token Probability Updates */
695 31 vp78_update_probability_tables(s);
696
697 31 s->mbskip_enabled = 0;
698
699 /* J. The remaining frame header data occurs ONLY FOR INTERFRAMES */
700
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1 times.
31 if (!s->keyframe) {
701 30 s->prob->intra = vp89_rac_get_uint(c, 8);
702 30 s->prob->last = vp89_rac_get_uint(c, 8);
703 30 vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE);
704 }
705
706
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
31 if (vpx_rac_is_end(c))
707 return AVERROR_INVALIDDATA;
708
709
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
31 if ((ret = vp7_fade_frame(s, alpha, beta)) < 0)
710 return ret;
711
712 31 return 0;
713 }
714
715 1119 static int vp8_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size)
716 {
717 1119 VPXRangeCoder *c = &s->c;
718 int header_size, hscale, vscale, ret;
719 1119 int width = s->avctx->width;
720 1119 int height = s->avctx->height;
721
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if (buf_size < 3) {
723 av_log(s->avctx, AV_LOG_ERROR, "Insufficent data (%d) for header\n", buf_size);
724 return AVERROR_INVALIDDATA;
725 }
726
727 1119 s->keyframe = !(buf[0] & 1);
728 1119 s->profile = (buf[0]>>1) & 7;
729 1119 s->invisible = !(buf[0] & 0x10);
730 1119 header_size = AV_RL24(buf) >> 5;
731 1119 buf += 3;
732 1119 buf_size -= 3;
733
734 1119 s->header_partition_size = header_size;
735
736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if (s->profile > 3)
737 av_log(s->avctx, AV_LOG_WARNING, "Unknown profile %d\n", s->profile);
738
739
2/2
✓ Branch 0 taken 963 times.
✓ Branch 1 taken 156 times.
1119 if (!s->profile)
740 963 memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab,
741 sizeof(s->put_pixels_tab));
742 else // profile 1-3 use bilinear, 4+ aren't defined so whatever
743 156 memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_bilinear_pixels_tab,
744 sizeof(s->put_pixels_tab));
745
746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if (header_size > buf_size - 7 * s->keyframe) {
747 av_log(s->avctx, AV_LOG_ERROR, "Header size larger than data provided\n");
748 return AVERROR_INVALIDDATA;
749 }
750
751
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1068 times.
1119 if (s->keyframe) {
752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if (AV_RL24(buf) != 0x2a019d) {
753 av_log(s->avctx, AV_LOG_ERROR,
754 "Invalid start code 0x%x\n", AV_RL24(buf));
755 return AVERROR_INVALIDDATA;
756 }
757 51 width = AV_RL16(buf + 3) & 0x3fff;
758 51 height = AV_RL16(buf + 5) & 0x3fff;
759 51 hscale = buf[4] >> 6;
760 51 vscale = buf[6] >> 6;
761 51 buf += 7;
762 51 buf_size -= 7;
763
764
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
51 if (hscale || vscale)
765 avpriv_request_sample(s->avctx, "Upscaling");
766
767 51 s->update_golden = s->update_altref = VP8_FRAME_CURRENT;
768 51 vp78_reset_probability_tables(s);
769 51 memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter,
770 sizeof(s->prob->pred16x16));
771 51 memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter,
772 sizeof(s->prob->pred8x8c));
773 51 memcpy(s->prob->mvc, vp8_mv_default_prob,
774 sizeof(s->prob->mvc));
775 51 memset(&s->segmentation, 0, sizeof(s->segmentation));
776 51 memset(&s->lf_delta, 0, sizeof(s->lf_delta));
777 }
778
779 1119 ret = ff_vpx_init_range_decoder(c, buf, header_size);
780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if (ret < 0)
781 return ret;
782 1119 buf += header_size;
783 1119 buf_size -= header_size;
784
785
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1068 times.
1119 if (s->keyframe) {
786 51 s->colorspace = vp89_rac_get(c);
787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if (s->colorspace)
788 av_log(s->avctx, AV_LOG_WARNING, "Unspecified colorspace\n");
789 51 s->fullrange = vp89_rac_get(c);
790 }
791
792
2/2
✓ Branch 1 taken 433 times.
✓ Branch 2 taken 686 times.
1119 if ((s->segmentation.enabled = vp89_rac_get(c)))
793 433 parse_segment_info(s);
794 else
795 686 s->segmentation.update_map = 0; // FIXME: move this to some init function?
796
797 1119 s->filter.simple = vp89_rac_get(c);
798 1119 s->filter.level = vp89_rac_get_uint(c, 6);
799 1119 s->filter.sharpness = vp89_rac_get_uint(c, 3);
800
801
2/2
✓ Branch 1 taken 1113 times.
✓ Branch 2 taken 6 times.
1119 if ((s->lf_delta.enabled = vp89_rac_get(c))) {
802 1113 s->lf_delta.update = vp89_rac_get(c);
803
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 1068 times.
1113 if (s->lf_delta.update)
804 45 update_lf_deltas(s);
805 }
806
807
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1119 times.
1119 if (setup_partitions(s, buf, buf_size)) {
808 av_log(s->avctx, AV_LOG_ERROR, "Invalid partitions\n");
809 return AVERROR_INVALIDDATA;
810 }
811
812
2/2
✓ Branch 0 taken 1092 times.
✓ Branch 1 taken 27 times.
1119 if (!s->macroblocks_base || /* first frame */
813
4/4
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1080 times.
✓ Branch 3 taken 6 times.
1092 width != s->avctx->width || height != s->avctx->height ||
814
2/4
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1080 times.
1080 (width+15)/16 != s->mb_width || (height+15)/16 != s->mb_height)
815
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
39 if ((ret = vp8_update_dimensions(s, width, height)) < 0)
816 return ret;
817
818 1119 vp8_get_quants(s);
819
820
2/2
✓ Branch 0 taken 1068 times.
✓ Branch 1 taken 51 times.
1119 if (!s->keyframe) {
821 1068 update_refs(s);
822 1068 s->sign_bias[VP8_FRAME_GOLDEN] = vp89_rac_get(c);
823 1068 s->sign_bias[VP8_FRAME_ALTREF] = vp89_rac_get(c);
824 }
825
826 // if we aren't saving this frame's probabilities for future frames,
827 // make a copy of the current probabilities
828
2/2
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 1055 times.
1119 if (!(s->update_probabilities = vp89_rac_get(c)))
829 64 s->prob[1] = s->prob[0];
830
831
4/4
✓ Branch 0 taken 1068 times.
✓ Branch 1 taken 51 times.
✓ Branch 3 taken 1057 times.
✓ Branch 4 taken 11 times.
1119 s->update_last = s->keyframe || vp89_rac_get(c);
832
833 1119 vp78_update_probability_tables(s);
834
835
2/2
✓ Branch 1 taken 1113 times.
✓ Branch 2 taken 6 times.
1119 if ((s->mbskip_enabled = vp89_rac_get(c)))
836 1113 s->prob->mbskip = vp89_rac_get_uint(c, 8);
837
838
2/2
✓ Branch 0 taken 1068 times.
✓ Branch 1 taken 51 times.
1119 if (!s->keyframe) {
839 1068 s->prob->intra = vp89_rac_get_uint(c, 8);
840 1068 s->prob->last = vp89_rac_get_uint(c, 8);
841 1068 s->prob->golden = vp89_rac_get_uint(c, 8);
842 1068 vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP8_MVC_SIZE);
843 }
844
845 // Record the entropy coder state here so that hwaccels can use it.
846 1119 s->c.code_word = vpx_rac_renorm(&s->c);
847 1119 s->coder_state_at_header_end.input = s->c.buffer - (-s->c.bits / 8);
848 1119 s->coder_state_at_header_end.range = s->c.high;
849 1119 s->coder_state_at_header_end.value = s->c.code_word >> 16;
850 1119 s->coder_state_at_header_end.bit_count = -s->c.bits % 8;
851
852 1119 return 0;
853 }
854
855 static av_always_inline
856 57182 void clamp_mv(const VP8mvbounds *s, VP8mv *dst, const VP8mv *src)
857 {
858 57182 dst->x = av_clip(src->x, av_clip(s->mv_min.x, INT16_MIN, INT16_MAX),
859 57182 av_clip(s->mv_max.x, INT16_MIN, INT16_MAX));
860 57182 dst->y = av_clip(src->y, av_clip(s->mv_min.y, INT16_MIN, INT16_MAX),
861 57182 av_clip(s->mv_max.y, INT16_MIN, INT16_MAX));
862 57182 }
863
864 /**
865 * Motion vector coding, 17.1.
866 */
867 84910 static av_always_inline int read_mv_component(VPXRangeCoder *c, const uint8_t *p, int vp7)
868 {
869 84910 int bit, x = 0;
870
871
2/2
✓ Branch 1 taken 19966 times.
✓ Branch 2 taken 64944 times.
84910 if (vpx_rac_get_prob_branchy(c, p[0])) {
872 int i;
873
874
2/2
✓ Branch 0 taken 59898 times.
✓ Branch 1 taken 19966 times.
79864 for (i = 0; i < 3; i++)
875 59898 x += vpx_rac_get_prob(c, p[9 + i]) << i;
876
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19966 times.
✓ Branch 2 taken 119796 times.
✓ Branch 3 taken 19966 times.
139762 for (i = (vp7 ? 7 : 9); i > 3; i--)
877 119796 x += vpx_rac_get_prob(c, p[9 + i]) << i;
878
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 19966 times.
✓ Branch 2 taken 12222 times.
✓ Branch 3 taken 7744 times.
✓ Branch 5 taken 5564 times.
✓ Branch 6 taken 6658 times.
19966 if (!(x & (vp7 ? 0xF0 : 0xFFF0)) || vpx_rac_get_prob(c, p[12]))
879 13308 x += 8;
880 } else {
881 // small_mvtree
882 64944 const uint8_t *ps = p + 2;
883 64944 bit = vpx_rac_get_prob(c, *ps);
884 64944 ps += 1 + 3 * bit;
885 64944 x += 4 * bit;
886 64944 bit = vpx_rac_get_prob(c, *ps);
887 64944 ps += 1 + bit;
888 64944 x += 2 * bit;
889 64944 x += vpx_rac_get_prob(c, *ps);
890 }
891
892
4/4
✓ Branch 0 taken 66588 times.
✓ Branch 1 taken 18322 times.
✓ Branch 3 taken 34958 times.
✓ Branch 4 taken 31630 times.
84910 return (x && vpx_rac_get_prob(c, p[1])) ? -x : x;
893 }
894
895 static int vp7_read_mv_component(VPXRangeCoder *c, const uint8_t *p)
896 {
897 return read_mv_component(c, p, 1);
898 }
899
900 28394 static int vp8_read_mv_component(VPXRangeCoder *c, const uint8_t *p)
901 {
902 28394 return read_mv_component(c, p, 0);
903 }
904
905 static av_always_inline
906 136610 const uint8_t *get_submv_prob(uint32_t left, uint32_t top, int is_vp7)
907 {
908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136610 times.
136610 if (is_vp7)
909 return vp7_submv_prob;
910
911
2/2
✓ Branch 0 taken 58719 times.
✓ Branch 1 taken 77891 times.
136610 if (left == top)
912
2/2
✓ Branch 0 taken 23422 times.
✓ Branch 1 taken 35297 times.
58719 return vp8_submv_prob[4 - !!left];
913
2/2
✓ Branch 0 taken 18934 times.
✓ Branch 1 taken 58957 times.
77891 if (!top)
914 18934 return vp8_submv_prob[2];
915 58957 return vp8_submv_prob[1 - !!left];
916 }
917
918 /**
919 * Split motion vector prediction, 16.4.
920 * @returns the number of motion vectors parsed (2, 4 or 16)
921 */
922 static av_always_inline
923 18330 int decode_splitmvs(const VP8Context *s, VPXRangeCoder *c, VP8Macroblock *mb,
924 int layout, int is_vp7)
925 {
926 int part_idx;
927 int n, num;
928 const VP8Macroblock *top_mb;
929 18330 const VP8Macroblock *left_mb = &mb[-1];
930 18330 const uint8_t *mbsplits_left = vp8_mbsplits[left_mb->partitioning];
931 const uint8_t *mbsplits_top, *mbsplits_cur, *firstidx;
932 const VP8mv *top_mv;
933 18330 const VP8mv *left_mv = left_mb->bmv;
934 18330 const VP8mv *cur_mv = mb->bmv;
935
936
1/2
✓ Branch 0 taken 18330 times.
✗ Branch 1 not taken.
18330 if (!layout) // layout is inlined, s->mb_layout is not
937 18330 top_mb = &mb[2];
938 else
939 top_mb = &mb[-s->mb_width - 1];
940 18330 mbsplits_top = vp8_mbsplits[top_mb->partitioning];
941 18330 top_mv = top_mb->bmv;
942
943
2/2
✓ Branch 1 taken 11715 times.
✓ Branch 2 taken 6615 times.
18330 if (vpx_rac_get_prob_branchy(c, vp8_mbsplit_prob[0])) {
944
2/2
✓ Branch 1 taken 8045 times.
✓ Branch 2 taken 3670 times.
11715 if (vpx_rac_get_prob_branchy(c, vp8_mbsplit_prob[1]))
945 8045 part_idx = VP8_SPLITMVMODE_16x8 + vpx_rac_get_prob(c, vp8_mbsplit_prob[2]);
946 else
947 3670 part_idx = VP8_SPLITMVMODE_8x8;
948 } else {
949 6615 part_idx = VP8_SPLITMVMODE_4x4;
950 }
951
952 18330 num = vp8_mbsplit_count[part_idx];
953 18330 mbsplits_cur = vp8_mbsplits[part_idx],
954 18330 firstidx = vp8_mbfirstidx[part_idx];
955 18330 mb->partitioning = part_idx;
956
957
2/2
✓ Branch 0 taken 136610 times.
✓ Branch 1 taken 18330 times.
154940 for (n = 0; n < num; n++) {
958 136610 int k = firstidx[n];
959 uint32_t left, above;
960 const uint8_t *submv_prob;
961
962
2/2
✓ Branch 0 taken 46755 times.
✓ Branch 1 taken 89855 times.
136610 if (!(k & 3))
963 46755 left = AV_RN32A(&left_mv[mbsplits_left[k + 3]]);
964 else
965 89855 left = AV_RN32A(&cur_mv[mbsplits_cur[k - 1]]);
966
2/2
✓ Branch 0 taken 44980 times.
✓ Branch 1 taken 91630 times.
136610 if (k <= 3)
967 44980 above = AV_RN32A(&top_mv[mbsplits_top[k + 12]]);
968 else
969 91630 above = AV_RN32A(&cur_mv[mbsplits_cur[k - 4]]);
970
971 136610 submv_prob = get_submv_prob(left, above, is_vp7);
972
973
2/2
✓ Branch 1 taken 50617 times.
✓ Branch 2 taken 85993 times.
136610 if (vpx_rac_get_prob_branchy(c, submv_prob[0])) {
974
2/2
✓ Branch 1 taken 31746 times.
✓ Branch 2 taken 18871 times.
50617 if (vpx_rac_get_prob_branchy(c, submv_prob[1])) {
975
2/2
✓ Branch 1 taken 28258 times.
✓ Branch 2 taken 3488 times.
31746 if (vpx_rac_get_prob_branchy(c, submv_prob[2])) {
976 56516 mb->bmv[n].y = mb->mv.y +
977 28258 read_mv_component(c, s->prob->mvc[0], is_vp7);
978 28258 mb->bmv[n].x = mb->mv.x +
979 28258 read_mv_component(c, s->prob->mvc[1], is_vp7);
980 } else {
981 3488 AV_ZERO32(&mb->bmv[n]);
982 }
983 } else {
984 18871 AV_WN32A(&mb->bmv[n], above);
985 }
986 } else {
987 85993 AV_WN32A(&mb->bmv[n], left);
988 }
989 }
990
991 18330 return num;
992 }
993
994 /**
995 * The vp7 reference decoder uses a padding macroblock column (added to right
996 * edge of the frame) to guard against illegal macroblock offsets. The
997 * algorithm has bugs that permit offsets to straddle the padding column.
998 * This function replicates those bugs.
999 *
1000 * @param[out] edge_x macroblock x address
1001 * @param[out] edge_y macroblock y address
1002 *
1003 * @return macroblock offset legal (boolean)
1004 */
1005 79200 static int vp7_calculate_mb_offset(int mb_x, int mb_y, int mb_width,
1006 int xoffset, int yoffset, int boundary,
1007 int *edge_x, int *edge_y)
1008 {
1009 79200 int vwidth = mb_width + 1;
1010 79200 int new = (mb_y + yoffset) * vwidth + mb_x + xoffset;
1011
4/4
✓ Branch 0 taken 69690 times.
✓ Branch 1 taken 9510 times.
✓ Branch 2 taken 2760 times.
✓ Branch 3 taken 66930 times.
79200 if (new < boundary || new % vwidth == vwidth - 1)
1012 12270 return 0;
1013 66930 *edge_y = new / vwidth;
1014 66930 *edge_x = new % vwidth;
1015 66930 return 1;
1016 }
1017
1018 66930 static const VP8mv *get_bmv_ptr(const VP8Macroblock *mb, int subblock)
1019 {
1020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66930 times.
66930 return &mb->bmv[mb->mode == VP8_MVMODE_SPLIT ? vp8_mbsplits[mb->partitioning][subblock] : 0];
1021 }
1022
1023 static av_always_inline
1024 6600 void vp7_decode_mvs(VP8Context *s, VP8Macroblock *mb,
1025 int mb_x, int mb_y, int layout)
1026 {
1027 enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR };
1028 enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
1029 6600 int idx = CNT_ZERO;
1030 VP8mv near_mv[3];
1031 6600 uint8_t cnt[3] = { 0 };
1032 6600 VPXRangeCoder *c = &s->c;
1033 int i;
1034
1035 6600 AV_ZERO32(&near_mv[0]);
1036 6600 AV_ZERO32(&near_mv[1]);
1037 6600 AV_ZERO32(&near_mv[2]);
1038
1039
2/2
✓ Branch 0 taken 79200 times.
✓ Branch 1 taken 6600 times.
85800 for (i = 0; i < VP7_MV_PRED_COUNT; i++) {
1040 79200 const VP7MVPred * pred = &vp7_mv_pred[i];
1041 int edge_x, edge_y;
1042
1043
2/2
✓ Branch 0 taken 66930 times.
✓ Branch 1 taken 12270 times.
79200 if (vp7_calculate_mb_offset(mb_x, mb_y, s->mb_width, pred->xoffset,
1044 79200 pred->yoffset, !s->profile, &edge_x, &edge_y)) {
1045
1/2
✓ Branch 0 taken 66930 times.
✗ Branch 1 not taken.
66930 const VP8Macroblock *edge = (s->mb_layout == 1)
1046 66930 ? s->macroblocks_base + 1 + edge_x +
1047 66930 (s->mb_width + 1) * (edge_y + 1)
1048 : s->macroblocks + edge_x +
1049 (s->mb_height - edge_y - 1) * 2;
1050 66930 uint32_t mv = AV_RN32A(get_bmv_ptr(edge, vp7_mv_pred[i].subblock));
1051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66930 times.
66930 if (mv) {
1052 if (AV_RN32A(&near_mv[CNT_NEAREST])) {
1053 if (mv == AV_RN32A(&near_mv[CNT_NEAREST])) {
1054 idx = CNT_NEAREST;
1055 } else if (AV_RN32A(&near_mv[CNT_NEAR])) {
1056 if (mv != AV_RN32A(&near_mv[CNT_NEAR]))
1057 continue;
1058 idx = CNT_NEAR;
1059 } else {
1060 AV_WN32A(&near_mv[CNT_NEAR], mv);
1061 idx = CNT_NEAR;
1062 }
1063 } else {
1064 AV_WN32A(&near_mv[CNT_NEAREST], mv);
1065 idx = CNT_NEAREST;
1066 }
1067 } else {
1068 66930 idx = CNT_ZERO;
1069 }
1070 } else {
1071 12270 idx = CNT_ZERO;
1072 }
1073 79200 cnt[idx] += vp7_mv_pred[i].score;
1074 }
1075
1076 6600 mb->partitioning = VP8_SPLITMVMODE_NONE;
1077
1078
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6600 times.
6600 if (vpx_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_ZERO]][0])) {
1079 mb->mode = VP8_MVMODE_MV;
1080
1081 if (vpx_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_NEAREST]][1])) {
1082
1083 if (vpx_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_NEAR]][2])) {
1084
1085 if (cnt[CNT_NEAREST] > cnt[CNT_NEAR])
1086 AV_WN32A(&mb->mv, cnt[CNT_ZERO] > cnt[CNT_NEAREST] ? 0 : AV_RN32A(&near_mv[CNT_NEAREST]));
1087 else
1088 AV_WN32A(&mb->mv, cnt[CNT_ZERO] > cnt[CNT_NEAR] ? 0 : AV_RN32A(&near_mv[CNT_NEAR]));
1089
1090 if (vpx_rac_get_prob_branchy(c, vp7_mode_contexts[cnt[CNT_NEAR]][3])) {
1091 mb->mode = VP8_MVMODE_SPLIT;
1092 mb->mv = mb->bmv[decode_splitmvs(s, c, mb, layout, IS_VP7) - 1];
1093 } else {
1094 mb->mv.y += vp7_read_mv_component(c, s->prob->mvc[0]);
1095 mb->mv.x += vp7_read_mv_component(c, s->prob->mvc[1]);
1096 mb->bmv[0] = mb->mv;
1097 }
1098 } else {
1099 mb->mv = near_mv[CNT_NEAR];
1100 mb->bmv[0] = mb->mv;
1101 }
1102 } else {
1103 mb->mv = near_mv[CNT_NEAREST];
1104 mb->bmv[0] = mb->mv;
1105 }
1106 } else {
1107 6600 mb->mode = VP8_MVMODE_ZERO;
1108 6600 AV_ZERO32(&mb->mv);
1109 6600 mb->bmv[0] = mb->mv;
1110 }
1111 6600 }
1112
1113 static av_always_inline
1114 379966 void vp8_decode_mvs(VP8Context *s, const VP8mvbounds *mv_bounds, VP8Macroblock *mb,
1115 int mb_x, int mb_y, int layout)
1116 {
1117 379966 VP8Macroblock *mb_edge[3] = { 0 /* top */,
1118 379966 mb - 1 /* left */,
1119 0 /* top-left */ };
1120 enum { CNT_ZERO, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV };
1121 enum { VP8_EDGE_TOP, VP8_EDGE_LEFT, VP8_EDGE_TOPLEFT };
1122 379966 int idx = CNT_ZERO;
1123 379966 int cur_sign_bias = s->sign_bias[mb->ref_frame];
1124 379966 const int8_t *sign_bias = s->sign_bias;
1125 VP8mv near_mv[4];
1126 379966 uint8_t cnt[4] = { 0 };
1127 379966 VPXRangeCoder *c = &s->c;
1128
1129
1/2
✓ Branch 0 taken 379966 times.
✗ Branch 1 not taken.
379966 if (!layout) { // layout is inlined (s->mb_layout is not)
1130 379966 mb_edge[0] = mb + 2;
1131 379966 mb_edge[2] = mb + 1;
1132 } else {
1133 mb_edge[0] = mb - s->mb_width - 1;
1134 mb_edge[2] = mb - s->mb_width - 2;
1135 }
1136
1137 379966 AV_ZERO32(&near_mv[0]);
1138 379966 AV_ZERO32(&near_mv[1]);
1139 379966 AV_ZERO32(&near_mv[2]);
1140
1141 /* Process MB on top, left and top-left */
1142 #define MV_EDGE_CHECK(n) \
1143 { \
1144 const VP8Macroblock *edge = mb_edge[n]; \
1145 int edge_ref = edge->ref_frame; \
1146 if (edge_ref != VP8_FRAME_CURRENT) { \
1147 uint32_t mv = AV_RN32A(&edge->mv); \
1148 if (mv) { \
1149 if (cur_sign_bias != sign_bias[edge_ref]) { \
1150 /* SWAR negate of the values in mv. */ \
1151 mv = ~mv; \
1152 mv = ((mv & 0x7fff7fff) + \
1153 0x00010001) ^ (mv & 0x80008000); \
1154 } \
1155 if (!n || mv != AV_RN32A(&near_mv[idx])) \
1156 AV_WN32A(&near_mv[++idx], mv); \
1157 cnt[idx] += 1 + (n != 2); \
1158 } else \
1159 cnt[CNT_ZERO] += 1 + (n != 2); \
1160 } \
1161 }
1162
1163
6/6
✓ Branch 0 taken 353088 times.
✓ Branch 1 taken 26878 times.
✓ Branch 2 taken 44594 times.
✓ Branch 3 taken 308494 times.
✓ Branch 4 taken 109 times.
✓ Branch 5 taken 44485 times.
379966 MV_EDGE_CHECK(0)
1164
8/8
✓ Branch 0 taken 361057 times.
✓ Branch 1 taken 18909 times.
✓ Branch 2 taken 44761 times.
✓ Branch 3 taken 316296 times.
✓ Branch 4 taken 87 times.
✓ Branch 5 taken 44674 times.
✓ Branch 6 taken 36130 times.
✓ Branch 7 taken 8631 times.
379966 MV_EDGE_CHECK(1)
1165
8/8
✓ Branch 0 taken 339875 times.
✓ Branch 1 taken 40091 times.
✓ Branch 2 taken 41903 times.
✓ Branch 3 taken 297972 times.
✓ Branch 4 taken 123 times.
✓ Branch 5 taken 41780 times.
✓ Branch 6 taken 24718 times.
✓ Branch 7 taken 17185 times.
379966 MV_EDGE_CHECK(2)
1166
1167 379966 mb->partitioning = VP8_SPLITMVMODE_NONE;
1168
2/2
✓ Branch 1 taken 57182 times.
✓ Branch 2 taken 322784 times.
379966 if (vpx_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_ZERO]][0])) {
1169 57182 mb->mode = VP8_MVMODE_MV;
1170
1171 /* If we have three distinct MVs, merge first and last if they're the same */
1172
2/2
✓ Branch 0 taken 12759 times.
✓ Branch 1 taken 44423 times.
57182 if (cnt[CNT_SPLITMV] &&
1173
2/2
✓ Branch 0 taken 5465 times.
✓ Branch 1 taken 7294 times.
12759 AV_RN32A(&near_mv[1 + VP8_EDGE_TOP]) == AV_RN32A(&near_mv[1 + VP8_EDGE_TOPLEFT]))
1174 5465 cnt[CNT_NEAREST] += 1;
1175
1176 /* Swap near and nearest if necessary */
1177
2/2
✓ Branch 0 taken 4482 times.
✓ Branch 1 taken 52700 times.
57182 if (cnt[CNT_NEAR] > cnt[CNT_NEAREST]) {
1178 4482 FFSWAP(uint8_t, cnt[CNT_NEAREST], cnt[CNT_NEAR]);
1179 4482 FFSWAP(VP8mv, near_mv[CNT_NEAREST], near_mv[CNT_NEAR]);
1180 }
1181
1182
2/2
✓ Branch 1 taken 37615 times.
✓ Branch 2 taken 19567 times.
57182 if (vpx_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAREST]][1])) {
1183
2/2
✓ Branch 1 taken 32527 times.
✓ Branch 2 taken 5088 times.
37615 if (vpx_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_NEAR]][2])) {
1184 /* Choose the best mv out of 0,0 and the nearest mv */
1185 32527 clamp_mv(mv_bounds, &mb->mv, &near_mv[CNT_ZERO + (cnt[CNT_NEAREST] >= cnt[CNT_ZERO])]);
1186 32527 cnt[CNT_SPLITMV] = ((mb_edge[VP8_EDGE_LEFT]->mode == VP8_MVMODE_SPLIT) +
1187 32527 (mb_edge[VP8_EDGE_TOP]->mode == VP8_MVMODE_SPLIT)) * 2 +
1188 32527 (mb_edge[VP8_EDGE_TOPLEFT]->mode == VP8_MVMODE_SPLIT);
1189
1190
2/2
✓ Branch 1 taken 18330 times.
✓ Branch 2 taken 14197 times.
32527 if (vpx_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[CNT_SPLITMV]][3])) {
1191 18330 mb->mode = VP8_MVMODE_SPLIT;
1192 18330 mb->mv = mb->bmv[decode_splitmvs(s, c, mb, layout, IS_VP8) - 1];
1193 } else {
1194 14197 mb->mv.y += vp8_read_mv_component(c, s->prob->mvc[0]);
1195 14197 mb->mv.x += vp8_read_mv_component(c, s->prob->mvc[1]);
1196 14197 mb->bmv[0] = mb->mv;
1197 }
1198 } else {
1199 5088 clamp_mv(mv_bounds, &mb->mv, &near_mv[CNT_NEAR]);
1200 5088 mb->bmv[0] = mb->mv;
1201 }
1202 } else {
1203 19567 clamp_mv(mv_bounds, &mb->mv, &near_mv[CNT_NEAREST]);
1204 19567 mb->bmv[0] = mb->mv;
1205 }
1206 } else {
1207 322784 mb->mode = VP8_MVMODE_ZERO;
1208 322784 AV_ZERO32(&mb->mv);
1209 322784 mb->bmv[0] = mb->mv;
1210 }
1211 379966 }
1212
1213 static av_always_inline
1214 17954 void decode_intra4x4_modes(VP8Context *s, VPXRangeCoder *c, VP8Macroblock *mb,
1215 int mb_x, int keyframe, int layout)
1216 {
1217 17954 uint8_t *intra4x4 = mb->intra4x4_pred_mode_mb;
1218
1219
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 17921 times.
17954 if (layout) {
1220 33 VP8Macroblock *mb_top = mb - s->mb_width - 1;
1221 33 memcpy(mb->intra4x4_pred_mode_top, mb_top->intra4x4_pred_mode_top, 4);
1222 }
1223
2/2
✓ Branch 0 taken 11054 times.
✓ Branch 1 taken 6900 times.
17954 if (keyframe) {
1224 int x, y;
1225 uint8_t *top;
1226 11054 uint8_t *const left = s->intra4x4_pred_mode_left;
1227
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 11021 times.
11054 if (layout)
1228 33 top = mb->intra4x4_pred_mode_top;
1229 else
1230 11021 top = s->intra4x4_pred_mode_top + 4 * mb_x;
1231
2/2
✓ Branch 0 taken 44216 times.
✓ Branch 1 taken 11054 times.
55270 for (y = 0; y < 4; y++) {
1232
2/2
✓ Branch 0 taken 176864 times.
✓ Branch 1 taken 44216 times.
221080 for (x = 0; x < 4; x++) {
1233 const uint8_t *ctx;
1234 176864 ctx = vp8_pred4x4_prob_intra[top[x]][left[y]];
1235 176864 *intra4x4 = vp89_rac_get_tree(c, vp8_pred4x4_tree, ctx);
1236 176864 left[y] = top[x] = *intra4x4;
1237 176864 intra4x4++;
1238 }
1239 }
1240 } else {
1241 int i;
1242
2/2
✓ Branch 0 taken 110400 times.
✓ Branch 1 taken 6900 times.
117300 for (i = 0; i < 16; i++)
1243 110400 intra4x4[i] = vp89_rac_get_tree(c, vp8_pred4x4_tree,
1244 vp8_pred4x4_prob_inter);
1245 }
1246 17954 }
1247
1248 static av_always_inline
1249 444689 void decode_mb_mode(VP8Context *s, const VP8mvbounds *mv_bounds,
1250 VP8Macroblock *mb, int mb_x, int mb_y,
1251 uint8_t *segment, const uint8_t *ref, int layout, int is_vp7)
1252 {
1253 444689 VPXRangeCoder *c = &s->c;
1254 static const char * const vp7_feature_name[] = { "q-index",
1255 "lf-delta",
1256 "partial-golden-update",
1257 "blit-pitch" };
1258
2/2
✓ Branch 0 taken 6820 times.
✓ Branch 1 taken 437869 times.
444689 if (is_vp7) {
1259 int i;
1260 6820 *segment = 0;
1261
2/2
✓ Branch 0 taken 27280 times.
✓ Branch 1 taken 6820 times.
34100 for (i = 0; i < 4; i++) {
1262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27280 times.
27280 if (s->feature_enabled[i]) {
1263 if (vpx_rac_get_prob_branchy(c, s->feature_present_prob[i])) {
1264 int index = vp89_rac_get_tree(c, vp7_feature_index_tree,
1265 s->feature_index_prob[i]);
1266 av_log(s->avctx, AV_LOG_WARNING,
1267 "Feature %s present in macroblock (value 0x%x)\n",
1268 vp7_feature_name[i], s->feature_value[i][index]);
1269 }
1270 }
1271 }
1272
2/2
✓ Branch 0 taken 8289 times.
✓ Branch 1 taken 429580 times.
437869 } else if (s->segmentation.update_map) {
1273 8289 int bit = vpx_rac_get_prob(c, s->prob->segmentid[0]);
1274 8289 *segment = vpx_rac_get_prob(c, s->prob->segmentid[1+bit]) + 2*bit;
1275
2/2
✓ Branch 0 taken 94425 times.
✓ Branch 1 taken 335155 times.
429580 } else if (s->segmentation.enabled)
1276
1/2
✓ Branch 0 taken 94425 times.
✗ Branch 1 not taken.
94425 *segment = ref ? *ref : *segment;
1277 444689 mb->segment = *segment;
1278
1279
2/2
✓ Branch 0 taken 437115 times.
✓ Branch 1 taken 7574 times.
444689 mb->skip = s->mbskip_enabled ? vpx_rac_get_prob(c, s->prob->mbskip) : 0;
1280
1281
2/2
✓ Branch 0 taken 33492 times.
✓ Branch 1 taken 411197 times.
444689 if (s->keyframe) {
1282 33492 mb->mode = vp89_rac_get_tree(c, vp8_pred16x16_tree_intra,
1283 vp8_pred16x16_prob_intra);
1284
1285
2/2
✓ Branch 0 taken 11054 times.
✓ Branch 1 taken 22438 times.
33492 if (mb->mode == MODE_I4x4) {
1286 11054 decode_intra4x4_modes(s, c, mb, mb_x, 1, layout);
1287 } else {
1288 22438 const uint32_t modes = (is_vp7 ? vp7_pred4x4_mode
1289
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 22251 times.
22438 : vp8_pred4x4_mode)[mb->mode] * 0x01010101u;
1290
2/2
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 22251 times.
22438 if (s->mb_layout)
1291 187 AV_WN32A(mb->intra4x4_pred_mode_top, modes);
1292 else
1293 22251 AV_WN32A(s->intra4x4_pred_mode_top + 4 * mb_x, modes);
1294 22438 AV_WN32A(s->intra4x4_pred_mode_left, modes);
1295 }
1296
1297 33492 mb->chroma_pred_mode = vp89_rac_get_tree(c, vp8_pred8x8c_tree,
1298 vp8_pred8x8c_prob_intra);
1299 33492 mb->ref_frame = VP8_FRAME_CURRENT;
1300
2/2
✓ Branch 1 taken 386566 times.
✓ Branch 2 taken 24631 times.
411197 } else if (vpx_rac_get_prob_branchy(c, s->prob->intra)) {
1301 // inter MB, 16.2
1302
2/2
✓ Branch 1 taken 17281 times.
✓ Branch 2 taken 369285 times.
386566 if (vpx_rac_get_prob_branchy(c, s->prob->last))
1303
2/2
✓ Branch 0 taken 17249 times.
✓ Branch 1 taken 32 times.
34530 mb->ref_frame =
1304
2/2
✓ Branch 1 taken 8904 times.
✓ Branch 2 taken 8345 times.
17249 (!is_vp7 && vpx_rac_get_prob(c, s->prob->golden)) ? VP8_FRAME_ALTREF
1305 : VP8_FRAME_GOLDEN;
1306 else
1307 369285 mb->ref_frame = VP8_FRAME_PREVIOUS;
1308 386566 s->ref_count[mb->ref_frame - 1]++;
1309
1310 // motion vectors, 16.3
1311
2/2
✓ Branch 0 taken 6600 times.
✓ Branch 1 taken 379966 times.
386566 if (is_vp7)
1312 6600 vp7_decode_mvs(s, mb, mb_x, mb_y, layout);
1313 else
1314 379966 vp8_decode_mvs(s, mv_bounds, mb, mb_x, mb_y, layout);
1315 } else {
1316 // intra MB, 16.1
1317 49262 mb->mode = vp89_rac_get_tree(c, vp8_pred16x16_tree_inter,
1318 24631 s->prob->pred16x16);
1319
1320
2/2
✓ Branch 0 taken 6900 times.
✓ Branch 1 taken 17731 times.
24631 if (mb->mode == MODE_I4x4)
1321 6900 decode_intra4x4_modes(s, c, mb, mb_x, 0, layout);
1322
1323 49262 mb->chroma_pred_mode = vp89_rac_get_tree(c, vp8_pred8x8c_tree,
1324 24631 s->prob->pred8x8c);
1325 24631 mb->ref_frame = VP8_FRAME_CURRENT;
1326 24631 mb->partitioning = VP8_SPLITMVMODE_NONE;
1327 24631 AV_ZERO32(&mb->bmv[0]);
1328 }
1329 444689 }
1330
1331 /**
1332 * @param r arithmetic bitstream reader context
1333 * @param block destination for block coefficients
1334 * @param probs probabilities to use when reading trees from the bitstream
1335 * @param i initial coeff index, 0 unless a separate DC block is coded
1336 * @param qmul array holding the dc/ac dequant factor at position 0/1
1337 *
1338 * @return 0 if no coeffs were decoded
1339 * otherwise, the index of the last coeff decoded plus one
1340 */
1341 static av_always_inline
1342 397173 int decode_block_coeffs_internal(VPXRangeCoder *r, int16_t block[16],
1343 uint8_t probs[16][3][NUM_DCT_TOKENS - 1],
1344 int i, const uint8_t *token_prob, const int16_t qmul[2],
1345 const uint8_t scan[16], int vp7)
1346 {
1347 397173 VPXRangeCoder c = *r;
1348 397173 goto skip_eob;
1349 do {
1350 int coeff;
1351 1124544 restart:
1352
2/2
✓ Branch 1 taken 376675 times.
✓ Branch 2 taken 749988 times.
1126663 if (!vpx_rac_get_prob_branchy(&c, token_prob[0])) // DCT_EOB
1353 376675 break;
1354
1355 1594371 skip_eob:
1356
2/2
✓ Branch 1 taken 846502 times.
✓ Branch 2 taken 1145042 times.
1991544 if (!vpx_rac_get_prob_branchy(&c, token_prob[1])) { // DCT_0
1357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 846502 times.
846502 if (++i == 16)
1358 break; // invalid input; blocks should end with EOB
1359 846502 token_prob = probs[i][0];
1360
2/2
✓ Branch 0 taken 2119 times.
✓ Branch 1 taken 844383 times.
846502 if (vp7)
1361 2119 goto restart;
1362 844383 goto skip_eob;
1363 }
1364
1365
2/2
✓ Branch 1 taken 726117 times.
✓ Branch 2 taken 418925 times.
1145042 if (!vpx_rac_get_prob_branchy(&c, token_prob[2])) { // DCT_1
1366 726117 coeff = 1;
1367 726117 token_prob = probs[i + 1][1];
1368 } else {
1369
2/2
✓ Branch 1 taken 279804 times.
✓ Branch 2 taken 139121 times.
418925 if (!vpx_rac_get_prob_branchy(&c, token_prob[3])) { // DCT 2,3,4
1370 279804 coeff = vpx_rac_get_prob_branchy(&c, token_prob[4]);
1371
2/2
✓ Branch 0 taken 116371 times.
✓ Branch 1 taken 163433 times.
279804 if (coeff)
1372 116371 coeff += vpx_rac_get_prob(&c, token_prob[5]);
1373 279804 coeff += 2;
1374 } else {
1375 // DCT_CAT*
1376
2/2
✓ Branch 1 taken 88195 times.
✓ Branch 2 taken 50926 times.
139121 if (!vpx_rac_get_prob_branchy(&c, token_prob[6])) {
1377
2/2
✓ Branch 1 taken 47284 times.
✓ Branch 2 taken 40911 times.
88195 if (!vpx_rac_get_prob_branchy(&c, token_prob[7])) { // DCT_CAT1
1378 47284 coeff = 5 + vpx_rac_get_prob(&c, vp8_dct_cat1_prob[0]);
1379 } else { // DCT_CAT2
1380 40911 coeff = 7;
1381 40911 coeff += vpx_rac_get_prob(&c, vp8_dct_cat2_prob[0]) << 1;
1382 40911 coeff += vpx_rac_get_prob(&c, vp8_dct_cat2_prob[1]);
1383 }
1384 } else { // DCT_CAT3 and up
1385 50926 int a = vpx_rac_get_prob(&c, token_prob[8]);
1386 50926 int b = vpx_rac_get_prob(&c, token_prob[9 + a]);
1387 50926 int cat = (a << 1) + b;
1388 50926 coeff = 3 + (8 << cat);
1389 50926 coeff += vp8_rac_get_coeff(&c, ff_vp8_dct_cat_prob[cat]);
1390 }
1391 }
1392 418925 token_prob = probs[i + 1][2];
1393 }
1394
4/4
✓ Branch 1 taken 576420 times.
✓ Branch 2 taken 568622 times.
✓ Branch 3 taken 843305 times.
✓ Branch 4 taken 301737 times.
1145042 block[scan[i]] = (vp89_rac_get(&c) ? -coeff : coeff) * qmul[!!i];
1395
2/2
✓ Branch 0 taken 1124544 times.
✓ Branch 1 taken 20498 times.
1145042 } while (++i < 16);
1396
1397 397173 *r = c;
1398 397173 return i;
1399 }
1400
1401 static av_always_inline
1402 6600 int inter_predict_dc(int16_t block[16], int16_t pred[2])
1403 {
1404 6600 int16_t dc = block[0];
1405 6600 int ret = 0;
1406
1407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6600 times.
6600 if (pred[1] > 3) {
1408 dc += pred[0];
1409 ret = 1;
1410 }
1411
1412
1/2
✓ Branch 0 taken 6600 times.
✗ Branch 1 not taken.
6600 if (!pred[0] | !dc | ((int32_t)pred[0] ^ (int32_t)dc) >> 31) {
1413 6600 block[0] = pred[0] = dc;
1414 6600 pred[1] = 0;
1415 } else {
1416 if (pred[0] == dc)
1417 pred[1]++;
1418 block[0] = pred[0] = dc;
1419 }
1420
1421 6600 return ret;
1422 }
1423
1424 735 static int vp7_decode_block_coeffs_internal(VPXRangeCoder *r,
1425 int16_t block[16],
1426 uint8_t probs[16][3][NUM_DCT_TOKENS - 1],
1427 int i, const uint8_t *token_prob,
1428 const int16_t qmul[2],
1429 const uint8_t scan[16])
1430 {
1431 735 return decode_block_coeffs_internal(r, block, probs, i,
1432 token_prob, qmul, scan, IS_VP7);
1433 }
1434
1435 #ifndef vp8_decode_block_coeffs_internal
1436 396438 static int vp8_decode_block_coeffs_internal(VPXRangeCoder *r,
1437 int16_t block[16],
1438 uint8_t probs[16][3][NUM_DCT_TOKENS - 1],
1439 int i, const uint8_t *token_prob,
1440 const int16_t qmul[2])
1441 {
1442 396438 return decode_block_coeffs_internal(r, block, probs, i,
1443 token_prob, qmul, ff_zigzag_scan, IS_VP8);
1444 }
1445 #endif
1446
1447 /**
1448 * @param c arithmetic bitstream reader context
1449 * @param block destination for block coefficients
1450 * @param probs probabilities to use when reading trees from the bitstream
1451 * @param i initial coeff index, 0 unless a separate DC block is coded
1452 * @param zero_nhood the initial prediction context for number of surrounding
1453 * all-zero blocks (only left/top, so 0-2)
1454 * @param qmul array holding the dc/ac dequant factor at position 0/1
1455 * @param scan scan pattern (VP7 only)
1456 *
1457 * @return 0 if no coeffs were decoded
1458 * otherwise, the index of the last coeff decoded plus one
1459 */
1460 static av_always_inline
1461 2078837 int decode_block_coeffs(VPXRangeCoder *c, int16_t block[16],
1462 uint8_t probs[16][3][NUM_DCT_TOKENS - 1],
1463 int i, int zero_nhood, const int16_t qmul[2],
1464 const uint8_t scan[16], int vp7)
1465 {
1466 2078837 const uint8_t *token_prob = probs[i][zero_nhood];
1467
2/2
✓ Branch 1 taken 1681664 times.
✓ Branch 2 taken 397173 times.
2078837 if (!vpx_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB
1468 1681664 return 0;
1469 735 return vp7 ? vp7_decode_block_coeffs_internal(c, block, probs, i,
1470 token_prob, qmul, scan)
1471
2/2
✓ Branch 0 taken 735 times.
✓ Branch 1 taken 396438 times.
397908 : vp8_decode_block_coeffs_internal(c, block, probs, i,
1472 token_prob, qmul);
1473 }
1474
1475 static av_always_inline
1476 84455 void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VPXRangeCoder *c,
1477 VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9],
1478 int is_vp7)
1479 {
1480 84455 int i, x, y, luma_start = 0, luma_ctx = 3;
1481 84455 int nnz_pred, nnz, nnz_total = 0;
1482 84455 int segment = mb->segment;
1483 84455 int block_dc = 0;
1484
1485
6/6
✓ Branch 0 taken 66980 times.
✓ Branch 1 taken 17475 times.
✓ Branch 2 taken 60193 times.
✓ Branch 3 taken 6787 times.
✓ Branch 4 taken 45130 times.
✓ Branch 5 taken 15063 times.
84455 if (mb->mode != MODE_I4x4 && (is_vp7 || mb->mode != VP8_MVMODE_SPLIT)) {
1486 51917 nnz_pred = t_nnz[8] + l_nnz[8];
1487
1488 // decode DC values and do hadamard
1489 51917 nnz = decode_block_coeffs(c, td->block_dc, s->prob->token[1], 0,
1490 51917 nnz_pred, s->qmat[segment].luma_dc_qmul,
1491 ff_zigzag_scan, is_vp7);
1492 51917 l_nnz[8] = t_nnz[8] = !!nnz;
1493
1494
4/4
✓ Branch 0 taken 6787 times.
✓ Branch 1 taken 45130 times.
✓ Branch 2 taken 6600 times.
✓ Branch 3 taken 187 times.
51917 if (is_vp7 && mb->mode > MODE_I4x4) {
1495 6600 nnz |= inter_predict_dc(td->block_dc,
1496 6600 s->inter_dc_pred[mb->ref_frame - 1]);
1497 }
1498
1499
2/2
✓ Branch 0 taken 35375 times.
✓ Branch 1 taken 16542 times.
51917 if (nnz) {
1500 35375 nnz_total += nnz;
1501 35375 block_dc = 1;
1502
2/2
✓ Branch 0 taken 10512 times.
✓ Branch 1 taken 24863 times.
35375 if (nnz == 1)
1503 10512 s->vp8dsp.vp8_luma_dc_wht_dc(td->block, td->block_dc);
1504 else
1505 24863 s->vp8dsp.vp8_luma_dc_wht(td->block, td->block_dc);
1506 }
1507 51917 luma_start = 1;
1508 51917 luma_ctx = 0;
1509 }
1510
1511 // luma blocks
1512
2/2
✓ Branch 0 taken 337820 times.
✓ Branch 1 taken 84455 times.
422275 for (y = 0; y < 4; y++)
1513
2/2
✓ Branch 0 taken 1351280 times.
✓ Branch 1 taken 337820 times.
1689100 for (x = 0; x < 4; x++) {
1514 1351280 nnz_pred = l_nnz[y] + t_nnz[x];
1515 1351280 nnz = decode_block_coeffs(c, td->block[y][x],
1516 1351280 s->prob->token[luma_ctx],
1517 luma_start, nnz_pred,
1518 1351280 s->qmat[segment].luma_qmul,
1519 1351280 s->prob[0].scan, is_vp7);
1520 /* nnz+block_dc may be one more than the actual last index,
1521 * but we don't care */
1522 1351280 td->non_zero_count_cache[y][x] = nnz + block_dc;
1523 1351280 t_nnz[x] = l_nnz[y] = !!nnz;
1524 1351280 nnz_total += nnz;
1525 }
1526
1527 // chroma blocks
1528 // TODO: what to do about dimensions? 2nd dim for luma is x,
1529 // but for chroma it's (y<<1)|x
1530
2/2
✓ Branch 0 taken 168910 times.
✓ Branch 1 taken 84455 times.
253365 for (i = 4; i < 6; i++)
1531
2/2
✓ Branch 0 taken 337820 times.
✓ Branch 1 taken 168910 times.
506730 for (y = 0; y < 2; y++)
1532
2/2
✓ Branch 0 taken 675640 times.
✓ Branch 1 taken 337820 times.
1013460 for (x = 0; x < 2; x++) {
1533 675640 nnz_pred = l_nnz[i + 2 * y] + t_nnz[i + 2 * x];
1534 675640 nnz = decode_block_coeffs(c, td->block[i][(y << 1) + x],
1535 675640 s->prob->token[2], 0, nnz_pred,
1536 675640 s->qmat[segment].chroma_qmul,
1537 675640 s->prob[0].scan, is_vp7);
1538 675640 td->non_zero_count_cache[i][(y << 1) + x] = nnz;
1539 675640 t_nnz[i + 2 * x] = l_nnz[i + 2 * y] = !!nnz;
1540 675640 nnz_total += nnz;
1541 }
1542
1543 // if there were no coded coeffs despite the macroblock not being marked skip,
1544 // we MUST not do the inner loop filter and should not do IDCT
1545 // Since skip isn't used for bitstream prediction, just manually set it.
1546
2/2
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 77779 times.
84455 if (!nnz_total)
1547 6676 mb->skip = 1;
1548 84455 }
1549
1550 static av_always_inline
1551 425089 void backup_mb_border(uint8_t *top_border, const uint8_t *src_y,
1552 const uint8_t *src_cb, const uint8_t *src_cr,
1553 ptrdiff_t linesize, ptrdiff_t uvlinesize, int simple)
1554 {
1555 425089 AV_COPY128(top_border, src_y + 15 * linesize);
1556
2/2
✓ Branch 0 taken 417367 times.
✓ Branch 1 taken 7722 times.
425089 if (!simple) {
1557 417367 AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
1558 417367 AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
1559 }
1560 425089 }
1561
1562 static av_always_inline
1563 84358 void xchg_mb_border(uint8_t *top_border, uint8_t *src_y, uint8_t *src_cb,
1564 uint8_t *src_cr, ptrdiff_t linesize, ptrdiff_t uvlinesize, int mb_x,
1565 int mb_y, int mb_width, int simple, int xchg)
1566 {
1567 84358 uint8_t *top_border_m1 = top_border - 32; // for TL prediction
1568 84358 src_y -= linesize;
1569 84358 src_cb -= uvlinesize;
1570 84358 src_cr -= uvlinesize;
1571
1572 #define XCHG(a, b, xchg) \
1573 do { \
1574 if (xchg) \
1575 AV_SWAP64(b, a); \
1576 else \
1577 AV_COPY64(b, a); \
1578 } while (0)
1579
1580
2/2
✓ Branch 0 taken 42179 times.
✓ Branch 1 taken 42179 times.
84358 XCHG(top_border_m1 + 8, src_y - 8, xchg);
1581
2/2
✓ Branch 0 taken 42179 times.
✓ Branch 1 taken 42179 times.
84358 XCHG(top_border, src_y, xchg);
1582 84358 XCHG(top_border + 8, src_y + 8, 1);
1583
2/2
✓ Branch 0 taken 80910 times.
✓ Branch 1 taken 3448 times.
84358 if (mb_x < mb_width - 1)
1584 80910 XCHG(top_border + 32, src_y + 16, 1);
1585
1586 // only copy chroma for normal loop filter
1587 // or to initialize the top row to 127
1588
3/4
✓ Branch 0 taken 3082 times.
✓ Branch 1 taken 81276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3082 times.
84358 if (!simple || !mb_y) {
1589
2/2
✓ Branch 0 taken 40638 times.
✓ Branch 1 taken 40638 times.
81276 XCHG(top_border_m1 + 16, src_cb - 8, xchg);
1590
2/2
✓ Branch 0 taken 40638 times.
✓ Branch 1 taken 40638 times.
81276 XCHG(top_border_m1 + 24, src_cr - 8, xchg);
1591 81276 XCHG(top_border + 16, src_cb, 1);
1592 81276 XCHG(top_border + 24, src_cr, 1);
1593 }
1594 84358 }
1595
1596 static av_always_inline
1597 73877 int check_dc_pred8x8_mode(int mode, int mb_x, int mb_y)
1598 {
1599
2/2
✓ Branch 0 taken 3118 times.
✓ Branch 1 taken 70759 times.
73877 if (!mb_x)
1600
2/2
✓ Branch 0 taken 2915 times.
✓ Branch 1 taken 203 times.
3118 return mb_y ? TOP_DC_PRED8x8 : DC_128_PRED8x8;
1601 else
1602
2/2
✓ Branch 0 taken 65359 times.
✓ Branch 1 taken 5400 times.
70759 return mb_y ? mode : LEFT_DC_PRED8x8;
1603 }
1604
1605 static av_always_inline
1606 1825 int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y, int vp7)
1607 {
1608
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1824 times.
1825 if (!mb_x)
1609
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 return mb_y ? VERT_PRED8x8 : (vp7 ? DC_128_PRED8x8 : DC_129_PRED8x8);
1610 else
1611
2/2
✓ Branch 0 taken 1822 times.
✓ Branch 1 taken 2 times.
1824 return mb_y ? mode : HOR_PRED8x8;
1612 }
1613
1614 static av_always_inline
1615 98292 int check_intra_pred8x8_mode_emuedge(int mode, int mb_x, int mb_y, int vp7)
1616 {
1617
4/5
✓ Branch 0 taken 73877 times.
✓ Branch 1 taken 5810 times.
✓ Branch 2 taken 16780 times.
✓ Branch 3 taken 1825 times.
✗ Branch 4 not taken.
98292 switch (mode) {
1618 73877 case DC_PRED8x8:
1619 73877 return check_dc_pred8x8_mode(mode, mb_x, mb_y);
1620 5810 case VERT_PRED8x8:
1621
3/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 5743 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
5810 return !mb_y ? (vp7 ? DC_128_PRED8x8 : DC_127_PRED8x8) : mode;
1622 16780 case HOR_PRED8x8:
1623
3/4
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 16638 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 142 times.
16780 return !mb_x ? (vp7 ? DC_128_PRED8x8 : DC_129_PRED8x8) : mode;
1624 1825 case PLANE_PRED8x8: /* TM */
1625 1825 return check_tm_pred8x8_mode(mode, mb_x, mb_y, vp7);
1626 }
1627 return mode;
1628 }
1629
1630 static av_always_inline
1631 50891 int check_tm_pred4x4_mode(int mode, int mb_x, int mb_y, int vp7)
1632 {
1633
2/2
✓ Branch 0 taken 1362 times.
✓ Branch 1 taken 49529 times.
50891 if (!mb_x) {
1634
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1361 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1362 return mb_y ? VERT_VP8_PRED : (vp7 ? DC_128_PRED : DC_129_PRED);
1635 } else {
1636
2/2
✓ Branch 0 taken 48120 times.
✓ Branch 1 taken 1409 times.
49529 return mb_y ? mode : HOR_VP8_PRED;
1637 }
1638 }
1639
1640 static av_always_inline
1641 287264 int check_intra_pred4x4_mode_emuedge(int mode, int mb_x, int mb_y,
1642 int *copy_buf, int vp7)
1643 {
1644
6/7
✓ Branch 0 taken 13784 times.
✓ Branch 1 taken 21690 times.
✓ Branch 2 taken 19725 times.
✓ Branch 3 taken 12416 times.
✓ Branch 4 taken 50891 times.
✓ Branch 5 taken 168758 times.
✗ Branch 6 not taken.
287264 switch (mode) {
1645 13784 case VERT_PRED:
1646
3/4
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 13689 times.
✓ Branch 2 taken 95 times.
✗ Branch 3 not taken.
13784 if (!mb_x && mb_y) {
1647 95 *copy_buf = 1;
1648 95 return mode;
1649 }
1650 /* fall-through */
1651 case DIAG_DOWN_LEFT_PRED:
1652 case VERT_LEFT_PRED:
1653
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 35355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
35379 return !mb_y ? (vp7 ? DC_128_PRED : DC_127_PRED) : mode;
1654 19725 case HOR_PRED:
1655
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 19597 times.
19725 if (!mb_y) {
1656 128 *copy_buf = 1;
1657 128 return mode;
1658 }
1659 /* fall-through */
1660 case HOR_UP_PRED:
1661
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 31969 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
32013 return !mb_x ? (vp7 ? DC_128_PRED : DC_129_PRED) : mode;
1662 50891 case TM_VP8_PRED:
1663 50891 return check_tm_pred4x4_mode(mode, mb_x, mb_y, vp7);
1664 168758 case DC_PRED: /* 4x4 DC doesn't use the same "H.264-style" exceptions
1665 * as 16x16/8x8 DC */
1666 case DIAG_DOWN_RIGHT_PRED:
1667 case VERT_RIGHT_PRED:
1668 case HOR_DOWN_PRED:
1669
4/4
✓ Branch 0 taken 168184 times.
✓ Branch 1 taken 574 times.
✓ Branch 2 taken 566 times.
✓ Branch 3 taken 167618 times.
168758 if (!mb_y || !mb_x)
1670 1140 *copy_buf = 1;
1671 168758 return mode;
1672 }
1673 return mode;
1674 }
1675
1676 static av_always_inline
1677 58123 void intra_predict(VP8Context *s, VP8ThreadData *td, uint8_t *const dst[3],
1678 VP8Macroblock *mb, int mb_x, int mb_y, int is_vp7)
1679 {
1680 int x, y, mode, nnz;
1681 uint32_t tr;
1682
1683 /* for the first row, we need to run xchg_mb_border to init the top edge
1684 * to 127 otherwise, skip it if we aren't going to deblock */
1685
6/8
✓ Branch 0 taken 54692 times.
✓ Branch 1 taken 3431 times.
✓ Branch 2 taken 12513 times.
✓ Branch 3 taken 42179 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12513 times.
✓ Branch 6 taken 42179 times.
✗ Branch 7 not taken.
58123 if (mb_y && (s->deblock_filter || !mb_y) && td->thread_nr == 0)
1686 42179 xchg_mb_border(s->top_border[mb_x + 1], dst[0], dst[1], dst[2],
1687 42179 s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
1688 42179 s->filter.simple, 1);
1689
1690
2/2
✓ Branch 0 taken 40169 times.
✓ Branch 1 taken 17954 times.
58123 if (mb->mode < MODE_I4x4) {
1691 40169 mode = check_intra_pred8x8_mode_emuedge(mb->mode, mb_x, mb_y, is_vp7);
1692 40169 s->hpc.pred16x16[mode](dst[0], s->linesize);
1693 } else {
1694 17954 uint8_t *ptr = dst[0];
1695 17954 const uint8_t *intra4x4 = mb->intra4x4_pred_mode_mb;
1696
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 17921 times.
17954 const uint8_t lo = is_vp7 ? 128 : 127;
1697
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 17921 times.
17954 const uint8_t hi = is_vp7 ? 128 : 129;
1698 17954 const uint8_t tr_top[4] = { lo, lo, lo, lo };
1699
1700 // all blocks on the right edge of the macroblock use bottom edge
1701 // the top macroblock for their topright edge
1702 17954 const uint8_t *tr_right = ptr - s->linesize + 16;
1703
1704 // if we're on the right edge of the frame, said edge is extended
1705 // from the top macroblock
1706
4/4
✓ Branch 0 taken 17323 times.
✓ Branch 1 taken 631 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 16685 times.
17954 if (mb_y && mb_x == s->mb_width - 1) {
1707 638 tr = tr_right[-1] * 0x01010101u;
1708 638 tr_right = (uint8_t *) &tr;
1709 }
1710
1711
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 17474 times.
17954 if (mb->skip)
1712 480 AV_ZERO128(td->non_zero_count_cache);
1713
1714
2/2
✓ Branch 0 taken 71816 times.
✓ Branch 1 taken 17954 times.
89770 for (y = 0; y < 4; y++) {
1715 71816 const uint8_t *topright = ptr + 4 - s->linesize;
1716
2/2
✓ Branch 0 taken 287264 times.
✓ Branch 1 taken 71816 times.
359080 for (x = 0; x < 4; x++) {
1717 287264 int copy = 0;
1718 287264 ptrdiff_t linesize = s->linesize;
1719 287264 uint8_t *dst = ptr + 4 * x;
1720 287264 LOCAL_ALIGNED(4, uint8_t, copy_dst, [5 * 8]);
1721
1722
6/6
✓ Branch 0 taken 215448 times.
✓ Branch 1 taken 71816 times.
✓ Branch 2 taken 53862 times.
✓ Branch 3 taken 161586 times.
✓ Branch 4 taken 4417 times.
✓ Branch 5 taken 121261 times.
287264 if ((y == 0 || x == 3) && mb_y == 0) {
1723 4417 topright = tr_top;
1724
2/2
✓ Branch 0 taken 69292 times.
✓ Branch 1 taken 213555 times.
282847 } else if (x == 3)
1725 69292 topright = tr_right;
1726
1727 287264 mode = check_intra_pred4x4_mode_emuedge(intra4x4[x], mb_x + x,
1728 mb_y + y, &copy, is_vp7);
1729
2/2
✓ Branch 0 taken 1363 times.
✓ Branch 1 taken 285901 times.
287264 if (copy) {
1730 1363 dst = copy_dst + 12;
1731 1363 linesize = 8;
1732
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 661 times.
1363 if (!(mb_y + y)) {
1733 702 copy_dst[3] = lo;
1734 702 AV_WN32A(copy_dst + 4, lo * 0x01010101U);
1735 } else {
1736 661 AV_COPY32(copy_dst + 4, ptr + 4 * x - s->linesize);
1737
1/2
✓ Branch 0 taken 661 times.
✗ Branch 1 not taken.
661 if (!(mb_x + x)) {
1738 661 copy_dst[3] = hi;
1739 } else {
1740 copy_dst[3] = ptr[4 * x - s->linesize - 1];
1741 }
1742 }
1743
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 661 times.
1363 if (!(mb_x + x)) {
1744 702 copy_dst[11] =
1745 702 copy_dst[19] =
1746 702 copy_dst[27] =
1747 702 copy_dst[35] = hi;
1748 } else {
1749 661 copy_dst[11] = ptr[4 * x - 1];
1750 661 copy_dst[19] = ptr[4 * x + s->linesize - 1];
1751 661 copy_dst[27] = ptr[4 * x + s->linesize * 2 - 1];
1752 661 copy_dst[35] = ptr[4 * x + s->linesize * 3 - 1];
1753 }
1754 }
1755 287264 s->hpc.pred4x4[mode](dst, topright, linesize);
1756
2/2
✓ Branch 0 taken 1363 times.
✓ Branch 1 taken 285901 times.
287264 if (copy) {
1757 1363 AV_COPY32(ptr + 4 * x, copy_dst + 12);
1758 1363 AV_COPY32(ptr + 4 * x + s->linesize, copy_dst + 20);
1759 1363 AV_COPY32(ptr + 4 * x + s->linesize * 2, copy_dst + 28);
1760 1363 AV_COPY32(ptr + 4 * x + s->linesize * 3, copy_dst + 36);
1761 }
1762
1763 287264 nnz = td->non_zero_count_cache[y][x];
1764
2/2
✓ Branch 0 taken 124659 times.
✓ Branch 1 taken 162605 times.
287264 if (nnz) {
1765
2/2
✓ Branch 0 taken 35482 times.
✓ Branch 1 taken 89177 times.
124659 if (nnz == 1)
1766 35482 s->vp8dsp.vp8_idct_dc_add(ptr + 4 * x,
1767 35482 td->block[y][x], s->linesize);
1768 else
1769 89177 s->vp8dsp.vp8_idct_add(ptr + 4 * x,
1770 89177 td->block[y][x], s->linesize);
1771 }
1772 287264 topright += 4;
1773 }
1774
1775 71816 ptr += 4 * s->linesize;
1776 71816 intra4x4 += 4;
1777 }
1778 }
1779
1780 58123 mode = check_intra_pred8x8_mode_emuedge(mb->chroma_pred_mode,
1781 mb_x, mb_y, is_vp7);
1782 58123 s->hpc.pred8x8[mode](dst[1], s->uvlinesize);
1783 58123 s->hpc.pred8x8[mode](dst[2], s->uvlinesize);
1784
1785
6/8
✓ Branch 0 taken 54692 times.
✓ Branch 1 taken 3431 times.
✓ Branch 2 taken 12513 times.
✓ Branch 3 taken 42179 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12513 times.
✓ Branch 6 taken 42179 times.
✗ Branch 7 not taken.
58123 if (mb_y && (s->deblock_filter || !mb_y) && td->thread_nr == 0)
1786 42179 xchg_mb_border(s->top_border[mb_x + 1], dst[0], dst[1], dst[2],
1787 42179 s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
1788 42179 s->filter.simple, 0);
1789 58123 }
1790
1791 static const uint8_t subpel_idx[3][8] = {
1792 { 0, 1, 2, 1, 2, 1, 2, 1 }, // nr. of left extra pixels,
1793 // also function pointer index
1794 { 0, 3, 5, 3, 5, 3, 5, 3 }, // nr. of extra pixels required
1795 { 0, 2, 3, 2, 3, 2, 3, 2 }, // nr. of right extra pixels
1796 };
1797
1798 /**
1799 * luma MC function
1800 *
1801 * @param s VP8 decoding context
1802 * @param dst target buffer for block data at block position
1803 * @param ref reference picture buffer at origin (0, 0)
1804 * @param mv motion vector (relative to block position) to get pixel data from
1805 * @param x_off horizontal position of block from origin (0, 0)
1806 * @param y_off vertical position of block from origin (0, 0)
1807 * @param block_w width of block (16, 8 or 4)
1808 * @param block_h height of block (always same as block_w)
1809 * @param width width of src/dst plane data
1810 * @param height height of src/dst plane data
1811 * @param linesize size of a single line of plane data, including padding
1812 * @param mc_func motion compensation function pointers (bilinear or sixtap MC)
1813 */
1814 static av_always_inline
1815 504846 void vp8_mc_luma(VP8Context *s, VP8ThreadData *td, uint8_t *dst,
1816 const ProgressFrame *ref, const VP8mv *mv,
1817 int x_off, int y_off, int block_w, int block_h,
1818 int width, int height, ptrdiff_t linesize,
1819 vp8_mc_func mc_func[3][3])
1820 {
1821 504846 const uint8_t *src = ref->f->data[0];
1822
1823
2/2
✓ Branch 0 taken 124899 times.
✓ Branch 1 taken 379947 times.
504846 if (AV_RN32A(mv)) {
1824 124899 ptrdiff_t src_linesize = linesize;
1825
1826 124899 int mx = (mv->x * 2) & 7, mx_idx = subpel_idx[0][mx];
1827 124899 int my = (mv->y * 2) & 7, my_idx = subpel_idx[0][my];
1828
1829 124899 x_off += mv->x >> 2;
1830 124899 y_off += mv->y >> 2;
1831
1832 // edge emulation
1833 124899 ff_progress_frame_await(ref, (3 + y_off + block_h + subpel_idx[2][my]) >> 4);
1834 124899 src += y_off * linesize + x_off;
1835
6/6
✓ Branch 0 taken 123700 times.
✓ Branch 1 taken 1199 times.
✓ Branch 2 taken 120199 times.
✓ Branch 3 taken 3501 times.
✓ Branch 4 taken 118706 times.
✓ Branch 5 taken 1493 times.
124899 if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
1836
2/2
✓ Branch 0 taken 3043 times.
✓ Branch 1 taken 115663 times.
118706 y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
1837 9236 s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
1838 9236 src - my_idx * linesize - mx_idx,
1839 EDGE_EMU_LINESIZE, linesize,
1840 9236 block_w + subpel_idx[1][mx],
1841 9236 block_h + subpel_idx[1][my],
1842 x_off - mx_idx, y_off - my_idx,
1843 width, height);
1844 9236 src = td->edge_emu_buffer + mx_idx + EDGE_EMU_LINESIZE * my_idx;
1845 9236 src_linesize = EDGE_EMU_LINESIZE;
1846 }
1847 124899 mc_func[my_idx][mx_idx](dst, linesize, src, src_linesize, block_h, mx, my);
1848 } else {
1849 379947 ff_progress_frame_await(ref, (3 + y_off + block_h) >> 4);
1850 379947 mc_func[0][0](dst, linesize, src + y_off * linesize + x_off,
1851 linesize, block_h, 0, 0);
1852 }
1853 504846 }
1854
1855 /**
1856 * chroma MC function
1857 *
1858 * @param s VP8 decoding context
1859 * @param dst1 target buffer for block data at block position (U plane)
1860 * @param dst2 target buffer for block data at block position (V plane)
1861 * @param ref reference picture buffer at origin (0, 0)
1862 * @param mv motion vector (relative to block position) to get pixel data from
1863 * @param x_off horizontal position of block from origin (0, 0)
1864 * @param y_off vertical position of block from origin (0, 0)
1865 * @param block_w width of block (16, 8 or 4)
1866 * @param block_h height of block (always same as block_w)
1867 * @param width width of src/dst plane data
1868 * @param height height of src/dst plane data
1869 * @param linesize size of a single line of plane data, including padding
1870 * @param mc_func motion compensation function pointers (bilinear or sixtap MC)
1871 */
1872 static av_always_inline
1873 425466 void vp8_mc_chroma(VP8Context *s, VP8ThreadData *td, uint8_t *dst1,
1874 uint8_t *dst2, const ProgressFrame *ref, const VP8mv *mv,
1875 int x_off, int y_off, int block_w, int block_h,
1876 int width, int height, ptrdiff_t linesize,
1877 vp8_mc_func mc_func[3][3])
1878 {
1879 425466 const uint8_t *src1 = ref->f->data[1], *src2 = ref->f->data[2];
1880
1881
2/2
✓ Branch 0 taken 79190 times.
✓ Branch 1 taken 346276 times.
425466 if (AV_RN32A(mv)) {
1882 79190 int mx = mv->x & 7, mx_idx = subpel_idx[0][mx];
1883 79190 int my = mv->y & 7, my_idx = subpel_idx[0][my];
1884
1885 79190 x_off += mv->x >> 3;
1886 79190 y_off += mv->y >> 3;
1887
1888 // edge emulation
1889 79190 src1 += y_off * linesize + x_off;
1890 79190 src2 += y_off * linesize + x_off;
1891 79190 ff_progress_frame_await(ref, (3 + y_off + block_h + subpel_idx[2][my]) >> 3);
1892
6/6
✓ Branch 0 taken 77874 times.
✓ Branch 1 taken 1316 times.
✓ Branch 2 taken 74583 times.
✓ Branch 3 taken 3291 times.
✓ Branch 4 taken 73050 times.
✓ Branch 5 taken 1533 times.
79190 if (x_off < mx_idx || x_off >= width - block_w - subpel_idx[2][mx] ||
1893
2/2
✓ Branch 0 taken 3017 times.
✓ Branch 1 taken 70033 times.
73050 y_off < my_idx || y_off >= height - block_h - subpel_idx[2][my]) {
1894 9157 s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
1895 9157 src1 - my_idx * linesize - mx_idx,
1896 EDGE_EMU_LINESIZE, linesize,
1897 9157 block_w + subpel_idx[1][mx],
1898 9157 block_h + subpel_idx[1][my],
1899 x_off - mx_idx, y_off - my_idx, width, height);
1900 9157 src1 = td->edge_emu_buffer + mx_idx + EDGE_EMU_LINESIZE * my_idx;
1901 9157 mc_func[my_idx][mx_idx](dst1, linesize, src1, EDGE_EMU_LINESIZE, block_h, mx, my);
1902
1903 9157 s->vdsp.emulated_edge_mc(td->edge_emu_buffer,
1904 9157 src2 - my_idx * linesize - mx_idx,
1905 EDGE_EMU_LINESIZE, linesize,
1906 9157 block_w + subpel_idx[1][mx],
1907 9157 block_h + subpel_idx[1][my],
1908 x_off - mx_idx, y_off - my_idx, width, height);
1909 9157 src2 = td->edge_emu_buffer + mx_idx + EDGE_EMU_LINESIZE * my_idx;
1910 9157 mc_func[my_idx][mx_idx](dst2, linesize, src2, EDGE_EMU_LINESIZE, block_h, mx, my);
1911 } else {
1912 70033 mc_func[my_idx][mx_idx](dst1, linesize, src1, linesize, block_h, mx, my);
1913 70033 mc_func[my_idx][mx_idx](dst2, linesize, src2, linesize, block_h, mx, my);
1914 }
1915 } else {
1916 346276 ff_progress_frame_await(ref, (3 + y_off + block_h) >> 3);
1917 346276 mc_func[0][0](dst1, linesize, src1 + y_off * linesize + x_off, linesize, block_h, 0, 0);
1918 346276 mc_func[0][0](dst2, linesize, src2 + y_off * linesize + x_off, linesize, block_h, 0, 0);
1919 }
1920 425466 }
1921
1922 static av_always_inline
1923 399006 void vp8_mc_part(VP8Context *s, VP8ThreadData *td, uint8_t *const dst[3],
1924 const ProgressFrame *ref_frame, int x_off, int y_off,
1925 int bx_off, int by_off, int block_w, int block_h,
1926 int width, int height, const VP8mv *mv)
1927 {
1928 399006 VP8mv uvmv = *mv;
1929
1930 /* Y */
1931 399006 vp8_mc_luma(s, td, dst[0] + by_off * s->linesize + bx_off,
1932 ref_frame, mv, x_off + bx_off, y_off + by_off,
1933 block_w, block_h, width, height, s->linesize,
1934 399006 s->put_pixels_tab[block_w == 8]);
1935
1936 /* U/V */
1937
2/2
✓ Branch 0 taken 4775 times.
✓ Branch 1 taken 394231 times.
399006 if (s->profile == 3) {
1938 /* this block only applies VP8; it is safe to check
1939 * only the profile, as VP7 profile <= 1 */
1940 4775 uvmv.x &= ~7;
1941 4775 uvmv.y &= ~7;
1942 }
1943 399006 x_off >>= 1;
1944 399006 y_off >>= 1;
1945 399006 bx_off >>= 1;
1946 399006 by_off >>= 1;
1947 399006 width >>= 1;
1948 399006 height >>= 1;
1949 399006 block_w >>= 1;
1950 399006 block_h >>= 1;
1951 399006 vp8_mc_chroma(s, td, dst[1] + by_off * s->uvlinesize + bx_off,
1952 399006 dst[2] + by_off * s->uvlinesize + bx_off, ref_frame,
1953 &uvmv, x_off + bx_off, y_off + by_off,
1954 block_w, block_h, width, height, s->uvlinesize,
1955
2/2
✓ Branch 0 taken 20950 times.
✓ Branch 1 taken 378056 times.
399006 s->put_pixels_tab[1 + (block_w == 4)]);
1956 399006 }
1957
1958 /* Fetch pixels for estimated mv 4 macroblocks ahead.
1959 * Optimized for 64-byte cache lines. Inspired by ffh264 prefetch_motion. */
1960 static av_always_inline
1961 1334067 void prefetch_motion(const VP8Context *s, const VP8Macroblock *mb,
1962 int mb_x, int mb_y, int mb_xy, int ref)
1963 {
1964 /* Don't prefetch refs that haven't been used very often this frame. */
1965
2/2
✓ Branch 0 taken 479591 times.
✓ Branch 1 taken 854476 times.
1334067 if (s->ref_count[ref - 1] > (mb_xy >> 5)) {
1966 479591 int x_off = mb_x << 4, y_off = mb_y << 4;
1967 479591 int mx = (mb->mv.x >> 2) + x_off + 8;
1968 479591 int my = (mb->mv.y >> 2) + y_off;
1969 479591 uint8_t **src = s->framep[ref]->tf.f->data;
1970 479591 int off = mx + (my + (mb_x & 3) * 4) * s->linesize + 64;
1971 /* For threading, a ff_thread_await_progress here might be useful, but
1972 * it actually slows down the decoder. Since a bad prefetch doesn't
1973 * generate bad decoder output, we don't run it here. */
1974 479591 s->vdsp.prefetch(src[0] + off, s->linesize, 4);
1975 479591 off = (mx >> 1) + ((my >> 1) + (mb_x & 7)) * s->uvlinesize + 64;
1976 479591 s->vdsp.prefetch(src[1] + off, src[2] - src[1], 2);
1977 }
1978 1334067 }
1979
1980 /**
1981 * Apply motion vectors to prediction buffer, chapter 18.
1982 */
1983 static av_always_inline
1984 386566 void inter_predict(VP8Context *s, VP8ThreadData *td, uint8_t *const dst[3],
1985 VP8Macroblock *mb, int mb_x, int mb_y)
1986 {
1987 386566 int x_off = mb_x << 4, y_off = mb_y << 4;
1988 386566 int width = 16 * s->mb_width, height = 16 * s->mb_height;
19