media/libvpx/vp8/common/x86/variance_mmx.c

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /*
michael@0 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license
michael@0 5 * that can be found in the LICENSE file in the root of the source
michael@0 6 * tree. An additional intellectual property rights grant can be found
michael@0 7 * in the file PATENTS. All contributing project authors may
michael@0 8 * be found in the AUTHORS file in the root of the source tree.
michael@0 9 */
michael@0 10
michael@0 11 #include "vpx_config.h"
michael@0 12 #include "vp8/common/variance.h"
michael@0 13 #include "vp8/common/pragmas.h"
michael@0 14 #include "vpx_ports/mem.h"
michael@0 15 #include "vp8/common/x86/filter_x86.h"
michael@0 16
michael@0 17 extern void filter_block1d_h6_mmx
michael@0 18 (
michael@0 19 const unsigned char *src_ptr,
michael@0 20 unsigned short *output_ptr,
michael@0 21 unsigned int src_pixels_per_line,
michael@0 22 unsigned int pixel_step,
michael@0 23 unsigned int output_height,
michael@0 24 unsigned int output_width,
michael@0 25 short *filter
michael@0 26 );
michael@0 27 extern void filter_block1d_v6_mmx
michael@0 28 (
michael@0 29 const short *src_ptr,
michael@0 30 unsigned char *output_ptr,
michael@0 31 unsigned int pixels_per_line,
michael@0 32 unsigned int pixel_step,
michael@0 33 unsigned int output_height,
michael@0 34 unsigned int output_width,
michael@0 35 short *filter
michael@0 36 );
michael@0 37
michael@0 38 extern unsigned int vp8_get_mb_ss_mmx(const short *src_ptr);
michael@0 39 extern unsigned int vp8_get8x8var_mmx
michael@0 40 (
michael@0 41 const unsigned char *src_ptr,
michael@0 42 int source_stride,
michael@0 43 const unsigned char *ref_ptr,
michael@0 44 int recon_stride,
michael@0 45 unsigned int *SSE,
michael@0 46 int *Sum
michael@0 47 );
michael@0 48 extern unsigned int vp8_get4x4var_mmx
michael@0 49 (
michael@0 50 const unsigned char *src_ptr,
michael@0 51 int source_stride,
michael@0 52 const unsigned char *ref_ptr,
michael@0 53 int recon_stride,
michael@0 54 unsigned int *SSE,
michael@0 55 int *Sum
michael@0 56 );
michael@0 57 extern void vp8_filter_block2d_bil4x4_var_mmx
michael@0 58 (
michael@0 59 const unsigned char *ref_ptr,
michael@0 60 int ref_pixels_per_line,
michael@0 61 const unsigned char *src_ptr,
michael@0 62 int src_pixels_per_line,
michael@0 63 const short *HFilter,
michael@0 64 const short *VFilter,
michael@0 65 int *sum,
michael@0 66 unsigned int *sumsquared
michael@0 67 );
michael@0 68 extern void vp8_filter_block2d_bil_var_mmx
michael@0 69 (
michael@0 70 const unsigned char *ref_ptr,
michael@0 71 int ref_pixels_per_line,
michael@0 72 const unsigned char *src_ptr,
michael@0 73 int src_pixels_per_line,
michael@0 74 unsigned int Height,
michael@0 75 const short *HFilter,
michael@0 76 const short *VFilter,
michael@0 77 int *sum,
michael@0 78 unsigned int *sumsquared
michael@0 79 );
michael@0 80
michael@0 81
michael@0 82 unsigned int vp8_variance4x4_mmx(
michael@0 83 const unsigned char *src_ptr,
michael@0 84 int source_stride,
michael@0 85 const unsigned char *ref_ptr,
michael@0 86 int recon_stride,
michael@0 87 unsigned int *sse)
michael@0 88 {
michael@0 89 unsigned int var;
michael@0 90 int avg;
michael@0 91
michael@0 92 vp8_get4x4var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg) ;
michael@0 93 *sse = var;
michael@0 94 return (var - (((unsigned int)avg * avg) >> 4));
michael@0 95
michael@0 96 }
michael@0 97
michael@0 98 unsigned int vp8_variance8x8_mmx(
michael@0 99 const unsigned char *src_ptr,
michael@0 100 int source_stride,
michael@0 101 const unsigned char *ref_ptr,
michael@0 102 int recon_stride,
michael@0 103 unsigned int *sse)
michael@0 104 {
michael@0 105 unsigned int var;
michael@0 106 int avg;
michael@0 107
michael@0 108 vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &var, &avg) ;
michael@0 109 *sse = var;
michael@0 110
michael@0 111 return (var - (((unsigned int)avg * avg) >> 6));
michael@0 112
michael@0 113 }
michael@0 114
michael@0 115 unsigned int vp8_mse16x16_mmx(
michael@0 116 const unsigned char *src_ptr,
michael@0 117 int source_stride,
michael@0 118 const unsigned char *ref_ptr,
michael@0 119 int recon_stride,
michael@0 120 unsigned int *sse)
michael@0 121 {
michael@0 122 unsigned int sse0, sse1, sse2, sse3, var;
michael@0 123 int sum0, sum1, sum2, sum3;
michael@0 124
michael@0 125
michael@0 126 vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
michael@0 127 vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
michael@0 128 vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2) ;
michael@0 129 vp8_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3);
michael@0 130
michael@0 131 var = sse0 + sse1 + sse2 + sse3;
michael@0 132 *sse = var;
michael@0 133 return var;
michael@0 134 }
michael@0 135
michael@0 136
michael@0 137 unsigned int vp8_variance16x16_mmx(
michael@0 138 const unsigned char *src_ptr,
michael@0 139 int source_stride,
michael@0 140 const unsigned char *ref_ptr,
michael@0 141 int recon_stride,
michael@0 142 unsigned int *sse)
michael@0 143 {
michael@0 144 unsigned int sse0, sse1, sse2, sse3, var;
michael@0 145 int sum0, sum1, sum2, sum3, avg;
michael@0 146
michael@0 147
michael@0 148 vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
michael@0 149 vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
michael@0 150 vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse2, &sum2) ;
michael@0 151 vp8_get8x8var_mmx(src_ptr + 8 * source_stride + 8, source_stride, ref_ptr + 8 * recon_stride + 8, recon_stride, &sse3, &sum3);
michael@0 152
michael@0 153 var = sse0 + sse1 + sse2 + sse3;
michael@0 154 avg = sum0 + sum1 + sum2 + sum3;
michael@0 155 *sse = var;
michael@0 156 return (var - (((unsigned int)avg * avg) >> 8));
michael@0 157 }
michael@0 158
michael@0 159 unsigned int vp8_variance16x8_mmx(
michael@0 160 const unsigned char *src_ptr,
michael@0 161 int source_stride,
michael@0 162 const unsigned char *ref_ptr,
michael@0 163 int recon_stride,
michael@0 164 unsigned int *sse)
michael@0 165 {
michael@0 166 unsigned int sse0, sse1, var;
michael@0 167 int sum0, sum1, avg;
michael@0 168
michael@0 169 vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
michael@0 170 vp8_get8x8var_mmx(src_ptr + 8, source_stride, ref_ptr + 8, recon_stride, &sse1, &sum1);
michael@0 171
michael@0 172 var = sse0 + sse1;
michael@0 173 avg = sum0 + sum1;
michael@0 174 *sse = var;
michael@0 175 return (var - (((unsigned int)avg * avg) >> 7));
michael@0 176
michael@0 177 }
michael@0 178
michael@0 179
michael@0 180 unsigned int vp8_variance8x16_mmx(
michael@0 181 const unsigned char *src_ptr,
michael@0 182 int source_stride,
michael@0 183 const unsigned char *ref_ptr,
michael@0 184 int recon_stride,
michael@0 185 unsigned int *sse)
michael@0 186 {
michael@0 187 unsigned int sse0, sse1, var;
michael@0 188 int sum0, sum1, avg;
michael@0 189
michael@0 190 vp8_get8x8var_mmx(src_ptr, source_stride, ref_ptr, recon_stride, &sse0, &sum0) ;
michael@0 191 vp8_get8x8var_mmx(src_ptr + 8 * source_stride, source_stride, ref_ptr + 8 * recon_stride, recon_stride, &sse1, &sum1) ;
michael@0 192
michael@0 193 var = sse0 + sse1;
michael@0 194 avg = sum0 + sum1;
michael@0 195 *sse = var;
michael@0 196
michael@0 197 return (var - (((unsigned int)avg * avg) >> 7));
michael@0 198
michael@0 199 }
michael@0 200
michael@0 201
michael@0 202 unsigned int vp8_sub_pixel_variance4x4_mmx
michael@0 203 (
michael@0 204 const unsigned char *src_ptr,
michael@0 205 int src_pixels_per_line,
michael@0 206 int xoffset,
michael@0 207 int yoffset,
michael@0 208 const unsigned char *dst_ptr,
michael@0 209 int dst_pixels_per_line,
michael@0 210 unsigned int *sse)
michael@0 211
michael@0 212 {
michael@0 213 int xsum;
michael@0 214 unsigned int xxsum;
michael@0 215 vp8_filter_block2d_bil4x4_var_mmx(
michael@0 216 src_ptr, src_pixels_per_line,
michael@0 217 dst_ptr, dst_pixels_per_line,
michael@0 218 vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset],
michael@0 219 &xsum, &xxsum
michael@0 220 );
michael@0 221 *sse = xxsum;
michael@0 222 return (xxsum - (((unsigned int)xsum * xsum) >> 4));
michael@0 223 }
michael@0 224
michael@0 225
michael@0 226 unsigned int vp8_sub_pixel_variance8x8_mmx
michael@0 227 (
michael@0 228 const unsigned char *src_ptr,
michael@0 229 int src_pixels_per_line,
michael@0 230 int xoffset,
michael@0 231 int yoffset,
michael@0 232 const unsigned char *dst_ptr,
michael@0 233 int dst_pixels_per_line,
michael@0 234 unsigned int *sse
michael@0 235 )
michael@0 236 {
michael@0 237
michael@0 238 int xsum;
michael@0 239 unsigned int xxsum;
michael@0 240 vp8_filter_block2d_bil_var_mmx(
michael@0 241 src_ptr, src_pixels_per_line,
michael@0 242 dst_ptr, dst_pixels_per_line, 8,
michael@0 243 vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset],
michael@0 244 &xsum, &xxsum
michael@0 245 );
michael@0 246 *sse = xxsum;
michael@0 247 return (xxsum - (((unsigned int)xsum * xsum) >> 6));
michael@0 248 }
michael@0 249
michael@0 250 unsigned int vp8_sub_pixel_variance16x16_mmx
michael@0 251 (
michael@0 252 const unsigned char *src_ptr,
michael@0 253 int src_pixels_per_line,
michael@0 254 int xoffset,
michael@0 255 int yoffset,
michael@0 256 const unsigned char *dst_ptr,
michael@0 257 int dst_pixels_per_line,
michael@0 258 unsigned int *sse
michael@0 259 )
michael@0 260 {
michael@0 261
michael@0 262 int xsum0, xsum1;
michael@0 263 unsigned int xxsum0, xxsum1;
michael@0 264
michael@0 265
michael@0 266 vp8_filter_block2d_bil_var_mmx(
michael@0 267 src_ptr, src_pixels_per_line,
michael@0 268 dst_ptr, dst_pixels_per_line, 16,
michael@0 269 vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset],
michael@0 270 &xsum0, &xxsum0
michael@0 271 );
michael@0 272
michael@0 273
michael@0 274 vp8_filter_block2d_bil_var_mmx(
michael@0 275 src_ptr + 8, src_pixels_per_line,
michael@0 276 dst_ptr + 8, dst_pixels_per_line, 16,
michael@0 277 vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset],
michael@0 278 &xsum1, &xxsum1
michael@0 279 );
michael@0 280
michael@0 281 xsum0 += xsum1;
michael@0 282 xxsum0 += xxsum1;
michael@0 283
michael@0 284 *sse = xxsum0;
michael@0 285 return (xxsum0 - (((unsigned int)xsum0 * xsum0) >> 8));
michael@0 286
michael@0 287
michael@0 288 }
michael@0 289
michael@0 290 unsigned int vp8_sub_pixel_mse16x16_mmx(
michael@0 291 const unsigned char *src_ptr,
michael@0 292 int src_pixels_per_line,
michael@0 293 int xoffset,
michael@0 294 int yoffset,
michael@0 295 const unsigned char *dst_ptr,
michael@0 296 int dst_pixels_per_line,
michael@0 297 unsigned int *sse
michael@0 298 )
michael@0 299 {
michael@0 300 vp8_sub_pixel_variance16x16_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, dst_ptr, dst_pixels_per_line, sse);
michael@0 301 return *sse;
michael@0 302 }
michael@0 303
michael@0 304 unsigned int vp8_sub_pixel_variance16x8_mmx
michael@0 305 (
michael@0 306 const unsigned char *src_ptr,
michael@0 307 int src_pixels_per_line,
michael@0 308 int xoffset,
michael@0 309 int yoffset,
michael@0 310 const unsigned char *dst_ptr,
michael@0 311 int dst_pixels_per_line,
michael@0 312 unsigned int *sse
michael@0 313 )
michael@0 314 {
michael@0 315 int xsum0, xsum1;
michael@0 316 unsigned int xxsum0, xxsum1;
michael@0 317
michael@0 318
michael@0 319 vp8_filter_block2d_bil_var_mmx(
michael@0 320 src_ptr, src_pixels_per_line,
michael@0 321 dst_ptr, dst_pixels_per_line, 8,
michael@0 322 vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset],
michael@0 323 &xsum0, &xxsum0
michael@0 324 );
michael@0 325
michael@0 326
michael@0 327 vp8_filter_block2d_bil_var_mmx(
michael@0 328 src_ptr + 8, src_pixels_per_line,
michael@0 329 dst_ptr + 8, dst_pixels_per_line, 8,
michael@0 330 vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset],
michael@0 331 &xsum1, &xxsum1
michael@0 332 );
michael@0 333
michael@0 334 xsum0 += xsum1;
michael@0 335 xxsum0 += xxsum1;
michael@0 336
michael@0 337 *sse = xxsum0;
michael@0 338 return (xxsum0 - (((unsigned int)xsum0 * xsum0) >> 7));
michael@0 339 }
michael@0 340
michael@0 341 unsigned int vp8_sub_pixel_variance8x16_mmx
michael@0 342 (
michael@0 343 const unsigned char *src_ptr,
michael@0 344 int src_pixels_per_line,
michael@0 345 int xoffset,
michael@0 346 int yoffset,
michael@0 347 const unsigned char *dst_ptr,
michael@0 348 int dst_pixels_per_line,
michael@0 349 unsigned int *sse
michael@0 350 )
michael@0 351 {
michael@0 352 int xsum;
michael@0 353 unsigned int xxsum;
michael@0 354 vp8_filter_block2d_bil_var_mmx(
michael@0 355 src_ptr, src_pixels_per_line,
michael@0 356 dst_ptr, dst_pixels_per_line, 16,
michael@0 357 vp8_bilinear_filters_x86_4[xoffset], vp8_bilinear_filters_x86_4[yoffset],
michael@0 358 &xsum, &xxsum
michael@0 359 );
michael@0 360 *sse = xxsum;
michael@0 361 return (xxsum - (((unsigned int)xsum * xsum) >> 7));
michael@0 362 }
michael@0 363
michael@0 364
michael@0 365 unsigned int vp8_variance_halfpixvar16x16_h_mmx(
michael@0 366 const unsigned char *src_ptr,
michael@0 367 int source_stride,
michael@0 368 const unsigned char *ref_ptr,
michael@0 369 int recon_stride,
michael@0 370 unsigned int *sse)
michael@0 371 {
michael@0 372 return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 4, 0,
michael@0 373 ref_ptr, recon_stride, sse);
michael@0 374 }
michael@0 375
michael@0 376
michael@0 377 unsigned int vp8_variance_halfpixvar16x16_v_mmx(
michael@0 378 const unsigned char *src_ptr,
michael@0 379 int source_stride,
michael@0 380 const unsigned char *ref_ptr,
michael@0 381 int recon_stride,
michael@0 382 unsigned int *sse)
michael@0 383 {
michael@0 384 return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 0, 4,
michael@0 385 ref_ptr, recon_stride, sse);
michael@0 386 }
michael@0 387
michael@0 388
michael@0 389 unsigned int vp8_variance_halfpixvar16x16_hv_mmx(
michael@0 390 const unsigned char *src_ptr,
michael@0 391 int source_stride,
michael@0 392 const unsigned char *ref_ptr,
michael@0 393 int recon_stride,
michael@0 394 unsigned int *sse)
michael@0 395 {
michael@0 396 return vp8_sub_pixel_variance16x16_mmx(src_ptr, source_stride, 4, 4,
michael@0 397 ref_ptr, recon_stride, sse);
michael@0 398 }

mercurial