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

Side by Side Diff: source/libvpx/vp9/encoder/vp9_avg.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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 #include "vp9/common/vp9_common.h" 10 #include "vp9/common/vp9_common.h"
(...skipping 10 matching lines...) Expand all
21 21
22 unsigned int vp9_avg_4x4_c(const uint8_t *s, int p) { 22 unsigned int vp9_avg_4x4_c(const uint8_t *s, int p) {
23 int i, j; 23 int i, j;
24 int sum = 0; 24 int sum = 0;
25 for (i = 0; i < 4; ++i, s+=p) 25 for (i = 0; i < 4; ++i, s+=p)
26 for (j = 0; j < 4; sum += s[j], ++j) {} 26 for (j = 0; j < 4; sum += s[j], ++j) {}
27 27
28 return (sum + 8) >> 4; 28 return (sum + 8) >> 4;
29 } 29 }
30 30
31 static void hadamard_col8(const int16_t *src_diff, int src_stride,
32 int16_t *coeff) {
33 int16_t b0 = src_diff[0 * src_stride] + src_diff[1 * src_stride];
34 int16_t b1 = src_diff[0 * src_stride] - src_diff[1 * src_stride];
35 int16_t b2 = src_diff[2 * src_stride] + src_diff[3 * src_stride];
36 int16_t b3 = src_diff[2 * src_stride] - src_diff[3 * src_stride];
37 int16_t b4 = src_diff[4 * src_stride] + src_diff[5 * src_stride];
38 int16_t b5 = src_diff[4 * src_stride] - src_diff[5 * src_stride];
39 int16_t b6 = src_diff[6 * src_stride] + src_diff[7 * src_stride];
40 int16_t b7 = src_diff[6 * src_stride] - src_diff[7 * src_stride];
41
42 int16_t c0 = b0 + b2;
43 int16_t c1 = b1 + b3;
44 int16_t c2 = b0 - b2;
45 int16_t c3 = b1 - b3;
46 int16_t c4 = b4 + b6;
47 int16_t c5 = b5 + b7;
48 int16_t c6 = b4 - b6;
49 int16_t c7 = b5 - b7;
50
51 coeff[0] = c0 + c4;
52 coeff[7] = c1 + c5;
53 coeff[3] = c2 + c6;
54 coeff[4] = c3 + c7;
55 coeff[2] = c0 - c4;
56 coeff[6] = c1 - c5;
57 coeff[1] = c2 - c6;
58 coeff[5] = c3 - c7;
59 }
60
61 void vp9_hadamard_8x8_c(int16_t const *src_diff, int src_stride,
62 int16_t *coeff) {
63 int idx;
64 int16_t buffer[64];
65 int16_t *tmp_buf = &buffer[0];
66 for (idx = 0; idx < 8; ++idx) {
67 hadamard_col8(src_diff, src_stride, tmp_buf);
68 tmp_buf += 8;
69 ++src_diff;
70 }
71
72 tmp_buf = &buffer[0];
73 for (idx = 0; idx < 8; ++idx) {
74 hadamard_col8(tmp_buf, 8, coeff);
75 coeff += 8;
76 ++tmp_buf;
77 }
78 }
79
80 // In place 16x16 2D Hadamard transform
81 void vp9_hadamard_16x16_c(int16_t const *src_diff, int src_stride,
82 int16_t *coeff) {
83 int idx;
84 for (idx = 0; idx < 4; ++idx) {
85 int16_t const *src_ptr = src_diff + (idx >> 1) * 8 * src_stride
86 + (idx & 0x01) * 8;
87 vp9_hadamard_8x8_c(src_ptr, src_stride, coeff + idx * 64);
88 }
89
90 for (idx = 0; idx < 64; ++idx) {
91 int16_t a0 = coeff[0];
92 int16_t a1 = coeff[64];
93 int16_t a2 = coeff[128];
94 int16_t a3 = coeff[192];
95
96 int16_t b0 = a0 + a1;
97 int16_t b1 = a0 - a1;
98 int16_t b2 = a2 + a3;
99 int16_t b3 = a2 - a3;
100
101 coeff[0] = (b0 + b2) >> 1;
102 coeff[64] = (b1 + b3) >> 1;
103 coeff[128] = (b0 - b2) >> 1;
104 coeff[192] = (b1 - b3) >> 1;
105
106 ++coeff;
107 }
108 }
109
110 int16_t vp9_satd_c(const int16_t *coeff, int length) {
111 int i;
112 int satd = 0;
113 for (i = 0; i < length; ++i)
114 satd += abs(coeff[i]);
115
116 return (int16_t)satd;
117 }
118
31 // Integer projection onto row vectors. 119 // Integer projection onto row vectors.
32 void vp9_int_pro_row_c(int16_t *hbuf, uint8_t const *ref, 120 void vp9_int_pro_row_c(int16_t *hbuf, uint8_t const *ref,
33 const int ref_stride, const int height) { 121 const int ref_stride, const int height) {
34 int idx; 122 int idx;
35 const int norm_factor = MAX(8, height >> 1); 123 const int norm_factor = MAX(8, height >> 1);
36 for (idx = 0; idx < 16; ++idx) { 124 for (idx = 0; idx < 16; ++idx) {
37 int i; 125 int i;
38 hbuf[idx] = 0; 126 hbuf[idx] = 0;
39 for (i = 0; i < height; ++i) 127 for (i = 0; i < height; ++i)
40 hbuf[idx] += ref[i * ref_stride]; 128 hbuf[idx] += ref[i * ref_stride];
(...skipping 19 matching lines...) Expand all
60 for (i = 0; i < width; ++i) { 148 for (i = 0; i < width; ++i) {
61 int diff = ref[i] - src[i]; 149 int diff = ref[i] - src[i];
62 mean += diff; 150 mean += diff;
63 sse += diff * diff; 151 sse += diff * diff;
64 } 152 }
65 153
66 var = sse - ((mean * mean) >> (bwl + 2)); 154 var = sse - ((mean * mean) >> (bwl + 2));
67 return var; 155 return var;
68 } 156 }
69 157
158 void vp9_minmax_8x8_c(const uint8_t *s, int p, const uint8_t *d, int dp,
159 int *min, int *max) {
160 int i, j;
161 *min = 255;
162 *max = 0;
163 for (i = 0; i < 8; ++i, s += p, d += dp) {
164 for (j = 0; j < 8; ++j) {
165 int diff = abs(s[j]-d[j]);
166 *min = diff < *min ? diff : *min;
167 *max = diff > *max ? diff : *max;
168 }
169 }
170 }
171
70 #if CONFIG_VP9_HIGHBITDEPTH 172 #if CONFIG_VP9_HIGHBITDEPTH
71 unsigned int vp9_highbd_avg_8x8_c(const uint8_t *s8, int p) { 173 unsigned int vp9_highbd_avg_8x8_c(const uint8_t *s8, int p) {
72 int i, j; 174 int i, j;
73 int sum = 0; 175 int sum = 0;
74 const uint16_t* s = CONVERT_TO_SHORTPTR(s8); 176 const uint16_t* s = CONVERT_TO_SHORTPTR(s8);
75 for (i = 0; i < 8; ++i, s+=p) 177 for (i = 0; i < 8; ++i, s+=p)
76 for (j = 0; j < 8; sum += s[j], ++j) {} 178 for (j = 0; j < 8; sum += s[j], ++j) {}
77 179
78 return (sum + 32) >> 6; 180 return (sum + 32) >> 6;
79 } 181 }
80 182
81 unsigned int vp9_highbd_avg_4x4_c(const uint8_t *s8, int p) { 183 unsigned int vp9_highbd_avg_4x4_c(const uint8_t *s8, int p) {
82 int i, j; 184 int i, j;
83 int sum = 0; 185 int sum = 0;
84 const uint16_t* s = CONVERT_TO_SHORTPTR(s8); 186 const uint16_t* s = CONVERT_TO_SHORTPTR(s8);
85 for (i = 0; i < 4; ++i, s+=p) 187 for (i = 0; i < 4; ++i, s+=p)
86 for (j = 0; j < 4; sum += s[j], ++j) {} 188 for (j = 0; j < 4; sum += s[j], ++j) {}
87 189
88 return (sum + 8) >> 4; 190 return (sum + 8) >> 4;
89 } 191 }
192
193 void vp9_highbd_minmax_8x8_c(const uint8_t *s8, int p, const uint8_t *d8,
194 int dp, int *min, int *max) {
195 int i, j;
196 const uint16_t* s = CONVERT_TO_SHORTPTR(s8);
197 const uint16_t* d = CONVERT_TO_SHORTPTR(d8);
198 *min = 255;
199 *max = 0;
200 for (i = 0; i < 8; ++i, s += p, d += dp) {
201 for (j = 0; j < 8; ++j) {
202 int diff = abs(s[j]-d[j]);
203 *min = diff < *min ? diff : *min;
204 *max = diff > *max ? diff : *max;
205 }
206 }
207 }
90 #endif // CONFIG_VP9_HIGHBITDEPTH 208 #endif // CONFIG_VP9_HIGHBITDEPTH
91 209
92 210
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_aq_cyclicrefresh.c ('k') | source/libvpx/vp9/encoder/vp9_bitstream.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698