ref: 833ad89f721c0bea15b2114b72cd940a2d4279d4
parent: 4ec5569f506880c33fd4926330228d77e9c7689a
parent: 7a85ba8ac3f9ef3725b88f51ea4215d146a84ee7
author: Dmitry Kovalev <[email protected]>
date: Wed Apr 16 10:07:46 EDT 2014
Merge "Adding sad function generation macros."
--- a/vp9/encoder/vp9_sad.c
+++ b/vp9/encoder/vp9_sad.c
@@ -33,292 +33,105 @@
return sad;
}
-#define sad_mxn_func(m, n) \
-unsigned int vp9_sad##m##x##n##_c(const uint8_t *src_ptr, int src_stride, \
- const uint8_t *ref_ptr, int ref_stride, \
+#define sadMxN(m, n) \
+unsigned int vp9_sad##m##x##n##_c(const uint8_t *src, int src_stride, \
+ const uint8_t *ref, int ref_stride, \
unsigned int max_sad) { \
- return sad(src_ptr, src_stride, ref_ptr, ref_stride, m, n); \
+ return sad(src, src_stride, ref, ref_stride, m, n); \
} \
-unsigned int vp9_sad##m##x##n##_avg_c(const uint8_t *src_ptr, int src_stride, \
- const uint8_t *ref_ptr, int ref_stride, \
+unsigned int vp9_sad##m##x##n##_avg_c(const uint8_t *src, int src_stride, \
+ const uint8_t *ref, int ref_stride, \
const uint8_t *second_pred, \
unsigned int max_sad) { \
uint8_t comp_pred[m * n]; \
- vp9_comp_avg_pred(comp_pred, second_pred, m, n, ref_ptr, ref_stride); \
- return sad(src_ptr, src_stride, comp_pred, m, m, n); \
+ vp9_comp_avg_pred(comp_pred, second_pred, m, n, ref, ref_stride); \
+ return sad(src, src_stride, comp_pred, m, m, n); \
}
-sad_mxn_func(64, 64)
-sad_mxn_func(64, 32)
-sad_mxn_func(32, 64)
-sad_mxn_func(32, 32)
-sad_mxn_func(32, 16)
-sad_mxn_func(16, 32)
-sad_mxn_func(16, 16)
-sad_mxn_func(16, 8)
-sad_mxn_func(8, 16)
-sad_mxn_func(8, 8)
-sad_mxn_func(8, 4)
-sad_mxn_func(4, 8)
-sad_mxn_func(4, 4)
-
-void vp9_sad64x32x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad64x32(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
+#define sadMxNxK(m, n, k) \
+void vp9_sad##m##x##n##x##k##_c(const uint8_t *src, int src_stride, \
+ const uint8_t *ref, int ref_stride, \
+ unsigned int *sads) { \
+ int i; \
+ for (i = 0; i < k; ++i) \
+ sads[i] = vp9_sad##m##x##n##_c(src, src_stride, &ref[i], ref_stride, \
+ 0x7fffffff); \
}
-void vp9_sad32x64x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad32x64(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
+#define sadMxNx4D(m, n) \
+void vp9_sad##m##x##n##x4d_c(const uint8_t *src, int src_stride, \
+ const uint8_t *const refs[], int ref_stride, \
+ unsigned int *sads) { \
+ int i; \
+ for (i = 0; i < 4; ++i) \
+ sads[i] = vp9_sad##m##x##n##_c(src, src_stride, refs[i], ref_stride, \
+ 0x7fffffff); \
}
-void vp9_sad32x16x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad32x16(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
+// 64x64
+sadMxN(64, 64)
+sadMxNxK(64, 64, 3)
+sadMxNxK(64, 64, 8)
+sadMxNx4D(64, 64)
-void vp9_sad16x32x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad16x32(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
+// 64x32
+sadMxN(64, 32)
+sadMxNx4D(64, 32)
-void vp9_sad64x64x3_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 3; ++i)
- sad_array[i] = vp9_sad64x64(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
+// 32x64
+sadMxN(32, 64)
+sadMxNx4D(32, 64)
-void vp9_sad32x32x3_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 3; ++i)
- sad_array[i] = vp9_sad32x32(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
+// 32x32
+sadMxN(32, 32)
+sadMxNxK(32, 32, 3)
+sadMxNxK(32, 32, 8)
+sadMxNx4D(32, 32)
-void vp9_sad64x64x8_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 8; ++i)
- sad_array[i] = vp9_sad64x64(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
+// 32x16
+sadMxN(32, 16)
+sadMxNx4D(32, 16)
-void vp9_sad32x32x8_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 8; ++i)
- sad_array[i] = vp9_sad32x32(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
+// 16x32
+sadMxN(16, 32)
+sadMxNx4D(16, 32)
-void vp9_sad16x16x3_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 3; ++i)
- sad_array[i] = vp9_sad16x16(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
+// 16x16
+sadMxN(16, 16)
+sadMxNxK(16, 16, 3)
+sadMxNxK(16, 16, 8)
+sadMxNx4D(16, 16)
-void vp9_sad16x16x8_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- uint32_t *sad_array) {
- int i;
- for (i = 0; i < 8; ++i)
- sad_array[i] = vp9_sad16x16(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
+// 16x8
+sadMxN(16, 8)
+sadMxNxK(16, 8, 3)
+sadMxNxK(16, 8, 8)
+sadMxNx4D(16, 8)
-void vp9_sad16x8x3_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 3; ++i)
- sad_array[i] = vp9_sad16x8(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
+// 8x16
+sadMxN(8, 16)
+sadMxNxK(8, 16, 3)
+sadMxNxK(8, 16, 8)
+sadMxNx4D(8, 16)
-void vp9_sad16x8x8_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- uint32_t *sad_array) {
- int i;
- for (i = 0; i < 8; ++i)
- sad_array[i] = vp9_sad16x8(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
+// 8x8
+sadMxN(8, 8)
+sadMxNxK(8, 8, 3)
+sadMxNxK(8, 8, 8)
+sadMxNx4D(8, 8)
-void vp9_sad8x8x3_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 3; ++i)
- sad_array[i] = vp9_sad8x8(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
+// 8x4
+sadMxN(8, 4)
+sadMxNxK(8, 4, 8)
+sadMxNx4D(8, 4)
-void vp9_sad8x8x8_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- uint32_t *sad_array) {
- int i;
- for (i = 0; i < 8; ++i)
- sad_array[i] = vp9_sad8x8(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
+// 4x8
+sadMxN(4, 8)
+sadMxNxK(4, 8, 8)
+sadMxNx4D(4, 8)
-void vp9_sad8x16x3_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 3; ++i)
- sad_array[i] = vp9_sad8x16(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad8x16x8_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- uint32_t *sad_array) {
- int i;
- for (i = 0; i < 8; ++i)
- sad_array[i] = vp9_sad8x16(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad4x4x3_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 3; ++i)
- sad_array[i] = vp9_sad4x4(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad4x4x8_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- uint32_t *sad_array) {
- int i;
- for (i = 0; i < 8; ++i)
- sad_array[i] = vp9_sad4x4(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad64x64x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad64x64(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad32x32x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad32x32(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad16x16x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad16x16(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad16x8x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad16x8(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad8x8x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad8x8(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad8x16x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad8x16(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad8x4x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad8x4(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad8x4x8_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- uint32_t *sad_array) {
- int i;
- for (i = 0; i < 8; ++i)
- sad_array[i] = vp9_sad8x4(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad4x8x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad4x8(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad4x8x8_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t *ref_ptr, int ref_stride,
- uint32_t *sad_array) {
- int i;
- for (i = 0; i < 8; ++i)
- sad_array[i] = vp9_sad4x8(src_ptr, src_stride, ref_ptr + i, ref_stride,
- 0x7fffffff);
-}
-
-void vp9_sad4x4x4d_c(const uint8_t *src_ptr, int src_stride,
- const uint8_t* const ref_ptr[], int ref_stride,
- unsigned int *sad_array) {
- int i;
- for (i = 0; i < 4; ++i)
- sad_array[i] = vp9_sad4x4(src_ptr, src_stride, ref_ptr[i], ref_stride,
- 0x7fffffff);
-}
+// 4x4
+sadMxN(4, 4)
+sadMxNxK(4, 4, 3)
+sadMxNxK(4, 4, 8)
+sadMxNx4D(4, 4)