2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
12 #include "vpx_ports/config.h"
14 #include "vpx_mem/vpx_mem.h"
15 #include "reconintra.h"
17 void vp8_predict_intra4x4(BLOCKD
*x
,
19 unsigned char *predictor
)
23 unsigned char *Above
= *(x
->base_dst
) + x
->dst
- x
->dst_stride
;
24 unsigned char Left
[4];
25 unsigned char top_left
= Above
[-1];
27 Left
[0] = (*(x
->base_dst
))[x
->dst
- 1];
28 Left
[1] = (*(x
->base_dst
))[x
->dst
- 1 + x
->dst_stride
];
29 Left
[2] = (*(x
->base_dst
))[x
->dst
- 1 + 2 * x
->dst_stride
];
30 Left
[3] = (*(x
->base_dst
))[x
->dst
- 1 + 3 * x
->dst_stride
];
38 for (i
= 0; i
< 4; i
++)
40 expected_dc
+= Above
[i
];
41 expected_dc
+= Left
[i
];
44 expected_dc
= (expected_dc
+ 4) >> 3;
46 for (r
= 0; r
< 4; r
++)
48 for (c
= 0; c
< 4; c
++)
50 predictor
[c
] = expected_dc
;
59 // prediction similar to true_motion prediction
60 for (r
= 0; r
< 4; r
++)
62 for (c
= 0; c
< 4; c
++)
64 int pred
= Above
[c
] - top_left
+ Left
[r
];
84 ap
[0] = (top_left
+ 2 * Above
[0] + Above
[1] + 2) >> 2;
85 ap
[1] = (Above
[0] + 2 * Above
[1] + Above
[2] + 2) >> 2;
86 ap
[2] = (Above
[1] + 2 * Above
[2] + Above
[3] + 2) >> 2;
87 ap
[3] = (Above
[2] + 2 * Above
[3] + Above
[4] + 2) >> 2;
89 for (r
= 0; r
< 4; r
++)
91 for (c
= 0; c
< 4; c
++)
108 lp
[0] = (top_left
+ 2 * Left
[0] + Left
[1] + 2) >> 2;
109 lp
[1] = (Left
[0] + 2 * Left
[1] + Left
[2] + 2) >> 2;
110 lp
[2] = (Left
[1] + 2 * Left
[2] + Left
[3] + 2) >> 2;
111 lp
[3] = (Left
[2] + 2 * Left
[3] + Left
[3] + 2) >> 2;
113 for (r
= 0; r
< 4; r
++)
115 for (c
= 0; c
< 4; c
++)
117 predictor
[c
] = lp
[r
];
126 unsigned char *ptr
= Above
;
127 predictor
[0 * 16 + 0] = (ptr
[0] + ptr
[1] * 2 + ptr
[2] + 2) >> 2;
128 predictor
[0 * 16 + 1] =
129 predictor
[1 * 16 + 0] = (ptr
[1] + ptr
[2] * 2 + ptr
[3] + 2) >> 2;
130 predictor
[0 * 16 + 2] =
131 predictor
[1 * 16 + 1] =
132 predictor
[2 * 16 + 0] = (ptr
[2] + ptr
[3] * 2 + ptr
[4] + 2) >> 2;
133 predictor
[0 * 16 + 3] =
134 predictor
[1 * 16 + 2] =
135 predictor
[2 * 16 + 1] =
136 predictor
[3 * 16 + 0] = (ptr
[3] + ptr
[4] * 2 + ptr
[5] + 2) >> 2;
137 predictor
[1 * 16 + 3] =
138 predictor
[2 * 16 + 2] =
139 predictor
[3 * 16 + 1] = (ptr
[4] + ptr
[5] * 2 + ptr
[6] + 2) >> 2;
140 predictor
[2 * 16 + 3] =
141 predictor
[3 * 16 + 2] = (ptr
[5] + ptr
[6] * 2 + ptr
[7] + 2) >> 2;
142 predictor
[3 * 16 + 3] = (ptr
[6] + ptr
[7] * 2 + ptr
[7] + 2) >> 2;
161 predictor
[3 * 16 + 0] = (pp
[0] + pp
[1] * 2 + pp
[2] + 2) >> 2;
162 predictor
[3 * 16 + 1] =
163 predictor
[2 * 16 + 0] = (pp
[1] + pp
[2] * 2 + pp
[3] + 2) >> 2;
164 predictor
[3 * 16 + 2] =
165 predictor
[2 * 16 + 1] =
166 predictor
[1 * 16 + 0] = (pp
[2] + pp
[3] * 2 + pp
[4] + 2) >> 2;
167 predictor
[3 * 16 + 3] =
168 predictor
[2 * 16 + 2] =
169 predictor
[1 * 16 + 1] =
170 predictor
[0 * 16 + 0] = (pp
[3] + pp
[4] * 2 + pp
[5] + 2) >> 2;
171 predictor
[2 * 16 + 3] =
172 predictor
[1 * 16 + 2] =
173 predictor
[0 * 16 + 1] = (pp
[4] + pp
[5] * 2 + pp
[6] + 2) >> 2;
174 predictor
[1 * 16 + 3] =
175 predictor
[0 * 16 + 2] = (pp
[5] + pp
[6] * 2 + pp
[7] + 2) >> 2;
176 predictor
[0 * 16 + 3] = (pp
[6] + pp
[7] * 2 + pp
[8] + 2) >> 2;
196 predictor
[3 * 16 + 0] = (pp
[1] + pp
[2] * 2 + pp
[3] + 2) >> 2;
197 predictor
[2 * 16 + 0] = (pp
[2] + pp
[3] * 2 + pp
[4] + 2) >> 2;
198 predictor
[3 * 16 + 1] =
199 predictor
[1 * 16 + 0] = (pp
[3] + pp
[4] * 2 + pp
[5] + 2) >> 2;
200 predictor
[2 * 16 + 1] =
201 predictor
[0 * 16 + 0] = (pp
[4] + pp
[5] + 1) >> 1;
202 predictor
[3 * 16 + 2] =
203 predictor
[1 * 16 + 1] = (pp
[4] + pp
[5] * 2 + pp
[6] + 2) >> 2;
204 predictor
[2 * 16 + 2] =
205 predictor
[0 * 16 + 1] = (pp
[5] + pp
[6] + 1) >> 1;
206 predictor
[3 * 16 + 3] =
207 predictor
[1 * 16 + 2] = (pp
[5] + pp
[6] * 2 + pp
[7] + 2) >> 2;
208 predictor
[2 * 16 + 3] =
209 predictor
[0 * 16 + 2] = (pp
[6] + pp
[7] + 1) >> 1;
210 predictor
[1 * 16 + 3] = (pp
[6] + pp
[7] * 2 + pp
[8] + 2) >> 2;
211 predictor
[0 * 16 + 3] = (pp
[7] + pp
[8] + 1) >> 1;
218 unsigned char *pp
= Above
;
220 predictor
[0 * 16 + 0] = (pp
[0] + pp
[1] + 1) >> 1;
221 predictor
[1 * 16 + 0] = (pp
[0] + pp
[1] * 2 + pp
[2] + 2) >> 2;
222 predictor
[2 * 16 + 0] =
223 predictor
[0 * 16 + 1] = (pp
[1] + pp
[2] + 1) >> 1;
224 predictor
[1 * 16 + 1] =
225 predictor
[3 * 16 + 0] = (pp
[1] + pp
[2] * 2 + pp
[3] + 2) >> 2;
226 predictor
[2 * 16 + 1] =
227 predictor
[0 * 16 + 2] = (pp
[2] + pp
[3] + 1) >> 1;
228 predictor
[3 * 16 + 1] =
229 predictor
[1 * 16 + 2] = (pp
[2] + pp
[3] * 2 + pp
[4] + 2) >> 2;
230 predictor
[0 * 16 + 3] =
231 predictor
[2 * 16 + 2] = (pp
[3] + pp
[4] + 1) >> 1;
232 predictor
[1 * 16 + 3] =
233 predictor
[3 * 16 + 2] = (pp
[3] + pp
[4] * 2 + pp
[5] + 2) >> 2;
234 predictor
[2 * 16 + 3] = (pp
[4] + pp
[5] * 2 + pp
[6] + 2) >> 2;
235 predictor
[3 * 16 + 3] = (pp
[5] + pp
[6] * 2 + pp
[7] + 2) >> 2;
253 predictor
[3 * 16 + 0] = (pp
[0] + pp
[1] + 1) >> 1;
254 predictor
[3 * 16 + 1] = (pp
[0] + pp
[1] * 2 + pp
[2] + 2) >> 2;
255 predictor
[2 * 16 + 0] =
256 predictor
[3 * 16 + 2] = (pp
[1] + pp
[2] + 1) >> 1;
257 predictor
[2 * 16 + 1] =
258 predictor
[3 * 16 + 3] = (pp
[1] + pp
[2] * 2 + pp
[3] + 2) >> 2;
259 predictor
[2 * 16 + 2] =
260 predictor
[1 * 16 + 0] = (pp
[2] + pp
[3] + 1) >> 1;
261 predictor
[2 * 16 + 3] =
262 predictor
[1 * 16 + 1] = (pp
[2] + pp
[3] * 2 + pp
[4] + 2) >> 2;
263 predictor
[1 * 16 + 2] =
264 predictor
[0 * 16 + 0] = (pp
[3] + pp
[4] + 1) >> 1;
265 predictor
[1 * 16 + 3] =
266 predictor
[0 * 16 + 1] = (pp
[3] + pp
[4] * 2 + pp
[5] + 2) >> 2;
267 predictor
[0 * 16 + 2] = (pp
[4] + pp
[5] * 2 + pp
[6] + 2) >> 2;
268 predictor
[0 * 16 + 3] = (pp
[5] + pp
[6] * 2 + pp
[7] + 2) >> 2;
275 unsigned char *pp
= Left
;
276 predictor
[0 * 16 + 0] = (pp
[0] + pp
[1] + 1) >> 1;
277 predictor
[0 * 16 + 1] = (pp
[0] + pp
[1] * 2 + pp
[2] + 2) >> 2;
278 predictor
[0 * 16 + 2] =
279 predictor
[1 * 16 + 0] = (pp
[1] + pp
[2] + 1) >> 1;
280 predictor
[0 * 16 + 3] =
281 predictor
[1 * 16 + 1] = (pp
[1] + pp
[2] * 2 + pp
[3] + 2) >> 2;
282 predictor
[1 * 16 + 2] =
283 predictor
[2 * 16 + 0] = (pp
[2] + pp
[3] + 1) >> 1;
284 predictor
[1 * 16 + 3] =
285 predictor
[2 * 16 + 1] = (pp
[2] + pp
[3] * 2 + pp
[3] + 2) >> 2;
286 predictor
[2 * 16 + 2] =
287 predictor
[2 * 16 + 3] =
288 predictor
[3 * 16 + 0] =
289 predictor
[3 * 16 + 1] =
290 predictor
[3 * 16 + 2] =
291 predictor
[3 * 16 + 3] = pp
[3];
299 extern void vp8_intra_prediction_down_copy(MACROBLOCKD
*x
);
303 void vp8_recon_intra4x4mb(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
307 vp8_intra_prediction_down_copy(x);
311 BLOCKD *b = &x->block[i];
313 vp8_predict_intra4x4(b, x->block[i].bmi.mode,x->block[i].predictor);
314 RECON_INVOKE(rtcd, recon)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
317 vp8_recon_intra_mbuv(x);
321 void vp8_recon_intra4x4mb(const vp8_recon_rtcd_vtable_t
*rtcd
, MACROBLOCKD
*x
)
324 BLOCKD
*b
= &x
->block
[0];
326 vp8_intra_prediction_down_copy(x
);
329 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
330 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
333 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
334 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
337 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
338 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
341 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
342 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
345 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
346 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
349 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
350 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
353 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
354 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
357 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
358 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
361 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
362 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
365 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
366 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
369 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
370 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
373 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
374 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
377 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
378 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
381 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
382 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
385 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
386 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
389 vp8_predict_intra4x4(b
, b
->bmi
.mode
, b
->predictor
);
390 RECON_INVOKE(rtcd
, recon
)(b
->predictor
, b
->diff
, *(b
->base_dst
) + b
->dst
, b
->dst_stride
);
393 vp8_recon_intra_mbuv(rtcd
, x
);