2 * Copyright (c) 2015 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #include "./vpx_config.h"
12 #include "./vpx_dsp_rtcd.h"
14 #include "vpx_dsp/vpx_dsp_common.h"
15 #include "vpx_mem/vpx_mem.h"
17 #define DST(x, y) dst[(x) + (y) * stride]
18 #define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2)
19 #define AVG2(a, b) (((a) + (b) + 1) >> 1)
21 static INLINE
void d207_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
22 const uint8_t *above
, const uint8_t *left
) {
26 for (r
= 0; r
< bs
- 1; ++r
)
27 dst
[r
* stride
] = AVG2(left
[r
], left
[r
+ 1]);
28 dst
[(bs
- 1) * stride
] = left
[bs
- 1];
32 for (r
= 0; r
< bs
- 2; ++r
)
33 dst
[r
* stride
] = AVG3(left
[r
], left
[r
+ 1], left
[r
+ 2]);
34 dst
[(bs
- 2) * stride
] = AVG3(left
[bs
- 2], left
[bs
- 1], left
[bs
- 1]);
35 dst
[(bs
- 1) * stride
] = left
[bs
- 1];
39 for (c
= 0; c
< bs
- 2; ++c
)
40 dst
[(bs
- 1) * stride
+ c
] = left
[bs
- 1];
42 for (r
= bs
- 2; r
>= 0; --r
)
43 for (c
= 0; c
< bs
- 2; ++c
)
44 dst
[r
* stride
+ c
] = dst
[(r
+ 1) * stride
+ c
- 2];
47 static INLINE
void d207e_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
48 const uint8_t *above
, const uint8_t *left
) {
52 for (r
= 0; r
< bs
; ++r
) {
53 for (c
= 0; c
< bs
; ++c
) {
54 dst
[c
] = c
& 1 ? AVG3(left
[(c
>> 1) + r
], left
[(c
>> 1) + r
+ 1],
55 left
[(c
>> 1) + r
+ 2])
56 : AVG2(left
[(c
>> 1) + r
], left
[(c
>> 1) + r
+ 1]);
62 static INLINE
void d63_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
63 const uint8_t *above
, const uint8_t *left
) {
67 for (c
= 0; c
< bs
; ++c
) {
68 dst
[c
] = AVG2(above
[c
], above
[c
+ 1]);
69 dst
[stride
+ c
] = AVG3(above
[c
], above
[c
+ 1], above
[c
+ 2]);
71 for (r
= 2, size
= bs
- 2; r
< bs
; r
+= 2, --size
) {
72 memcpy(dst
+ (r
+ 0) * stride
, dst
+ (r
>> 1), size
);
73 memset(dst
+ (r
+ 0) * stride
+ size
, above
[bs
- 1], bs
- size
);
74 memcpy(dst
+ (r
+ 1) * stride
, dst
+ stride
+ (r
>> 1), size
);
75 memset(dst
+ (r
+ 1) * stride
+ size
, above
[bs
- 1], bs
- size
);
79 static INLINE
void d63e_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
80 const uint8_t *above
, const uint8_t *left
) {
83 for (r
= 0; r
< bs
; ++r
) {
84 for (c
= 0; c
< bs
; ++c
) {
85 dst
[c
] = r
& 1 ? AVG3(above
[(r
>> 1) + c
], above
[(r
>> 1) + c
+ 1],
86 above
[(r
>> 1) + c
+ 2])
87 : AVG2(above
[(r
>> 1) + c
], above
[(r
>> 1) + c
+ 1]);
93 static INLINE
void d45_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
94 const uint8_t *above
, const uint8_t *left
) {
95 const uint8_t above_right
= above
[bs
- 1];
96 const uint8_t *const dst_row0
= dst
;
100 for (x
= 0; x
< bs
- 1; ++x
) {
101 dst
[x
] = AVG3(above
[x
], above
[x
+ 1], above
[x
+ 2]);
103 dst
[bs
- 1] = above_right
;
105 for (x
= 1, size
= bs
- 2; x
< bs
; ++x
, --size
) {
106 memcpy(dst
, dst_row0
+ x
, size
);
107 memset(dst
+ size
, above_right
, x
+ 1);
112 static INLINE
void d45e_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
113 const uint8_t *above
, const uint8_t *left
) {
116 for (r
= 0; r
< bs
; ++r
) {
117 for (c
= 0; c
< bs
; ++c
) {
118 dst
[c
] = AVG3(above
[r
+ c
], above
[r
+ c
+ 1],
119 above
[r
+ c
+ 1 + (r
+ c
+ 2 < bs
* 2)]);
125 static INLINE
void d117_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
126 const uint8_t *above
, const uint8_t *left
) {
130 for (c
= 0; c
< bs
; c
++)
131 dst
[c
] = AVG2(above
[c
- 1], above
[c
]);
135 dst
[0] = AVG3(left
[0], above
[-1], above
[0]);
136 for (c
= 1; c
< bs
; c
++)
137 dst
[c
] = AVG3(above
[c
- 2], above
[c
- 1], above
[c
]);
140 // the rest of first col
141 dst
[0] = AVG3(above
[-1], left
[0], left
[1]);
142 for (r
= 3; r
< bs
; ++r
)
143 dst
[(r
- 2) * stride
] = AVG3(left
[r
- 3], left
[r
- 2], left
[r
- 1]);
145 // the rest of the block
146 for (r
= 2; r
< bs
; ++r
) {
147 for (c
= 1; c
< bs
; c
++)
148 dst
[c
] = dst
[-2 * stride
+ c
- 1];
153 static INLINE
void d135_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
154 const uint8_t *above
, const uint8_t *left
) {
156 dst
[0] = AVG3(left
[0], above
[-1], above
[0]);
157 for (c
= 1; c
< bs
; c
++)
158 dst
[c
] = AVG3(above
[c
- 2], above
[c
- 1], above
[c
]);
160 dst
[stride
] = AVG3(above
[-1], left
[0], left
[1]);
161 for (r
= 2; r
< bs
; ++r
)
162 dst
[r
* stride
] = AVG3(left
[r
- 2], left
[r
- 1], left
[r
]);
165 for (r
= 1; r
< bs
; ++r
) {
166 for (c
= 1; c
< bs
; c
++)
167 dst
[c
] = dst
[-stride
+ c
- 1];
172 static INLINE
void d153_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
173 const uint8_t *above
, const uint8_t *left
) {
175 dst
[0] = AVG2(above
[-1], left
[0]);
176 for (r
= 1; r
< bs
; r
++)
177 dst
[r
* stride
] = AVG2(left
[r
- 1], left
[r
]);
180 dst
[0] = AVG3(left
[0], above
[-1], above
[0]);
181 dst
[stride
] = AVG3(above
[-1], left
[0], left
[1]);
182 for (r
= 2; r
< bs
; r
++)
183 dst
[r
* stride
] = AVG3(left
[r
- 2], left
[r
- 1], left
[r
]);
186 for (c
= 0; c
< bs
- 2; c
++)
187 dst
[c
] = AVG3(above
[c
- 1], above
[c
], above
[c
+ 1]);
190 for (r
= 1; r
< bs
; ++r
) {
191 for (c
= 0; c
< bs
- 2; c
++)
192 dst
[c
] = dst
[-stride
+ c
- 2];
197 static INLINE
void v_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
198 const uint8_t *above
, const uint8_t *left
) {
202 for (r
= 0; r
< bs
; r
++) {
203 memcpy(dst
, above
, bs
);
208 static INLINE
void h_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
209 const uint8_t *above
, const uint8_t *left
) {
213 for (r
= 0; r
< bs
; r
++) {
214 memset(dst
, left
[r
], bs
);
219 static INLINE
void tm_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
220 const uint8_t *above
, const uint8_t *left
) {
222 int ytop_left
= above
[-1];
224 for (r
= 0; r
< bs
; r
++) {
225 for (c
= 0; c
< bs
; c
++)
226 dst
[c
] = clip_pixel(left
[r
] + above
[c
] - ytop_left
);
231 static INLINE
void dc_128_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
232 const uint8_t *above
, const uint8_t *left
) {
237 for (r
= 0; r
< bs
; r
++) {
238 memset(dst
, 128, bs
);
243 static INLINE
void dc_left_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
244 const uint8_t *above
,
245 const uint8_t *left
) {
246 int i
, r
, expected_dc
, sum
= 0;
249 for (i
= 0; i
< bs
; i
++)
251 expected_dc
= (sum
+ (bs
>> 1)) / bs
;
253 for (r
= 0; r
< bs
; r
++) {
254 memset(dst
, expected_dc
, bs
);
259 static INLINE
void dc_top_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
260 const uint8_t *above
, const uint8_t *left
) {
261 int i
, r
, expected_dc
, sum
= 0;
264 for (i
= 0; i
< bs
; i
++)
266 expected_dc
= (sum
+ (bs
>> 1)) / bs
;
268 for (r
= 0; r
< bs
; r
++) {
269 memset(dst
, expected_dc
, bs
);
274 static INLINE
void dc_predictor(uint8_t *dst
, ptrdiff_t stride
, int bs
,
275 const uint8_t *above
, const uint8_t *left
) {
276 int i
, r
, expected_dc
, sum
= 0;
277 const int count
= 2 * bs
;
279 for (i
= 0; i
< bs
; i
++) {
284 expected_dc
= (sum
+ (count
>> 1)) / count
;
286 for (r
= 0; r
< bs
; r
++) {
287 memset(dst
, expected_dc
, bs
);
292 void vpx_he_predictor_4x4_c(uint8_t *dst
, ptrdiff_t stride
,
293 const uint8_t *above
, const uint8_t *left
) {
294 const int H
= above
[-1];
295 const int I
= left
[0];
296 const int J
= left
[1];
297 const int K
= left
[2];
298 const int L
= left
[3];
300 memset(dst
+ stride
* 0, AVG3(H
, I
, J
), 4);
301 memset(dst
+ stride
* 1, AVG3(I
, J
, K
), 4);
302 memset(dst
+ stride
* 2, AVG3(J
, K
, L
), 4);
303 memset(dst
+ stride
* 3, AVG3(K
, L
, L
), 4);
306 void vpx_ve_predictor_4x4_c(uint8_t *dst
, ptrdiff_t stride
,
307 const uint8_t *above
, const uint8_t *left
) {
308 const int H
= above
[-1];
309 const int I
= above
[0];
310 const int J
= above
[1];
311 const int K
= above
[2];
312 const int L
= above
[3];
313 const int M
= above
[4];
315 dst
[0] = AVG3(H
, I
, J
);
316 dst
[1] = AVG3(I
, J
, K
);
317 dst
[2] = AVG3(J
, K
, L
);
318 dst
[3] = AVG3(K
, L
, M
);
319 memcpy(dst
+ stride
* 1, dst
, 4);
320 memcpy(dst
+ stride
* 2, dst
, 4);
321 memcpy(dst
+ stride
* 3, dst
, 4);
324 void vpx_d207_predictor_4x4_c(uint8_t *dst
, ptrdiff_t stride
,
325 const uint8_t *above
, const uint8_t *left
) {
326 const int I
= left
[0];
327 const int J
= left
[1];
328 const int K
= left
[2];
329 const int L
= left
[3];
331 DST(0, 0) = AVG2(I
, J
);
332 DST(2, 0) = DST(0, 1) = AVG2(J
, K
);
333 DST(2, 1) = DST(0, 2) = AVG2(K
, L
);
334 DST(1, 0) = AVG3(I
, J
, K
);
335 DST(3, 0) = DST(1, 1) = AVG3(J
, K
, L
);
336 DST(3, 1) = DST(1, 2) = AVG3(K
, L
, L
);
337 DST(3, 2) = DST(2, 2) =
338 DST(0, 3) = DST(1, 3) = DST(2, 3) = DST(3, 3) = L
;
341 void vpx_d63_predictor_4x4_c(uint8_t *dst
, ptrdiff_t stride
,
342 const uint8_t *above
, const uint8_t *left
) {
343 const int A
= above
[0];
344 const int B
= above
[1];
345 const int C
= above
[2];
346 const int D
= above
[3];
347 const int E
= above
[4];
348 const int F
= above
[5];
349 const int G
= above
[6];
351 DST(0, 0) = AVG2(A
, B
);
352 DST(1, 0) = DST(0, 2) = AVG2(B
, C
);
353 DST(2, 0) = DST(1, 2) = AVG2(C
, D
);
354 DST(3, 0) = DST(2, 2) = AVG2(D
, E
);
355 DST(3, 2) = AVG2(E
, F
); // differs from vp8
357 DST(0, 1) = AVG3(A
, B
, C
);
358 DST(1, 1) = DST(0, 3) = AVG3(B
, C
, D
);
359 DST(2, 1) = DST(1, 3) = AVG3(C
, D
, E
);
360 DST(3, 1) = DST(2, 3) = AVG3(D
, E
, F
);
361 DST(3, 3) = AVG3(E
, F
, G
); // differs from vp8
364 void vpx_d63f_predictor_4x4_c(uint8_t *dst
, ptrdiff_t stride
,
365 const uint8_t *above
, const uint8_t *left
) {
366 const int A
= above
[0];
367 const int B
= above
[1];
368 const int C
= above
[2];
369 const int D
= above
[3];
370 const int E
= above
[4];
371 const int F
= above
[5];
372 const int G
= above
[6];
373 const int H
= above
[7];
375 DST(0, 0) = AVG2(A
, B
);
376 DST(1, 0) = DST(0, 2) = AVG2(B
, C
);
377 DST(2, 0) = DST(1, 2) = AVG2(C
, D
);
378 DST(3, 0) = DST(2, 2) = AVG2(D
, E
);
379 DST(3, 2) = AVG3(E
, F
, G
);
381 DST(0, 1) = AVG3(A
, B
, C
);
382 DST(1, 1) = DST(0, 3) = AVG3(B
, C
, D
);
383 DST(2, 1) = DST(1, 3) = AVG3(C
, D
, E
);
384 DST(3, 1) = DST(2, 3) = AVG3(D
, E
, F
);
385 DST(3, 3) = AVG3(F
, G
, H
);
388 void vpx_d45_predictor_4x4_c(uint8_t *dst
, ptrdiff_t stride
,
389 const uint8_t *above
, const uint8_t *left
) {
390 const int A
= above
[0];
391 const int B
= above
[1];
392 const int C
= above
[2];
393 const int D
= above
[3];
394 const int E
= above
[4];
395 const int F
= above
[5];
396 const int G
= above
[6];
397 const int H
= above
[7];
400 DST(0, 0) = AVG3(A
, B
, C
);
401 DST(1, 0) = DST(0, 1) = AVG3(B
, C
, D
);
402 DST(2, 0) = DST(1, 1) = DST(0, 2) = AVG3(C
, D
, E
);
403 DST(3, 0) = DST(2, 1) = DST(1, 2) = DST(0, 3) = AVG3(D
, E
, F
);
404 DST(3, 1) = DST(2, 2) = DST(1, 3) = AVG3(E
, F
, G
);
405 DST(3, 2) = DST(2, 3) = AVG3(F
, G
, H
);
406 DST(3, 3) = H
; // differs from vp8
409 void vpx_d45e_predictor_4x4_c(uint8_t *dst
, ptrdiff_t stride
,
410 const uint8_t *above
, const uint8_t *left
) {
411 const int A
= above
[0];
412 const int B
= above
[1];
413 const int C
= above
[2];
414 const int D
= above
[3];
415 const int E
= above
[4];
416 const int F
= above
[5];
417 const int G
= above
[6];
418 const int H
= above
[7];
421 DST(0, 0) = AVG3(A
, B
, C
);
422 DST(1, 0) = DST(0, 1) = AVG3(B
, C
, D
);
423 DST(2, 0) = DST(1, 1) = DST(0, 2) = AVG3(C
, D
, E
);
424 DST(3, 0) = DST(2, 1) = DST(1, 2) = DST(0, 3) = AVG3(D
, E
, F
);
425 DST(3, 1) = DST(2, 2) = DST(1, 3) = AVG3(E
, F
, G
);
426 DST(3, 2) = DST(2, 3) = AVG3(F
, G
, H
);
427 DST(3, 3) = AVG3(G
, H
, H
);
430 void vpx_d117_predictor_4x4_c(uint8_t *dst
, ptrdiff_t stride
,
431 const uint8_t *above
, const uint8_t *left
) {
432 const int I
= left
[0];
433 const int J
= left
[1];
434 const int K
= left
[2];
435 const int X
= above
[-1];
436 const int A
= above
[0];
437 const int B
= above
[1];
438 const int C
= above
[2];
439 const int D
= above
[3];
440 DST(0, 0) = DST(1, 2) = AVG2(X
, A
);
441 DST(1, 0) = DST(2, 2) = AVG2(A
, B
);
442 DST(2, 0) = DST(3, 2) = AVG2(B
, C
);
443 DST(3, 0) = AVG2(C
, D
);
445 DST(0, 3) = AVG3(K
, J
, I
);
446 DST(0, 2) = AVG3(J
, I
, X
);
447 DST(0, 1) = DST(1, 3) = AVG3(I
, X
, A
);
448 DST(1, 1) = DST(2, 3) = AVG3(X
, A
, B
);
449 DST(2, 1) = DST(3, 3) = AVG3(A
, B
, C
);
450 DST(3, 1) = AVG3(B
, C
, D
);
453 void vpx_d135_predictor_4x4_c(uint8_t *dst
, ptrdiff_t stride
,
454 const uint8_t *above
, const uint8_t *left
) {
455 const int I
= left
[0];
456 const int J
= left
[1];
457 const int K
= left
[2];
458 const int L
= left
[3];
459 const int X
= above
[-1];
460 const int A
= above
[0];
461 const int B
= above
[1];
462 const int C
= above
[2];
463 const int D
= above
[3];
465 DST(0, 3) = AVG3(J
, K
, L
);
466 DST(1, 3) = DST(0, 2) = AVG3(I
, J
, K
);
467 DST(2, 3) = DST(1, 2) = DST(0, 1) = AVG3(X
, I
, J
);
468 DST(3, 3) = DST(2, 2) = DST(1, 1) = DST(0, 0) = AVG3(A
, X
, I
);
469 DST(3, 2) = DST(2, 1) = DST(1, 0) = AVG3(B
, A
, X
);
470 DST(3, 1) = DST(2, 0) = AVG3(C
, B
, A
);
471 DST(3, 0) = AVG3(D
, C
, B
);
474 void vpx_d153_predictor_4x4_c(uint8_t *dst
, ptrdiff_t stride
,
475 const uint8_t *above
, const uint8_t *left
) {
476 const int I
= left
[0];
477 const int J
= left
[1];
478 const int K
= left
[2];
479 const int L
= left
[3];
480 const int X
= above
[-1];
481 const int A
= above
[0];
482 const int B
= above
[1];
483 const int C
= above
[2];
485 DST(0, 0) = DST(2, 1) = AVG2(I
, X
);
486 DST(0, 1) = DST(2, 2) = AVG2(J
, I
);
487 DST(0, 2) = DST(2, 3) = AVG2(K
, J
);
488 DST(0, 3) = AVG2(L
, K
);
490 DST(3, 0) = AVG3(A
, B
, C
);
491 DST(2, 0) = AVG3(X
, A
, B
);
492 DST(1, 0) = DST(3, 1) = AVG3(I
, X
, A
);
493 DST(1, 1) = DST(3, 2) = AVG3(J
, I
, X
);
494 DST(1, 2) = DST(3, 3) = AVG3(K
, J
, I
);
495 DST(1, 3) = AVG3(L
, K
, J
);
498 #if CONFIG_VP9_HIGHBITDEPTH
499 static INLINE
void highbd_d207_predictor(uint16_t *dst
, ptrdiff_t stride
,
500 int bs
, const uint16_t *above
,
501 const uint16_t *left
, int bd
) {
507 for (r
= 0; r
< bs
- 1; ++r
) {
508 dst
[r
* stride
] = AVG2(left
[r
], left
[r
+ 1]);
510 dst
[(bs
- 1) * stride
] = left
[bs
- 1];
514 for (r
= 0; r
< bs
- 2; ++r
) {
515 dst
[r
* stride
] = AVG3(left
[r
], left
[r
+ 1], left
[r
+ 2]);
517 dst
[(bs
- 2) * stride
] = AVG3(left
[bs
- 2], left
[bs
- 1], left
[bs
- 1]);
518 dst
[(bs
- 1) * stride
] = left
[bs
- 1];
522 for (c
= 0; c
< bs
- 2; ++c
)
523 dst
[(bs
- 1) * stride
+ c
] = left
[bs
- 1];
525 for (r
= bs
- 2; r
>= 0; --r
) {
526 for (c
= 0; c
< bs
- 2; ++c
)
527 dst
[r
* stride
+ c
] = dst
[(r
+ 1) * stride
+ c
- 2];
531 static INLINE
void highbd_d207e_predictor(uint16_t *dst
, ptrdiff_t stride
,
532 int bs
, const uint16_t *above
,
533 const uint16_t *left
, int bd
) {
538 for (r
= 0; r
< bs
; ++r
) {
539 for (c
= 0; c
< bs
; ++c
) {
540 dst
[c
] = c
& 1 ? AVG3(left
[(c
>> 1) + r
], left
[(c
>> 1) + r
+ 1],
541 left
[(c
>> 1) + r
+ 2])
542 : AVG2(left
[(c
>> 1) + r
], left
[(c
>> 1) + r
+ 1]);
548 static INLINE
void highbd_d63_predictor(uint16_t *dst
, ptrdiff_t stride
,
549 int bs
, const uint16_t *above
,
550 const uint16_t *left
, int bd
) {
554 for (r
= 0; r
< bs
; ++r
) {
555 for (c
= 0; c
< bs
; ++c
) {
556 dst
[c
] = r
& 1 ? AVG3(above
[(r
>> 1) + c
], above
[(r
>> 1) + c
+ 1],
557 above
[(r
>> 1) + c
+ 2])
558 : AVG2(above
[(r
>> 1) + c
], above
[(r
>> 1) + c
+ 1]);
564 #define highbd_d63e_predictor highbd_d63_predictor
566 static INLINE
void highbd_d45_predictor(uint16_t *dst
, ptrdiff_t stride
, int bs
,
567 const uint16_t *above
,
568 const uint16_t *left
, int bd
) {
572 for (r
= 0; r
< bs
; ++r
) {
573 for (c
= 0; c
< bs
; ++c
) {
574 dst
[c
] = r
+ c
+ 2 < bs
* 2 ? AVG3(above
[r
+ c
], above
[r
+ c
+ 1],
582 static INLINE
void highbd_d45e_predictor(uint16_t *dst
, ptrdiff_t stride
,
583 int bs
, const uint16_t *above
,
584 const uint16_t *left
, int bd
) {
588 for (r
= 0; r
< bs
; ++r
) {
589 for (c
= 0; c
< bs
; ++c
) {
590 dst
[c
] = AVG3(above
[r
+ c
], above
[r
+ c
+ 1],
591 above
[r
+ c
+ 1 + (r
+ c
+ 2 < bs
* 2)]);
597 static INLINE
void highbd_d117_predictor(uint16_t *dst
, ptrdiff_t stride
,
598 int bs
, const uint16_t *above
,
599 const uint16_t *left
, int bd
) {
604 for (c
= 0; c
< bs
; c
++)
605 dst
[c
] = AVG2(above
[c
- 1], above
[c
]);
609 dst
[0] = AVG3(left
[0], above
[-1], above
[0]);
610 for (c
= 1; c
< bs
; c
++)
611 dst
[c
] = AVG3(above
[c
- 2], above
[c
- 1], above
[c
]);
614 // the rest of first col
615 dst
[0] = AVG3(above
[-1], left
[0], left
[1]);
616 for (r
= 3; r
< bs
; ++r
)
617 dst
[(r
- 2) * stride
] = AVG3(left
[r
- 3], left
[r
- 2], left
[r
- 1]);
619 // the rest of the block
620 for (r
= 2; r
< bs
; ++r
) {
621 for (c
= 1; c
< bs
; c
++)
622 dst
[c
] = dst
[-2 * stride
+ c
- 1];
627 static INLINE
void highbd_d135_predictor(uint16_t *dst
, ptrdiff_t stride
,
628 int bs
, const uint16_t *above
,
629 const uint16_t *left
, int bd
) {
632 dst
[0] = AVG3(left
[0], above
[-1], above
[0]);
633 for (c
= 1; c
< bs
; c
++)
634 dst
[c
] = AVG3(above
[c
- 2], above
[c
- 1], above
[c
]);
636 dst
[stride
] = AVG3(above
[-1], left
[0], left
[1]);
637 for (r
= 2; r
< bs
; ++r
)
638 dst
[r
* stride
] = AVG3(left
[r
- 2], left
[r
- 1], left
[r
]);
641 for (r
= 1; r
< bs
; ++r
) {
642 for (c
= 1; c
< bs
; c
++)
643 dst
[c
] = dst
[-stride
+ c
- 1];
648 static INLINE
void highbd_d153_predictor(uint16_t *dst
, ptrdiff_t stride
,
649 int bs
, const uint16_t *above
,
650 const uint16_t *left
, int bd
) {
653 dst
[0] = AVG2(above
[-1], left
[0]);
654 for (r
= 1; r
< bs
; r
++)
655 dst
[r
* stride
] = AVG2(left
[r
- 1], left
[r
]);
658 dst
[0] = AVG3(left
[0], above
[-1], above
[0]);
659 dst
[stride
] = AVG3(above
[-1], left
[0], left
[1]);
660 for (r
= 2; r
< bs
; r
++)
661 dst
[r
* stride
] = AVG3(left
[r
- 2], left
[r
- 1], left
[r
]);
664 for (c
= 0; c
< bs
- 2; c
++)
665 dst
[c
] = AVG3(above
[c
- 1], above
[c
], above
[c
+ 1]);
668 for (r
= 1; r
< bs
; ++r
) {
669 for (c
= 0; c
< bs
- 2; c
++)
670 dst
[c
] = dst
[-stride
+ c
- 2];
675 static INLINE
void highbd_v_predictor(uint16_t *dst
, ptrdiff_t stride
,
676 int bs
, const uint16_t *above
,
677 const uint16_t *left
, int bd
) {
681 for (r
= 0; r
< bs
; r
++) {
682 memcpy(dst
, above
, bs
* sizeof(uint16_t));
687 static INLINE
void highbd_h_predictor(uint16_t *dst
, ptrdiff_t stride
,
688 int bs
, const uint16_t *above
,
689 const uint16_t *left
, int bd
) {
693 for (r
= 0; r
< bs
; r
++) {
694 vpx_memset16(dst
, left
[r
], bs
);
699 static INLINE
void highbd_tm_predictor(uint16_t *dst
, ptrdiff_t stride
,
700 int bs
, const uint16_t *above
,
701 const uint16_t *left
, int bd
) {
703 int ytop_left
= above
[-1];
706 for (r
= 0; r
< bs
; r
++) {
707 for (c
= 0; c
< bs
; c
++)
708 dst
[c
] = clip_pixel_highbd(left
[r
] + above
[c
] - ytop_left
, bd
);
713 static INLINE
void highbd_dc_128_predictor(uint16_t *dst
, ptrdiff_t stride
,
714 int bs
, const uint16_t *above
,
715 const uint16_t *left
, int bd
) {
720 for (r
= 0; r
< bs
; r
++) {
721 vpx_memset16(dst
, 128 << (bd
- 8), bs
);
726 static INLINE
void highbd_dc_left_predictor(uint16_t *dst
, ptrdiff_t stride
,
727 int bs
, const uint16_t *above
,
728 const uint16_t *left
, int bd
) {
729 int i
, r
, expected_dc
, sum
= 0;
733 for (i
= 0; i
< bs
; i
++)
735 expected_dc
= (sum
+ (bs
>> 1)) / bs
;
737 for (r
= 0; r
< bs
; r
++) {
738 vpx_memset16(dst
, expected_dc
, bs
);
743 static INLINE
void highbd_dc_top_predictor(uint16_t *dst
, ptrdiff_t stride
,
744 int bs
, const uint16_t *above
,
745 const uint16_t *left
, int bd
) {
746 int i
, r
, expected_dc
, sum
= 0;
750 for (i
= 0; i
< bs
; i
++)
752 expected_dc
= (sum
+ (bs
>> 1)) / bs
;
754 for (r
= 0; r
< bs
; r
++) {
755 vpx_memset16(dst
, expected_dc
, bs
);
760 static INLINE
void highbd_dc_predictor(uint16_t *dst
, ptrdiff_t stride
,
761 int bs
, const uint16_t *above
,
762 const uint16_t *left
, int bd
) {
763 int i
, r
, expected_dc
, sum
= 0;
764 const int count
= 2 * bs
;
767 for (i
= 0; i
< bs
; i
++) {
772 expected_dc
= (sum
+ (count
>> 1)) / count
;
774 for (r
= 0; r
< bs
; r
++) {
775 vpx_memset16(dst
, expected_dc
, bs
);
779 #endif // CONFIG_VP9_HIGHBITDEPTH
781 // This serves as a wrapper function, so that all the prediction functions
782 // can be unified and accessed as a pointer array. Note that the boundary
783 // above and left are not necessarily used all the time.
784 #define intra_pred_sized(type, size) \
785 void vpx_##type##_predictor_##size##x##size##_c(uint8_t *dst, \
787 const uint8_t *above, \
788 const uint8_t *left) { \
789 type##_predictor(dst, stride, size, above, left); \
792 #if CONFIG_VP9_HIGHBITDEPTH
793 #define intra_pred_highbd_sized(type, size) \
794 void vpx_highbd_##type##_predictor_##size##x##size##_c( \
795 uint16_t *dst, ptrdiff_t stride, const uint16_t *above, \
796 const uint16_t *left, int bd) { \
797 highbd_##type##_predictor(dst, stride, size, above, left, bd); \
800 #define intra_pred_allsizes(type) \
801 intra_pred_sized(type, 4) \
802 intra_pred_sized(type, 8) \
803 intra_pred_sized(type, 16) \
804 intra_pred_sized(type, 32) \
805 intra_pred_highbd_sized(type, 4) \
806 intra_pred_highbd_sized(type, 8) \
807 intra_pred_highbd_sized(type, 16) \
808 intra_pred_highbd_sized(type, 32)
810 #define intra_pred_no_4x4(type) \
811 intra_pred_sized(type, 8) \
812 intra_pred_sized(type, 16) \
813 intra_pred_sized(type, 32) \
814 intra_pred_highbd_sized(type, 4) \
815 intra_pred_highbd_sized(type, 8) \
816 intra_pred_highbd_sized(type, 16) \
817 intra_pred_highbd_sized(type, 32)
820 #define intra_pred_allsizes(type) \
821 intra_pred_sized(type, 4) \
822 intra_pred_sized(type, 8) \
823 intra_pred_sized(type, 16) \
824 intra_pred_sized(type, 32)
826 #define intra_pred_no_4x4(type) \
827 intra_pred_sized(type, 8) \
828 intra_pred_sized(type, 16) \
829 intra_pred_sized(type, 32)
830 #endif // CONFIG_VP9_HIGHBITDEPTH
832 intra_pred_no_4x4(d207
)
833 intra_pred_no_4x4(d63
)
834 intra_pred_no_4x4(d45
)
835 #if CONFIG_EXT_IPRED_BLTR
836 intra_pred_allsizes(d207e
)
837 intra_pred_allsizes(d63e
)
838 intra_pred_no_4x4(d45e
)
840 intra_pred_no_4x4(d117
)
841 intra_pred_no_4x4(d135
)
842 intra_pred_no_4x4(d153
)
843 intra_pred_allsizes(v
)
844 intra_pred_allsizes(h
)
845 intra_pred_allsizes(tm
)
846 intra_pred_allsizes(dc_128
)
847 intra_pred_allsizes(dc_left
)
848 intra_pred_allsizes(dc_top
)
849 intra_pred_allsizes(dc
)
850 #if CONFIG_VP9_HIGHBITDEPTH && CONFIG_MISC_FIXES && !CONFIG_EXT_IPRED_BLTR
851 intra_pred_highbd_sized(d45e
, 4)
853 #undef intra_pred_allsizes