1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
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.
9 */
10
11
12 #include "./vpx_config.h"
13 #include "./vpx_dsp_rtcd.h"
14 #include "./vp8_rtcd.h"
15 #include "vpx_mem/vpx_mem.h"
16 #include "vpx_ports/vpx_once.h"
17 #include "blockd.h"
18 #include "vp8/common/reconintra.h"
19 #include "vp8/common/reconintra4x4.h"
20
21 enum {
22 SIZE_16,
23 SIZE_8,
24 NUM_SIZES,
25 };
26
27 typedef void (*intra_pred_fn)(uint8_t *dst, ptrdiff_t stride,
28 const uint8_t *above, const uint8_t *left);
29
30 static intra_pred_fn pred[4][NUM_SIZES];
31 static intra_pred_fn dc_pred[2][2][NUM_SIZES];
32
vp8_init_intra_predictors_internal(void)33 static void vp8_init_intra_predictors_internal(void)
34 {
35 #define INIT_SIZE(sz) \
36 pred[V_PRED][SIZE_##sz] = vpx_v_predictor_##sz##x##sz; \
37 pred[H_PRED][SIZE_##sz] = vpx_h_predictor_##sz##x##sz; \
38 pred[TM_PRED][SIZE_##sz] = vpx_tm_predictor_##sz##x##sz; \
39 \
40 dc_pred[0][0][SIZE_##sz] = vpx_dc_128_predictor_##sz##x##sz; \
41 dc_pred[0][1][SIZE_##sz] = vpx_dc_top_predictor_##sz##x##sz; \
42 dc_pred[1][0][SIZE_##sz] = vpx_dc_left_predictor_##sz##x##sz; \
43 dc_pred[1][1][SIZE_##sz] = vpx_dc_predictor_##sz##x##sz
44
45 INIT_SIZE(16);
46 INIT_SIZE(8);
47 vp8_init_intra4x4_predictors_internal();
48 }
49
vp8_build_intra_predictors_mby_s(MACROBLOCKD * x,unsigned char * yabove_row,unsigned char * yleft,int left_stride,unsigned char * ypred_ptr,int y_stride)50 void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x,
51 unsigned char * yabove_row,
52 unsigned char * yleft,
53 int left_stride,
54 unsigned char * ypred_ptr,
55 int y_stride)
56 {
57 MB_PREDICTION_MODE mode = x->mode_info_context->mbmi.mode;
58 DECLARE_ALIGNED(16, uint8_t, yleft_col[16]);
59 int i;
60 intra_pred_fn fn;
61
62 for (i = 0; i < 16; i++)
63 {
64 yleft_col[i] = yleft[i* left_stride];
65 }
66
67 if (mode == DC_PRED)
68 {
69 fn = dc_pred[x->left_available][x->up_available][SIZE_16];
70 }
71 else
72 {
73 fn = pred[mode][SIZE_16];
74 }
75
76 fn(ypred_ptr, y_stride, yabove_row, yleft_col);
77 }
78
vp8_build_intra_predictors_mbuv_s(MACROBLOCKD * x,unsigned char * uabove_row,unsigned char * vabove_row,unsigned char * uleft,unsigned char * vleft,int left_stride,unsigned char * upred_ptr,unsigned char * vpred_ptr,int pred_stride)79 void vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x,
80 unsigned char * uabove_row,
81 unsigned char * vabove_row,
82 unsigned char * uleft,
83 unsigned char * vleft,
84 int left_stride,
85 unsigned char * upred_ptr,
86 unsigned char * vpred_ptr,
87 int pred_stride)
88 {
89 MB_PREDICTION_MODE uvmode = x->mode_info_context->mbmi.uv_mode;
90 unsigned char uleft_col[8];
91 unsigned char vleft_col[8];
92 int i;
93 intra_pred_fn fn;
94
95 for (i = 0; i < 8; i++)
96 {
97 uleft_col[i] = uleft[i * left_stride];
98 vleft_col[i] = vleft[i * left_stride];
99 }
100
101 if (uvmode == DC_PRED)
102 {
103 fn = dc_pred[x->left_available][x->up_available][SIZE_8];
104 }
105 else
106 {
107 fn = pred[uvmode][SIZE_8];
108 }
109
110 fn(upred_ptr, pred_stride, uabove_row, uleft_col);
111 fn(vpred_ptr, pred_stride, vabove_row, vleft_col);
112 }
113
vp8_init_intra_predictors(void)114 void vp8_init_intra_predictors(void)
115 {
116 once(vp8_init_intra_predictors_internal);
117 }
118