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

Side by Side Diff: source/libvpx/vp9/encoder/vp9_variance_c.c

Issue 54923004: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 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 "./vp9_rtcd.h"
12
13 #include "vpx_ports/mem.h"
14 #include "vpx/vpx_integer.h"
15
16 #include "vp9/common/vp9_common.h"
17 #include "vp9/common/vp9_filter.h"
11 18
12 #include "vp9/encoder/vp9_variance.h" 19 #include "vp9/encoder/vp9_variance.h"
13 #include "vp9/common/vp9_filter.h" 20
14 #include "vp9/common/vp9_subpelvar.h" 21 void variance(const uint8_t *src_ptr,
15 #include "vpx/vpx_integer.h" 22 int source_stride,
16 #include "vpx_ports/mem.h" 23 const uint8_t *ref_ptr,
17 #include "./vp9_rtcd.h" 24 int recon_stride,
25 int w,
26 int h,
27 unsigned int *sse,
28 int *sum) {
29 int i, j;
30 int diff;
31
32 *sum = 0;
33 *sse = 0;
34
35 for (i = 0; i < h; i++) {
36 for (j = 0; j < w; j++) {
37 diff = src_ptr[j] - ref_ptr[j];
38 *sum += diff;
39 *sse += diff * diff;
40 }
41
42 src_ptr += source_stride;
43 ref_ptr += recon_stride;
44 }
45 }
46
47 /****************************************************************************
48 *
49 * ROUTINE : filter_block2d_bil_first_pass
50 *
51 * INPUTS : uint8_t *src_ptr : Pointer to source block.
52 * uint32_t src_pixels_per_line : Stride of input block.
53 * uint32_t pixel_step : Offset between filter input
54 * samples (see notes).
55 * uint32_t output_height : Input block height.
56 * uint32_t output_width : Input block width.
57 * int32_t *vp9_filter : Array of 2 bi-linear filter
58 * taps.
59 *
60 * OUTPUTS : int32_t *output_ptr : Pointer to filtered block.
61 *
62 * RETURNS : void
63 *
64 * FUNCTION : Applies a 1-D 2-tap bi-linear filter to the source block in
65 * either horizontal or vertical direction to produce the
66 * filtered output block. Used to implement first-pass
67 * of 2-D separable filter.
68 *
69 * SPECIAL NOTES : Produces int32_t output to retain precision for next pass.
70 * Two filter taps should sum to VP9_FILTER_WEIGHT.
71 * pixel_step defines whether the filter is applied
72 * horizontally (pixel_step=1) or vertically (pixel_step=
73 * stride).
74 * It defines the offset required to move from one input
75 * to the next.
76 *
77 ****************************************************************************/
78 static void var_filter_block2d_bil_first_pass(const uint8_t *src_ptr,
79 uint16_t *output_ptr,
80 unsigned int src_pixels_per_line,
81 int pixel_step,
82 unsigned int output_height,
83 unsigned int output_width,
84 const int16_t *vp9_filter) {
85 unsigned int i, j;
86
87 for (i = 0; i < output_height; i++) {
88 for (j = 0; j < output_width; j++) {
89 output_ptr[j] = ROUND_POWER_OF_TWO((int)src_ptr[0] * vp9_filter[0] +
90 (int)src_ptr[pixel_step] * vp9_filter[1],
91 FILTER_BITS);
92
93 src_ptr++;
94 }
95
96 // Next row...
97 src_ptr += src_pixels_per_line - output_width;
98 output_ptr += output_width;
99 }
100 }
101
102 /****************************************************************************
103 *
104 * ROUTINE : filter_block2d_bil_second_pass
105 *
106 * INPUTS : int32_t *src_ptr : Pointer to source block.
107 * uint32_t src_pixels_per_line : Stride of input block.
108 * uint32_t pixel_step : Offset between filter input
109 * samples (see notes).
110 * uint32_t output_height : Input block height.
111 * uint32_t output_width : Input block width.
112 * int32_t *vp9_filter : Array of 2 bi-linear filter
113 * taps.
114 *
115 * OUTPUTS : uint16_t *output_ptr : Pointer to filtered block.
116 *
117 * RETURNS : void
118 *
119 * FUNCTION : Applies a 1-D 2-tap bi-linear filter to the source block in
120 * either horizontal or vertical direction to produce the
121 * filtered output block. Used to implement second-pass
122 * of 2-D separable filter.
123 *
124 * SPECIAL NOTES : Requires 32-bit input as produced by
125 * filter_block2d_bil_first_pass.
126 * Two filter taps should sum to VP9_FILTER_WEIGHT.
127 * pixel_step defines whether the filter is applied
128 * horizontally (pixel_step=1) or vertically (pixel_step=
129 * stride).
130 * It defines the offset required to move from one input
131 * to the next.
132 *
133 ****************************************************************************/
134 static void var_filter_block2d_bil_second_pass(const uint16_t *src_ptr,
135 uint8_t *output_ptr,
136 unsigned int src_pixels_per_line,
137 unsigned int pixel_step,
138 unsigned int output_height,
139 unsigned int output_width,
140 const int16_t *vp9_filter) {
141 unsigned int i, j;
142
143 for (i = 0; i < output_height; i++) {
144 for (j = 0; j < output_width; j++) {
145 output_ptr[j] = ROUND_POWER_OF_TWO((int)src_ptr[0] * vp9_filter[0] +
146 (int)src_ptr[pixel_step] * vp9_filter[1],
147 FILTER_BITS);
148 src_ptr++;
149 }
150
151 src_ptr += src_pixels_per_line - output_width;
152 output_ptr += output_width;
153 }
154 }
18 155
19 unsigned int vp9_get_mb_ss_c(const int16_t *src_ptr) { 156 unsigned int vp9_get_mb_ss_c(const int16_t *src_ptr) {
20 unsigned int i, sum = 0; 157 unsigned int i, sum = 0;
21 158
22 for (i = 0; i < 256; i++) { 159 for (i = 0; i < 256; i++) {
23 sum += (src_ptr[i] * src_ptr[i]); 160 sum += (src_ptr[i] * src_ptr[i]);
24 } 161 }
25 162
26 return sum; 163 return sum;
27 } 164 }
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 1085
949 hfilter = BILINEAR_FILTERS_2TAP(xoffset); 1086 hfilter = BILINEAR_FILTERS_2TAP(xoffset);
950 vfilter = BILINEAR_FILTERS_2TAP(yoffset); 1087 vfilter = BILINEAR_FILTERS_2TAP(yoffset);
951 1088
952 var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line, 1089 var_filter_block2d_bil_first_pass(src_ptr, fdata3, src_pixels_per_line,
953 1, 9, 4, hfilter); 1090 1, 9, 4, hfilter);
954 var_filter_block2d_bil_second_pass(fdata3, temp2, 4, 4, 8, 4, vfilter); 1091 var_filter_block2d_bil_second_pass(fdata3, temp2, 4, 4, 8, 4, vfilter);
955 comp_avg_pred(temp3, second_pred, 4, 8, temp2, 4); 1092 comp_avg_pred(temp3, second_pred, 4, 8, temp2, 4);
956 return vp9_variance4x8(temp3, 4, dst_ptr, dst_pixels_per_line, sse); 1093 return vp9_variance4x8(temp3, 4, dst_ptr, dst_pixels_per_line, sse);
957 } 1094 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_variance.h ('k') | source/libvpx/vp9/encoder/x86/vp9_dct32x32_sse2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698