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

Side by Side Diff: source/libvpx/vp9/common/vp9_reconinter.c

Issue 11974002: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/common/vp9_reconinter.h ('k') | source/libvpx/vp9/common/vp9_reconintra.h » ('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) 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 11
12 #include "vpx_ports/config.h" 12 #include "./vpx_config.h"
13 #include "vpx/vpx_integer.h" 13 #include "vpx/vpx_integer.h"
14 #include "vp9/common/vp9_blockd.h" 14 #include "vp9/common/vp9_blockd.h"
15 #include "vp9/common/vp9_reconinter.h" 15 #include "vp9/common/vp9_reconinter.h"
16 #include "vp9/common/vp9_reconintra.h" 16 #include "vp9/common/vp9_reconintra.h"
17 17
18 void vp9_setup_interp_filters(MACROBLOCKD *xd, 18 void vp9_setup_interp_filters(MACROBLOCKD *xd,
19 INTERPOLATIONFILTERTYPE mcomp_filter_type, 19 INTERPOLATIONFILTERTYPE mcomp_filter_type,
20 VP9_COMMON *cm) { 20 VP9_COMMON *cm) {
21 #if CONFIG_ENABLE_6TAP
21 if (mcomp_filter_type == SIXTAP) { 22 if (mcomp_filter_type == SIXTAP) {
22 xd->subpixel_predict = vp9_sixtap_predict; 23 xd->subpixel_predict4x4 = vp9_sixtap_predict4x4;
23 xd->subpixel_predict8x4 = vp9_sixtap_predict8x4; 24 xd->subpixel_predict8x4 = vp9_sixtap_predict8x4;
24 xd->subpixel_predict8x8 = vp9_sixtap_predict8x8; 25 xd->subpixel_predict8x8 = vp9_sixtap_predict8x8;
25 xd->subpixel_predict16x16 = vp9_sixtap_predict16x16; 26 xd->subpixel_predict16x16 = vp9_sixtap_predict16x16;
26 xd->subpixel_predict_avg = vp9_sixtap_predict_avg; 27 xd->subpixel_predict_avg4x4 = vp9_sixtap_predict_avg4x4;
27 xd->subpixel_predict_avg8x8 = vp9_sixtap_predict_avg8x8; 28 xd->subpixel_predict_avg8x8 = vp9_sixtap_predict_avg8x8;
28 xd->subpixel_predict_avg16x16 = vp9_sixtap_predict_avg16x16; 29 xd->subpixel_predict_avg16x16 = vp9_sixtap_predict_avg16x16;
29 } else if (mcomp_filter_type == EIGHTTAP || mcomp_filter_type == SWITCHABLE) { 30 } else {
30 xd->subpixel_predict = vp9_eighttap_predict; 31 #endif
32 if (mcomp_filter_type == EIGHTTAP || mcomp_filter_type == SWITCHABLE) {
33 xd->subpixel_predict4x4 = vp9_eighttap_predict4x4;
31 xd->subpixel_predict8x4 = vp9_eighttap_predict8x4; 34 xd->subpixel_predict8x4 = vp9_eighttap_predict8x4;
32 xd->subpixel_predict8x8 = vp9_eighttap_predict8x8; 35 xd->subpixel_predict8x8 = vp9_eighttap_predict8x8;
33 xd->subpixel_predict16x16 = vp9_eighttap_predict16x16; 36 xd->subpixel_predict16x16 = vp9_eighttap_predict16x16;
34 xd->subpixel_predict_avg = vp9_eighttap_predict_avg4x4; 37 xd->subpixel_predict_avg4x4 = vp9_eighttap_predict_avg4x4;
35 xd->subpixel_predict_avg8x8 = vp9_eighttap_predict_avg8x8; 38 xd->subpixel_predict_avg8x8 = vp9_eighttap_predict_avg8x8;
36 xd->subpixel_predict_avg16x16 = vp9_eighttap_predict_avg16x16; 39 xd->subpixel_predict_avg16x16 = vp9_eighttap_predict_avg16x16;
40 } else if (mcomp_filter_type == EIGHTTAP_SMOOTH) {
41 xd->subpixel_predict4x4 = vp9_eighttap_predict4x4_smooth;
42 xd->subpixel_predict8x4 = vp9_eighttap_predict8x4_smooth;
43 xd->subpixel_predict8x8 = vp9_eighttap_predict8x8_smooth;
44 xd->subpixel_predict16x16 = vp9_eighttap_predict16x16_smooth;
45 xd->subpixel_predict_avg4x4 = vp9_eighttap_predict_avg4x4_smooth;
46 xd->subpixel_predict_avg8x8 = vp9_eighttap_predict_avg8x8_smooth;
47 xd->subpixel_predict_avg16x16 = vp9_eighttap_predict_avg16x16_smooth;
37 } else if (mcomp_filter_type == EIGHTTAP_SHARP) { 48 } else if (mcomp_filter_type == EIGHTTAP_SHARP) {
38 xd->subpixel_predict = vp9_eighttap_predict_sharp; 49 xd->subpixel_predict4x4 = vp9_eighttap_predict4x4_sharp;
39 xd->subpixel_predict8x4 = vp9_eighttap_predict8x4_sharp; 50 xd->subpixel_predict8x4 = vp9_eighttap_predict8x4_sharp;
40 xd->subpixel_predict8x8 = vp9_eighttap_predict8x8_sharp; 51 xd->subpixel_predict8x8 = vp9_eighttap_predict8x8_sharp;
41 xd->subpixel_predict16x16 = vp9_eighttap_predict16x16_sharp; 52 xd->subpixel_predict16x16 = vp9_eighttap_predict16x16_sharp;
42 xd->subpixel_predict_avg = vp9_eighttap_predict_avg4x4_sharp; 53 xd->subpixel_predict_avg4x4 = vp9_eighttap_predict_avg4x4_sharp;
43 xd->subpixel_predict_avg8x8 = vp9_eighttap_predict_avg8x8_sharp; 54 xd->subpixel_predict_avg8x8 = vp9_eighttap_predict_avg8x8_sharp;
44 xd->subpixel_predict_avg16x16 = vp9_eighttap_predict_avg16x16_sharp_c; 55 xd->subpixel_predict_avg16x16 = vp9_eighttap_predict_avg16x16_sharp_c;
45 } 56 } else {
46 else { 57 xd->subpixel_predict4x4 = vp9_bilinear_predict4x4;
47 xd->subpixel_predict = vp9_bilinear_predict4x4;
48 xd->subpixel_predict8x4 = vp9_bilinear_predict8x4; 58 xd->subpixel_predict8x4 = vp9_bilinear_predict8x4;
49 xd->subpixel_predict8x8 = vp9_bilinear_predict8x8; 59 xd->subpixel_predict8x8 = vp9_bilinear_predict8x8;
50 xd->subpixel_predict16x16 = vp9_bilinear_predict16x16; 60 xd->subpixel_predict16x16 = vp9_bilinear_predict16x16;
51 xd->subpixel_predict_avg = vp9_bilinear_predict_avg4x4; 61 xd->subpixel_predict_avg4x4 = vp9_bilinear_predict_avg4x4;
52 xd->subpixel_predict_avg8x8 = vp9_bilinear_predict_avg8x8; 62 xd->subpixel_predict_avg8x8 = vp9_bilinear_predict_avg8x8;
53 xd->subpixel_predict_avg16x16 = vp9_bilinear_predict_avg16x16; 63 xd->subpixel_predict_avg16x16 = vp9_bilinear_predict_avg16x16;
54 } 64 }
65 #if CONFIG_ENABLE_6TAP
66 }
67 #endif
55 } 68 }
56 69
57 void vp9_copy_mem16x16_c(unsigned char *src, 70 void vp9_copy_mem16x16_c(uint8_t *src,
58 int src_stride, 71 int src_stride,
59 unsigned char *dst, 72 uint8_t *dst,
60 int dst_stride) { 73 int dst_stride) {
61 int r; 74 int r;
62 75
63 for (r = 0; r < 16; r++) { 76 for (r = 0; r < 16; r++) {
64 #if !(CONFIG_FAST_UNALIGNED) 77 #if !(CONFIG_FAST_UNALIGNED)
65 dst[0] = src[0]; 78 dst[0] = src[0];
66 dst[1] = src[1]; 79 dst[1] = src[1];
67 dst[2] = src[2]; 80 dst[2] = src[2];
68 dst[3] = src[3]; 81 dst[3] = src[3];
69 dst[4] = src[4]; 82 dst[4] = src[4];
(...skipping 14 matching lines...) Expand all
84 ((uint32_t *)dst)[1] = ((uint32_t *)src)[1]; 97 ((uint32_t *)dst)[1] = ((uint32_t *)src)[1];
85 ((uint32_t *)dst)[2] = ((uint32_t *)src)[2]; 98 ((uint32_t *)dst)[2] = ((uint32_t *)src)[2];
86 ((uint32_t *)dst)[3] = ((uint32_t *)src)[3]; 99 ((uint32_t *)dst)[3] = ((uint32_t *)src)[3];
87 100
88 #endif 101 #endif
89 src += src_stride; 102 src += src_stride;
90 dst += dst_stride; 103 dst += dst_stride;
91 } 104 }
92 } 105 }
93 106
94 void vp9_avg_mem16x16_c(unsigned char *src, 107 void vp9_avg_mem16x16_c(uint8_t *src,
95 int src_stride, 108 int src_stride,
96 unsigned char *dst, 109 uint8_t *dst,
97 int dst_stride) { 110 int dst_stride) {
98 int r; 111 int r;
99 112
100 for (r = 0; r < 16; r++) { 113 for (r = 0; r < 16; r++) {
101 int n; 114 int n;
102 115
103 for (n = 0; n < 16; n++) { 116 for (n = 0; n < 16; n++) {
104 dst[n] = (dst[n] + src[n] + 1) >> 1; 117 dst[n] = (dst[n] + src[n] + 1) >> 1;
105 } 118 }
106 119
107 src += src_stride; 120 src += src_stride;
108 dst += dst_stride; 121 dst += dst_stride;
109 } 122 }
110 } 123 }
111 124
112 void vp9_copy_mem8x8_c(unsigned char *src, 125 void vp9_copy_mem8x8_c(uint8_t *src,
113 int src_stride, 126 int src_stride,
114 unsigned char *dst, 127 uint8_t *dst,
115 int dst_stride) { 128 int dst_stride) {
116 int r; 129 int r;
117 130
118 for (r = 0; r < 8; r++) { 131 for (r = 0; r < 8; r++) {
119 #if !(CONFIG_FAST_UNALIGNED) 132 #if !(CONFIG_FAST_UNALIGNED)
120 dst[0] = src[0]; 133 dst[0] = src[0];
121 dst[1] = src[1]; 134 dst[1] = src[1];
122 dst[2] = src[2]; 135 dst[2] = src[2];
123 dst[3] = src[3]; 136 dst[3] = src[3];
124 dst[4] = src[4]; 137 dst[4] = src[4];
125 dst[5] = src[5]; 138 dst[5] = src[5];
126 dst[6] = src[6]; 139 dst[6] = src[6];
127 dst[7] = src[7]; 140 dst[7] = src[7];
128 #else 141 #else
129 ((uint32_t *)dst)[0] = ((uint32_t *)src)[0]; 142 ((uint32_t *)dst)[0] = ((uint32_t *)src)[0];
130 ((uint32_t *)dst)[1] = ((uint32_t *)src)[1]; 143 ((uint32_t *)dst)[1] = ((uint32_t *)src)[1];
131 #endif 144 #endif
132 src += src_stride; 145 src += src_stride;
133 dst += dst_stride; 146 dst += dst_stride;
134 } 147 }
135 } 148 }
136 149
137 void vp9_avg_mem8x8_c(unsigned char *src, 150 void vp9_avg_mem8x8_c(uint8_t *src,
138 int src_stride, 151 int src_stride,
139 unsigned char *dst, 152 uint8_t *dst,
140 int dst_stride) { 153 int dst_stride) {
141 int r; 154 int r;
142 155
143 for (r = 0; r < 8; r++) { 156 for (r = 0; r < 8; r++) {
144 int n; 157 int n;
145 158
146 for (n = 0; n < 8; n++) { 159 for (n = 0; n < 8; n++) {
147 dst[n] = (dst[n] + src[n] + 1) >> 1; 160 dst[n] = (dst[n] + src[n] + 1) >> 1;
148 } 161 }
149 162
150 src += src_stride; 163 src += src_stride;
151 dst += dst_stride; 164 dst += dst_stride;
152 } 165 }
153 } 166 }
154 167
155 void vp9_copy_mem8x4_c(unsigned char *src, 168 void vp9_copy_mem8x4_c(uint8_t *src,
156 int src_stride, 169 int src_stride,
157 unsigned char *dst, 170 uint8_t *dst,
158 int dst_stride) { 171 int dst_stride) {
159 int r; 172 int r;
160 173
161 for (r = 0; r < 4; r++) { 174 for (r = 0; r < 4; r++) {
162 #if !(CONFIG_FAST_UNALIGNED) 175 #if !(CONFIG_FAST_UNALIGNED)
163 dst[0] = src[0]; 176 dst[0] = src[0];
164 dst[1] = src[1]; 177 dst[1] = src[1];
165 dst[2] = src[2]; 178 dst[2] = src[2];
166 dst[3] = src[3]; 179 dst[3] = src[3];
167 dst[4] = src[4]; 180 dst[4] = src[4];
168 dst[5] = src[5]; 181 dst[5] = src[5];
169 dst[6] = src[6]; 182 dst[6] = src[6];
170 dst[7] = src[7]; 183 dst[7] = src[7];
171 #else 184 #else
172 ((uint32_t *)dst)[0] = ((uint32_t *)src)[0]; 185 ((uint32_t *)dst)[0] = ((uint32_t *)src)[0];
173 ((uint32_t *)dst)[1] = ((uint32_t *)src)[1]; 186 ((uint32_t *)dst)[1] = ((uint32_t *)src)[1];
174 #endif 187 #endif
175 src += src_stride; 188 src += src_stride;
176 dst += dst_stride; 189 dst += dst_stride;
177 } 190 }
178 } 191 }
179 192
180 void vp9_build_inter_predictors_b(BLOCKD *d, int pitch, vp9_subpix_fn_t sppf) { 193 void vp9_build_inter_predictors_b(BLOCKD *d, int pitch, vp9_subpix_fn_t sppf) {
181 int r; 194 int r;
182 unsigned char *ptr_base; 195 uint8_t *ptr_base;
183 unsigned char *ptr; 196 uint8_t *ptr;
184 unsigned char *pred_ptr = d->predictor; 197 uint8_t *pred_ptr = d->predictor;
185 int_mv mv; 198 int_mv mv;
186 199
187 ptr_base = *(d->base_pre); 200 ptr_base = *(d->base_pre);
188 mv.as_int = d->bmi.as_mv.first.as_int; 201 mv.as_int = d->bmi.as_mv.first.as_int;
189 202
190 if (mv.as_mv.row & 7 || mv.as_mv.col & 7) { 203 if (mv.as_mv.row & 7 || mv.as_mv.col & 7) {
191 ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + 204 ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride +
192 (mv.as_mv.col >> 3); 205 (mv.as_mv.col >> 3);
193 sppf(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, (mv.as_mv.row & 7) << 1, 206 sppf(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, (mv.as_mv.row & 7) << 1,
194 pred_ptr, pitch); 207 pred_ptr, pitch);
(...skipping 19 matching lines...) Expand all
214 227
215 /* 228 /*
216 * Similar to vp9_build_inter_predictors_b(), but instead of storing the 229 * Similar to vp9_build_inter_predictors_b(), but instead of storing the
217 * results in d->predictor, we average the contents of d->predictor (which 230 * results in d->predictor, we average the contents of d->predictor (which
218 * come from an earlier call to vp9_build_inter_predictors_b()) with the 231 * come from an earlier call to vp9_build_inter_predictors_b()) with the
219 * predictor of the second reference frame / motion vector. 232 * predictor of the second reference frame / motion vector.
220 */ 233 */
221 void vp9_build_2nd_inter_predictors_b(BLOCKD *d, int pitch, 234 void vp9_build_2nd_inter_predictors_b(BLOCKD *d, int pitch,
222 vp9_subpix_fn_t sppf) { 235 vp9_subpix_fn_t sppf) {
223 int r; 236 int r;
224 unsigned char *ptr_base; 237 uint8_t *ptr_base;
225 unsigned char *ptr; 238 uint8_t *ptr;
226 unsigned char *pred_ptr = d->predictor; 239 uint8_t *pred_ptr = d->predictor;
227 int_mv mv; 240 int_mv mv;
228 241
229 ptr_base = *(d->base_second_pre); 242 ptr_base = *(d->base_second_pre);
230 mv.as_int = d->bmi.as_mv.second.as_int; 243 mv.as_int = d->bmi.as_mv.second.as_int;
231 244
232 if (mv.as_mv.row & 7 || mv.as_mv.col & 7) { 245 if (mv.as_mv.row & 7 || mv.as_mv.col & 7) {
233 ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + 246 ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride +
234 (mv.as_mv.col >> 3); 247 (mv.as_mv.col >> 3);
235 sppf(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, (mv.as_mv.row & 7) << 1, 248 sppf(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, (mv.as_mv.row & 7) << 1,
236 pred_ptr, pitch); 249 pred_ptr, pitch);
237 } else { 250 } else {
238 ptr_base += d->pre + (mv.as_mv.row >> 3) * d->pre_stride + 251 ptr_base += d->pre + (mv.as_mv.row >> 3) * d->pre_stride +
239 (mv.as_mv.col >> 3); 252 (mv.as_mv.col >> 3);
240 ptr = ptr_base; 253 ptr = ptr_base;
241 254
242 for (r = 0; r < 4; r++) { 255 for (r = 0; r < 4; r++) {
243 pred_ptr[0] = (pred_ptr[0] + ptr[0] + 1) >> 1; 256 pred_ptr[0] = (pred_ptr[0] + ptr[0] + 1) >> 1;
244 pred_ptr[1] = (pred_ptr[1] + ptr[1] + 1) >> 1; 257 pred_ptr[1] = (pred_ptr[1] + ptr[1] + 1) >> 1;
245 pred_ptr[2] = (pred_ptr[2] + ptr[2] + 1) >> 1; 258 pred_ptr[2] = (pred_ptr[2] + ptr[2] + 1) >> 1;
246 pred_ptr[3] = (pred_ptr[3] + ptr[3] + 1) >> 1; 259 pred_ptr[3] = (pred_ptr[3] + ptr[3] + 1) >> 1;
247 pred_ptr += pitch; 260 pred_ptr += pitch;
248 ptr += d->pre_stride; 261 ptr += d->pre_stride;
249 } 262 }
250 } 263 }
251 } 264 }
252 265
253 void vp9_build_inter_predictors4b(MACROBLOCKD *xd, BLOCKD *d, int pitch) { 266 void vp9_build_inter_predictors4b(MACROBLOCKD *xd, BLOCKD *d, int pitch) {
254 unsigned char *ptr_base; 267 uint8_t *ptr_base;
255 unsigned char *ptr; 268 uint8_t *ptr;
256 unsigned char *pred_ptr = d->predictor; 269 uint8_t *pred_ptr = d->predictor;
257 int_mv mv; 270 int_mv mv;
258 271
259 ptr_base = *(d->base_pre); 272 ptr_base = *(d->base_pre);
260 mv.as_int = d->bmi.as_mv.first.as_int; 273 mv.as_int = d->bmi.as_mv.first.as_int;
261 ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + 274 ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride +
262 (mv.as_mv.col >> 3); 275 (mv.as_mv.col >> 3);
263 276
264 if (mv.as_mv.row & 7 || mv.as_mv.col & 7) { 277 if (mv.as_mv.row & 7 || mv.as_mv.col & 7) {
265 xd->subpixel_predict8x8(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, 278 xd->subpixel_predict8x8(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1,
266 (mv.as_mv.row & 7) << 1, pred_ptr, pitch); 279 (mv.as_mv.row & 7) << 1, pred_ptr, pitch);
267 } else { 280 } else {
268 vp9_copy_mem8x8(ptr, d->pre_stride, pred_ptr, pitch); 281 vp9_copy_mem8x8(ptr, d->pre_stride, pred_ptr, pitch);
269 } 282 }
270 } 283 }
271 284
272 /* 285 /*
273 * Similar to build_inter_predictors_4b(), but instead of storing the 286 * Similar to build_inter_predictors_4b(), but instead of storing the
274 * results in d->predictor, we average the contents of d->predictor (which 287 * results in d->predictor, we average the contents of d->predictor (which
275 * come from an earlier call to build_inter_predictors_4b()) with the 288 * come from an earlier call to build_inter_predictors_4b()) with the
276 * predictor of the second reference frame / motion vector. 289 * predictor of the second reference frame / motion vector.
277 */ 290 */
278 void vp9_build_2nd_inter_predictors4b(MACROBLOCKD *xd, 291 void vp9_build_2nd_inter_predictors4b(MACROBLOCKD *xd,
279 BLOCKD *d, int pitch) { 292 BLOCKD *d, int pitch) {
280 unsigned char *ptr_base; 293 uint8_t *ptr_base;
281 unsigned char *ptr; 294 uint8_t *ptr;
282 unsigned char *pred_ptr = d->predictor; 295 uint8_t *pred_ptr = d->predictor;
283 int_mv mv; 296 int_mv mv;
284 297
285 ptr_base = *(d->base_second_pre); 298 ptr_base = *(d->base_second_pre);
286 mv.as_int = d->bmi.as_mv.second.as_int; 299 mv.as_int = d->bmi.as_mv.second.as_int;
287 ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + 300 ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride +
288 (mv.as_mv.col >> 3); 301 (mv.as_mv.col >> 3);
289 302
290 if (mv.as_mv.row & 7 || mv.as_mv.col & 7) { 303 if (mv.as_mv.row & 7 || mv.as_mv.col & 7) {
291 xd->subpixel_predict_avg8x8(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, 304 xd->subpixel_predict_avg8x8(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1,
292 (mv.as_mv.row & 7) << 1, pred_ptr, pitch); 305 (mv.as_mv.row & 7) << 1, pred_ptr, pitch);
293 } else { 306 } else {
294 vp9_avg_mem8x8(ptr, d->pre_stride, pred_ptr, pitch); 307 vp9_avg_mem8x8(ptr, d->pre_stride, pred_ptr, pitch);
295 } 308 }
296 } 309 }
297 310
298 static void build_inter_predictors2b(MACROBLOCKD *xd, BLOCKD *d, int pitch) { 311 static void build_inter_predictors2b(MACROBLOCKD *xd, BLOCKD *d, int pitch) {
299 unsigned char *ptr_base; 312 uint8_t *ptr_base;
300 unsigned char *ptr; 313 uint8_t *ptr;
301 unsigned char *pred_ptr = d->predictor; 314 uint8_t *pred_ptr = d->predictor;
302 int_mv mv; 315 int_mv mv;
303 316
304 ptr_base = *(d->base_pre); 317 ptr_base = *(d->base_pre);
305 mv.as_int = d->bmi.as_mv.first.as_int; 318 mv.as_int = d->bmi.as_mv.first.as_int;
306 ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride + 319 ptr = ptr_base + d->pre + (mv.as_mv.row >> 3) * d->pre_stride +
307 (mv.as_mv.col >> 3); 320 (mv.as_mv.col >> 3);
308 321
309 if (mv.as_mv.row & 7 || mv.as_mv.col & 7) { 322 if (mv.as_mv.row & 7 || mv.as_mv.col & 7) {
310 xd->subpixel_predict8x4(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1, 323 xd->subpixel_predict8x4(ptr, d->pre_stride, (mv.as_mv.col & 7) << 1,
311 (mv.as_mv.row & 7) << 1, pred_ptr, pitch); 324 (mv.as_mv.row & 7) << 1, pred_ptr, pitch);
312 } else { 325 } else {
313 vp9_copy_mem8x4(ptr, d->pre_stride, pred_ptr, pitch); 326 vp9_copy_mem8x4(ptr, d->pre_stride, pred_ptr, pitch);
314 } 327 }
315 } 328 }
316 329
317
318 /*encoder only*/
319 #if CONFIG_PRED_FILTER
320
321 // Select the thresholded or non-thresholded filter
322 #define USE_THRESH_FILTER 0
323
324 #define PRED_FILT_LEN 5
325
326 static const int filt_shift = 4;
327 static const int pred_filter[PRED_FILT_LEN] = {1, 2, 10, 2, 1};
328 // Alternative filter {1, 1, 4, 1, 1}
329
330 #if !USE_THRESH_FILTER
331 void filter_mb(unsigned char *src, int src_stride,
332 unsigned char *dst, int dst_stride,
333 int width, int height) {
334 int i, j, k;
335 unsigned int Temp[32 * 32];
336 unsigned int *pTmp = Temp;
337 unsigned char *pSrc = src - (1 + src_stride) * (PRED_FILT_LEN / 2);
338
339 // Horizontal
340 for (i = 0; i < height + PRED_FILT_LEN - 1; i++) {
341 for (j = 0; j < width; j++) {
342 int sum = 0;
343 for (k = 0; k < PRED_FILT_LEN; k++)
344 sum += pSrc[j + k] * pred_filter[k];
345 pTmp[j] = sum;
346 }
347
348 pSrc += src_stride;
349 pTmp += width;
350 }
351
352 // Vertical
353 pTmp = Temp;
354 for (i = 0; i < width; i++) {
355 unsigned char *pDst = dst + i;
356 for (j = 0; j < height; j++) {
357 int sum = 0;
358 for (k = 0; k < PRED_FILT_LEN; k++)
359 sum += pTmp[(j + k) * width] * pred_filter[k];
360 // Round
361 sum = (sum + ((1 << (filt_shift << 1)) >> 1)) >> (filt_shift << 1);
362 pDst[j * dst_stride] = (sum < 0 ? 0 : sum > 255 ? 255 : sum);
363 }
364 ++pTmp;
365 }
366 }
367 #else
368 // Based on vp9_post_proc_down_and_across_c (vp9_postproc.c)
369 void filter_mb(unsigned char *src, int src_stride,
370 unsigned char *dst, int dst_stride,
371 int width, int height) {
372 unsigned char *pSrc, *pDst;
373 int row;
374 int col;
375 int i;
376 int v;
377 unsigned char d[8];
378
379 /* TODO flimit should be linked to the quantizer value */
380 int flimit = 7;
381
382 for (row = 0; row < height; row++) {
383 /* post_proc_down for one row */
384 pSrc = src;
385 pDst = dst;
386
387 for (col = 0; col < width; col++) {
388 int kernel = (1 << (filt_shift - 1));
389 int v = pSrc[col];
390
391 for (i = -2; i <= 2; i++) {
392 if (abs(v - pSrc[col + i * src_stride]) > flimit)
393 goto down_skip_convolve;
394
395 kernel += pred_filter[2 + i] * pSrc[col + i * src_stride];
396 }
397
398 v = (kernel >> filt_shift);
399 down_skip_convolve:
400 pDst[col] = v;
401 }
402
403 /* now post_proc_across */
404 pSrc = dst;
405 pDst = dst;
406
407 for (i = 0; i < 8; i++)
408 d[i] = pSrc[i];
409
410 for (col = 0; col < width; col++) {
411 int kernel = (1 << (filt_shift - 1));
412 v = pSrc[col];
413
414 d[col & 7] = v;
415
416 for (i = -2; i <= 2; i++) {
417 if (abs(v - pSrc[col + i]) > flimit)
418 goto across_skip_convolve;
419
420 kernel += pred_filter[2 + i] * pSrc[col + i];
421 }
422
423 d[col & 7] = (kernel >> filt_shift);
424 across_skip_convolve:
425
426 if (col >= 2)
427 pDst[col - 2] = d[(col - 2) & 7];
428 }
429
430 /* handle the last two pixels */
431 pDst[col - 2] = d[(col - 2) & 7];
432 pDst[col - 1] = d[(col - 1) & 7];
433
434 /* next row */
435 src += src_stride;
436 dst += dst_stride;
437 }
438 }
439 #endif // !USE_THRESH_FILTER
440
441 #endif // CONFIG_PRED_FILTER
442
443 /*encoder only*/ 330 /*encoder only*/
444 void vp9_build_inter4x4_predictors_mbuv(MACROBLOCKD *xd) { 331 void vp9_build_inter4x4_predictors_mbuv(MACROBLOCKD *xd) {
445 int i, j; 332 int i, j;
446 BLOCKD *blockd = xd->block; 333 BLOCKD *blockd = xd->block;
447 334
448 /* build uv mvs */ 335 /* build uv mvs */
449 for (i = 0; i < 2; i++) { 336 for (i = 0; i < 2; i++) {
450 for (j = 0; j < 2; j++) { 337 for (j = 0; j < 2; j++) {
451 int yoffset = i * 8 + j * 2; 338 int yoffset = i * 8 + j * 2;
452 int uoffset = 16 + i * 2 + j; 339 int uoffset = 16 + i * 2 + j;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 } 404 }
518 } 405 }
519 406
520 for (i = 16; i < 24; i += 2) { 407 for (i = 16; i < 24; i += 2) {
521 BLOCKD *d0 = &blockd[i]; 408 BLOCKD *d0 = &blockd[i];
522 BLOCKD *d1 = &blockd[i + 1]; 409 BLOCKD *d1 = &blockd[i + 1];
523 410
524 if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int) 411 if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int)
525 build_inter_predictors2b(xd, d0, 8); 412 build_inter_predictors2b(xd, d0, 8);
526 else { 413 else {
527 vp9_build_inter_predictors_b(d0, 8, xd->subpixel_predict); 414 vp9_build_inter_predictors_b(d0, 8, xd->subpixel_predict4x4);
528 vp9_build_inter_predictors_b(d1, 8, xd->subpixel_predict); 415 vp9_build_inter_predictors_b(d1, 8, xd->subpixel_predict4x4);
529 } 416 }
530 417
531 if (xd->mode_info_context->mbmi.second_ref_frame > 0) { 418 if (xd->mode_info_context->mbmi.second_ref_frame > 0) {
532 vp9_build_2nd_inter_predictors_b(d0, 8, xd->subpixel_predict_avg); 419 vp9_build_2nd_inter_predictors_b(d0, 8, xd->subpixel_predict_avg4x4);
533 vp9_build_2nd_inter_predictors_b(d1, 8, xd->subpixel_predict_avg); 420 vp9_build_2nd_inter_predictors_b(d1, 8, xd->subpixel_predict_avg4x4);
534 } 421 }
535 } 422 }
536 } 423 }
537 424
538 static void clamp_mv_to_umv_border(MV *mv, const MACROBLOCKD *xd) { 425 static void clamp_mv_to_umv_border(MV *mv, const MACROBLOCKD *xd) {
539 /* If the MV points so far into the UMV border that no visible pixels 426 /* If the MV points so far into the UMV border that no visible pixels
540 * are used for reconstruction, the subpel part of the MV can be 427 * are used for reconstruction, the subpel part of the MV can be
541 * discarded and the MV limited to 16 pixels with equivalent results. 428 * discarded and the MV limited to 16 pixels with equivalent results.
542 * 429 *
543 * This limit kicks in at 19 pixels for the top and left edges, for 430 * This limit kicks in at 19 pixels for the top and left edges, for
(...skipping 22 matching lines...) Expand all
566 (xd->mb_to_right_edge + (16 << 3)) >> 1 : mv->col; 453 (xd->mb_to_right_edge + (16 << 3)) >> 1 : mv->col;
567 454
568 mv->row = (2 * mv->row < (xd->mb_to_top_edge - ((16 + extend) << 3))) ? 455 mv->row = (2 * mv->row < (xd->mb_to_top_edge - ((16 + extend) << 3))) ?
569 (xd->mb_to_top_edge - (16 << 3)) >> 1 : mv->row; 456 (xd->mb_to_top_edge - (16 << 3)) >> 1 : mv->row;
570 mv->row = (2 * mv->row > xd->mb_to_bottom_edge + ((15 + extend) << 3)) ? 457 mv->row = (2 * mv->row > xd->mb_to_bottom_edge + ((15 + extend) << 3)) ?
571 (xd->mb_to_bottom_edge + (16 << 3)) >> 1 : mv->row; 458 (xd->mb_to_bottom_edge + (16 << 3)) >> 1 : mv->row;
572 } 459 }
573 460
574 /*encoder only*/ 461 /*encoder only*/
575 void vp9_build_1st_inter16x16_predictors_mby(MACROBLOCKD *xd, 462 void vp9_build_1st_inter16x16_predictors_mby(MACROBLOCKD *xd,
576 unsigned char *dst_y, 463 uint8_t *dst_y,
577 int dst_ystride, 464 int dst_ystride,
578 int clamp_mvs) { 465 int clamp_mvs) {
579 unsigned char *ptr_base = xd->pre.y_buffer; 466 uint8_t *ptr_base = xd->pre.y_buffer;
580 unsigned char *ptr; 467 uint8_t *ptr;
581 int pre_stride = xd->block[0].pre_stride; 468 int pre_stride = xd->block[0].pre_stride;
582 int_mv ymv; 469 int_mv ymv;
583 470
584 ymv.as_int = xd->mode_info_context->mbmi.mv[0].as_int; 471 ymv.as_int = xd->mode_info_context->mbmi.mv[0].as_int;
585 472
586 if (clamp_mvs) 473 if (clamp_mvs)
587 clamp_mv_to_umv_border(&ymv.as_mv, xd); 474 clamp_mv_to_umv_border(&ymv.as_mv, xd);
588 475
589 ptr = ptr_base + (ymv.as_mv.row >> 3) * pre_stride + (ymv.as_mv.col >> 3); 476 ptr = ptr_base + (ymv.as_mv.row >> 3) * pre_stride + (ymv.as_mv.col >> 3);
590 477
591 #if CONFIG_PRED_FILTER
592 if (xd->mode_info_context->mbmi.pred_filter_enabled) {
593 if ((ymv.as_mv.row | ymv.as_mv.col) & 7) {
594 // Sub-pel filter needs extended input
595 int len = 15 + (VP9_INTERP_EXTEND << 1);
596 unsigned char Temp[32 * 32]; // Data required by sub-pel filter
597 unsigned char *pTemp = Temp + (VP9_INTERP_EXTEND - 1) * (len + 1);
598
599 // Copy extended MB into Temp array, applying the spatial filter
600 filter_mb(ptr - (VP9_INTERP_EXTEND - 1) * (pre_stride + 1), pre_stride,
601 Temp, len, len, len);
602
603 // Sub-pel interpolation
604 xd->subpixel_predict16x16(pTemp, len,
605 (ymv.as_mv.col & 7) << 1,
606 (ymv.as_mv.row & 7) << 1,
607 dst_y, dst_ystride);
608 } else {
609 // Apply spatial filter to create the prediction directly
610 filter_mb(ptr, pre_stride, dst_y, dst_ystride, 16, 16);
611 }
612 } else
613 #endif
614 if ((ymv.as_mv.row | ymv.as_mv.col) & 7) { 478 if ((ymv.as_mv.row | ymv.as_mv.col) & 7) {
615 xd->subpixel_predict16x16(ptr, pre_stride, 479 xd->subpixel_predict16x16(ptr, pre_stride,
616 (ymv.as_mv.col & 7) << 1, 480 (ymv.as_mv.col & 7) << 1,
617 (ymv.as_mv.row & 7) << 1, 481 (ymv.as_mv.row & 7) << 1,
618 dst_y, dst_ystride); 482 dst_y, dst_ystride);
619 } else { 483 } else {
620 vp9_copy_mem16x16(ptr, pre_stride, dst_y, dst_ystride); 484 vp9_copy_mem16x16(ptr, pre_stride, dst_y, dst_ystride);
621 } 485 }
622 } 486 }
623 487
624 void vp9_build_1st_inter16x16_predictors_mbuv(MACROBLOCKD *xd, 488 void vp9_build_1st_inter16x16_predictors_mbuv(MACROBLOCKD *xd,
625 unsigned char *dst_u, 489 uint8_t *dst_u,
626 unsigned char *dst_v, 490 uint8_t *dst_v,
627 int dst_uvstride) { 491 int dst_uvstride) {
628 int offset; 492 int offset;
629 unsigned char *uptr, *vptr; 493 uint8_t *uptr, *vptr;
630 int pre_stride = xd->block[0].pre_stride; 494 int pre_stride = xd->block[0].pre_stride;
631 int_mv _o16x16mv; 495 int_mv _o16x16mv;
632 int_mv _16x16mv; 496 int_mv _16x16mv;
633 497
634 _16x16mv.as_int = xd->mode_info_context->mbmi.mv[0].as_int; 498 _16x16mv.as_int = xd->mode_info_context->mbmi.mv[0].as_int;
635 499
636 if (xd->mode_info_context->mbmi.need_to_clamp_mvs) 500 if (xd->mode_info_context->mbmi.need_to_clamp_mvs)
637 clamp_mv_to_umv_border(&_16x16mv.as_mv, xd); 501 clamp_mv_to_umv_border(&_16x16mv.as_mv, xd);
638 502
639 _o16x16mv = _16x16mv; 503 _o16x16mv = _16x16mv;
(...skipping 12 matching lines...) Expand all
652 _16x16mv.as_mv.col /= 2; 516 _16x16mv.as_mv.col /= 2;
653 517
654 _16x16mv.as_mv.row &= xd->fullpixel_mask; 518 _16x16mv.as_mv.row &= xd->fullpixel_mask;
655 _16x16mv.as_mv.col &= xd->fullpixel_mask; 519 _16x16mv.as_mv.col &= xd->fullpixel_mask;
656 520
657 pre_stride >>= 1; 521 pre_stride >>= 1;
658 offset = (_16x16mv.as_mv.row >> 3) * pre_stride + (_16x16mv.as_mv.col >> 3); 522 offset = (_16x16mv.as_mv.row >> 3) * pre_stride + (_16x16mv.as_mv.col >> 3);
659 uptr = xd->pre.u_buffer + offset; 523 uptr = xd->pre.u_buffer + offset;
660 vptr = xd->pre.v_buffer + offset; 524 vptr = xd->pre.v_buffer + offset;
661 525
662 #if CONFIG_PRED_FILTER
663 if (xd->mode_info_context->mbmi.pred_filter_enabled) {
664 int i;
665 unsigned char *pSrc = uptr;
666 unsigned char *pDst = dst_u;
667 int len = 7 + (VP9_INTERP_EXTEND << 1);
668 unsigned char Temp[32 * 32]; // Data required by the sub-pel filter
669 unsigned char *pTemp = Temp + (VP9_INTERP_EXTEND - 1) * (len + 1);
670
671 // U & V
672 for (i = 0; i < 2; i++) {
673 if (_o16x16mv.as_int & 0x000f000f) {
674 // Copy extended MB into Temp array, applying the spatial filter
675 filter_mb(pSrc - (VP9_INTERP_EXTEND - 1) * (pre_stride + 1), pre_stride,
676 Temp, len, len, len);
677
678 // Sub-pel filter
679 xd->subpixel_predict8x8(pTemp, len,
680 _o16x16mv.as_mv.col & 15,
681 _o16x16mv.as_mv.row & 15,
682 pDst, dst_uvstride);
683 } else {
684 filter_mb(pSrc, pre_stride, pDst, dst_uvstride, 8, 8);
685 }
686
687 // V
688 pSrc = vptr;
689 pDst = dst_v;
690 }
691 } else
692 #endif
693 if (_o16x16mv.as_int & 0x000f000f) { 526 if (_o16x16mv.as_int & 0x000f000f) {
694 xd->subpixel_predict8x8(uptr, pre_stride, _o16x16mv.as_mv.col & 15, 527 xd->subpixel_predict8x8(uptr, pre_stride, _o16x16mv.as_mv.col & 15,
695 _o16x16mv.as_mv.row & 15, dst_u, dst_uvstride); 528 _o16x16mv.as_mv.row & 15, dst_u, dst_uvstride);
696 xd->subpixel_predict8x8(vptr, pre_stride, _o16x16mv.as_mv.col & 15, 529 xd->subpixel_predict8x8(vptr, pre_stride, _o16x16mv.as_mv.col & 15,
697 _o16x16mv.as_mv.row & 15, dst_v, dst_uvstride); 530 _o16x16mv.as_mv.row & 15, dst_v, dst_uvstride);
698 } else { 531 } else {
699 vp9_copy_mem8x8(uptr, pre_stride, dst_u, dst_uvstride); 532 vp9_copy_mem8x8(uptr, pre_stride, dst_u, dst_uvstride);
700 vp9_copy_mem8x8(vptr, pre_stride, dst_v, dst_uvstride); 533 vp9_copy_mem8x8(vptr, pre_stride, dst_v, dst_uvstride);
701 } 534 }
702 } 535 }
703 536
704 537
705 void vp9_build_1st_inter16x16_predictors_mb(MACROBLOCKD *xd, 538 void vp9_build_1st_inter16x16_predictors_mb(MACROBLOCKD *xd,
706 unsigned char *dst_y, 539 uint8_t *dst_y,
707 unsigned char *dst_u, 540 uint8_t *dst_u,
708 unsigned char *dst_v, 541 uint8_t *dst_v,
709 int dst_ystride, int dst_uvstride) { 542 int dst_ystride, int dst_uvstride) {
710 vp9_build_1st_inter16x16_predictors_mby(xd, dst_y, dst_ystride, 543 vp9_build_1st_inter16x16_predictors_mby(xd, dst_y, dst_ystride,
711 xd->mode_info_context->mbmi.need_to_clamp_mvs); 544 xd->mode_info_context->mbmi.need_to_clamp_mvs);
712 vp9_build_1st_inter16x16_predictors_mbuv(xd, dst_u, dst_v, dst_uvstride); 545 vp9_build_1st_inter16x16_predictors_mbuv(xd, dst_u, dst_v, dst_uvstride);
713 } 546 }
714 547
715 #if CONFIG_SUPERBLOCKS
716 void vp9_build_inter32x32_predictors_sb(MACROBLOCKD *x, 548 void vp9_build_inter32x32_predictors_sb(MACROBLOCKD *x,
717 unsigned char *dst_y, 549 uint8_t *dst_y,
718 unsigned char *dst_u, 550 uint8_t *dst_u,
719 unsigned char *dst_v, 551 uint8_t *dst_v,
720 int dst_ystride, 552 int dst_ystride,
721 int dst_uvstride) { 553 int dst_uvstride) {
722 uint8_t *y1 = x->pre.y_buffer, *u1 = x->pre.u_buffer, *v1 = x->pre.v_buffer; 554 uint8_t *y1 = x->pre.y_buffer, *u1 = x->pre.u_buffer, *v1 = x->pre.v_buffer;
723 uint8_t *y2 = x->second_pre.y_buffer, *u2 = x->second_pre.u_buffer, 555 uint8_t *y2 = x->second_pre.y_buffer, *u2 = x->second_pre.u_buffer,
724 *v2 = x->second_pre.v_buffer; 556 *v2 = x->second_pre.v_buffer;
725 int edge[4], n; 557 int edge[4], n;
726 558
727 edge[0] = x->mb_to_top_edge; 559 edge[0] = x->mb_to_top_edge;
728 edge[1] = x->mb_to_bottom_edge; 560 edge[1] = x->mb_to_bottom_edge;
729 edge[2] = x->mb_to_left_edge; 561 edge[2] = x->mb_to_left_edge;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 x->second_pre.v_buffer = v2; 606 x->second_pre.v_buffer = v2;
775 } 607 }
776 608
777 #if CONFIG_COMP_INTERINTRA_PRED 609 #if CONFIG_COMP_INTERINTRA_PRED
778 if (x->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) { 610 if (x->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) {
779 vp9_build_interintra_32x32_predictors_sb( 611 vp9_build_interintra_32x32_predictors_sb(
780 x, dst_y, dst_u, dst_v, dst_ystride, dst_uvstride); 612 x, dst_y, dst_u, dst_v, dst_ystride, dst_uvstride);
781 } 613 }
782 #endif 614 #endif
783 } 615 }
616
617 void vp9_build_inter64x64_predictors_sb(MACROBLOCKD *x,
618 uint8_t *dst_y,
619 uint8_t *dst_u,
620 uint8_t *dst_v,
621 int dst_ystride,
622 int dst_uvstride) {
623 uint8_t *y1 = x->pre.y_buffer, *u1 = x->pre.u_buffer, *v1 = x->pre.v_buffer;
624 uint8_t *y2 = x->second_pre.y_buffer, *u2 = x->second_pre.u_buffer,
625 *v2 = x->second_pre.v_buffer;
626 int edge[4], n;
627
628 edge[0] = x->mb_to_top_edge;
629 edge[1] = x->mb_to_bottom_edge;
630 edge[2] = x->mb_to_left_edge;
631 edge[3] = x->mb_to_right_edge;
632
633 for (n = 0; n < 4; n++) {
634 const int x_idx = n & 1, y_idx = n >> 1;
635
636 x->mb_to_top_edge = edge[0] - ((y_idx * 32) << 3);
637 x->mb_to_bottom_edge = edge[1] + (((1 - y_idx) * 32) << 3);
638 x->mb_to_left_edge = edge[2] - ((x_idx * 32) << 3);
639 x->mb_to_right_edge = edge[3] + (((1 - x_idx) * 32) << 3);
640
641 x->pre.y_buffer = y1 + y_idx * 32 * x->pre.y_stride + x_idx * 32;
642 x->pre.u_buffer = u1 + y_idx * 16 * x->pre.uv_stride + x_idx * 16;
643 x->pre.v_buffer = v1 + y_idx * 16 * x->pre.uv_stride + x_idx * 16;
644
645 if (x->mode_info_context->mbmi.second_ref_frame > 0) {
646 x->second_pre.y_buffer = y2 + y_idx * 32 * x->pre.y_stride + x_idx * 32;
647 x->second_pre.u_buffer = u2 + y_idx * 16 * x->pre.uv_stride + x_idx * 16;
648 x->second_pre.v_buffer = v2 + y_idx * 16 * x->pre.uv_stride + x_idx * 16;
649 }
650
651 vp9_build_inter32x32_predictors_sb(x,
652 dst_y + y_idx * 32 * dst_ystride + x_idx * 32,
653 dst_u + y_idx * 16 * dst_uvstride + x_idx * 16,
654 dst_v + y_idx * 16 * dst_uvstride + x_idx * 16,
655 dst_ystride, dst_uvstride);
656 }
657
658 x->mb_to_top_edge = edge[0];
659 x->mb_to_bottom_edge = edge[1];
660 x->mb_to_left_edge = edge[2];
661 x->mb_to_right_edge = edge[3];
662
663 x->pre.y_buffer = y1;
664 x->pre.u_buffer = u1;
665 x->pre.v_buffer = v1;
666
667 if (x->mode_info_context->mbmi.second_ref_frame > 0) {
668 x->second_pre.y_buffer = y2;
669 x->second_pre.u_buffer = u2;
670 x->second_pre.v_buffer = v2;
671 }
672
673 #if CONFIG_COMP_INTERINTRA_PRED
674 if (x->mode_info_context->mbmi.second_ref_frame == INTRA_FRAME) {
675 vp9_build_interintra_64x64_predictors_sb(x, dst_y, dst_u, dst_v,
676 dst_ystride, dst_uvstride);
677 }
784 #endif 678 #endif
679 }
785 680
786 /* 681 /*
787 * The following functions should be called after an initial 682 * The following functions should be called after an initial
788 * call to vp9_build_1st_inter16x16_predictors_mb() or _mby()/_mbuv(). 683 * call to vp9_build_1st_inter16x16_predictors_mb() or _mby()/_mbuv().
789 * It will run a second sixtap filter on a (different) ref 684 * It will run a second filter on a (different) ref
790 * frame and average the result with the output of the 685 * frame and average the result with the output of the
791 * first sixtap filter. The second reference frame is stored 686 * first filter. The second reference frame is stored
792 * in x->second_pre (the reference frame index is in 687 * in x->second_pre (the reference frame index is in
793 * x->mode_info_context->mbmi.second_ref_frame). The second 688 * x->mode_info_context->mbmi.second_ref_frame). The second
794 * motion vector is x->mode_info_context->mbmi.second_mv. 689 * motion vector is x->mode_info_context->mbmi.second_mv.
795 * 690 *
796 * This allows blending prediction from two reference frames 691 * This allows blending prediction from two reference frames
797 * which sometimes leads to better prediction than from a 692 * which sometimes leads to better prediction than from a
798 * single reference framer. 693 * single reference framer.
799 */ 694 */
800 void vp9_build_2nd_inter16x16_predictors_mby(MACROBLOCKD *xd, 695 void vp9_build_2nd_inter16x16_predictors_mby(MACROBLOCKD *xd,
801 unsigned char *dst_y, 696 uint8_t *dst_y,
802 int dst_ystride) { 697 int dst_ystride) {
803 unsigned char *ptr; 698 uint8_t *ptr;
804 699
805 int_mv _16x16mv; 700 int_mv _16x16mv;
806 int mv_row; 701 int mv_row;
807 int mv_col; 702 int mv_col;
808 703
809 unsigned char *ptr_base = xd->second_pre.y_buffer; 704 uint8_t *ptr_base = xd->second_pre.y_buffer;
810 int pre_stride = xd->block[0].pre_stride; 705 int pre_stride = xd->block[0].pre_stride;
811 706
812 _16x16mv.as_int = xd->mode_info_context->mbmi.mv[1].as_int; 707 _16x16mv.as_int = xd->mode_info_context->mbmi.mv[1].as_int;
813 708
814 if (xd->mode_info_context->mbmi.need_to_clamp_secondmv) 709 if (xd->mode_info_context->mbmi.need_to_clamp_secondmv)
815 clamp_mv_to_umv_border(&_16x16mv.as_mv, xd); 710 clamp_mv_to_umv_border(&_16x16mv.as_mv, xd);
816 711
817 mv_row = _16x16mv.as_mv.row; 712 mv_row = _16x16mv.as_mv.row;
818 mv_col = _16x16mv.as_mv.col; 713 mv_col = _16x16mv.as_mv.col;
819 714
820 ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3); 715 ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
821 716
822 #if CONFIG_PRED_FILTER 717 if ((mv_row | mv_col) & 7) {
823 if (xd->mode_info_context->mbmi.pred_filter_enabled) { 718 xd->subpixel_predict_avg16x16(ptr, pre_stride, (mv_col & 7) << 1,
824 if ((mv_row | mv_col) & 7) { 719 (mv_row & 7) << 1, dst_y, dst_ystride);
825 // Sub-pel filter needs extended input 720 } else {
826 int len = 15 + (VP9_INTERP_EXTEND << 1); 721 vp9_avg_mem16x16(ptr, pre_stride, dst_y, dst_ystride);
827 unsigned char Temp[32 * 32]; // Data required by sub-pel filter
828 unsigned char *pTemp = Temp + (VP9_INTERP_EXTEND - 1) * (len + 1);
829
830 // Copy extended MB into Temp array, applying the spatial filter
831 filter_mb(ptr - (VP9_INTERP_EXTEND - 1) * (pre_stride + 1), pre_stride,
832 Temp, len, len, len);
833
834 // Sub-pel filter
835 xd->subpixel_predict_avg16x16(pTemp, len, (mv_col & 7) << 1,
836 (mv_row & 7) << 1, dst_y, dst_ystride);
837 } else {
838 // TODO Needs to AVERAGE with the dst_y
839 // For now, do not apply the prediction filter in these cases!
840 vp9_avg_mem16x16(ptr, pre_stride, dst_y, dst_ystride);
841 }
842 } else
843 #endif // CONFIG_PRED_FILTER
844 {
845 if ((mv_row | mv_col) & 7) {
846 xd->subpixel_predict_avg16x16(ptr, pre_stride, (mv_col & 7) << 1,
847 (mv_row & 7) << 1, dst_y, dst_ystride);
848 } else {
849 vp9_avg_mem16x16(ptr, pre_stride, dst_y, dst_ystride);
850 }
851 } 722 }
852 } 723 }
853 724
854 void vp9_build_2nd_inter16x16_predictors_mbuv(MACROBLOCKD *xd, 725 void vp9_build_2nd_inter16x16_predictors_mbuv(MACROBLOCKD *xd,
855 unsigned char *dst_u, 726 uint8_t *dst_u,
856 unsigned char *dst_v, 727 uint8_t *dst_v,
857 int dst_uvstride) { 728 int dst_uvstride) {
858 int offset; 729 int offset;
859 unsigned char *uptr, *vptr; 730 uint8_t *uptr, *vptr;
860 731
861 int_mv _16x16mv; 732 int_mv _16x16mv;
862 int mv_row; 733 int mv_row;
863 int mv_col; 734 int mv_col;
864 int omv_row, omv_col; 735 int omv_row, omv_col;
865 736
866 int pre_stride = xd->block[0].pre_stride; 737 int pre_stride = xd->block[0].pre_stride;
867 738
868 _16x16mv.as_int = xd->mode_info_context->mbmi.mv[1].as_int; 739 _16x16mv.as_int = xd->mode_info_context->mbmi.mv[1].as_int;
869 740
(...skipping 10 matching lines...) Expand all
880 mv_col = (mv_col + (mv_col > 0)) >> 1; 751 mv_col = (mv_col + (mv_col > 0)) >> 1;
881 752
882 mv_row &= xd->fullpixel_mask; 753 mv_row &= xd->fullpixel_mask;
883 mv_col &= xd->fullpixel_mask; 754 mv_col &= xd->fullpixel_mask;
884 755
885 pre_stride >>= 1; 756 pre_stride >>= 1;
886 offset = (mv_row >> 3) * pre_stride + (mv_col >> 3); 757 offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
887 uptr = xd->second_pre.u_buffer + offset; 758 uptr = xd->second_pre.u_buffer + offset;
888 vptr = xd->second_pre.v_buffer + offset; 759 vptr = xd->second_pre.v_buffer + offset;
889 760
890 #if CONFIG_PRED_FILTER
891 if (xd->mode_info_context->mbmi.pred_filter_enabled) {
892 int i;
893 int len = 7 + (VP9_INTERP_EXTEND << 1);
894 unsigned char Temp[32 * 32]; // Data required by sub-pel filter
895 unsigned char *pTemp = Temp + (VP9_INTERP_EXTEND - 1) * (len + 1);
896 unsigned char *pSrc = uptr;
897 unsigned char *pDst = dst_u;
898
899 // U & V
900 for (i = 0; i < 2; i++) {
901 if ((omv_row | omv_col) & 15) {
902 // Copy extended MB into Temp array, applying the spatial filter
903 filter_mb(pSrc - (VP9_INTERP_EXTEND - 1) * (pre_stride + 1), pre_stride,
904 Temp, len, len, len);
905
906 // Sub-pel filter
907 xd->subpixel_predict_avg8x8(pTemp, len, omv_col & 15,
908 omv_row & 15, pDst, dst_uvstride);
909 } else {
910 // TODO Needs to AVERAGE with the dst_[u|v]
911 // For now, do not apply the prediction filter here!
912 vp9_avg_mem8x8(pSrc, pre_stride, pDst, dst_uvstride);
913 }
914
915 // V
916 pSrc = vptr;
917 pDst = dst_v;
918 }
919 } else
920 #endif // CONFIG_PRED_FILTER
921 if ((omv_row | omv_col) & 15) { 761 if ((omv_row | omv_col) & 15) {
922 xd->subpixel_predict_avg8x8(uptr, pre_stride, omv_col & 15, 762 xd->subpixel_predict_avg8x8(uptr, pre_stride, omv_col & 15,
923 omv_row & 15, dst_u, dst_uvstride); 763 omv_row & 15, dst_u, dst_uvstride);
924 xd->subpixel_predict_avg8x8(vptr, pre_stride, omv_col & 15, 764 xd->subpixel_predict_avg8x8(vptr, pre_stride, omv_col & 15,
925 omv_row & 15, dst_v, dst_uvstride); 765 omv_row & 15, dst_v, dst_uvstride);
926 } else { 766 } else {
927 vp9_avg_mem8x8(uptr, pre_stride, dst_u, dst_uvstride); 767 vp9_avg_mem8x8(uptr, pre_stride, dst_u, dst_uvstride);
928 vp9_avg_mem8x8(vptr, pre_stride, dst_v, dst_uvstride); 768 vp9_avg_mem8x8(vptr, pre_stride, dst_v, dst_uvstride);
929 } 769 }
930 } 770 }
931 771
932 void vp9_build_2nd_inter16x16_predictors_mb(MACROBLOCKD *xd, 772 void vp9_build_2nd_inter16x16_predictors_mb(MACROBLOCKD *xd,
933 unsigned char *dst_y, 773 uint8_t *dst_y,
934 unsigned char *dst_u, 774 uint8_t *dst_u,
935 unsigned char *dst_v, 775 uint8_t *dst_v,
936 int dst_ystride, 776 int dst_ystride,
937 int dst_uvstride) { 777 int dst_uvstride) {
938 vp9_build_2nd_inter16x16_predictors_mby(xd, dst_y, dst_ystride); 778 vp9_build_2nd_inter16x16_predictors_mby(xd, dst_y, dst_ystride);
939 vp9_build_2nd_inter16x16_predictors_mbuv(xd, dst_u, dst_v, dst_uvstride); 779 vp9_build_2nd_inter16x16_predictors_mbuv(xd, dst_u, dst_v, dst_uvstride);
940 } 780 }
941 781
942 static void build_inter4x4_predictors_mb(MACROBLOCKD *xd) { 782 static void build_inter4x4_predictors_mb(MACROBLOCKD *xd) {
943 int i; 783 int i;
944 MB_MODE_INFO * mbmi = &xd->mode_info_context->mbmi; 784 MB_MODE_INFO * mbmi = &xd->mode_info_context->mbmi;
945 BLOCKD *blockd = xd->block; 785 BLOCKD *blockd = xd->block;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 clamp_mv_to_umv_border(&blockd[i + 1].bmi.as_mv.first.as_mv, xd); 828 clamp_mv_to_umv_border(&blockd[i + 1].bmi.as_mv.first.as_mv, xd);
989 if (mbmi->second_ref_frame > 0) { 829 if (mbmi->second_ref_frame > 0) {
990 clamp_mv_to_umv_border(&blockd[i + 0].bmi.as_mv.second.as_mv, xd); 830 clamp_mv_to_umv_border(&blockd[i + 0].bmi.as_mv.second.as_mv, xd);
991 clamp_mv_to_umv_border(&blockd[i + 1].bmi.as_mv.second.as_mv, xd); 831 clamp_mv_to_umv_border(&blockd[i + 1].bmi.as_mv.second.as_mv, xd);
992 } 832 }
993 } 833 }
994 834
995 if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int) 835 if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int)
996 build_inter_predictors2b(xd, d0, 16); 836 build_inter_predictors2b(xd, d0, 16);
997 else { 837 else {
998 vp9_build_inter_predictors_b(d0, 16, xd->subpixel_predict); 838 vp9_build_inter_predictors_b(d0, 16, xd->subpixel_predict4x4);
999 vp9_build_inter_predictors_b(d1, 16, xd->subpixel_predict); 839 vp9_build_inter_predictors_b(d1, 16, xd->subpixel_predict4x4);
1000 } 840 }
1001 841
1002 if (mbmi->second_ref_frame > 0) { 842 if (mbmi->second_ref_frame > 0) {
1003 vp9_build_2nd_inter_predictors_b(d0, 16, xd->subpixel_predict_avg); 843 vp9_build_2nd_inter_predictors_b(d0, 16, xd->subpixel_predict_avg4x4);
1004 vp9_build_2nd_inter_predictors_b(d1, 16, xd->subpixel_predict_avg); 844 vp9_build_2nd_inter_predictors_b(d1, 16, xd->subpixel_predict_avg4x4);
1005 } 845 }
1006 } 846 }
1007 } 847 }
1008 848
1009 for (i = 16; i < 24; i += 2) { 849 for (i = 16; i < 24; i += 2) {
1010 BLOCKD *d0 = &blockd[i]; 850 BLOCKD *d0 = &blockd[i];
1011 BLOCKD *d1 = &blockd[i + 1]; 851 BLOCKD *d1 = &blockd[i + 1];
1012 852
1013 if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int) 853 if (d0->bmi.as_mv.first.as_int == d1->bmi.as_mv.first.as_int)
1014 build_inter_predictors2b(xd, d0, 8); 854 build_inter_predictors2b(xd, d0, 8);
1015 else { 855 else {
1016 vp9_build_inter_predictors_b(d0, 8, xd->subpixel_predict); 856 vp9_build_inter_predictors_b(d0, 8, xd->subpixel_predict4x4);
1017 vp9_build_inter_predictors_b(d1, 8, xd->subpixel_predict); 857 vp9_build_inter_predictors_b(d1, 8, xd->subpixel_predict4x4);
1018 } 858 }
1019 859
1020 if (mbmi->second_ref_frame > 0) { 860 if (mbmi->second_ref_frame > 0) {
1021 vp9_build_2nd_inter_predictors_b(d0, 8, xd->subpixel_predict_avg); 861 vp9_build_2nd_inter_predictors_b(d0, 8, xd->subpixel_predict_avg4x4);
1022 vp9_build_2nd_inter_predictors_b(d1, 8, xd->subpixel_predict_avg); 862 vp9_build_2nd_inter_predictors_b(d1, 8, xd->subpixel_predict_avg4x4);
1023 } 863 }
1024 } 864 }
1025 } 865 }
1026 866
1027 static 867 static
1028 void build_4x4uvmvs(MACROBLOCKD *xd) { 868 void build_4x4uvmvs(MACROBLOCKD *xd) {
1029 int i, j; 869 int i, j;
1030 BLOCKD *blockd = xd->block; 870 BLOCKD *blockd = xd->block;
1031 871
1032 for (i = 0; i < 2; i++) { 872 for (i = 0; i < 2; i++) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 vp9_build_interintra_16x16_predictors_mb(xd, xd->predictor, 975 vp9_build_interintra_16x16_predictors_mb(xd, xd->predictor,
1136 &xd->predictor[256], 976 &xd->predictor[256],
1137 &xd->predictor[320], 16, 8); 977 &xd->predictor[320], 16, 8);
1138 } 978 }
1139 #endif 979 #endif
1140 } else { 980 } else {
1141 build_4x4uvmvs(xd); 981 build_4x4uvmvs(xd);
1142 build_inter4x4_predictors_mb(xd); 982 build_inter4x4_predictors_mb(xd);
1143 } 983 }
1144 } 984 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_reconinter.h ('k') | source/libvpx/vp9/common/vp9_reconintra.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698