OLD | NEW |
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 "vpx_ports/config.h" | 11 #include "./vpx_config.h" |
12 #include "vp9_rtcd.h" | 12 #include "vp9_rtcd.h" |
13 #include "vp9/encoder/vp9_quantize.h" | 13 #include "vp9/encoder/vp9_quantize.h" |
14 #include "vp9/common/vp9_reconintra.h" | 14 #include "vp9/common/vp9_reconintra.h" |
15 #include "vp9/common/vp9_reconintra4x4.h" | 15 #include "vp9/common/vp9_reconintra4x4.h" |
16 #include "vp9/encoder/vp9_encodemb.h" | 16 #include "vp9/encoder/vp9_encodemb.h" |
17 #include "vp9/common/vp9_invtrans.h" | 17 #include "vp9/common/vp9_invtrans.h" |
18 #include "vp9/encoder/vp9_encodeintra.h" | 18 #include "vp9/encoder/vp9_encodeintra.h" |
19 | 19 |
20 int vp9_encode_intra(VP9_COMP *cpi, MACROBLOCK *x, int use_16x16_pred) { | 20 int vp9_encode_intra(VP9_COMP *cpi, MACROBLOCK *x, int use_16x16_pred) { |
21 int i; | 21 int i; |
22 int intra_pred_var = 0; | 22 int intra_pred_var = 0; |
23 MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi; | 23 MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi; |
24 (void) cpi; | 24 (void) cpi; |
25 | 25 |
26 if (use_16x16_pred) { | 26 if (use_16x16_pred) { |
27 mbmi->mode = DC_PRED; | 27 mbmi->mode = DC_PRED; |
28 #if CONFIG_COMP_INTRA_PRED | |
29 mbmi->second_mode = (MB_PREDICTION_MODE)(DC_PRED - 1); | |
30 #endif | |
31 mbmi->uv_mode = DC_PRED; | 28 mbmi->uv_mode = DC_PRED; |
32 mbmi->ref_frame = INTRA_FRAME; | 29 mbmi->ref_frame = INTRA_FRAME; |
33 | 30 |
34 vp9_encode_intra16x16mby(x); | 31 vp9_encode_intra16x16mby(x); |
35 } else { | 32 } else { |
36 for (i = 0; i < 16; i++) { | 33 for (i = 0; i < 16; i++) { |
37 x->e_mbd.block[i].bmi.as_mode.first = B_DC_PRED; | 34 x->e_mbd.block[i].bmi.as_mode.first = B_DC_PRED; |
38 vp9_encode_intra4x4block(x, i); | 35 vp9_encode_intra4x4block(x, i); |
39 } | 36 } |
40 } | 37 } |
41 | 38 |
42 intra_pred_var = vp9_get_mb_ss(x->src_diff); | 39 intra_pred_var = vp9_get_mb_ss(x->src_diff); |
43 | 40 |
44 return intra_pred_var; | 41 return intra_pred_var; |
45 } | 42 } |
46 | 43 |
47 void vp9_encode_intra4x4block(MACROBLOCK *x, int ib) { | 44 void vp9_encode_intra4x4block(MACROBLOCK *x, int ib) { |
48 BLOCKD *b = &x->e_mbd.block[ib]; | 45 BLOCKD *b = &x->e_mbd.block[ib]; |
49 BLOCK *be = &x->block[ib]; | 46 BLOCK *be = &x->block[ib]; |
50 TX_TYPE tx_type; | 47 TX_TYPE tx_type; |
51 | 48 |
52 #if CONFIG_NEWBINTRAMODES | 49 #if CONFIG_NEWBINTRAMODES |
53 b->bmi.as_mode.context = vp9_find_bpred_context(b); | 50 b->bmi.as_mode.context = vp9_find_bpred_context(b); |
54 #endif | 51 #endif |
55 | 52 |
56 #if CONFIG_COMP_INTRA_PRED | 53 vp9_intra4x4_predict(b, b->bmi.as_mode.first, b->predictor); |
57 if (b->bmi.as_mode.second == (B_PREDICTION_MODE)(B_DC_PRED - 1)) { | |
58 #endif | |
59 vp9_intra4x4_predict(b, b->bmi.as_mode.first, b->predictor); | |
60 #if CONFIG_COMP_INTRA_PRED | |
61 } else { | |
62 vp9_comp_intra4x4_predict(b, b->bmi.as_mode.first, b->bmi.as_mode.second, | |
63 b->predictor); | |
64 } | |
65 #endif | |
66 | |
67 vp9_subtract_b(be, b, 16); | 54 vp9_subtract_b(be, b, 16); |
68 | 55 |
69 tx_type = get_tx_type_4x4(&x->e_mbd, b); | 56 tx_type = get_tx_type_4x4(&x->e_mbd, b); |
70 if (tx_type != DCT_DCT) { | 57 if (tx_type != DCT_DCT) { |
71 vp9_fht(be->src_diff, 32, be->coeff, tx_type, 4); | 58 vp9_fht(be->src_diff, 32, be->coeff, tx_type, 4); |
72 vp9_ht_quantize_b_4x4(be, b, tx_type); | 59 vp9_ht_quantize_b_4x4(be, b, tx_type); |
73 vp9_ihtllm(b->dqcoeff, b->diff, 32, tx_type, 4, b->eob); | 60 vp9_ihtllm(b->dqcoeff, b->diff, 32, tx_type, 4, b->eob); |
74 } else { | 61 } else { |
75 x->vp9_short_fdct4x4(be->src_diff, be->coeff, 32); | 62 x->vp9_short_fdct4x4(be->src_diff, be->coeff, 32); |
76 x->quantize_b_4x4(be, b) ; | 63 x->quantize_b_4x4(be, b) ; |
77 vp9_inverse_transform_b_4x4(&x->e_mbd, ib, 32); | 64 vp9_inverse_transform_b_4x4(&x->e_mbd, ib, 32); |
78 } | 65 } |
79 | 66 |
80 vp9_recon_b(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride); | 67 vp9_recon_b(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride); |
81 } | 68 } |
82 | 69 |
83 void vp9_encode_intra4x4mby(MACROBLOCK *mb) { | 70 void vp9_encode_intra4x4mby(MACROBLOCK *mb) { |
84 int i; | 71 int i; |
85 | 72 |
86 for (i = 0; i < 16; i++) | 73 for (i = 0; i < 16; i++) |
87 vp9_encode_intra4x4block(mb, i); | 74 vp9_encode_intra4x4block(mb, i); |
88 return; | 75 return; |
89 } | 76 } |
90 | 77 |
91 void vp9_encode_intra16x16mby(MACROBLOCK *x) { | 78 void vp9_encode_intra16x16mby(MACROBLOCK *x) { |
92 MACROBLOCKD *xd = &x->e_mbd; | 79 MACROBLOCKD *xd = &x->e_mbd; |
93 BLOCK *b = &x->block[0]; | 80 BLOCK *b = &x->block[0]; |
94 TX_SIZE tx_size = xd->mode_info_context->mbmi.txfm_size; | 81 TX_SIZE tx_size = xd->mode_info_context->mbmi.txfm_size; |
95 | 82 |
96 #if CONFIG_COMP_INTRA_PRED | 83 vp9_build_intra_predictors_mby(xd); |
97 if (xd->mode_info_context->mbmi.second_mode == (MB_PREDICTION_MODE)(DC_PRED -
1)) | |
98 #endif | |
99 vp9_build_intra_predictors_mby(xd); | |
100 #if CONFIG_COMP_INTRA_PRED | |
101 else | |
102 vp9_build_comp_intra_predictors_mby(xd); | |
103 #endif | |
104 | 84 |
105 vp9_subtract_mby(x->src_diff, *(b->base_src), xd->predictor, b->src_stride); | 85 vp9_subtract_mby(x->src_diff, *(b->base_src), xd->predictor, b->src_stride); |
106 | 86 |
107 if (tx_size == TX_16X16) { | 87 if (tx_size == TX_16X16) { |
108 vp9_transform_mby_16x16(x); | 88 vp9_transform_mby_16x16(x); |
109 vp9_quantize_mby_16x16(x); | 89 vp9_quantize_mby_16x16(x); |
110 if (x->optimize) | 90 if (x->optimize) |
111 vp9_optimize_mby_16x16(x); | 91 vp9_optimize_mby_16x16(x); |
112 vp9_inverse_transform_mby_16x16(xd); | 92 vp9_inverse_transform_mby_16x16(xd); |
113 } else if (tx_size == TX_8X8) { | 93 } else if (tx_size == TX_8X8) { |
(...skipping 10 matching lines...) Expand all Loading... |
124 vp9_inverse_transform_mby_4x4(xd); | 104 vp9_inverse_transform_mby_4x4(xd); |
125 } | 105 } |
126 | 106 |
127 vp9_recon_mby(xd); | 107 vp9_recon_mby(xd); |
128 } | 108 } |
129 | 109 |
130 void vp9_encode_intra16x16mbuv(MACROBLOCK *x) { | 110 void vp9_encode_intra16x16mbuv(MACROBLOCK *x) { |
131 MACROBLOCKD *xd = &x->e_mbd; | 111 MACROBLOCKD *xd = &x->e_mbd; |
132 TX_SIZE tx_size = xd->mode_info_context->mbmi.txfm_size; | 112 TX_SIZE tx_size = xd->mode_info_context->mbmi.txfm_size; |
133 | 113 |
134 #if CONFIG_COMP_INTRA_PRED | 114 vp9_build_intra_predictors_mbuv(xd); |
135 if (xd->mode_info_context->mbmi.second_uv_mode == (MB_PREDICTION_MODE)(DC_PRED
- 1)) { | |
136 #endif | |
137 vp9_build_intra_predictors_mbuv(xd); | |
138 #if CONFIG_COMP_INTRA_PRED | |
139 } else { | |
140 vp9_build_comp_intra_predictors_mbuv(xd); | |
141 } | |
142 #endif | |
143 | 115 |
144 vp9_subtract_mbuv(x->src_diff, x->src.u_buffer, x->src.v_buffer, | 116 vp9_subtract_mbuv(x->src_diff, x->src.u_buffer, x->src.v_buffer, |
145 xd->predictor, x->src.uv_stride); | 117 xd->predictor, x->src.uv_stride); |
146 | 118 |
147 if (tx_size == TX_4X4) { | 119 if (tx_size == TX_4X4) { |
148 vp9_transform_mbuv_4x4(x); | 120 vp9_transform_mbuv_4x4(x); |
149 vp9_quantize_mbuv_4x4(x); | 121 vp9_quantize_mbuv_4x4(x); |
150 if (x->optimize) | 122 if (x->optimize) |
151 vp9_optimize_mbuv_4x4(x); | 123 vp9_optimize_mbuv_4x4(x); |
152 vp9_inverse_transform_mbuv_4x4(xd); | 124 vp9_inverse_transform_mbuv_4x4(xd); |
153 } else /* 16x16 or 8x8 */ { | 125 } else /* 16x16 or 8x8 */ { |
154 vp9_transform_mbuv_8x8(x); | 126 vp9_transform_mbuv_8x8(x); |
155 vp9_quantize_mbuv_8x8(x); | 127 vp9_quantize_mbuv_8x8(x); |
156 if (x->optimize) | 128 if (x->optimize) |
157 vp9_optimize_mbuv_8x8(x); | 129 vp9_optimize_mbuv_8x8(x); |
158 vp9_inverse_transform_mbuv_8x8(xd); | 130 vp9_inverse_transform_mbuv_8x8(xd); |
159 } | 131 } |
160 | 132 |
161 vp9_recon_intra_mbuv(xd); | 133 vp9_recon_intra_mbuv(xd); |
162 } | 134 } |
163 | 135 |
164 void vp9_encode_intra8x8(MACROBLOCK *x, int ib) { | 136 void vp9_encode_intra8x8(MACROBLOCK *x, int ib) { |
165 MACROBLOCKD *xd = &x->e_mbd; | 137 MACROBLOCKD *xd = &x->e_mbd; |
166 BLOCKD *b = &xd->block[ib]; | 138 BLOCKD *b = &xd->block[ib]; |
167 BLOCK *be = &x->block[ib]; | 139 BLOCK *be = &x->block[ib]; |
168 const int iblock[4] = {0, 1, 4, 5}; | 140 const int iblock[4] = {0, 1, 4, 5}; |
169 int i; | 141 int i; |
170 TX_TYPE tx_type; | 142 TX_TYPE tx_type; |
171 | 143 |
172 #if CONFIG_COMP_INTRA_PRED | 144 vp9_intra8x8_predict(b, b->bmi.as_mode.first, b->predictor); |
173 if (b->bmi.as_mode.second == (MB_PREDICTION_MODE)(DC_PRED - 1)) { | |
174 #endif | |
175 vp9_intra8x8_predict(b, b->bmi.as_mode.first, b->predictor); | |
176 #if CONFIG_COMP_INTRA_PRED | |
177 } else { | |
178 vp9_comp_intra8x8_predict(b, b->bmi.as_mode.first, b->bmi.as_mode.second, | |
179 b->predictor); | |
180 } | |
181 #endif | |
182 // generate residual blocks | 145 // generate residual blocks |
183 vp9_subtract_4b_c(be, b, 16); | 146 vp9_subtract_4b_c(be, b, 16); |
184 | 147 |
185 if (xd->mode_info_context->mbmi.txfm_size == TX_8X8) { | 148 if (xd->mode_info_context->mbmi.txfm_size == TX_8X8) { |
186 int idx = (ib & 0x02) ? (ib + 2) : ib; | 149 int idx = (ib & 0x02) ? (ib + 2) : ib; |
187 | 150 |
188 tx_type = get_tx_type_8x8(xd, &xd->block[ib]); | 151 tx_type = get_tx_type_8x8(xd, &xd->block[ib]); |
189 if (tx_type != DCT_DCT) { | 152 if (tx_type != DCT_DCT) { |
190 vp9_fht(be->src_diff, 32, (x->block + idx)->coeff, | 153 vp9_fht(be->src_diff, 32, (x->block + idx)->coeff, |
191 tx_type, 8); | 154 tx_type, 8); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 187 |
225 void vp9_encode_intra8x8mby(MACROBLOCK *x) { | 188 void vp9_encode_intra8x8mby(MACROBLOCK *x) { |
226 int i, ib; | 189 int i, ib; |
227 | 190 |
228 for (i = 0; i < 4; i++) { | 191 for (i = 0; i < 4; i++) { |
229 ib = vp9_i8x8_block[i]; | 192 ib = vp9_i8x8_block[i]; |
230 vp9_encode_intra8x8(x, ib); | 193 vp9_encode_intra8x8(x, ib); |
231 } | 194 } |
232 } | 195 } |
233 | 196 |
234 void vp9_encode_intra_uv4x4(MACROBLOCK *x, int ib, | 197 static void encode_intra_uv4x4(MACROBLOCK *x, int ib, |
235 int mode, int second) { | 198 int mode) { |
236 BLOCKD *b = &x->e_mbd.block[ib]; | 199 BLOCKD *b = &x->e_mbd.block[ib]; |
237 BLOCK *be = &x->block[ib]; | 200 BLOCK *be = &x->block[ib]; |
238 | 201 |
239 #if CONFIG_COMP_INTRA_PRED | 202 vp9_intra_uv4x4_predict(b, mode, b->predictor); |
240 if (second == -1) { | |
241 #endif | |
242 vp9_intra_uv4x4_predict(b, mode, b->predictor); | |
243 #if CONFIG_COMP_INTRA_PRED | |
244 } else { | |
245 vp9_comp_intra_uv4x4_predict(b, mode, second, b->predictor); | |
246 } | |
247 #endif | |
248 | 203 |
249 vp9_subtract_b(be, b, 8); | 204 vp9_subtract_b(be, b, 8); |
250 | 205 |
251 x->vp9_short_fdct4x4(be->src_diff, be->coeff, 16); | 206 x->vp9_short_fdct4x4(be->src_diff, be->coeff, 16); |
252 x->quantize_b_4x4(be, b); | 207 x->quantize_b_4x4(be, b); |
253 vp9_inverse_transform_b_4x4(&x->e_mbd, ib, 16); | 208 vp9_inverse_transform_b_4x4(&x->e_mbd, ib, 16); |
254 | 209 |
255 vp9_recon_uv_b_c(b->predictor, b->diff, *(b->base_dst) + b->dst, | 210 vp9_recon_uv_b_c(b->predictor, b->diff, *(b->base_dst) + b->dst, |
256 b->dst_stride); | 211 b->dst_stride); |
257 } | 212 } |
258 | 213 |
259 void vp9_encode_intra8x8mbuv(MACROBLOCK *x) { | 214 void vp9_encode_intra8x8mbuv(MACROBLOCK *x) { |
260 int i, ib, mode, second; | 215 int i, ib, mode; |
261 BLOCKD *b; | 216 BLOCKD *b; |
262 | 217 |
263 for (i = 0; i < 4; i++) { | 218 for (i = 0; i < 4; i++) { |
264 ib = vp9_i8x8_block[i]; | 219 ib = vp9_i8x8_block[i]; |
265 b = &x->e_mbd.block[ib]; | 220 b = &x->e_mbd.block[ib]; |
266 mode = b->bmi.as_mode.first; | 221 mode = b->bmi.as_mode.first; |
267 #if CONFIG_COMP_INTRA_PRED | 222 |
268 second = b->bmi.as_mode.second; | |
269 #else | |
270 second = -1; | |
271 #endif | |
272 /*u */ | 223 /*u */ |
273 vp9_encode_intra_uv4x4(x, i + 16, mode, second); | 224 encode_intra_uv4x4(x, i + 16, mode); |
274 /*v */ | 225 /*v */ |
275 vp9_encode_intra_uv4x4(x, i + 20, mode, second); | 226 encode_intra_uv4x4(x, i + 20, mode); |
276 } | 227 } |
277 } | 228 } |
OLD | NEW |