Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: source/libvpx/vpx_dsp/sad.c

Issue 1124333011: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: only update to last nights LKGR Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/vpx_dsp/arm/sad_neon.c ('k') | source/libvpx/vpx_dsp/vpx_dsp.mk » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <stdlib.h> 11 #include <stdlib.h>
12 12
13 #include "./vp9_rtcd.h"
14 #include "./vpx_config.h" 13 #include "./vpx_config.h"
14 #include "./vpx_dsp_rtcd.h"
15 15
16 #include "vpx/vpx_integer.h" 16 #include "vpx/vpx_integer.h"
17
17 #if CONFIG_VP9_HIGHBITDEPTH 18 #if CONFIG_VP9_HIGHBITDEPTH
18 #include "vp9/common/vp9_common.h" 19 #include "vp9/common/vp9_common.h"
19 #endif 20 #endif // CONFIG_VP9_HIGHBITDEPTH
20 #include "vp9/encoder/vp9_variance.h" 21 // Temporary ...
22 #define ROUND_POWER_OF_TWO(value, n) \
23 (((value) + (1 << ((n) - 1))) >> (n))
21 24
25 /* Sum the difference between every corresponding element of the buffers. */
22 static INLINE unsigned int sad(const uint8_t *a, int a_stride, 26 static INLINE unsigned int sad(const uint8_t *a, int a_stride,
23 const uint8_t *b, int b_stride, 27 const uint8_t *b, int b_stride,
24 int width, int height) { 28 int width, int height) {
25 int y, x; 29 int y, x;
26 unsigned int sad = 0; 30 unsigned int sad = 0;
27 31
28 for (y = 0; y < height; y++) { 32 for (y = 0; y < height; y++) {
29 for (x = 0; x < width; x++) 33 for (x = 0; x < width; x++)
30 sad += abs(a[x] - b[x]); 34 sad += abs(a[x] - b[x]);
31 35
32 a += a_stride; 36 a += a_stride;
33 b += b_stride; 37 b += b_stride;
34 } 38 }
35 return sad; 39 return sad;
36 } 40 }
37 41
42 /* Remove dependency on vp9 variance function by duplicating vp9_comp_avg_pred.
43 * The function averages every corresponding element of the buffers and stores
44 * the value in a third buffer, comp_pred.
45 * pred and comp_pred are assumed to have stride = width
46 * In the usage below comp_pred is a local array.
47 */
48 static INLINE void avg_pred(uint8_t *comp_pred, const uint8_t *pred, int width,
49 int height, const uint8_t *ref, int ref_stride) {
50 int i, j;
51
52 for (i = 0; i < height; i++) {
53 for (j = 0; j < width; j++) {
54 const int tmp = pred[j] + ref[j];
55 comp_pred[j] = ROUND_POWER_OF_TWO(tmp, 1);
56 }
57 comp_pred += width;
58 pred += width;
59 ref += ref_stride;
60 }
61 }
62
63 #if CONFIG_VP9_HIGHBITDEPTH
64 static INLINE void highbd_avg_pred(uint16_t *comp_pred, const uint8_t *pred8,
65 int width, int height, const uint8_t *ref8,
66 int ref_stride) {
67 int i, j;
68 uint16_t *pred = CONVERT_TO_SHORTPTR(pred8);
69 uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
70 for (i = 0; i < height; i++) {
71 for (j = 0; j < width; j++) {
72 const int tmp = pred[j] + ref[j];
73 comp_pred[j] = ROUND_POWER_OF_TWO(tmp, 1);
74 }
75 comp_pred += width;
76 pred += width;
77 ref += ref_stride;
78 }
79 }
80 #endif // CONFIG_VP9_HIGHBITDEPTH
81
38 #define sadMxN(m, n) \ 82 #define sadMxN(m, n) \
39 unsigned int vp9_sad##m##x##n##_c(const uint8_t *src, int src_stride, \ 83 unsigned int vpx_sad##m##x##n##_c(const uint8_t *src, int src_stride, \
40 const uint8_t *ref, int ref_stride) { \ 84 const uint8_t *ref, int ref_stride) { \
41 return sad(src, src_stride, ref, ref_stride, m, n); \ 85 return sad(src, src_stride, ref, ref_stride, m, n); \
42 } \ 86 } \
43 unsigned int vp9_sad##m##x##n##_avg_c(const uint8_t *src, int src_stride, \ 87 unsigned int vpx_sad##m##x##n##_avg_c(const uint8_t *src, int src_stride, \
44 const uint8_t *ref, int ref_stride, \ 88 const uint8_t *ref, int ref_stride, \
45 const uint8_t *second_pred) { \ 89 const uint8_t *second_pred) { \
46 uint8_t comp_pred[m * n]; \ 90 uint8_t comp_pred[m * n]; \
47 vp9_comp_avg_pred(comp_pred, second_pred, m, n, ref, ref_stride); \ 91 avg_pred(comp_pred, second_pred, m, n, ref, ref_stride); \
48 return sad(src, src_stride, comp_pred, m, m, n); \ 92 return sad(src, src_stride, comp_pred, m, m, n); \
49 } 93 }
50 94
95 // depending on call sites, pass **ref_array to avoid & in subsequent call and
96 // de-dup with 4D below.
51 #define sadMxNxK(m, n, k) \ 97 #define sadMxNxK(m, n, k) \
52 void vp9_sad##m##x##n##x##k##_c(const uint8_t *src, int src_stride, \ 98 void vpx_sad##m##x##n##x##k##_c(const uint8_t *src, int src_stride, \
53 const uint8_t *ref, int ref_stride, \ 99 const uint8_t *ref_array, int ref_stride, \
54 unsigned int *sads) { \ 100 uint32_t *sad_array) { \
55 int i; \ 101 int i; \
56 for (i = 0; i < k; ++i) \ 102 for (i = 0; i < k; ++i) \
57 sads[i] = vp9_sad##m##x##n##_c(src, src_stride, &ref[i], ref_stride); \ 103 sad_array[i] = vpx_sad##m##x##n##_c(src, src_stride, &ref_array[i], ref_stri de); \
58 } 104 }
59 105
106 // This appears to be equivalent to the above when k == 4 and refs is const
60 #define sadMxNx4D(m, n) \ 107 #define sadMxNx4D(m, n) \
61 void vp9_sad##m##x##n##x4d_c(const uint8_t *src, int src_stride, \ 108 void vpx_sad##m##x##n##x4d_c(const uint8_t *src, int src_stride, \
62 const uint8_t *const refs[], int ref_stride, \ 109 const uint8_t *const ref_array[], int ref_stride, \
63 unsigned int *sads) { \ 110 uint32_t *sad_array) { \
64 int i; \ 111 int i; \
65 for (i = 0; i < 4; ++i) \ 112 for (i = 0; i < 4; ++i) \
66 sads[i] = vp9_sad##m##x##n##_c(src, src_stride, refs[i], ref_stride); \ 113 sad_array[i] = vpx_sad##m##x##n##_c(src, src_stride, ref_array[i], ref_strid e); \
67 } 114 }
68 115
69 // 64x64 116 // 64x64
70 sadMxN(64, 64) 117 sadMxN(64, 64)
71 sadMxNxK(64, 64, 3) 118 sadMxNxK(64, 64, 3)
72 sadMxNxK(64, 64, 8) 119 sadMxNxK(64, 64, 8)
73 sadMxNx4D(64, 64) 120 sadMxNx4D(64, 64)
74 121
75 // 64x32 122 // 64x32
76 sadMxN(64, 32) 123 sadMxN(64, 32)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 for (x = 0; x < width; x++) 209 for (x = 0; x < width; x++)
163 sad += abs(a[x] - b[x]); 210 sad += abs(a[x] - b[x]);
164 211
165 a += a_stride; 212 a += a_stride;
166 b += b_stride; 213 b += b_stride;
167 } 214 }
168 return sad; 215 return sad;
169 } 216 }
170 217
171 #define highbd_sadMxN(m, n) \ 218 #define highbd_sadMxN(m, n) \
172 unsigned int vp9_highbd_sad##m##x##n##_c(const uint8_t *src, int src_stride, \ 219 unsigned int vpx_highbd_sad##m##x##n##_c(const uint8_t *src, int src_stride, \
173 const uint8_t *ref, int ref_stride) { \ 220 const uint8_t *ref, int ref_stride) { \
174 return highbd_sad(src, src_stride, ref, ref_stride, m, n); \ 221 return highbd_sad(src, src_stride, ref, ref_stride, m, n); \
175 } \ 222 } \
176 unsigned int vp9_highbd_sad##m##x##n##_avg_c(const uint8_t *src, \ 223 unsigned int vpx_highbd_sad##m##x##n##_avg_c(const uint8_t *src, \
177 int src_stride, \ 224 int src_stride, \
178 const uint8_t *ref, \ 225 const uint8_t *ref, \
179 int ref_stride, \ 226 int ref_stride, \
180 const uint8_t *second_pred) { \ 227 const uint8_t *second_pred) { \
181 uint16_t comp_pred[m * n]; \ 228 uint16_t comp_pred[m * n]; \
182 vp9_highbd_comp_avg_pred(comp_pred, second_pred, m, n, ref, ref_stride); \ 229 highbd_avg_pred(comp_pred, second_pred, m, n, ref, ref_stride); \
183 return highbd_sadb(src, src_stride, comp_pred, m, m, n); \ 230 return highbd_sadb(src, src_stride, comp_pred, m, m, n); \
184 } 231 }
185 232
186 #define highbd_sadMxNxK(m, n, k) \ 233 #define highbd_sadMxNxK(m, n, k) \
187 void vp9_highbd_sad##m##x##n##x##k##_c(const uint8_t *src, int src_stride, \ 234 void vpx_highbd_sad##m##x##n##x##k##_c(const uint8_t *src, int src_stride, \
188 const uint8_t *ref, int ref_stride, \ 235 const uint8_t *ref_array, int ref_stride, \
189 unsigned int *sads) { \ 236 uint32_t *sad_array) { \
190 int i; \ 237 int i; \
191 for (i = 0; i < k; ++i) { \ 238 for (i = 0; i < k; ++i) { \
192 sads[i] = vp9_highbd_sad##m##x##n##_c(src, src_stride, &ref[i], \ 239 sad_array[i] = vpx_highbd_sad##m##x##n##_c(src, src_stride, &ref_array[i], \
193 ref_stride); \ 240 ref_stride); \
194 } \ 241 } \
195 } 242 }
196 243
197 #define highbd_sadMxNx4D(m, n) \ 244 #define highbd_sadMxNx4D(m, n) \
198 void vp9_highbd_sad##m##x##n##x4d_c(const uint8_t *src, int src_stride, \ 245 void vpx_highbd_sad##m##x##n##x4d_c(const uint8_t *src, int src_stride, \
199 const uint8_t *const refs[], \ 246 const uint8_t *const ref_array[], \
200 int ref_stride, unsigned int *sads) { \ 247 int ref_stride, uint32_t *sad_array) { \
201 int i; \ 248 int i; \
202 for (i = 0; i < 4; ++i) { \ 249 for (i = 0; i < 4; ++i) { \
203 sads[i] = vp9_highbd_sad##m##x##n##_c(src, src_stride, refs[i], \ 250 sad_array[i] = vpx_highbd_sad##m##x##n##_c(src, src_stride, ref_array[i], \
204 ref_stride); \ 251 ref_stride); \
205 } \ 252 } \
206 } 253 }
207 254
208 // 64x64 255 // 64x64
209 highbd_sadMxN(64, 64) 256 highbd_sadMxN(64, 64)
210 highbd_sadMxNxK(64, 64, 3) 257 highbd_sadMxNxK(64, 64, 3)
211 highbd_sadMxNxK(64, 64, 8) 258 highbd_sadMxNxK(64, 64, 8)
212 highbd_sadMxNx4D(64, 64) 259 highbd_sadMxNx4D(64, 64)
213 260
214 // 64x32 261 // 64x32
215 highbd_sadMxN(64, 32) 262 highbd_sadMxN(64, 32)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 highbd_sadMxNxK(4, 8, 8) 314 highbd_sadMxNxK(4, 8, 8)
268 highbd_sadMxNx4D(4, 8) 315 highbd_sadMxNx4D(4, 8)
269 316
270 // 4x4 317 // 4x4
271 highbd_sadMxN(4, 4) 318 highbd_sadMxN(4, 4)
272 highbd_sadMxNxK(4, 4, 3) 319 highbd_sadMxNxK(4, 4, 3)
273 highbd_sadMxNxK(4, 4, 8) 320 highbd_sadMxNxK(4, 4, 8)
274 highbd_sadMxNx4D(4, 4) 321 highbd_sadMxNx4D(4, 4)
275 322
276 #endif // CONFIG_VP9_HIGHBITDEPTH 323 #endif // CONFIG_VP9_HIGHBITDEPTH
OLDNEW
« no previous file with comments | « source/libvpx/vpx_dsp/arm/sad_neon.c ('k') | source/libvpx/vpx_dsp/vpx_dsp.mk » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698