49 for (y = 0; y < 8; y++) {
61 for (y = 0; y < 16; y++) {
75 for (y = 0; y < 32; y++) {
87 AV_WN32A(dst + stride * 0, left[0] * 0x01010101U);
88 AV_WN32A(dst + stride * 1, left[1] * 0x01010101U);
89 AV_WN32A(dst + stride * 2, left[2] * 0x01010101U);
90 AV_WN32A(dst + stride * 3, left[3] * 0x01010101U);
98 for (y = 0; y < 8; y++) {
99 AV_WN64A(dst, left[y] * 0x0101010101010101ULL);
109 for (y = 0; y < 16; y++) {
110 uint64_t p8 = left[
y] * 0x0101010101010101ULL;
123 for (y = 0; y < 32; y++) {
124 uint64_t p8 = left[
y] * 0x0101010101010101ULL;
139 for (y = 0; y < 4; y++) {
140 int l_m_tl = left[
y] - tl;
142 dst[0] = av_clip_uint8(top[0] + l_m_tl);
143 dst[1] = av_clip_uint8(top[1] + l_m_tl);
144 dst[2] = av_clip_uint8(top[2] + l_m_tl);
145 dst[3] = av_clip_uint8(top[3] + l_m_tl);
155 for (y = 0; y < 8; y++) {
156 int l_m_tl = left[
y] - tl;
158 dst[0] = av_clip_uint8(top[0] + l_m_tl);
159 dst[1] = av_clip_uint8(top[1] + l_m_tl);
160 dst[2] = av_clip_uint8(top[2] + l_m_tl);
161 dst[3] = av_clip_uint8(top[3] + l_m_tl);
162 dst[4] = av_clip_uint8(top[4] + l_m_tl);
163 dst[5] = av_clip_uint8(top[5] + l_m_tl);
164 dst[6] = av_clip_uint8(top[6] + l_m_tl);
165 dst[7] = av_clip_uint8(top[7] + l_m_tl);
175 for (y = 0; y < 16; y++) {
176 int l_m_tl = left[
y] - tl;
178 dst[ 0] = av_clip_uint8(top[ 0] + l_m_tl);
179 dst[ 1] = av_clip_uint8(top[ 1] + l_m_tl);
180 dst[ 2] = av_clip_uint8(top[ 2] + l_m_tl);
181 dst[ 3] = av_clip_uint8(top[ 3] + l_m_tl);
182 dst[ 4] = av_clip_uint8(top[ 4] + l_m_tl);
183 dst[ 5] = av_clip_uint8(top[ 5] + l_m_tl);
184 dst[ 6] = av_clip_uint8(top[ 6] + l_m_tl);
185 dst[ 7] = av_clip_uint8(top[ 7] + l_m_tl);
186 dst[ 8] = av_clip_uint8(top[ 8] + l_m_tl);
187 dst[ 9] = av_clip_uint8(top[ 9] + l_m_tl);
188 dst[10] = av_clip_uint8(top[10] + l_m_tl);
189 dst[11] = av_clip_uint8(top[11] + l_m_tl);
190 dst[12] = av_clip_uint8(top[12] + l_m_tl);
191 dst[13] = av_clip_uint8(top[13] + l_m_tl);
192 dst[14] = av_clip_uint8(top[14] + l_m_tl);
193 dst[15] = av_clip_uint8(top[15] + l_m_tl);
203 for (y = 0; y < 32; y++) {
204 int l_m_tl = left[
y] - tl;
206 dst[ 0] = av_clip_uint8(top[ 0] + l_m_tl);
207 dst[ 1] = av_clip_uint8(top[ 1] + l_m_tl);
208 dst[ 2] = av_clip_uint8(top[ 2] + l_m_tl);
209 dst[ 3] = av_clip_uint8(top[ 3] + l_m_tl);
210 dst[ 4] = av_clip_uint8(top[ 4] + l_m_tl);
211 dst[ 5] = av_clip_uint8(top[ 5] + l_m_tl);
212 dst[ 6] = av_clip_uint8(top[ 6] + l_m_tl);
213 dst[ 7] = av_clip_uint8(top[ 7] + l_m_tl);
214 dst[ 8] = av_clip_uint8(top[ 8] + l_m_tl);
215 dst[ 9] = av_clip_uint8(top[ 9] + l_m_tl);
216 dst[10] = av_clip_uint8(top[10] + l_m_tl);
217 dst[11] = av_clip_uint8(top[11] + l_m_tl);
218 dst[12] = av_clip_uint8(top[12] + l_m_tl);
219 dst[13] = av_clip_uint8(top[13] + l_m_tl);
220 dst[14] = av_clip_uint8(top[14] + l_m_tl);
221 dst[15] = av_clip_uint8(top[15] + l_m_tl);
222 dst[16] = av_clip_uint8(top[16] + l_m_tl);
223 dst[17] = av_clip_uint8(top[17] + l_m_tl);
224 dst[18] = av_clip_uint8(top[18] + l_m_tl);
225 dst[19] = av_clip_uint8(top[19] + l_m_tl);
226 dst[20] = av_clip_uint8(top[20] + l_m_tl);
227 dst[21] = av_clip_uint8(top[21] + l_m_tl);
228 dst[22] = av_clip_uint8(top[22] + l_m_tl);
229 dst[23] = av_clip_uint8(top[23] + l_m_tl);
230 dst[24] = av_clip_uint8(top[24] + l_m_tl);
231 dst[25] = av_clip_uint8(top[25] + l_m_tl);
232 dst[26] = av_clip_uint8(top[26] + l_m_tl);
233 dst[27] = av_clip_uint8(top[27] + l_m_tl);
234 dst[28] = av_clip_uint8(top[28] + l_m_tl);
235 dst[29] = av_clip_uint8(top[29] + l_m_tl);
236 dst[30] = av_clip_uint8(top[30] + l_m_tl);
237 dst[31] = av_clip_uint8(top[31] + l_m_tl);
245 unsigned dc = 0x01010101
U * ((left[0] + left[1] + left[2] + left[3] +
246 top[0] + top[1] + top[2] + top[3] + 4) >> 3);
257 uint64_t
dc = 0x0101010101010101ULL *
258 ((left[0] + left[1] + left[2] + left[3] + left[4] + left[5] +
259 left[6] + left[7] + top[0] + top[1] + top[2] + top[3] +
260 top[4] + top[5] + top[6] + top[7] + 8) >> 4);
263 for (y = 0; y < 8; y++) {
272 uint64_t
dc = 0x0101010101010101ULL *
273 ((left[0] + left[1] + left[2] + left[3] + left[4] + left[5] + left[6] +
274 left[7] + left[8] + left[9] + left[10] + left[11] + left[12] +
275 left[13] + left[14] + left[15] + top[0] + top[1] + top[2] + top[3] +
276 top[4] + top[5] + top[6] + top[7] + top[8] + top[9] + top[10] +
277 top[11] + top[12] + top[13] + top[14] + top[15] + 16) >> 5);
280 for (y = 0; y < 16; y++) {
290 uint64_t
dc = 0x0101010101010101ULL *
291 ((left[0] + left[1] + left[2] + left[3] + left[4] + left[5] + left[6] +
292 left[7] + left[8] + left[9] + left[10] + left[11] + left[12] +
293 left[13] + left[14] + left[15] + left[16] + left[17] + left[18] +
294 left[19] + left[20] + left[21] + left[22] + left[23] + left[24] +
295 left[25] + left[26] + left[27] + left[28] + left[29] + left[30] +
296 left[31] + top[0] + top[1] + top[2] + top[3] + top[4] + top[5] +
297 top[6] + top[7] + top[8] + top[9] + top[10] + top[11] + top[12] +
298 top[13] + top[14] + top[15] + top[16] + top[17] + top[18] + top[19] +
299 top[20] + top[21] + top[22] + top[23] + top[24] + top[25] + top[26] +
300 top[27] + top[28] + top[29] + top[30] + top[31] + 32) >> 6);
303 for (y = 0; y < 32; y++) {
315 unsigned dc = 0x01010101
U * ((left[0] + left[1] + left[2] + left[3] + 2) >> 2);
326 uint64_t
dc = 0x0101010101010101ULL *
327 ((left[0] + left[1] + left[2] + left[3] +
328 left[4] + left[5] + left[6] + left[7] + 4) >> 3);
331 for (y = 0; y < 8; y++) {
340 uint64_t
dc = 0x0101010101010101ULL *
341 ((left[0] + left[1] + left[2] + left[3] + left[4] + left[5] +
342 left[6] + left[7] + left[8] + left[9] + left[10] + left[11] +
343 left[12] + left[13] + left[14] + left[15] + 8) >> 4);
346 for (y = 0; y < 16; y++) {
356 uint64_t
dc = 0x0101010101010101ULL *
357 ((left[0] + left[1] + left[2] + left[3] + left[4] + left[5] +
358 left[6] + left[7] + left[8] + left[9] + left[10] + left[11] +
359 left[12] + left[13] + left[14] + left[15] + left[16] + left[17] +
360 left[18] + left[19] + left[20] + left[21] + left[22] + left[23] +
361 left[24] + left[25] + left[26] + left[27] + left[28] + left[29] +
362 left[30] + left[31] + 16) >> 5);
365 for (y = 0; y < 32; y++) {
377 unsigned dc = 0x01010101
U * ((top[0] + top[1] + top[2] + top[3] + 2) >> 2);
388 uint64_t
dc = 0x0101010101010101ULL *
389 ((top[0] + top[1] + top[2] + top[3] +
390 top[4] + top[5] + top[6] + top[7] + 4) >> 3);
393 for (y = 0; y < 8; y++) {
402 uint64_t
dc = 0x0101010101010101ULL *
403 ((top[0] + top[1] + top[2] + top[3] + top[4] + top[5] +
404 top[6] + top[7] + top[8] + top[9] + top[10] + top[11] +
405 top[12] + top[13] + top[14] + top[15] + 8) >> 4);
408 for (y = 0; y < 16; y++) {
418 uint64_t
dc = 0x0101010101010101ULL *
419 ((top[0] + top[1] + top[2] + top[3] + top[4] + top[5] +
420 top[6] + top[7] + top[8] + top[9] + top[10] + top[11] +
421 top[12] + top[13] + top[14] + top[15] + top[16] + top[17] +
422 top[18] + top[19] + top[20] + top[21] + top[22] + top[23] +
423 top[24] + top[25] + top[26] + top[27] + top[28] + top[29] +
424 top[30] + top[31] + 16) >> 5);
427 for (y = 0; y < 32; y++) {
439 AV_WN32A(dst + stride * 0, 0x80808080U);
440 AV_WN32A(dst + stride * 1, 0x80808080U);
441 AV_WN32A(dst + stride * 2, 0x80808080U);
442 AV_WN32A(dst + stride * 3, 0x80808080U);
450 for (y = 0; y < 8; y++) {
451 AV_WN64A(dst, 0x8080808080808080ULL);
461 for (y = 0; y < 16; y++) {
462 AV_WN64A(dst + 0, 0x8080808080808080ULL);
463 AV_WN64A(dst + 8, 0x8080808080808080ULL);
473 for (y = 0; y < 32; y++) {
474 AV_WN64A(dst + 0, 0x8080808080808080ULL);
475 AV_WN64A(dst + 8, 0x8080808080808080ULL);
476 AV_WN64A(dst + 16, 0x8080808080808080ULL);
477 AV_WN64A(dst + 24, 0x8080808080808080ULL);
485 AV_WN32A(dst + stride * 0, 0x7F7F7F7FU);
486 AV_WN32A(dst + stride * 1, 0x7F7F7F7FU);
487 AV_WN32A(dst + stride * 2, 0x7F7F7F7FU);
488 AV_WN32A(dst + stride * 3, 0x7F7F7F7FU);
496 for (y = 0; y < 8; y++) {
497 AV_WN64A(dst, 0x7F7F7F7F7F7F7F7FULL);
507 for (y = 0; y < 16; y++) {
508 AV_WN64A(dst + 0, 0x7F7F7F7F7F7F7F7FULL);
509 AV_WN64A(dst + 8, 0x7F7F7F7F7F7F7F7FULL);
519 for (y = 0; y < 32; y++) {
520 AV_WN64A(dst + 0, 0x7F7F7F7F7F7F7F7FULL);
521 AV_WN64A(dst + 8, 0x7F7F7F7F7F7F7F7FULL);
522 AV_WN64A(dst + 16, 0x7F7F7F7F7F7F7F7FULL);
523 AV_WN64A(dst + 24, 0x7F7F7F7F7F7F7F7FULL);
531 AV_WN32A(dst + stride * 0, 0x81818181U);
532 AV_WN32A(dst + stride * 1, 0x81818181U);
533 AV_WN32A(dst + stride * 2, 0x81818181U);
534 AV_WN32A(dst + stride * 3, 0x81818181U);
542 for (y = 0; y < 8; y++) {
543 AV_WN64A(dst, 0x8181818181818181ULL);
553 for (y = 0; y < 16; y++) {
554 AV_WN64A(dst + 0, 0x8181818181818181ULL);
555 AV_WN64A(dst + 8, 0x8181818181818181ULL);
565 for (y = 0; y < 32; y++) {
566 AV_WN64A(dst + 0, 0x8181818181818181ULL);
567 AV_WN64A(dst + 8, 0x8181818181818181ULL);
568 AV_WN64A(dst + 16, 0x8181818181818181ULL);
569 AV_WN64A(dst + 24, 0x8181818181818181ULL);
574 #define DST(x, y) dst[(x) + (y) * stride]
579 int a0 = top[0],
a1 = top[1],
a2 = top[2],
a3 = top[3],
580 a4 = top[4],
a5 = top[5], a6 = top[6], a7 = top[7];
582 DST(0,0) = (a0 + a1 * 2 + a2 + 2) >> 2;
583 DST(1,0) =
DST(0,1) = (a1 + a2 * 2 + a3 + 2) >> 2;
584 DST(2,0) =
DST(1,1) =
DST(0,2) = (a2 + a3 * 2 + a4 + 2) >> 2;
585 DST(3,0) =
DST(2,1) =
DST(1,2) =
DST(0,3) = (a3 + a4 * 2 + a5 + 2) >> 2;
586 DST(3,1) =
DST(2,2) =
DST(1,3) = (a4 + a5 * 2 + a6 + 2) >> 2;
587 DST(3,2) =
DST(2,3) = (a5 + a6 * 2 + a7 + 2) >> 2;
591 #define def_diag_downleft(size) \
592 static void diag_downleft_##size##x##size##_c(uint8_t *dst, ptrdiff_t stride, \
593 const uint8_t *left, const uint8_t *top) \
596 uint8_t v[size - 1]; \
598 for (i = 0; i < size - 2; i++) \
599 v[i] = (top[i] + top[i + 1] * 2 + top[i + 2] + 2) >> 2; \
600 v[size - 2] = (top[size - 2] + top[size - 1] * 3 + 2) >> 2; \
602 for (j = 0; j < size; j++) { \
603 memcpy(dst + j*stride, v + j, size - 1 - j); \
604 memset(dst + j*stride + size - 1 - j, top[size - 1], j + 1); \
612 static
void diag_downright_4x4_c(
uint8_t *dst, ptrdiff_t
stride,
615 int tl = top[-1],
a0 = top[0],
a1 = top[1],
a2 = top[2],
a3 = top[3],
616 l0 = left[0], l1 = left[1], l2 = left[2], l3 = left[3];
618 DST(0,3) = (l1 + l2 * 2 + l3 + 2) >> 2;
619 DST(0,2) =
DST(1,3) = (l0 + l1 * 2 + l2 + 2) >> 2;
620 DST(0,1) =
DST(1,2) =
DST(2,3) = (tl + l0 * 2 + l1 + 2) >> 2;
621 DST(0,0) =
DST(1,1) =
DST(2,2) =
DST(3,3) = (l0 + tl * 2 + a0 + 2) >> 2;
622 DST(1,0) =
DST(2,1) =
DST(3,2) = (tl + a0 * 2 + a1 + 2) >> 2;
623 DST(2,0) =
DST(3,1) = (a0 + a1 * 2 + a2 + 2) >> 2;
624 DST(3,0) = (a1 + a2 * 2 + a3 + 2) >> 2;
627 #define def_diag_downright(size) \
628 static void diag_downright_##size##x##size##_c(uint8_t *dst, ptrdiff_t stride, \
629 const uint8_t *left, const uint8_t *top) \
632 uint8_t v[size + size - 1]; \
634 for (i = 0; i < size - 2; i++) { \
635 v[i ] = (left[size - 1 - i] + left[size - 2 - i] * 2 + left[size - 3 - i] + 2) >> 2; \
636 v[size + 1 + i] = (top[i] + top[i + 1] * 2 + top[i + 2] + 2) >> 2; \
638 v[size - 2] = (left[1] + left[0] * 2 + top[-1] + 2) >> 2; \
639 v[size - 1] = (left[0] + top[-1] * 2 + top[ 0] + 2) >> 2; \
640 v[size ] = (top[-1] + top[0] * 2 + top[ 1] + 2) >> 2; \
642 for (j = 0; j < size; j++) \
643 memcpy(dst + j*stride, v + size - 1 - j, size); \
653 int tl = top[-1],
a0 = top[0],
a1 = top[1],
a2 = top[2],
a3 = top[3],
654 l0 = left[0], l1 = left[1], l2 = left[2];
656 DST(0,3) = (l0 + l1 * 2 + l2 + 2) >> 2;
657 DST(0,2) = (tl + l0 * 2 + l1 + 2) >> 2;
658 DST(0,0) =
DST(1,2) = (tl + a0 + 1) >> 1;
659 DST(0,1) =
DST(1,3) = (l0 + tl * 2 + a0 + 2) >> 2;
660 DST(1,0) =
DST(2,2) = (a0 + a1 + 1) >> 1;
661 DST(1,1) =
DST(2,3) = (tl + a0 * 2 + a1 + 2) >> 2;
662 DST(2,0) =
DST(3,2) = (a1 + a2 + 1) >> 1;
663 DST(2,1) =
DST(3,3) = (a0 + a1 * 2 + a2 + 2) >> 2;
664 DST(3,0) = (a2 + a3 + 1) >> 1;
665 DST(3,1) = (a1 + a2 * 2 + a3 + 2) >> 2;
668 #define def_vert_right(size) \
669 static void vert_right_##size##x##size##_c(uint8_t *dst, ptrdiff_t stride, \
670 const uint8_t *left, const uint8_t *top) \
673 uint8_t ve[size + size/2 - 1], vo[size + size/2 - 1]; \
675 for (i = 0; i < size/2 - 2; i++) { \
676 vo[i] = (left[size - 4 - i*2] + left[size - 3 - i*2] * 2 + left[size - 2 - i*2] + 2) >> 2; \
677 ve[i] = (left[size - 5 - i*2] + left[size - 4 - i*2] * 2 + left[size - 3 - i*2] + 2) >> 2; \
679 vo[size/2 - 2] = (left[0] + left[1] * 2 + left[2] + 2) >> 2; \
680 ve[size/2 - 2] = (top[-1] + left[0] * 2 + left[1] + 2) >> 2; \
682 ve[size/2 - 1] = (top[-1] + top[0] + 1) >> 1; \
683 vo[size/2 - 1] = (left[0] + top[-1] * 2 + top[0] + 2) >> 2; \
684 for (i = 0; i < size - 1; i++) { \
685 ve[size/2 + i] = (top[i] + top[i + 1] + 1) >> 1; \
686 vo[size/2 + i] = (top[i - 1] + top[i] * 2 + top[i + 1] + 2) >> 2; \
689 for (j = 0; j < size / 2; j++) { \
690 memcpy(dst + j*2 *stride, ve + size/2 - 1 - j, size); \
691 memcpy(dst + (j*2 + 1)*stride, vo + size/2 - 1 - j, size); \
702 int l0 = left[0], l1 = left[1], l2 = left[2], l3 = left[3],
703 tl = top[-1],
a0 = top[0],
a1 = top[1],
a2 = top[2];
705 DST(2,0) = (tl + a0 * 2 + a1 + 2) >> 2;
706 DST(3,0) = (a0 + a1 * 2 + a2 + 2) >> 2;
707 DST(0,0) =
DST(2,1) = (tl + l0 + 1) >> 1;
708 DST(1,0) =
DST(3,1) = (a0 + tl * 2 + l0 + 2) >> 2;
709 DST(0,1) =
DST(2,2) = (l0 + l1 + 1) >> 1;
710 DST(1,1) =
DST(3,2) = (tl + l0 * 2 + l1 + 2) >> 2;
711 DST(0,2) =
DST(2,3) = (l1 + l2 + 1) >> 1;
712 DST(1,2) =
DST(3,3) = (l0 + l1 * 2 + l2 + 2) >> 2;
713 DST(0,3) = (l2 + l3 + 1) >> 1;
714 DST(1,3) = (l1 + l2 * 2 + l3 + 2) >> 2;
717 #define def_hor_down(size) \
718 static void hor_down_##size##x##size##_c(uint8_t *dst, ptrdiff_t stride, \
719 const uint8_t *left, const uint8_t *top) \
722 uint8_t v[size * 3 - 2]; \
724 for (i = 0; i < size - 2; i++) { \
725 v[i*2 ] = (left[size - 2 - i] + left[size - 1 - i] + 1) >> 1; \
726 v[i*2 + 1] = (left[size - 3 - i] + left[size - 2 - i] * 2 + left[size - 1 - i] + 2) >> 2; \
727 v[size*2 + i] = (top[i - 1] + top[i] * 2 + top[i + 1] + 2) >> 2; \
729 v[size*2 - 2] = (top[-1] + left[0] + 1) >> 1; \
730 v[size*2 - 4] = (left[0] + left[1] + 1) >> 1; \
731 v[size*2 - 1] = (top[0] + top[-1] * 2 + left[0] + 2) >> 2; \
732 v[size*2 - 3] = (top[-1] + left[0] * 2 + left[1] + 2) >> 2; \
734 for (j = 0; j < size; j++) \
735 memcpy(dst + j*stride, v + size*2 - 2 - j*2, size); \
745 int a0 = top[0],
a1 = top[1],
a2 = top[2],
a3 = top[3],
746 a4 = top[4],
a5 = top[5], a6 = top[6];
748 DST(0,0) = (a0 + a1 + 1) >> 1;
749 DST(0,1) = (a0 + a1 * 2 + a2 + 2) >> 2;
750 DST(1,0) =
DST(0,2) = (a1 + a2 + 1) >> 1;
751 DST(1,1) =
DST(0,3) = (a1 + a2 * 2 + a3 + 2) >> 2;
752 DST(2,0) =
DST(1,2) = (a2 + a3 + 1) >> 1;
753 DST(2,1) =
DST(1,3) = (a2 + a3 * 2 + a4 + 2) >> 2;
754 DST(3,0) =
DST(2,2) = (a3 + a4 + 1) >> 1;
755 DST(3,1) =
DST(2,3) = (a3 + a4 * 2 + a5 + 2) >> 2;
756 DST(3,2) = (a4 + a5 + 1) >> 1;
757 DST(3,3) = (a4 + a5 * 2 + a6 + 2) >> 2;
760 #define def_vert_left(size) \
761 static void vert_left_##size##x##size##_c(uint8_t *dst, ptrdiff_t stride, \
762 const uint8_t *left, const uint8_t *top) \
765 uint8_t ve[size - 1], vo[size - 1]; \
767 for (i = 0; i < size - 2; i++) { \
768 ve[i] = (top[i] + top[i + 1] + 1) >> 1; \
769 vo[i] = (top[i] + top[i + 1] * 2 + top[i + 2] + 2) >> 2; \
771 ve[size - 2] = (top[size - 2] + top[size - 1] + 1) >> 1; \
772 vo[size - 2] = (top[size - 2] + top[size - 1] * 3 + 2) >> 2; \
774 for (j = 0; j < size / 2; j++) { \
775 memcpy(dst + j*2 * stride, ve + j, size - j - 1); \
776 memset(dst + j*2 * stride + size - j - 1, top[size - 1], j + 1); \
777 memcpy(dst + (j*2 + 1) * stride, vo + j, size - j - 1); \
778 memset(dst + (j*2 + 1) * stride + size - j - 1, top[size - 1], j + 1); \
789 int l0 = left[0], l1 = left[1], l2 = left[2], l3 = left[3];
791 DST(0,0) = (l0 + l1 + 1) >> 1;
792 DST(1,0) = (l0 + l1 * 2 + l2 + 2) >> 2;
793 DST(0,1) =
DST(2,0) = (l1 + l2 + 1) >> 1;
794 DST(1,1) =
DST(3,0) = (l1 + l2 * 2 + l3 + 2) >> 2;
795 DST(0,2) =
DST(2,1) = (l2 + l3 + 1) >> 1;
796 DST(1,2) =
DST(3,1) = (l2 + l3 * 3 + 2) >> 2;
800 #define def_hor_up(size) \
801 static void hor_up_##size##x##size##_c(uint8_t *dst, ptrdiff_t stride, \
802 const uint8_t *left, const uint8_t *top) \
805 uint8_t v[size*2 - 2]; \
807 for (i = 0; i < size - 2; i++) { \
808 v[i*2 ] = (left[i] + left[i + 1] + 1) >> 1; \
809 v[i*2 + 1] = (left[i] + left[i + 1] * 2 + left[i + 2] + 2) >> 2; \
811 v[size*2 - 4] = (left[size - 2] + left[size - 1] + 1) >> 1; \
812 v[size*2 - 3] = (left[size - 2] + left[size - 1] * 3 + 2) >> 2; \
814 for (j = 0; j < size / 2; j++) \
815 memcpy(dst + j*stride, v + j*2, size); \
816 for (j = size / 2; j < size; j++) { \
817 memcpy(dst + j*stride, v + j*2, size*2 - 2 - j*2); \
818 memset(dst + j*stride + size*2 - 2 - j*2, left[size - 1], \
831 #define init_intra_pred(tx, sz) \
832 dsp->intra_pred[tx][VERT_PRED] = vert_##sz##_c; \
833 dsp->intra_pred[tx][HOR_PRED] = hor_##sz##_c; \
834 dsp->intra_pred[tx][DC_PRED] = dc_##sz##_c; \
835 dsp->intra_pred[tx][DIAG_DOWN_LEFT_PRED] = diag_downleft_##sz##_c; \
836 dsp->intra_pred[tx][DIAG_DOWN_RIGHT_PRED] = diag_downright_##sz##_c; \
837 dsp->intra_pred[tx][VERT_RIGHT_PRED] = vert_right_##sz##_c; \
838 dsp->intra_pred[tx][HOR_DOWN_PRED] = hor_down_##sz##_c; \
839 dsp->intra_pred[tx][VERT_LEFT_PRED] = vert_left_##sz##_c; \
840 dsp->intra_pred[tx][HOR_UP_PRED] = hor_up_##sz##_c; \
841 dsp->intra_pred[tx][TM_VP8_PRED] = tm_##sz##_c; \
842 dsp->intra_pred[tx][LEFT_DC_PRED] = dc_left_##sz##_c; \
843 dsp->intra_pred[tx][TOP_DC_PRED] = dc_top_##sz##_c; \
844 dsp->intra_pred[tx][DC_128_PRED] = dc_128_##sz##_c; \
845 dsp->intra_pred[tx][DC_127_PRED] = dc_127_##sz##_c; \
846 dsp->intra_pred[tx][DC_129_PRED] = dc_129_##sz##_c
853 #undef init_intra_pred
856 #define itxfm_wrapper(type_a, type_b, sz, bits) \
857 static void type_a##_##type_b##_##sz##x##sz##_add_c(uint8_t *dst, \
859 int16_t *block, int eob) \
862 int16_t tmp[sz * sz], out[sz]; \
863 for (i = 0; i < sz; i++) \
864 type_a##sz##_1d(block + i, sz, tmp + i * sz, 0); \
865 memset(block, 0, sz * sz * sizeof(*block)); \
866 for (i = 0; i < sz; i++) { \
867 type_b##sz##_1d(tmp + i, sz, out, 1); \
868 for (j = 0; j < sz; j++) \
869 dst[j * stride] = av_clip_uint8(dst[j * stride] + \
871 (out[j] + (1 << (bits - 1))) >> bits : \
877 #define itxfm_wrap(sz, bits) \
878 itxfm_wrapper(idct, idct, sz, bits) \
879 itxfm_wrapper(iadst, idct, sz, bits) \
880 itxfm_wrapper(idct, iadst, sz, bits) \
881 itxfm_wrapper(iadst, iadst, sz, bits)
883 #define IN(x) in[x * stride]
890 t0 = ((
IN(0) +
IN(2)) * 11585 + (1 << 13)) >> 14;
891 t1 = ((
IN(0) -
IN(2)) * 11585 + (1 << 13)) >> 14;
892 t2 = (
IN(1) * 6270 -
IN(3) * 15137 + (1 << 13)) >> 14;
893 t3 = (
IN(1) * 15137 +
IN(3) * 6270 + (1 << 13)) >> 14;
906 t0 = 5283 *
IN(0) + 15212 *
IN(2) + 9929 *
IN(3);
907 t1 = 9929 *
IN(0) - 5283 *
IN(2) - 15212 *
IN(3);
908 t2 = 13377 * (
IN(0) -
IN(2) +
IN(3));
911 out[0] = (t0 + t3 + (1 << 13)) >> 14;
912 out[1] = (t1 + t3 + (1 << 13)) >> 14;
913 out[2] = (t2 + (1 << 13)) >> 14;
914 out[3] = (t0 + t1 - t3 + (1 << 13)) >> 14;
922 int t0, t0a,
t1, t1a,
t2, t2a,
t3, t3a,
t4, t4a,
t5, t5a,
t6, t6a,
t7, t7a;
924 t0a = ((
IN(0) +
IN(4)) * 11585 + (1 << 13)) >> 14;
925 t1a = ((
IN(0) -
IN(4)) * 11585 + (1 << 13)) >> 14;
926 t2a = (
IN(2) * 6270 -
IN(6) * 15137 + (1 << 13)) >> 14;
927 t3a = (
IN(2) * 15137 +
IN(6) * 6270 + (1 << 13)) >> 14;
928 t4a = (
IN(1) * 3196 -
IN(7) * 16069 + (1 << 13)) >> 14;
929 t5a = (
IN(5) * 13623 -
IN(3) * 9102 + (1 << 13)) >> 14;
930 t6a = (
IN(5) * 9102 +
IN(3) * 13623 + (1 << 13)) >> 14;
931 t7a = (
IN(1) * 16069 +
IN(7) * 3196 + (1 << 13)) >> 14;
942 t5 = ((t6a - t5a) * 11585 + (1 << 13)) >> 14;
943 t6 = ((t6a + t5a) * 11585 + (1 << 13)) >> 14;
958 int t0, t0a,
t1, t1a,
t2, t2a,
t3, t3a,
t4, t4a,
t5, t5a,
t6, t6a,
t7, t7a;
960 t0a = 16305 *
IN(7) + 1606 *
IN(0);
961 t1a = 1606 *
IN(7) - 16305 *
IN(0);
962 t2a = 14449 *
IN(5) + 7723 *
IN(2);
963 t3a = 7723 *
IN(5) - 14449 *
IN(2);
964 t4a = 10394 *
IN(3) + 12665 *
IN(4);
965 t5a = 12665 *
IN(3) - 10394 *
IN(4);
966 t6a = 4756 *
IN(1) + 15679 *
IN(6);
967 t7a = 15679 *
IN(1) - 4756 *
IN(6);
969 t0 = (t0a + t4a + (1 << 13)) >> 14;
970 t1 = (t1a + t5a + (1 << 13)) >> 14;
971 t2 = (t2a + t6a + (1 << 13)) >> 14;
972 t3 = (t3a + t7a + (1 << 13)) >> 14;
973 t4 = (t0a - t4a + (1 << 13)) >> 14;
974 t5 = (t1a - t5a + (1 << 13)) >> 14;
975 t6 = (t2a - t6a + (1 << 13)) >> 14;
976 t7 = (t3a - t7a + (1 << 13)) >> 14;
978 t4a = 15137 * t4 + 6270 *
t5;
979 t5a = 6270 * t4 - 15137 *
t5;
980 t6a = 15137 * t7 - 6270 *
t6;
981 t7a = 6270 * t7 + 15137 *
t6;
988 out[1] = -((t4a + t6a + (1 << 13)) >> 14);
989 out[6] = (t5a + t7a + (1 << 13)) >> 14;
990 t6 = (t4a - t6a + (1 << 13)) >> 14;
991 t7 = (t5a - t7a + (1 << 13)) >> 14;
993 out[3] = -(((t2 +
t3) * 11585 + (1 << 13)) >> 14);
994 out[4] = ((t2 -
t3) * 11585 + (1 << 13)) >> 14;
995 out[2] = ((t6 +
t7) * 11585 + (1 << 13)) >> 14;
996 out[5] = -(((t6 -
t7) * 11585 + (1 << 13)) >> 14);
1004 int t0,
t1,
t2,
t3,
t4,
t5,
t6,
t7,
t8,
t9,
t10,
t11,
t12, t13, t14, t15;
1005 int t0a, t1a, t2a, t3a, t4a, t5a, t6a, t7a;
1006 int t8a, t9a, t10a, t11a, t12a, t13a, t14a, t15a;
1008 t0a = ((
IN(0) +
IN(8)) * 11585 + (1 << 13)) >> 14;
1009 t1a = ((
IN(0) -
IN(8)) * 11585 + (1 << 13)) >> 14;
1010 t2a = (
IN(4) * 6270 -
IN(12) * 15137 + (1 << 13)) >> 14;
1011 t3a = (
IN(4) * 15137 +
IN(12) * 6270 + (1 << 13)) >> 14;
1012 t4a = (
IN(2) * 3196 -
IN(14) * 16069 + (1 << 13)) >> 14;
1013 t7a = (
IN(2) * 16069 +
IN(14) * 3196 + (1 << 13)) >> 14;
1014 t5a = (
IN(10) * 13623 -
IN(6) * 9102 + (1 << 13)) >> 14;
1015 t6a = (
IN(10) * 9102 +
IN(6) * 13623 + (1 << 13)) >> 14;
1016 t8a = (
IN(1) * 1606 -
IN(15) * 16305 + (1 << 13)) >> 14;
1017 t15a = (
IN(1) * 16305 +
IN(15) * 1606 + (1 << 13)) >> 14;
1018 t9a = (
IN(9) * 12665 -
IN(7) * 10394 + (1 << 13)) >> 14;
1019 t14a = (
IN(9) * 10394 +
IN(7) * 12665 + (1 << 13)) >> 14;
1020 t10a = (
IN(5) * 7723 -
IN(11) * 14449 + (1 << 13)) >> 14;
1021 t13a = (
IN(5) * 14449 +
IN(11) * 7723 + (1 << 13)) >> 14;
1022 t11a = (
IN(13) * 15679 -
IN(3) * 4756 + (1 << 13)) >> 14;
1023 t12a = (
IN(13) * 4756 +
IN(3) * 15679 + (1 << 13)) >> 14;
1042 t5a = ((t6 -
t5) * 11585 + (1 << 13)) >> 14;
1043 t6a = ((t6 +
t5) * 11585 + (1 << 13)) >> 14;
1044 t9a = ( t14 * 6270 - t9 * 15137 + (1 << 13)) >> 14;
1045 t14a = ( t14 * 15137 + t9 * 6270 + (1 << 13)) >> 14;
1046 t10a = (-(t13 * 15137 + t10 * 6270) + (1 << 13)) >> 14;
1047 t13a = ( t13 * 6270 - t10 * 15137 + (1 << 13)) >> 14;
1066 t10a = ((t13 -
t10) * 11585 + (1 << 13)) >> 14;
1067 t13a = ((t13 +
t10) * 11585 + (1 << 13)) >> 14;
1068 t11 = ((t12a - t11a) * 11585 + (1 << 13)) >> 14;
1069 t12 = ((t12a + t11a) * 11585 + (1 << 13)) >> 14;
1071 out[ 0] = t0a + t15a;
1072 out[ 1] = t1a + t14;
1073 out[ 2] = t2a + t13a;
1074 out[ 3] = t3a +
t12;
1076 out[ 5] = t5 + t10a;
1081 out[10] = t5 - t10a;
1083 out[12] = t3a -
t12;
1084 out[13] = t2a - t13a;
1085 out[14] = t1a - t14;
1086 out[15] = t0a - t15a;
1092 int t0,
t1,
t2,
t3,
t4,
t5,
t6,
t7,
t8,
t9,
t10,
t11,
t12, t13, t14, t15;
1093 int t0a, t1a, t2a, t3a, t4a, t5a, t6a, t7a;
1094 int t8a, t9a, t10a, t11a, t12a, t13a, t14a, t15a;
1096 t0 =
IN(15) * 16364 +
IN(0) * 804;
1097 t1 =
IN(15) * 804 -
IN(0) * 16364;
1098 t2 =
IN(13) * 15893 +
IN(2) * 3981;
1099 t3 =
IN(13) * 3981 -
IN(2) * 15893;
1100 t4 =
IN(11) * 14811 +
IN(4) * 7005;
1101 t5 =
IN(11) * 7005 -
IN(4) * 14811;
1102 t6 =
IN(9) * 13160 +
IN(6) * 9760;
1103 t7 =
IN(9) * 9760 -
IN(6) * 13160;
1104 t8 =
IN(7) * 11003 +
IN(8) * 12140;
1105 t9 =
IN(7) * 12140 -
IN(8) * 11003;
1106 t10 =
IN(5) * 8423 +
IN(10) * 14053;
1107 t11 =
IN(5) * 14053 -
IN(10) * 8423;
1108 t12 =
IN(3) * 5520 +
IN(12) * 15426;
1109 t13 =
IN(3) * 15426 -
IN(12) * 5520;
1110 t14 =
IN(1) * 2404 +
IN(14) * 16207;
1111 t15 =
IN(1) * 16207 -
IN(14) * 2404;
1113 t0a = (t0 + t8 + (1 << 13)) >> 14;
1114 t1a = (t1 + t9 + (1 << 13)) >> 14;
1115 t2a = (t2 + t10 + (1 << 13)) >> 14;
1116 t3a = (t3 + t11 + (1 << 13)) >> 14;
1117 t4a = (t4 + t12 + (1 << 13)) >> 14;
1118 t5a = (t5 + t13 + (1 << 13)) >> 14;
1119 t6a = (t6 + t14 + (1 << 13)) >> 14;
1120 t7a = (t7 + t15 + (1 << 13)) >> 14;
1121 t8a = (t0 - t8 + (1 << 13)) >> 14;
1122 t9a = (t1 - t9 + (1 << 13)) >> 14;
1123 t10a = (t2 - t10 + (1 << 13)) >> 14;
1124 t11a = (t3 - t11 + (1 << 13)) >> 14;
1125 t12a = (t4 - t12 + (1 << 13)) >> 14;
1126 t13a = (t5 - t13 + (1 << 13)) >> 14;
1127 t14a = (t6 - t14 + (1 << 13)) >> 14;
1128 t15a = (t7 - t15 + (1 << 13)) >> 14;
1130 t8 = t8a * 16069 + t9a * 3196;
1131 t9 = t8a * 3196 - t9a * 16069;
1132 t10 = t10a * 9102 + t11a * 13623;
1133 t11 = t10a * 13623 - t11a * 9102;
1134 t12 = t13a * 16069 - t12a * 3196;
1135 t13 = t13a * 3196 + t12a * 16069;
1136 t14 = t15a * 9102 - t14a * 13623;
1137 t15 = t15a * 13623 + t14a * 9102;
1147 t8a = (t8 + t12 + (1 << 13)) >> 14;
1148 t9a = (t9 + t13 + (1 << 13)) >> 14;
1149 t10a = (t10 + t14 + (1 << 13)) >> 14;
1150 t11a = (t11 + t15 + (1 << 13)) >> 14;
1151 t12a = (t8 - t12 + (1 << 13)) >> 14;
1152 t13a = (t9 - t13 + (1 << 13)) >> 14;
1153 t14a = (t10 - t14 + (1 << 13)) >> 14;
1154 t15a = (t11 - t15 + (1 << 13)) >> 14;
1156 t4a = t4 * 15137 + t5 * 6270;
1157 t5a = t4 * 6270 - t5 * 15137;
1158 t6a = t7 * 15137 - t6 * 6270;
1159 t7a = t7 * 6270 + t6 * 15137;
1160 t12 = t12a * 15137 + t13a * 6270;
1161 t13 = t12a * 6270 - t13a * 15137;
1162 t14 = t15a * 15137 - t14a * 6270;
1163 t15 = t15a * 6270 + t14a * 15137;
1166 out[15] = -(t1 +
t3);
1169 out[ 3] = -((t4a + t6a + (1 << 13)) >> 14);
1170 out[12] = (t5a + t7a + (1 << 13)) >> 14;
1171 t6 = (t4a - t6a + (1 << 13)) >> 14;
1172 t7 = (t5a - t7a + (1 << 13)) >> 14;
1173 out[ 1] = -(t8a + t10a);
1174 out[14] = t9a + t11a;
1177 out[ 2] = (t12 + t14 + (1 << 13)) >> 14;
1178 out[13] = -((t13 + t15 + (1 << 13)) >> 14);
1179 t14a = (t12 - t14 + (1 << 13)) >> 14;
1180 t15a = (t13 - t15 + (1 << 13)) >> 14;
1182 out[ 7] = ((t2a + t3a) * -11585 + (1 << 13)) >> 14;
1183 out[ 8] = ((t2a - t3a) * 11585 + (1 << 13)) >> 14;
1184 out[ 4] = ((t7 +
t6) * 11585 + (1 << 13)) >> 14;
1185 out[11] = ((t7 -
t6) * 11585 + (1 << 13)) >> 14;
1186 out[ 6] = ((t11 +
t10) * 11585 + (1 << 13)) >> 14;
1187 out[ 9] = ((t11 -
t10) * 11585 + (1 << 13)) >> 14;
1188 out[ 5] = ((t14a + t15a) * -11585 + (1 << 13)) >> 14;
1189 out[10] = ((t14a - t15a) * 11585 + (1 << 13)) >> 14;
1197 int t0a = ((
IN(0) +
IN(16)) * 11585 + (1 << 13)) >> 14;
1198 int t1a = ((
IN(0) -
IN(16)) * 11585 + (1 << 13)) >> 14;
1199 int t2a = (
IN( 8) * 6270 -
IN(24) * 15137 + (1 << 13)) >> 14;
1200 int t3a = (
IN( 8) * 15137 +
IN(24) * 6270 + (1 << 13)) >> 14;
1201 int t4a = (
IN( 4) * 3196 -
IN(28) * 16069 + (1 << 13)) >> 14;
1202 int t7a = (
IN( 4) * 16069 +
IN(28) * 3196 + (1 << 13)) >> 14;
1203 int t5a = (
IN(20) * 13623 -
IN(12) * 9102 + (1 << 13)) >> 14;
1204 int t6a = (
IN(20) * 9102 +
IN(12) * 13623 + (1 << 13)) >> 14;
1205 int t8a = (
IN( 2) * 1606 -
IN(30) * 16305 + (1 << 13)) >> 14;
1206 int t15a = (
IN( 2) * 16305 +
IN(30) * 1606 + (1 << 13)) >> 14;
1207 int t9a = (
IN(18) * 12665 -
IN(14) * 10394 + (1 << 13)) >> 14;
1208 int t14a = (
IN(18) * 10394 +
IN(14) * 12665 + (1 << 13)) >> 14;
1209 int t10a = (
IN(10) * 7723 -
IN(22) * 14449 + (1 << 13)) >> 14;
1210 int t13a = (
IN(10) * 14449 +
IN(22) * 7723 + (1 << 13)) >> 14;
1211 int t11a = (
IN(26) * 15679 -
IN( 6) * 4756 + (1 << 13)) >> 14;
1212 int t12a = (
IN(26) * 4756 +
IN( 6) * 15679 + (1 << 13)) >> 14;
1213 int t16a = (
IN( 1) * 804 -
IN(31) * 16364 + (1 << 13)) >> 14;
1214 int t31a = (
IN( 1) * 16364 +
IN(31) * 804 + (1 << 13)) >> 14;
1215 int t17a = (
IN(17) * 12140 -
IN(15) * 11003 + (1 << 13)) >> 14;
1216 int t30a = (
IN(17) * 11003 +
IN(15) * 12140 + (1 << 13)) >> 14;
1217 int t18a = (
IN( 9) * 7005 -
IN(23) * 14811 + (1 << 13)) >> 14;
1218 int t29a = (
IN( 9) * 14811 +
IN(23) * 7005 + (1 << 13)) >> 14;
1219 int t19a = (
IN(25) * 15426 -
IN( 7) * 5520 + (1 << 13)) >> 14;
1220 int t28a = (
IN(25) * 5520 +
IN( 7) * 15426 + (1 << 13)) >> 14;
1221 int t20a = (
IN( 5) * 3981 -
IN(27) * 15893 + (1 << 13)) >> 14;
1222 int t27a = (
IN( 5) * 15893 +
IN(27) * 3981 + (1 << 13)) >> 14;
1223 int t21a = (
IN(21) * 14053 -
IN(11) * 8423 + (1 << 13)) >> 14;
1224 int t26a = (
IN(21) * 8423 +
IN(11) * 14053 + (1 << 13)) >> 14;
1225 int t22a = (
IN(13) * 9760 -
IN(19) * 13160 + (1 << 13)) >> 14;
1226 int t25a = (
IN(13) * 13160 +
IN(19) * 9760 + (1 << 13)) >> 14;
1227 int t23a = (
IN(29) * 16207 -
IN( 3) * 2404 + (1 << 13)) >> 14;
1228 int t24a = (
IN(29) * 2404 +
IN( 3) * 16207 + (1 << 13)) >> 14;
1240 int t10 = t11a - t10a;
1241 int t11 = t11a + t10a;
1242 int t12 = t12a + t13a;
1243 int t13 = t12a - t13a;
1244 int t14 = t15a - t14a;
1245 int t15 = t15a + t14a;
1246 int t16 = t16a + t17a;
1247 int t17 = t16a - t17a;
1248 int t18 = t19a - t18a;
1249 int t19 = t19a + t18a;
1250 int t20 = t20a + t21a;
1251 int t21 = t20a - t21a;
1252 int t22 = t23a - t22a;
1253 int t23 = t23a + t22a;
1254 int t24 = t24a + t25a;
1255 int t25 = t24a - t25a;
1256 int t26 = t27a - t26a;
1257 int t27 = t27a + t26a;
1258 int t28 = t28a + t29a;
1259 int t29 = t28a - t29a;
1260 int t30 = t31a - t30a;
1261 int t31 = t31a + t30a;
1263 t5a = ((t6 -
t5) * 11585 + (1 << 13)) >> 14;
1264 t6a = ((t6 +
t5) * 11585 + (1 << 13)) >> 14;
1265 t9a = ( t14 * 6270 - t9 * 15137 + (1 << 13)) >> 14;
1266 t14a = ( t14 * 15137 + t9 * 6270 + (1 << 13)) >> 14;
1267 t10a = (-(t13 * 15137 + t10 * 6270) + (1 << 13)) >> 14;
1268 t13a = ( t13 * 6270 - t10 * 15137 + (1 << 13)) >> 14;
1269 t17a = ( t30 * 3196 - t17 * 16069 + (1 << 13)) >> 14;
1270 t30a = ( t30 * 16069 + t17 * 3196 + (1 << 13)) >> 14;
1271 t18a = (-(t29 * 16069 + t18 * 3196) + (1 << 13)) >> 14;
1272 t29a = ( t29 * 3196 - t18 * 16069 + (1 << 13)) >> 14;
1273 t21a = ( t26 * 13623 - t21 * 9102 + (1 << 13)) >> 14;
1274 t26a = ( t26 * 9102 + t21 * 13623 + (1 << 13)) >> 14;
1275 t22a = (-(t25 * 9102 + t22 * 13623) + (1 << 13)) >> 14;
1276 t25a = ( t25 * 13623 - t22 * 9102 + (1 << 13)) >> 14;
1311 t10a = ((t13 -
t10) * 11585 + (1 << 13)) >> 14;
1312 t13a = ((t13 +
t10) * 11585 + (1 << 13)) >> 14;
1313 t11 = ((t12a - t11a) * 11585 + (1 << 13)) >> 14;
1314 t12 = ((t12a + t11a) * 11585 + (1 << 13)) >> 14;
1315 t18a = ( t29 * 6270 - t18 * 15137 + (1 << 13)) >> 14;
1316 t29a = ( t29 * 15137 + t18 * 6270 + (1 << 13)) >> 14;
1317 t19 = ( t28a * 6270 - t19a * 15137 + (1 << 13)) >> 14;
1318 t28 = ( t28a * 15137 + t19a * 6270 + (1 << 13)) >> 14;
1319 t20 = (-(t27a * 15137 + t20a * 6270) + (1 << 13)) >> 14;
1320 t27 = ( t27a * 6270 - t20a * 15137 + (1 << 13)) >> 14;
1321 t21a = (-(t26 * 15137 + t21 * 6270) + (1 << 13)) >> 14;
1322 t26a = ( t26 * 6270 - t21 * 15137 + (1 << 13)) >> 14;
1357 t20 = ((t27a - t20a) * 11585 + (1 << 13)) >> 14;
1358 t27 = ((t27a + t20a) * 11585 + (1 << 13)) >> 14;
1359 t21a = ((t26 - t21 ) * 11585 + (1 << 13)) >> 14;
1360 t26a = ((t26 + t21 ) * 11585 + (1 << 13)) >> 14;
1361 t22 = ((t25a - t22a) * 11585 + (1 << 13)) >> 14;
1362 t25 = ((t25a + t22a) * 11585 + (1 << 13)) >> 14;
1363 t23a = ((t24 - t23 ) * 11585 + (1 << 13)) >> 14;
1364 t24a = ((t24 + t23 ) * 11585 + (1 << 13)) >> 14;
1367 out[ 1] = t1 + t30a;
1369 out[ 3] = t3 + t28a;
1371 out[ 5] = t5a + t26a;
1372 out[ 6] = t6a + t25;
1373 out[ 7] = t7 + t24a;
1374 out[ 8] = t8 + t23a;
1375 out[ 9] = t9a + t22;
1376 out[10] = t10 + t21a;
1377 out[11] = t11a + t20;
1378 out[12] = t12a + t19a;
1379 out[13] = t13 + t18;
1380 out[14] = t14a + t17a;
1381 out[15] = t15 + t16;
1382 out[16] = t15 - t16;
1383 out[17] = t14a - t17a;
1384 out[18] = t13 - t18;
1385 out[19] = t12a - t19a;
1386 out[20] = t11a - t20;
1387 out[21] = t10 - t21a;
1388 out[22] = t9a - t22;
1389 out[23] = t8 - t23a;
1390 out[24] = t7 - t24a;
1391 out[25] = t6a - t25;
1392 out[26] = t5a - t26a;
1394 out[28] = t3 - t28a;
1396 out[30] = t1 - t30a;
1421 t4 = (t0 -
t3) >> 1;
1436 #undef itxfm_wrapper
1441 #define init_itxfm(tx, sz) \
1442 dsp->itxfm_add[tx][DCT_DCT] = idct_idct_##sz##_add_c; \
1443 dsp->itxfm_add[tx][DCT_ADST] = iadst_idct_##sz##_add_c; \
1444 dsp->itxfm_add[tx][ADST_DCT] = idct_iadst_##sz##_add_c; \
1445 dsp->itxfm_add[tx][ADST_ADST] = iadst_iadst_##sz##_add_c
1447 #define init_idct(tx, nm) \
1448 dsp->itxfm_add[tx][DCT_DCT] = \
1449 dsp->itxfm_add[tx][ADST_DCT] = \
1450 dsp->itxfm_add[tx][DCT_ADST] = \
1451 dsp->itxfm_add[tx][ADST_ADST] = nm##_add_c
1464 int E,
int I,
int H,
1465 ptrdiff_t stridea, ptrdiff_t strideb,
1470 for (i = 0; i < 8; i++, dst += stridea) {
1472 int p3 = dst[strideb * -4], p2 = dst[strideb * -3];
1473 int p1 = dst[strideb * -2], p0 = dst[strideb * -1];
1474 int q0 = dst[strideb * +0], q1 = dst[strideb * +1];
1475 int q2 = dst[strideb * +2], q3 = dst[strideb * +3];
1477 int fm =
FFABS(p3 - p2) <= I &&
FFABS(p2 - p1) <= I &&
1478 FFABS(p1 - p0) <= I &&
FFABS(q1 - q0) <= I &&
1479 FFABS(q2 - q1) <= I &&
FFABS(q3 - q2) <= I &&
1480 FFABS(p0 - q0) * 2 + (
FFABS(p1 - q1) >> 1) <= E;
1481 int flat8out, flat8in;
1487 p7 = dst[strideb * -8];
1488 p6 = dst[strideb * -7];
1489 p5 = dst[strideb * -6];
1490 p4 = dst[strideb * -5];
1491 q4 = dst[strideb * +4];
1492 q5 = dst[strideb * +5];
1493 q6 = dst[strideb * +6];
1494 q7 = dst[strideb * +7];
1496 flat8out =
FFABS(p7 - p0) <= 1 &&
FFABS(p6 - p0) <= 1 &&
1497 FFABS(p5 - p0) <= 1 &&
FFABS(p4 - p0) <= 1 &&
1498 FFABS(q4 - q0) <= 1 &&
FFABS(q5 - q0) <= 1 &&
1503 flat8in =
FFABS(p3 - p0) <= 1 &&
FFABS(p2 - p0) <= 1 &&
1504 FFABS(p1 - p0) <= 1 &&
FFABS(q1 - q0) <= 1 &&
1507 if (wd >= 16 && flat8out && flat8in) {
1508 dst[strideb * -7] = (p7 + p7 + p7 + p7 + p7 + p7 + p7 + p6 * 2 +
1509 p5 + p4 + p3 + p2 + p1 + p0 + q0 + 8) >> 4;
1510 dst[strideb * -6] = (p7 + p7 + p7 + p7 + p7 + p7 + p6 + p5 * 2 +
1511 p4 + p3 + p2 + p1 + p0 + q0 + q1 + 8) >> 4;
1512 dst[strideb * -5] = (p7 + p7 + p7 + p7 + p7 + p6 + p5 + p4 * 2 +
1513 p3 + p2 + p1 + p0 + q0 + q1 + q2 + 8) >> 4;
1514 dst[strideb * -4] = (p7 + p7 + p7 + p7 + p6 + p5 + p4 + p3 * 2 +
1515 p2 + p1 + p0 + q0 + q1 + q2 + q3 + 8) >> 4;
1516 dst[strideb * -3] = (p7 + p7 + p7 + p6 + p5 + p4 + p3 + p2 * 2 +
1517 p1 + p0 + q0 + q1 + q2 + q3 + q4 + 8) >> 4;
1518 dst[strideb * -2] = (p7 + p7 + p6 + p5 + p4 + p3 + p2 + p1 * 2 +
1519 p0 + q0 + q1 + q2 + q3 + q4 + q5 + 8) >> 4;
1520 dst[strideb * -1] = (p7 + p6 + p5 + p4 + p3 + p2 + p1 + p0 * 2 +
1521 q0 + q1 + q2 + q3 + q4 + q5 + q6 + 8) >> 4;
1522 dst[strideb * +0] = (p6 + p5 + p4 + p3 + p2 + p1 + p0 + q0 * 2 +
1523 q1 + q2 + q3 + q4 + q5 + q6 + q7 + 8) >> 4;
1524 dst[strideb * +1] = (p5 + p4 + p3 + p2 + p1 + p0 + q0 + q1 * 2 +
1525 q2 + q3 + q4 + q5 + q6 + q7 + q7 + 8) >> 4;
1526 dst[strideb * +2] = (p4 + p3 + p2 + p1 + p0 + q0 + q1 + q2 * 2 +
1527 q3 + q4 + q5 + q6 + q7 + q7 + q7 + 8) >> 4;
1528 dst[strideb * +3] = (p3 + p2 + p1 + p0 + q0 + q1 + q2 + q3 * 2 +
1529 q4 + q5 + q6 + q7 + q7 + q7 + q7 + 8) >> 4;
1530 dst[strideb * +4] = (p2 + p1 + p0 + q0 + q1 + q2 + q3 + q4 * 2 +
1531 q5 + q6 + q7 + q7 + q7 + q7 + q7 + 8) >> 4;
1532 dst[strideb * +5] = (p1 + p0 + q0 + q1 + q2 + q3 + q4 + q5 * 2 +
1533 q6 + q7 + q7 + q7 + q7 + q7 + q7 + 8) >> 4;
1534 dst[strideb * +6] = (p0 + q0 + q1 + q2 + q3 + q4 + q5 + q6 * 2 +
1535 q7 + q7 + q7 + q7 + q7 + q7 + q7 + 8) >> 4;
1536 }
else if (wd >= 8 && flat8in) {
1537 dst[strideb * -3] = (p3 + p3 + p3 + 2 * p2 + p1 + p0 + q0 + 4) >> 3;
1538 dst[strideb * -2] = (p3 + p3 + p2 + 2 * p1 + p0 + q0 + q1 + 4) >> 3;
1539 dst[strideb * -1] = (p3 + p2 + p1 + 2 * p0 + q0 + q1 + q2 + 4) >> 3;
1540 dst[strideb * +0] = (p2 + p1 + p0 + 2 * q0 + q1 + q2 + q3 + 4) >> 3;
1541 dst[strideb * +1] = (p1 + p0 + q0 + 2 * q1 + q2 + q3 + q3 + 4) >> 3;
1542 dst[strideb * +2] = (p0 + q0 + q1 + 2 * q2 + q3 + q3 + q3 + 4) >> 3;
1547 int f = av_clip_int8(3 * (q0 - p0) + av_clip_int8(p1 - q1)), f1, f2;
1549 f1 =
FFMIN(f + 4, 127) >> 3;
1550 f2 =
FFMIN(f + 3, 127) >> 3;
1552 dst[strideb * -1] = av_clip_uint8(p0 + f2);
1553 dst[strideb * +0] = av_clip_uint8(q0 - f1);
1555 int f = av_clip_int8(3 * (q0 - p0)), f1, f2;
1557 f1 =
FFMIN(f + 4, 127) >> 3;
1558 f2 =
FFMIN(f + 3, 127) >> 3;
1560 dst[strideb * -1] = av_clip_uint8(p0 + f2);
1561 dst[strideb * +0] = av_clip_uint8(q0 - f1);
1564 dst[strideb * -2] = av_clip_uint8(p1 + f);
1565 dst[strideb * +1] = av_clip_uint8(q1 - f);
1571 #define lf_8_fn(dir, wd, stridea, strideb) \
1572 static void loop_filter_##dir##_##wd##_8_c(uint8_t *dst, \
1574 int E, int I, int H) \
1576 loop_filter(dst, stride, E, I, H, stridea, strideb, wd); \
1579 #define lf_8_fns(wd) \
1580 lf_8_fn(h, wd, stride, 1) \
1581 lf_8_fn(v, wd, 1, stride)
1590 #define lf_16_fn(dir, stridea) \
1591 static void loop_filter_##dir##_16_16_c(uint8_t *dst, \
1593 int E, int I, int H) \
1595 loop_filter_##dir##_16_8_c(dst, stride, E, I, H); \
1596 loop_filter_##dir##_16_8_c(dst + 8 * stridea, stride, E, I, H); \
1604 #define lf_mix_fn(dir, wd1, wd2, stridea) \
1605 static void loop_filter_##dir##_##wd1##wd2##_16_c(uint8_t *dst, \
1607 int E, int I, int H) \
1609 loop_filter_##dir##_##wd1##_8_c(dst, stride, E & 0xff, I & 0xff, H & 0xff); \
1610 loop_filter_##dir##_##wd2##_8_c(dst + 8 * stridea, stride, E >> 8, I >> 8, H >> 8); \
1613 #define lf_mix_fns(wd1, wd2) \
1614 lf_mix_fn(h, wd1, wd2, stride) \
1615 lf_mix_fn(v, wd1, wd2, 1)
1652 memcpy(dst, src, w);
1666 for (x = 0; x < w; x += 4)
1674 #define fpel_fn(type, sz) \
1675 static void type##sz##_c(uint8_t *dst, ptrdiff_t dst_stride, \
1676 const uint8_t *src, ptrdiff_t src_stride, \
1677 int h, int mx, int my) \
1679 type##_c(dst, dst_stride, src, src_stride, sz, h); \
1682 #define copy_avg_fn(sz) \
1695 static const int8_t vp9_subpel_filters[3][15][8] = {
1697 { 0, 1, -5, 126, 8, -3, 1, 0 },
1698 { -1, 3, -10, 122, 18, -6, 2, 0 },
1699 { -1, 4, -13, 118, 27, -9, 3, -1 },
1700 { -1, 4, -16, 112, 37, -11, 4, -1 },
1701 { -1, 5, -18, 105, 48, -14, 4, -1 },
1702 { -1, 5, -19, 97, 58, -16, 5, -1 },
1703 { -1, 6, -19, 88, 68, -18, 5, -1 },
1704 { -1, 6, -19, 78, 78, -19, 6, -1 },
1705 { -1, 5, -18, 68, 88, -19, 6, -1 },
1706 { -1, 5, -16, 58, 97, -19, 5, -1 },
1707 { -1, 4, -14, 48, 105, -18, 5, -1 },
1708 { -1, 4, -11, 37, 112, -16, 4, -1 },
1709 { -1, 3, -9, 27, 118, -13, 4, -1 },
1710 { 0, 2, -6, 18, 122, -10, 3, -1 },
1711 { 0, 1, -3, 8, 126, -5, 1, 0 },
1713 { -1, 3, -7, 127, 8, -3, 1, 0 },
1714 { -2, 5, -13, 125, 17, -6, 3, -1 },
1715 { -3, 7, -17, 121, 27, -10, 5, -2 },
1716 { -4, 9, -20, 115, 37, -13, 6, -2 },
1717 { -4, 10, -23, 108, 48, -16, 8, -3 },
1718 { -4, 10, -24, 100, 59, -19, 9, -3 },
1719 { -4, 11, -24, 90, 70, -21, 10, -4 },
1720 { -4, 11, -23, 80, 80, -23, 11, -4 },
1721 { -4, 10, -21, 70, 90, -24, 11, -4 },
1722 { -3, 9, -19, 59, 100, -24, 10, -4 },
1723 { -3, 8, -16, 48, 108, -23, 10, -4 },
1724 { -2, 6, -13, 37, 115, -20, 9, -4 },
1725 { -2, 5, -10, 27, 121, -17, 7, -3 },
1726 { -1, 3, -6, 17, 125, -13, 5, -2 },
1727 { 0, 1, -3, 8, 127, -7, 3, -1 },
1729 { -3, -1, 32, 64, 38, 1, -3, 0 },
1730 { -2, -2, 29, 63, 41, 2, -3, 0 },
1731 { -2, -2, 26, 63, 43, 4, -4, 0 },
1732 { -2, -3, 24, 62, 46, 5, -4, 0 },
1733 { -2, -3, 21, 60, 49, 7, -4, 0 },
1734 { -1, -4, 18, 59, 51, 9, -4, 0 },
1735 { -1, -4, 16, 57, 53, 12, -4, -1 },
1736 { -1, -4, 14, 55, 55, 14, -4, -1 },
1737 { -1, -4, 12, 53, 57, 16, -4, -1 },
1738 { 0, -4, 9, 51, 59, 18, -4, -1 },
1739 { 0, -4, 7, 49, 60, 21, -3, -2 },
1740 { 0, -4, 5, 46, 62, 24, -3, -2 },
1741 { 0, -4, 4, 43, 63, 26, -2, -2 },
1742 { 0, -3, 2, 41, 63, 29, -2, -2 },
1743 { 0, -3, 1, 38, 64, 32, -1, -3 },
1747 #define FILTER_8TAP(src, x, F, stride) \
1748 av_clip_uint8((F[0] * src[x + -3 * stride] + \
1749 F[1] * src[x + -2 * stride] + \
1750 F[2] * src[x + -1 * stride] + \
1751 F[3] * src[x + +0 * stride] + \
1752 F[4] * src[x + +1 * stride] + \
1753 F[5] * src[x + +2 * stride] + \
1754 F[6] * src[x + +3 * stride] + \
1755 F[7] * src[x + +4 * stride] + 64) >> 7)
1759 int w,
int h, ptrdiff_t ds,
1760 const int8_t *
filter,
int avg)
1765 for (x = 0; x < w; x++)
1767 dst[x] = (dst[x] +
FILTER_8TAP(src, x, filter, ds) + 1) >> 1;
1777 #define filter_8tap_1d_fn(opn, opa, dir, ds) \
1778 static av_noinline void opn##_8tap_1d_##dir##_c(uint8_t *dst, ptrdiff_t dst_stride, \
1779 const uint8_t *src, ptrdiff_t src_stride, \
1780 int w, int h, const int8_t *filter) \
1782 do_8tap_1d_c(dst, dst_stride, src, src_stride, w, h, ds, filter, opa); \
1790 #undef filter_8tap_1d_fn
1794 int w,
int h,
const int8_t *filterx,
1795 const int8_t *filtery,
int avg)
1798 uint8_t tmp[64 * 71], *tmp_ptr = tmp;
1800 src -= src_stride * 3;
1804 for (x = 0; x < w; x++)
1811 tmp_ptr = tmp + 64 * 3;
1815 for (x = 0; x < w; x++)
1817 dst[x] = (dst[x] +
FILTER_8TAP(tmp_ptr, x, filtery, 64) + 1) >> 1;
1827 #define filter_8tap_2d_fn(opn, opa) \
1828 static av_noinline void opn##_8tap_2d_hv_c(uint8_t *dst, ptrdiff_t dst_stride, \
1829 const uint8_t *src, ptrdiff_t src_stride, \
1830 int w, int h, const int8_t *filterx, \
1831 const int8_t *filtery) \
1833 do_8tap_2d_c(dst, dst_stride, src, src_stride, w, h, filterx, filtery, opa); \
1839 #undef filter_8tap_2d_fn
1843 #define filter_fn_1d(sz, dir, dir_m, type, type_idx, avg) \
1844 static void avg##_8tap_##type##_##sz##dir##_c(uint8_t *dst, ptrdiff_t dst_stride, \
1845 const uint8_t *src, ptrdiff_t src_stride, \
1846 int h, int mx, int my) \
1848 avg##_8tap_1d_##dir##_c(dst, dst_stride, src, src_stride, sz, h, \
1849 vp9_subpel_filters[type_idx][dir_m - 1]); \
1852 #define filter_fn_2d(sz, type, type_idx, avg) \
1853 static void avg##_8tap_##type##_##sz##hv_c(uint8_t *dst, ptrdiff_t dst_stride, \
1854 const uint8_t *src, ptrdiff_t src_stride, \
1855 int h, int mx, int my) \
1857 avg##_8tap_2d_hv_c(dst, dst_stride, src, src_stride, sz, h, \
1858 vp9_subpel_filters[type_idx][mx - 1], \
1859 vp9_subpel_filters[type_idx][my - 1]); \
1862 #define FILTER_BILIN(src, x, mxy, stride) \
1863 (src[x] + ((mxy * (src[x + stride] - src[x]) + 8) >> 4))
1867 int w,
int h, ptrdiff_t ds,
int mxy,
int avg)
1872 for (x = 0; x < w; x++)
1874 dst[x] = (dst[x] +
FILTER_BILIN(src, x, mxy, ds) + 1) >> 1;
1884 #define bilin_1d_fn(opn, opa, dir, ds) \
1885 static av_noinline void opn##_bilin_1d_##dir##_c(uint8_t *dst, ptrdiff_t dst_stride, \
1886 const uint8_t *src, ptrdiff_t src_stride, \
1887 int w, int h, int mxy) \
1889 do_bilin_1d_c(dst, dst_stride, src, src_stride, w, h, ds, mxy, opa); \
1901 int w,
int h,
int mx,
int my,
int avg)
1903 uint8_t tmp[64 * 65], *tmp_ptr = tmp;
1909 for (x = 0; x < w; x++)
1920 for (x = 0; x < w; x++)
1922 dst[x] = (dst[x] +
FILTER_BILIN(tmp_ptr, x, my, 64) + 1) >> 1;
1932 #define bilin_2d_fn(opn, opa) \
1933 static av_noinline void opn##_bilin_2d_hv_c(uint8_t *dst, ptrdiff_t dst_stride, \
1934 const uint8_t *src, ptrdiff_t src_stride, \
1935 int w, int h, int mx, int my) \
1937 do_bilin_2d_c(dst, dst_stride, src, src_stride, w, h, mx, my, opa); \
1947 #define bilinf_fn_1d(sz, dir, dir_m, avg) \
1948 static void avg##_bilin_##sz##dir##_c(uint8_t *dst, ptrdiff_t dst_stride, \
1949 const uint8_t *src, ptrdiff_t src_stride, \
1950 int h, int mx, int my) \
1952 avg##_bilin_1d_##dir##_c(dst, dst_stride, src, src_stride, sz, h, dir_m); \
1955 #define bilinf_fn_2d(sz, avg) \
1956 static void avg##_bilin_##sz##hv_c(uint8_t *dst, ptrdiff_t dst_stride, \
1957 const uint8_t *src, ptrdiff_t src_stride, \
1958 int h, int mx, int my) \
1960 avg##_bilin_2d_hv_c(dst, dst_stride, src, src_stride, sz, h, mx, my); \
1963 #define filter_fn(sz, avg) \
1964 filter_fn_1d(sz, h, mx, regular, FILTER_8TAP_REGULAR, avg) \
1965 filter_fn_1d(sz, v, my, regular, FILTER_8TAP_REGULAR, avg) \
1966 filter_fn_2d(sz, regular, FILTER_8TAP_REGULAR, avg) \
1967 filter_fn_1d(sz, h, mx, smooth, FILTER_8TAP_SMOOTH, avg) \
1968 filter_fn_1d(sz, v, my, smooth, FILTER_8TAP_SMOOTH, avg) \
1969 filter_fn_2d(sz, smooth, FILTER_8TAP_SMOOTH, avg) \
1970 filter_fn_1d(sz, h, mx, sharp, FILTER_8TAP_SHARP, avg) \
1971 filter_fn_1d(sz, v, my, sharp, FILTER_8TAP_SHARP, avg) \
1972 filter_fn_2d(sz, sharp, FILTER_8TAP_SHARP, avg) \
1973 bilinf_fn_1d(sz, h, mx, avg) \
1974 bilinf_fn_1d(sz, v, my, avg) \
1975 bilinf_fn_2d(sz, avg)
1977 #define filter_fn_set(avg) \
1978 filter_fn(64, avg) \
1979 filter_fn(32, avg) \
1980 filter_fn(16, avg) \
1988 #undef filter_fn_set
1996 #define init_fpel(idx1, idx2, sz, type) \
1997 dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][0][0] = type##sz##_c; \
1998 dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][0][0] = type##sz##_c; \
1999 dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][0][0] = type##sz##_c; \
2000 dsp->mc[idx1][FILTER_BILINEAR ][idx2][0][0] = type##sz##_c
2002 #define init_copy_avg(idx, sz) \
2003 init_fpel(idx, 0, sz, copy); \
2004 init_fpel(idx, 1, sz, avg)
2012 #undef init_copy_avg
2015 #define init_subpel1(idx1, idx2, idxh, idxv, sz, dir, type) \
2016 dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][idxh][idxv] = type##_8tap_smooth_##sz##dir##_c; \
2017 dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][idxh][idxv] = type##_8tap_regular_##sz##dir##_c; \
2018 dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][idxh][idxv] = type##_8tap_sharp_##sz##dir##_c; \
2019 dsp->mc[idx1][FILTER_BILINEAR ][idx2][idxh][idxv] = type##_bilin_##sz##dir##_c
2021 #define init_subpel2(idx, idxh, idxv, dir, type) \
2022 init_subpel1(0, idx, idxh, idxv, 64, dir, type); \
2023 init_subpel1(1, idx, idxh, idxv, 32, dir, type); \
2024 init_subpel1(2, idx, idxh, idxv, 16, dir, type); \
2025 init_subpel1(3, idx, idxh, idxv, 8, dir, type); \
2026 init_subpel1(4, idx, idxh, idxv, 4, dir, type)
2028 #define init_subpel3(idx, type) \
2029 init_subpel2(idx, 1, 1, hv, type); \
2030 init_subpel2(idx, 0, 1, v, type); \
2031 init_subpel2(idx, 1, 0, h, type)
2043 vp9dsp_intrapred_init(dsp);
2044 vp9dsp_itxfm_init(dsp);
2045 vp9dsp_loopfilter_init(dsp);
2046 vp9dsp_mc_init(dsp);