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

Unified Diff: source/libvpx/vp8/common/variance_c.c

Issue 1162573005: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp8/common/variance.h ('k') | source/libvpx/vp8/common/x86/variance_impl_mmx.asm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp8/common/variance_c.c
diff --git a/source/libvpx/vp8/common/variance_c.c b/source/libvpx/vp8/common/variance_c.c
index 773b655efc518128e9ac38c71a025f78ef21e842..79d1ca00c1cc319af84fe351424e510954ff8ee1 100644
--- a/source/libvpx/vp8/common/variance_c.c
+++ b/source/libvpx/vp8/common/variance_c.c
@@ -8,43 +8,34 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
-#include "variance.h"
+#include "./vp8_rtcd.h"
#include "filter.h"
+#include "variance.h"
-
-unsigned int vp8_get_mb_ss_c
-(
- const short *src_ptr
-)
-{
- unsigned int i = 0, sum = 0;
-
- do
- {
- sum += (src_ptr[i] * src_ptr[i]);
- i++;
- }
- while (i < 256);
-
- return sum;
+/* This is a bad idea.
+ * ctz = count trailing zeros */
+static int ctz(int a) {
+ int b = 0;
+ while (a != 1) {
+ a >>= 1;
+ b++;
+ }
+ return b;
}
-
-static void variance(
+static unsigned int variance(
const unsigned char *src_ptr,
int source_stride,
const unsigned char *ref_ptr,
int recon_stride,
int w,
int h,
- unsigned int *sse,
- int *sum)
+ unsigned int *sse)
{
int i, j;
- int diff;
+ int diff, sum;
- *sum = 0;
+ sum = 0;
*sse = 0;
for (i = 0; i < h; i++)
@@ -52,114 +43,17 @@ static void variance(
for (j = 0; j < w; j++)
{
diff = src_ptr[j] - ref_ptr[j];
- *sum += diff;
+ sum += diff;
*sse += diff * diff;
}
src_ptr += source_stride;
ref_ptr += recon_stride;
}
-}
-
-
-unsigned int vp8_variance16x16_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 16, &var, &avg);
- *sse = var;
- return (var - (((unsigned int)avg * avg) >> 8));
+ return (*sse - (((unsigned int)sum * sum) >> (int)((ctz(w) + ctz(h)))));
}
-unsigned int vp8_variance8x16_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 16, &var, &avg);
- *sse = var;
- return (var - (((unsigned int)avg * avg) >> 7));
-}
-
-unsigned int vp8_variance16x8_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 8, &var, &avg);
- *sse = var;
- return (var - (((unsigned int)avg * avg) >> 7));
-}
-
-
-unsigned int vp8_variance8x8_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 8, &var, &avg);
- *sse = var;
- return (var - (((unsigned int)avg * avg) >> 6));
-}
-
-unsigned int vp8_variance4x4_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 4, 4, &var, &avg);
- *sse = var;
- return (var - (((unsigned int)avg * avg) >> 4));
-}
-
-
-unsigned int vp8_mse16x16_c(
- const unsigned char *src_ptr,
- int source_stride,
- const unsigned char *ref_ptr,
- int recon_stride,
- unsigned int *sse)
-{
- unsigned int var;
- int avg;
-
- variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 16, &var, &avg);
- *sse = var;
- return var;
-}
-
-
/****************************************************************************
*
* ROUTINE : filter_block2d_bil_first_pass
@@ -303,7 +197,7 @@ unsigned int vp8_sub_pixel_variance4x4_c
/* Now filter Verticaly */
var_filter_block2d_bil_second_pass(FData3, temp2, 4, 4, 4, 4, VFilter);
- return vp8_variance4x4_c(temp2, 4, dst_ptr, dst_pixels_per_line, sse);
+ return variance(temp2, 4, dst_ptr, dst_pixels_per_line, 4, 4, sse);
}
@@ -328,7 +222,7 @@ unsigned int vp8_sub_pixel_variance8x8_c
var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 9, 8, HFilter);
var_filter_block2d_bil_second_pass(FData3, temp2, 8, 8, 8, 8, VFilter);
- return vp8_variance8x8_c(temp2, 8, dst_ptr, dst_pixels_per_line, sse);
+ return variance(temp2, 8, dst_ptr, dst_pixels_per_line, 8, 8, sse);
}
unsigned int vp8_sub_pixel_variance16x16_c
@@ -352,7 +246,7 @@ unsigned int vp8_sub_pixel_variance16x16_c
var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 17, 16, HFilter);
var_filter_block2d_bil_second_pass(FData3, temp2, 16, 16, 16, 16, VFilter);
- return vp8_variance16x16_c(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
+ return variance(temp2, 16, dst_ptr, dst_pixels_per_line, 16, 16, sse);
}
@@ -428,7 +322,7 @@ unsigned int vp8_sub_pixel_variance16x8_c
var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 9, 16, HFilter);
var_filter_block2d_bil_second_pass(FData3, temp2, 16, 16, 8, 16, VFilter);
- return vp8_variance16x8_c(temp2, 16, dst_ptr, dst_pixels_per_line, sse);
+ return variance(temp2, 16, dst_ptr, dst_pixels_per_line, 16, 8, sse);
}
unsigned int vp8_sub_pixel_variance8x16_c
@@ -454,5 +348,5 @@ unsigned int vp8_sub_pixel_variance8x16_c
var_filter_block2d_bil_first_pass(src_ptr, FData3, src_pixels_per_line, 1, 17, 8, HFilter);
var_filter_block2d_bil_second_pass(FData3, temp2, 8, 8, 16, 8, VFilter);
- return vp8_variance8x16_c(temp2, 8, dst_ptr, dst_pixels_per_line, sse);
+ return variance(temp2, 8, dst_ptr, dst_pixels_per_line, 8, 16, sse);
}
« no previous file with comments | « source/libvpx/vp8/common/variance.h ('k') | source/libvpx/vp8/common/x86/variance_impl_mmx.asm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698