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 |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 static void inverse_transform_b_4x4_add(MACROBLOCKD *xd, int eob, | 41 static void inverse_transform_b_4x4_add(MACROBLOCKD *xd, int eob, |
42 int16_t *dqcoeff, uint8_t *dest, | 42 int16_t *dqcoeff, uint8_t *dest, |
43 int stride) { | 43 int stride) { |
44 if (eob <= 1) | 44 if (eob <= 1) |
45 xd->inv_txm4x4_1_add(dqcoeff, dest, stride); | 45 xd->inv_txm4x4_1_add(dqcoeff, dest, stride); |
46 else | 46 else |
47 xd->inv_txm4x4_add(dqcoeff, dest, stride); | 47 xd->inv_txm4x4_add(dqcoeff, dest, stride); |
48 } | 48 } |
49 | 49 |
| 50 static void inverse_transform_b_8x8_add(int eob, |
| 51 int16_t *dqcoeff, uint8_t *dest, |
| 52 int stride) { |
| 53 if (eob <= 1) |
| 54 vp9_short_idct8x8_1_add(dqcoeff, dest, stride); |
| 55 else if (eob <= 10) |
| 56 vp9_short_idct10_8x8_add(dqcoeff, dest, stride); |
| 57 else |
| 58 vp9_short_idct8x8_add(dqcoeff, dest, stride); |
| 59 } |
50 | 60 |
51 static void subtract_plane(MACROBLOCK *x, BLOCK_SIZE_TYPE bsize, int plane) { | 61 static void inverse_transform_b_16x16_add(int eob, |
| 62 int16_t *dqcoeff, uint8_t *dest, |
| 63 int stride) { |
| 64 if (eob <= 1) |
| 65 vp9_short_idct16x16_1_add(dqcoeff, dest, stride); |
| 66 else if (eob <= 10) |
| 67 vp9_short_idct10_16x16_add(dqcoeff, dest, stride); |
| 68 else |
| 69 vp9_short_idct16x16_add(dqcoeff, dest, stride); |
| 70 } |
| 71 |
| 72 static void subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { |
52 struct macroblock_plane *const p = &x->plane[plane]; | 73 struct macroblock_plane *const p = &x->plane[plane]; |
53 const MACROBLOCKD *const xd = &x->e_mbd; | 74 const MACROBLOCKD *const xd = &x->e_mbd; |
54 const struct macroblockd_plane *const pd = &xd->plane[plane]; | 75 const struct macroblockd_plane *const pd = &xd->plane[plane]; |
55 const int bw = plane_block_width(bsize, pd); | 76 const int bw = plane_block_width(bsize, pd); |
56 const int bh = plane_block_height(bsize, pd); | 77 const int bh = plane_block_height(bsize, pd); |
57 | 78 |
58 vp9_subtract_block(bh, bw, p->src_diff, bw, | 79 vp9_subtract_block(bh, bw, p->src_diff, bw, |
59 p->src.buf, p->src.stride, | 80 p->src.buf, p->src.stride, |
60 pd->dst.buf, pd->dst.stride); | 81 pd->dst.buf, pd->dst.stride); |
61 } | 82 } |
62 | 83 |
63 void vp9_subtract_sby(MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { | 84 void vp9_subtract_sby(MACROBLOCK *x, BLOCK_SIZE bsize) { |
64 subtract_plane(x, bsize, 0); | 85 subtract_plane(x, bsize, 0); |
65 } | 86 } |
66 | 87 |
67 void vp9_subtract_sbuv(MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { | 88 void vp9_subtract_sbuv(MACROBLOCK *x, BLOCK_SIZE bsize) { |
68 int i; | 89 int i; |
69 | 90 |
70 for (i = 1; i < MAX_MB_PLANE; i++) | 91 for (i = 1; i < MAX_MB_PLANE; i++) |
71 subtract_plane(x, bsize, i); | 92 subtract_plane(x, bsize, i); |
72 } | 93 } |
73 | 94 |
74 void vp9_subtract_sb(MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { | 95 void vp9_subtract_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { |
75 vp9_subtract_sby(x, bsize); | 96 vp9_subtract_sby(x, bsize); |
76 vp9_subtract_sbuv(x, bsize); | 97 vp9_subtract_sbuv(x, bsize); |
77 } | 98 } |
78 | 99 |
79 | 100 |
80 #define RDTRUNC(RM,DM,R,D) ( (128+(R)*(RM)) & 0xFF ) | 101 #define RDTRUNC(RM,DM,R,D) ( (128+(R)*(RM)) & 0xFF ) |
81 typedef struct vp9_token_state vp9_token_state; | 102 typedef struct vp9_token_state vp9_token_state; |
82 | 103 |
83 struct vp9_token_state { | 104 struct vp9_token_state { |
84 int rate; | 105 int rate; |
(...skipping 28 matching lines...) Expand all Loading... |
113 const int16_t *nb, | 134 const int16_t *nb, |
114 int idx, int token, | 135 int idx, int token, |
115 uint8_t *token_cache) { | 136 uint8_t *token_cache) { |
116 int bak = token_cache[scan[idx]], pt; | 137 int bak = token_cache[scan[idx]], pt; |
117 token_cache[scan[idx]] = vp9_pt_energy_class[token]; | 138 token_cache[scan[idx]] = vp9_pt_energy_class[token]; |
118 pt = get_coef_context(nb, token_cache, idx + 1); | 139 pt = get_coef_context(nb, token_cache, idx + 1); |
119 token_cache[scan[idx]] = bak; | 140 token_cache[scan[idx]] = bak; |
120 return pt; | 141 return pt; |
121 } | 142 } |
122 | 143 |
123 static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb, | 144 static void optimize_b(MACROBLOCK *mb, |
124 int plane, int block, BLOCK_SIZE_TYPE bsize, | 145 int plane, int block, BLOCK_SIZE plane_bsize, |
125 ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, | 146 ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, |
126 TX_SIZE tx_size) { | 147 TX_SIZE tx_size) { |
127 const int ref = mb->e_mbd.mode_info_context->mbmi.ref_frame[0] != INTRA_FRAME; | |
128 MACROBLOCKD *const xd = &mb->e_mbd; | 148 MACROBLOCKD *const xd = &mb->e_mbd; |
| 149 struct macroblockd_plane *pd = &xd->plane[plane]; |
| 150 const int ref = is_inter_block(&xd->mode_info_context->mbmi); |
129 vp9_token_state tokens[1025][2]; | 151 vp9_token_state tokens[1025][2]; |
130 unsigned best_index[1025][2]; | 152 unsigned best_index[1025][2]; |
131 const int16_t *coeff_ptr = BLOCK_OFFSET(mb->plane[plane].coeff, | 153 const int16_t *coeff_ptr = BLOCK_OFFSET(mb->plane[plane].coeff, block); |
132 block, 16); | |
133 int16_t *qcoeff_ptr; | 154 int16_t *qcoeff_ptr; |
134 int16_t *dqcoeff_ptr; | 155 int16_t *dqcoeff_ptr; |
135 int eob = xd->plane[plane].eobs[block], final_eob, sz = 0; | 156 int eob = pd->eobs[block], final_eob, sz = 0; |
136 const int i0 = 0; | 157 const int i0 = 0; |
137 int rc, x, next, i; | 158 int rc, x, next, i; |
138 int64_t rdmult, rddiv, rd_cost0, rd_cost1; | 159 int64_t rdmult, rddiv, rd_cost0, rd_cost1; |
139 int rate0, rate1, error0, error1, t0, t1; | 160 int rate0, rate1, error0, error1, t0, t1; |
140 int best, band, pt; | 161 int best, band, pt; |
141 PLANE_TYPE type = xd->plane[plane].plane_type; | 162 PLANE_TYPE type = pd->plane_type; |
142 int err_mult = plane_rd_mult[type]; | 163 int err_mult = plane_rd_mult[type]; |
143 int default_eob; | 164 int default_eob; |
144 const int16_t *scan, *nb; | 165 const int16_t *scan, *nb; |
145 const int mul = 1 + (tx_size == TX_32X32); | 166 const int mul = 1 + (tx_size == TX_32X32); |
146 uint8_t token_cache[1024]; | 167 uint8_t token_cache[1024]; |
147 const int ib = txfrm_block_to_raster_block(xd, bsize, plane, | 168 const int ib = txfrm_block_to_raster_block(plane_bsize, tx_size, block); |
148 block, 2 * tx_size); | 169 const int16_t *dequant_ptr = pd->dequant; |
149 const int16_t *dequant_ptr = xd->plane[plane].dequant; | |
150 const uint8_t * band_translate; | 170 const uint8_t * band_translate; |
151 | 171 |
152 assert((!type && !plane) || (type && plane)); | 172 assert((!type && !plane) || (type && plane)); |
153 dqcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block, 16); | 173 dqcoeff_ptr = BLOCK_OFFSET(pd->dqcoeff, block); |
154 qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block, 16); | 174 qcoeff_ptr = BLOCK_OFFSET(pd->qcoeff, block); |
155 switch (tx_size) { | 175 switch (tx_size) { |
156 default: | 176 default: |
157 case TX_4X4: | 177 case TX_4X4: |
158 default_eob = 16; | 178 default_eob = 16; |
159 scan = get_scan_4x4(get_tx_type_4x4(type, xd, ib)); | 179 scan = get_scan_4x4(get_tx_type_4x4(type, xd, ib)); |
160 band_translate = vp9_coefband_trans_4x4; | 180 band_translate = vp9_coefband_trans_4x4; |
161 break; | 181 break; |
162 case TX_8X8: | 182 case TX_8X8: |
163 scan = get_scan_8x8(get_tx_type_8x8(type, xd)); | 183 scan = get_scan_8x8(get_tx_type_8x8(type, xd)); |
164 default_eob = 64; | 184 default_eob = 64; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 error1 = tokens[next][1].error; | 227 error1 = tokens[next][1].error; |
208 /* Evaluate the first possibility for this state. */ | 228 /* Evaluate the first possibility for this state. */ |
209 rate0 = tokens[next][0].rate; | 229 rate0 = tokens[next][0].rate; |
210 rate1 = tokens[next][1].rate; | 230 rate1 = tokens[next][1].rate; |
211 t0 = (vp9_dct_value_tokens_ptr + x)->token; | 231 t0 = (vp9_dct_value_tokens_ptr + x)->token; |
212 /* Consider both possible successor states. */ | 232 /* Consider both possible successor states. */ |
213 if (next < default_eob) { | 233 if (next < default_eob) { |
214 band = get_coef_band(band_translate, i + 1); | 234 band = get_coef_band(band_translate, i + 1); |
215 pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache); | 235 pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache); |
216 rate0 += | 236 rate0 += |
217 mb->token_costs[tx_size][type][ref][0][band][pt] | 237 mb->token_costs[tx_size][type][ref][band][0][pt] |
218 [tokens[next][0].token]; | 238 [tokens[next][0].token]; |
219 rate1 += | 239 rate1 += |
220 mb->token_costs[tx_size][type][ref][0][band][pt] | 240 mb->token_costs[tx_size][type][ref][band][0][pt] |
221 [tokens[next][1].token]; | 241 [tokens[next][1].token]; |
222 } | 242 } |
223 UPDATE_RD_COST(); | 243 UPDATE_RD_COST(); |
224 /* And pick the best. */ | 244 /* And pick the best. */ |
225 best = rd_cost1 < rd_cost0; | 245 best = rd_cost1 < rd_cost0; |
226 base_bits = *(vp9_dct_value_cost_ptr + x); | 246 base_bits = *(vp9_dct_value_cost_ptr + x); |
227 dx = mul * (dqcoeff_ptr[rc] - coeff_ptr[rc]); | 247 dx = mul * (dqcoeff_ptr[rc] - coeff_ptr[rc]); |
228 d2 = dx * dx; | 248 d2 = dx * dx; |
229 tokens[i][0].rate = base_bits + (best ? rate1 : rate0); | 249 tokens[i][0].rate = base_bits + (best ? rate1 : rate0); |
230 tokens[i][0].error = d2 + (best ? error1 : error0); | 250 tokens[i][0].error = d2 + (best ? error1 : error0); |
(...skipping 27 matching lines...) Expand all Loading... |
258 DCT_EOB_TOKEN : ZERO_TOKEN; | 278 DCT_EOB_TOKEN : ZERO_TOKEN; |
259 t1 = tokens[next][1].token == DCT_EOB_TOKEN ? | 279 t1 = tokens[next][1].token == DCT_EOB_TOKEN ? |
260 DCT_EOB_TOKEN : ZERO_TOKEN; | 280 DCT_EOB_TOKEN : ZERO_TOKEN; |
261 } else { | 281 } else { |
262 t0 = t1 = (vp9_dct_value_tokens_ptr + x)->token; | 282 t0 = t1 = (vp9_dct_value_tokens_ptr + x)->token; |
263 } | 283 } |
264 if (next < default_eob) { | 284 if (next < default_eob) { |
265 band = get_coef_band(band_translate, i + 1); | 285 band = get_coef_band(band_translate, i + 1); |
266 if (t0 != DCT_EOB_TOKEN) { | 286 if (t0 != DCT_EOB_TOKEN) { |
267 pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache); | 287 pt = trellis_get_coeff_context(scan, nb, i, t0, token_cache); |
268 rate0 += mb->token_costs[tx_size][type][ref][!x][band][pt] | 288 rate0 += mb->token_costs[tx_size][type][ref][band][!x][pt] |
269 [tokens[next][0].token]; | 289 [tokens[next][0].token]; |
270 } | 290 } |
271 if (t1 != DCT_EOB_TOKEN) { | 291 if (t1 != DCT_EOB_TOKEN) { |
272 pt = trellis_get_coeff_context(scan, nb, i, t1, token_cache); | 292 pt = trellis_get_coeff_context(scan, nb, i, t1, token_cache); |
273 rate1 += mb->token_costs[tx_size][type][ref][!x][band][pt] | 293 rate1 += mb->token_costs[tx_size][type][ref][band][!x][pt] |
274 [tokens[next][1].token]; | 294 [tokens[next][1].token]; |
275 } | 295 } |
276 } | 296 } |
277 | 297 |
278 UPDATE_RD_COST(); | 298 UPDATE_RD_COST(); |
279 /* And pick the best. */ | 299 /* And pick the best. */ |
280 best = rd_cost1 < rd_cost0; | 300 best = rd_cost1 < rd_cost0; |
281 base_bits = *(vp9_dct_value_cost_ptr + x); | 301 base_bits = *(vp9_dct_value_cost_ptr + x); |
282 | 302 |
283 if (shortcut) { | 303 if (shortcut) { |
(...skipping 12 matching lines...) Expand all Loading... |
296 /* There's no choice to make for a zero coefficient, so we don't | 316 /* There's no choice to make for a zero coefficient, so we don't |
297 * add a new trellis node, but we do need to update the costs. | 317 * add a new trellis node, but we do need to update the costs. |
298 */ | 318 */ |
299 else { | 319 else { |
300 band = get_coef_band(band_translate, i + 1); | 320 band = get_coef_band(band_translate, i + 1); |
301 t0 = tokens[next][0].token; | 321 t0 = tokens[next][0].token; |
302 t1 = tokens[next][1].token; | 322 t1 = tokens[next][1].token; |
303 /* Update the cost of each path if we're past the EOB token. */ | 323 /* Update the cost of each path if we're past the EOB token. */ |
304 if (t0 != DCT_EOB_TOKEN) { | 324 if (t0 != DCT_EOB_TOKEN) { |
305 tokens[next][0].rate += | 325 tokens[next][0].rate += |
306 mb->token_costs[tx_size][type][ref][1][band][0][t0]; | 326 mb->token_costs[tx_size][type][ref][band][1][0][t0]; |
307 tokens[next][0].token = ZERO_TOKEN; | 327 tokens[next][0].token = ZERO_TOKEN; |
308 } | 328 } |
309 if (t1 != DCT_EOB_TOKEN) { | 329 if (t1 != DCT_EOB_TOKEN) { |
310 tokens[next][1].rate += | 330 tokens[next][1].rate += |
311 mb->token_costs[tx_size][type][ref][1][band][0][t1]; | 331 mb->token_costs[tx_size][type][ref][band][1][0][t1]; |
312 tokens[next][1].token = ZERO_TOKEN; | 332 tokens[next][1].token = ZERO_TOKEN; |
313 } | 333 } |
314 best_index[i][0] = best_index[i][1] = 0; | 334 best_index[i][0] = best_index[i][1] = 0; |
315 /* Don't update next, because we didn't add a new node. */ | 335 /* Don't update next, because we didn't add a new node. */ |
316 } | 336 } |
317 } | 337 } |
318 | 338 |
319 /* Now pick the best path through the whole trellis. */ | 339 /* Now pick the best path through the whole trellis. */ |
320 band = get_coef_band(band_translate, i + 1); | 340 band = get_coef_band(band_translate, i + 1); |
321 pt = combine_entropy_contexts(*a, *l); | 341 pt = combine_entropy_contexts(*a, *l); |
322 rate0 = tokens[next][0].rate; | 342 rate0 = tokens[next][0].rate; |
323 rate1 = tokens[next][1].rate; | 343 rate1 = tokens[next][1].rate; |
324 error0 = tokens[next][0].error; | 344 error0 = tokens[next][0].error; |
325 error1 = tokens[next][1].error; | 345 error1 = tokens[next][1].error; |
326 t0 = tokens[next][0].token; | 346 t0 = tokens[next][0].token; |
327 t1 = tokens[next][1].token; | 347 t1 = tokens[next][1].token; |
328 rate0 += mb->token_costs[tx_size][type][ref][0][band][pt][t0]; | 348 rate0 += mb->token_costs[tx_size][type][ref][band][0][pt][t0]; |
329 rate1 += mb->token_costs[tx_size][type][ref][0][band][pt][t1]; | 349 rate1 += mb->token_costs[tx_size][type][ref][band][0][pt][t1]; |
330 UPDATE_RD_COST(); | 350 UPDATE_RD_COST(); |
331 best = rd_cost1 < rd_cost0; | 351 best = rd_cost1 < rd_cost0; |
332 final_eob = i0 - 1; | 352 final_eob = i0 - 1; |
333 vpx_memset(qcoeff_ptr, 0, sizeof(*qcoeff_ptr) * (16 << (tx_size * 2))); | 353 vpx_memset(qcoeff_ptr, 0, sizeof(*qcoeff_ptr) * (16 << (tx_size * 2))); |
334 vpx_memset(dqcoeff_ptr, 0, sizeof(*dqcoeff_ptr) * (16 << (tx_size * 2))); | 354 vpx_memset(dqcoeff_ptr, 0, sizeof(*dqcoeff_ptr) * (16 << (tx_size * 2))); |
335 for (i = next; i < eob; i = next) { | 355 for (i = next; i < eob; i = next) { |
336 x = tokens[i][best].qc; | 356 x = tokens[i][best].qc; |
337 if (x) { | 357 if (x) { |
338 final_eob = i; | 358 final_eob = i; |
339 } | 359 } |
340 rc = scan[i]; | 360 rc = scan[i]; |
341 qcoeff_ptr[rc] = x; | 361 qcoeff_ptr[rc] = x; |
342 dqcoeff_ptr[rc] = (x * dequant_ptr[rc != 0]) / mul; | 362 dqcoeff_ptr[rc] = (x * dequant_ptr[rc != 0]) / mul; |
343 | 363 |
344 next = tokens[i][best].next; | 364 next = tokens[i][best].next; |
345 best = best_index[i][best]; | 365 best = best_index[i][best]; |
346 } | 366 } |
347 final_eob++; | 367 final_eob++; |
348 | 368 |
349 xd->plane[plane].eobs[block] = final_eob; | 369 xd->plane[plane].eobs[block] = final_eob; |
350 *a = *l = (final_eob > 0); | 370 *a = *l = (final_eob > 0); |
351 } | 371 } |
352 | 372 |
353 void vp9_optimize_b(int plane, int block, BLOCK_SIZE_TYPE bsize, | 373 void vp9_optimize_b(int plane, int block, BLOCK_SIZE plane_bsize, |
354 int ss_txfrm_size, VP9_COMMON *cm, MACROBLOCK *mb, | 374 TX_SIZE tx_size, MACROBLOCK *mb, struct optimize_ctx *ctx) { |
355 struct optimize_ctx *ctx) { | |
356 MACROBLOCKD *const xd = &mb->e_mbd; | |
357 int x, y; | 375 int x, y; |
358 | 376 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y); |
359 // find current entropy context | 377 optimize_b(mb, plane, block, plane_bsize, |
360 txfrm_block_to_raster_xy(xd, bsize, plane, block, ss_txfrm_size, &x, &y); | 378 &ctx->ta[plane][x], &ctx->tl[plane][y], tx_size); |
361 | |
362 optimize_b(cm, mb, plane, block, bsize, | |
363 &ctx->ta[plane][x], &ctx->tl[plane][y], ss_txfrm_size / 2); | |
364 } | 379 } |
365 | 380 |
366 static void optimize_block(int plane, int block, BLOCK_SIZE_TYPE bsize, | 381 static void optimize_init_b(int plane, BLOCK_SIZE bsize, |
367 int ss_txfrm_size, void *arg) { | 382 struct encode_b_args *args) { |
368 const struct encode_b_args* const args = arg; | 383 const MACROBLOCKD *xd = &args->x->e_mbd; |
369 vp9_optimize_b(plane, block, bsize, ss_txfrm_size, args->cm, args->x, | 384 const struct macroblockd_plane* const pd = &xd->plane[plane]; |
370 args->ctx); | 385 const BLOCK_SIZE plane_bsize = get_plane_block_size(bsize, pd); |
371 } | 386 const int num_4x4_w = num_4x4_blocks_wide_lookup[plane_bsize]; |
| 387 const int num_4x4_h = num_4x4_blocks_high_lookup[plane_bsize]; |
| 388 const MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; |
| 389 const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi) : mbmi->txfm_size; |
| 390 int i; |
372 | 391 |
373 void vp9_optimize_init(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize, | 392 switch (tx_size) { |
374 struct optimize_ctx *ctx) { | 393 case TX_4X4: |
375 int p; | 394 vpx_memcpy(args->ctx->ta[plane], pd->above_context, |
376 | 395 sizeof(ENTROPY_CONTEXT) * num_4x4_w); |
377 for (p = 0; p < MAX_MB_PLANE; p++) { | 396 vpx_memcpy(args->ctx->tl[plane], pd->left_context, |
378 const struct macroblockd_plane* const plane = &xd->plane[p]; | 397 sizeof(ENTROPY_CONTEXT) * num_4x4_h); |
379 const int bwl = b_width_log2(bsize) - plane->subsampling_x; | 398 break; |
380 const int bhl = b_height_log2(bsize) - plane->subsampling_y; | 399 case TX_8X8: |
381 const MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; | 400 for (i = 0; i < num_4x4_w; i += 2) |
382 const TX_SIZE tx_size = p ? get_uv_tx_size(mbmi) | 401 args->ctx->ta[plane][i] = !!*(uint16_t *)&pd->above_context[i]; |
383 : mbmi->txfm_size; | 402 for (i = 0; i < num_4x4_h; i += 2) |
384 int i, j; | 403 args->ctx->tl[plane][i] = !!*(uint16_t *)&pd->left_context[i]; |
385 | 404 break; |
386 for (i = 0; i < 1 << bwl; i += 1 << tx_size) { | 405 case TX_16X16: |
387 int c = 0; | 406 for (i = 0; i < num_4x4_w; i += 4) |
388 ctx->ta[p][i] = 0; | 407 args->ctx->ta[plane][i] = !!*(uint32_t *)&pd->above_context[i]; |
389 for (j = 0; j < 1 << tx_size && !c; j++) { | 408 for (i = 0; i < num_4x4_h; i += 4) |
390 c = ctx->ta[p][i] |= plane->above_context[i + j]; | 409 args->ctx->tl[plane][i] = !!*(uint32_t *)&pd->left_context[i]; |
391 } | 410 break; |
392 } | 411 case TX_32X32: |
393 for (i = 0; i < 1 << bhl; i += 1 << tx_size) { | 412 for (i = 0; i < num_4x4_w; i += 8) |
394 int c = 0; | 413 args->ctx->ta[plane][i] = !!*(uint64_t *)&pd->above_context[i]; |
395 ctx->tl[p][i] = 0; | 414 for (i = 0; i < num_4x4_h; i += 8) |
396 for (j = 0; j < 1 << tx_size && !c; j++) { | 415 args->ctx->tl[plane][i] = !!*(uint64_t *)&pd->left_context[i]; |
397 c = ctx->tl[p][i] |= plane->left_context[i + j]; | 416 break; |
398 } | 417 default: |
399 } | 418 assert(0); |
400 } | 419 } |
401 } | 420 } |
402 | 421 |
403 void vp9_optimize_sby(VP9_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { | 422 void vp9_xform_quant(int plane, int block, BLOCK_SIZE plane_bsize, |
404 struct optimize_ctx ctx; | 423 TX_SIZE tx_size, void *arg) { |
405 struct encode_b_args arg = {cm, x, &ctx}; | |
406 vp9_optimize_init(&x->e_mbd, bsize, &ctx); | |
407 foreach_transformed_block_in_plane(&x->e_mbd, bsize, 0, optimize_block, &arg); | |
408 } | |
409 | |
410 void vp9_optimize_sbuv(VP9_COMMON *const cm, MACROBLOCK *x, | |
411 BLOCK_SIZE_TYPE bsize) { | |
412 struct optimize_ctx ctx; | |
413 struct encode_b_args arg = {cm, x, &ctx}; | |
414 vp9_optimize_init(&x->e_mbd, bsize, &ctx); | |
415 foreach_transformed_block_uv(&x->e_mbd, bsize, optimize_block, &arg); | |
416 } | |
417 | |
418 void xform_quant(int plane, int block, BLOCK_SIZE_TYPE bsize, | |
419 int ss_txfrm_size, void *arg) { | |
420 struct encode_b_args* const args = arg; | 424 struct encode_b_args* const args = arg; |
421 MACROBLOCK* const x = args->x; | 425 MACROBLOCK* const x = args->x; |
422 MACROBLOCKD* const xd = &x->e_mbd; | 426 MACROBLOCKD* const xd = &x->e_mbd; |
423 struct macroblock_plane *const p = &x->plane[plane]; | 427 struct macroblock_plane *const p = &x->plane[plane]; |
424 struct macroblockd_plane *const pd = &xd->plane[plane]; | 428 struct macroblockd_plane *const pd = &xd->plane[plane]; |
425 int16_t *coeff = BLOCK_OFFSET(p->coeff, block, 16); | 429 int16_t *coeff = BLOCK_OFFSET(p->coeff, block); |
426 int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block, 16); | 430 int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block); |
427 int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block, 16); | 431 int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); |
428 const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size / 2); | |
429 const int16_t *scan, *iscan; | 432 const int16_t *scan, *iscan; |
430 uint16_t *eob = &pd->eobs[block]; | 433 uint16_t *eob = &pd->eobs[block]; |
431 const int bwl = plane_block_width_log2by4(bsize, pd), bw = 1 << bwl; | 434 const int bwl = b_width_log2(plane_bsize), bw = 1 << bwl; |
432 const int twl = bwl - tx_size, twmask = (1 << twl) - 1; | 435 const int twl = bwl - tx_size, twmask = (1 << twl) - 1; |
433 int xoff, yoff; | 436 int xoff, yoff; |
434 int16_t *src_diff; | 437 int16_t *src_diff; |
435 | 438 |
436 switch (tx_size) { | 439 switch (tx_size) { |
437 case TX_32X32: | 440 case TX_32X32: |
438 scan = vp9_default_scan_32x32; | 441 scan = vp9_default_scan_32x32; |
439 iscan = vp9_default_iscan_32x32; | 442 iscan = vp9_default_iscan_32x32; |
440 block >>= 6; | 443 block >>= 6; |
441 xoff = 32 * (block & twmask); | 444 xoff = 32 * (block & twmask); |
442 yoff = 32 * (block >> twl); | 445 yoff = 32 * (block >> twl); |
443 src_diff = p->src_diff + 4 * bw * yoff + xoff; | 446 src_diff = p->src_diff + 4 * bw * yoff + xoff; |
444 if (x->rd_search) | 447 if (x->use_lp32x32fdct) |
445 vp9_short_fdct32x32_rd(src_diff, coeff, bw * 8); | 448 vp9_short_fdct32x32_rd(src_diff, coeff, bw * 8); |
446 else | 449 else |
447 vp9_short_fdct32x32(src_diff, coeff, bw * 8); | 450 vp9_short_fdct32x32(src_diff, coeff, bw * 8); |
448 vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round, | 451 vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round, |
449 p->quant, p->quant_shift, qcoeff, dqcoeff, | 452 p->quant, p->quant_shift, qcoeff, dqcoeff, |
450 pd->dequant, p->zbin_extra, eob, scan, iscan); | 453 pd->dequant, p->zbin_extra, eob, scan, iscan); |
451 break; | 454 break; |
452 case TX_16X16: | 455 case TX_16X16: |
453 scan = vp9_default_scan_16x16; | 456 scan = vp9_default_scan_16x16; |
454 iscan = vp9_default_iscan_16x16; | 457 iscan = vp9_default_iscan_16x16; |
(...skipping 27 matching lines...) Expand all Loading... |
482 x->fwd_txm4x4(src_diff, coeff, bw * 8); | 485 x->fwd_txm4x4(src_diff, coeff, bw * 8); |
483 vp9_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round, | 486 vp9_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round, |
484 p->quant, p->quant_shift, qcoeff, dqcoeff, | 487 p->quant, p->quant_shift, qcoeff, dqcoeff, |
485 pd->dequant, p->zbin_extra, eob, scan, iscan); | 488 pd->dequant, p->zbin_extra, eob, scan, iscan); |
486 break; | 489 break; |
487 default: | 490 default: |
488 assert(0); | 491 assert(0); |
489 } | 492 } |
490 } | 493 } |
491 | 494 |
492 static void encode_block(int plane, int block, BLOCK_SIZE_TYPE bsize, | 495 static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize, |
493 int ss_txfrm_size, void *arg) { | 496 TX_SIZE tx_size, void *arg) { |
494 struct encode_b_args *const args = arg; | 497 struct encode_b_args *const args = arg; |
495 MACROBLOCK *const x = args->x; | 498 MACROBLOCK *const x = args->x; |
496 MACROBLOCKD *const xd = &x->e_mbd; | 499 MACROBLOCKD *const xd = &x->e_mbd; |
497 const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane, | |
498 block, ss_txfrm_size); | |
499 struct macroblockd_plane *const pd = &xd->plane[plane]; | 500 struct macroblockd_plane *const pd = &xd->plane[plane]; |
500 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block, 16); | 501 const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size, |
501 uint8_t *const dst = raster_block_offset_uint8(xd, bsize, plane, | 502 block); |
502 raster_block, | 503 |
| 504 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); |
| 505 uint8_t *const dst = raster_block_offset_uint8(plane_bsize, raster_block, |
503 pd->dst.buf, pd->dst.stride); | 506 pd->dst.buf, pd->dst.stride); |
504 xform_quant(plane, block, bsize, ss_txfrm_size, arg); | 507 vp9_xform_quant(plane, block, plane_bsize, tx_size, arg); |
505 | 508 |
506 if (x->optimize) | 509 if (x->optimize) |
507 vp9_optimize_b(plane, block, bsize, ss_txfrm_size, args->cm, x, args->ctx); | 510 vp9_optimize_b(plane, block, plane_bsize, tx_size, x, args->ctx); |
508 | 511 |
509 if (x->skip_encode) | 512 if (x->skip_encode || pd->eobs[block] == 0) |
510 return; | |
511 if (pd->eobs[block] == 0) | |
512 return; | 513 return; |
513 | 514 |
514 switch (ss_txfrm_size / 2) { | 515 switch (tx_size) { |
515 case TX_32X32: | 516 case TX_32X32: |
516 vp9_short_idct32x32_add(dqcoeff, dst, pd->dst.stride); | 517 vp9_short_idct32x32_add(dqcoeff, dst, pd->dst.stride); |
517 break; | 518 break; |
518 case TX_16X16: | 519 case TX_16X16: |
519 vp9_short_idct16x16_add(dqcoeff, dst, pd->dst.stride); | 520 inverse_transform_b_16x16_add(pd->eobs[block], dqcoeff, dst, |
| 521 pd->dst.stride); |
520 break; | 522 break; |
521 case TX_8X8: | 523 case TX_8X8: |
522 vp9_short_idct8x8_add(dqcoeff, dst, pd->dst.stride); | 524 inverse_transform_b_8x8_add(pd->eobs[block], dqcoeff, dst, |
| 525 pd->dst.stride); |
523 break; | 526 break; |
524 case TX_4X4: | 527 case TX_4X4: |
525 // this is like vp9_short_idct4x4 but has a special case around eob<=1 | 528 // this is like vp9_short_idct4x4 but has a special case around eob<=1 |
526 // which is significant (not just an optimization) for the lossless | 529 // which is significant (not just an optimization) for the lossless |
527 // case. | 530 // case. |
528 inverse_transform_b_4x4_add(xd, pd->eobs[block], dqcoeff, | 531 inverse_transform_b_4x4_add(xd, pd->eobs[block], dqcoeff, |
529 dst, pd->dst.stride); | 532 dst, pd->dst.stride); |
530 break; | 533 break; |
| 534 default: |
| 535 assert(!"Invalid transform size"); |
531 } | 536 } |
532 } | 537 } |
533 | 538 |
534 void vp9_xform_quant_sby(VP9_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { | 539 void vp9_encode_sby(MACROBLOCK *x, BLOCK_SIZE bsize) { |
535 MACROBLOCKD* const xd = &x->e_mbd; | |
536 struct encode_b_args arg = {cm, x, NULL}; | |
537 | |
538 foreach_transformed_block_in_plane(xd, bsize, 0, xform_quant, &arg); | |
539 } | |
540 | |
541 void vp9_xform_quant_sbuv(VP9_COMMON *cm, MACROBLOCK *x, | |
542 BLOCK_SIZE_TYPE bsize) { | |
543 MACROBLOCKD* const xd = &x->e_mbd; | |
544 struct encode_b_args arg = {cm, x, NULL}; | |
545 | |
546 foreach_transformed_block_uv(xd, bsize, xform_quant, &arg); | |
547 } | |
548 | |
549 void vp9_encode_sby(VP9_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { | |
550 MACROBLOCKD *const xd = &x->e_mbd; | 540 MACROBLOCKD *const xd = &x->e_mbd; |
551 struct optimize_ctx ctx; | 541 struct optimize_ctx ctx; |
552 struct encode_b_args arg = {cm, x, &ctx}; | 542 struct encode_b_args arg = {x, &ctx}; |
553 | 543 |
554 vp9_subtract_sby(x, bsize); | 544 vp9_subtract_sby(x, bsize); |
555 if (x->optimize) | 545 if (x->optimize) |
556 vp9_optimize_init(xd, bsize, &ctx); | 546 optimize_init_b(0, bsize, &arg); |
557 | 547 |
558 foreach_transformed_block_in_plane(xd, bsize, 0, encode_block, &arg); | 548 foreach_transformed_block_in_plane(xd, bsize, 0, encode_block, &arg); |
559 } | 549 } |
560 | 550 |
561 void vp9_encode_sbuv(VP9_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { | 551 void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { |
562 MACROBLOCKD *const xd = &x->e_mbd; | 552 MACROBLOCKD *const xd = &x->e_mbd; |
563 struct optimize_ctx ctx; | 553 struct optimize_ctx ctx; |
564 struct encode_b_args arg = {cm, x, &ctx}; | 554 struct encode_b_args arg = {x, &ctx}; |
565 | |
566 vp9_subtract_sbuv(x, bsize); | |
567 if (x->optimize) | |
568 vp9_optimize_init(xd, bsize, &ctx); | |
569 | |
570 foreach_transformed_block_uv(xd, bsize, encode_block, &arg); | |
571 } | |
572 | |
573 void vp9_encode_sb(VP9_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize) { | |
574 MACROBLOCKD *const xd = &x->e_mbd; | |
575 struct optimize_ctx ctx; | |
576 struct encode_b_args arg = {cm, x, &ctx}; | |
577 | 555 |
578 vp9_subtract_sb(x, bsize); | 556 vp9_subtract_sb(x, bsize); |
579 if (x->optimize) | 557 |
580 vp9_optimize_init(xd, bsize, &ctx); | 558 if (x->optimize) { |
| 559 int i; |
| 560 for (i = 0; i < MAX_MB_PLANE; ++i) |
| 561 optimize_init_b(i, bsize, &arg); |
| 562 } |
581 | 563 |
582 foreach_transformed_block(xd, bsize, encode_block, &arg); | 564 foreach_transformed_block(xd, bsize, encode_block, &arg); |
583 } | 565 } |
584 | 566 |
585 void encode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize, | 567 void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, |
586 int ss_txfrm_size, void *arg) { | 568 TX_SIZE tx_size, void *arg) { |
587 struct encode_b_args* const args = arg; | 569 struct encode_b_args* const args = arg; |
588 MACROBLOCK *const x = args->x; | 570 MACROBLOCK *const x = args->x; |
589 MACROBLOCKD *const xd = &x->e_mbd; | 571 MACROBLOCKD *const xd = &x->e_mbd; |
590 MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; | 572 MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; |
591 const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size / 2); | |
592 struct macroblock_plane *const p = &x->plane[plane]; | 573 struct macroblock_plane *const p = &x->plane[plane]; |
593 struct macroblockd_plane *const pd = &xd->plane[plane]; | 574 struct macroblockd_plane *const pd = &xd->plane[plane]; |
594 int16_t *coeff = BLOCK_OFFSET(p->coeff, block, 16); | 575 int16_t *coeff = BLOCK_OFFSET(p->coeff, block); |
595 int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block, 16); | 576 int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block); |
596 int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block, 16); | 577 int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); |
597 const int16_t *scan, *iscan; | 578 const int16_t *scan, *iscan; |
598 TX_TYPE tx_type; | 579 TX_TYPE tx_type; |
599 MB_PREDICTION_MODE mode; | 580 MB_PREDICTION_MODE mode; |
600 const int bwl = b_width_log2(bsize) - pd->subsampling_x, bw = 1 << bwl; | 581 const int bwl = b_width_log2(plane_bsize), bw = 1 << bwl; |
601 const int twl = bwl - tx_size, twmask = (1 << twl) - 1; | 582 const int twl = bwl - tx_size, twmask = (1 << twl) - 1; |
602 int xoff, yoff; | 583 int xoff, yoff; |
603 uint8_t *src, *dst; | 584 uint8_t *src, *dst; |
604 int16_t *src_diff; | 585 int16_t *src_diff; |
605 uint16_t *eob = &pd->eobs[block]; | 586 uint16_t *eob = &pd->eobs[block]; |
606 | 587 |
607 if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) { | 588 if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) |
608 extend_for_intra(xd, plane, block, bsize, ss_txfrm_size); | 589 extend_for_intra(xd, plane_bsize, plane, block, tx_size); |
609 } | |
610 | 590 |
611 // if (x->optimize) | 591 // if (x->optimize) |
612 // vp9_optimize_b(plane, block, bsize, ss_txfrm_size, | 592 // vp9_optimize_b(plane, block, plane_bsize, tx_size, x, args->ctx); |
613 // args->cm, x, args->ctx); | |
614 | 593 |
615 switch (tx_size) { | 594 switch (tx_size) { |
616 case TX_32X32: | 595 case TX_32X32: |
617 scan = vp9_default_scan_32x32; | 596 scan = vp9_default_scan_32x32; |
618 iscan = vp9_default_iscan_32x32; | 597 iscan = vp9_default_iscan_32x32; |
619 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; | 598 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; |
620 block >>= 6; | 599 block >>= 6; |
621 xoff = 32 * (block & twmask); | 600 xoff = 32 * (block & twmask); |
622 yoff = 32 * (block >> twl); | 601 yoff = 32 * (block >> twl); |
623 dst = pd->dst.buf + yoff * pd->dst.stride + xoff; | 602 dst = pd->dst.buf + yoff * pd->dst.stride + xoff; |
624 src = p->src.buf + yoff * p->src.stride + xoff; | 603 src = p->src.buf + yoff * p->src.stride + xoff; |
625 src_diff = p->src_diff + 4 * bw * yoff + xoff; | 604 src_diff = p->src_diff + 4 * bw * yoff + xoff; |
626 vp9_predict_intra_block(xd, block, bwl, TX_32X32, mode, | 605 vp9_predict_intra_block(xd, block, bwl, TX_32X32, mode, |
627 dst, pd->dst.stride, dst, pd->dst.stride); | 606 dst, pd->dst.stride, dst, pd->dst.stride); |
628 vp9_subtract_block(32, 32, src_diff, bw * 4, | 607 vp9_subtract_block(32, 32, src_diff, bw * 4, |
629 src, p->src.stride, dst, pd->dst.stride); | 608 src, p->src.stride, dst, pd->dst.stride); |
630 if (x->rd_search) | 609 if (x->use_lp32x32fdct) |
631 vp9_short_fdct32x32_rd(src_diff, coeff, bw * 8); | 610 vp9_short_fdct32x32_rd(src_diff, coeff, bw * 8); |
632 else | 611 else |
633 vp9_short_fdct32x32(src_diff, coeff, bw * 8); | 612 vp9_short_fdct32x32(src_diff, coeff, bw * 8); |
634 vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round, | 613 vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round, |
635 p->quant, p->quant_shift, qcoeff, dqcoeff, | 614 p->quant, p->quant_shift, qcoeff, dqcoeff, |
636 pd->dequant, p->zbin_extra, eob, scan, iscan); | 615 pd->dequant, p->zbin_extra, eob, scan, iscan); |
637 if (!x->skip_encode && *eob) | 616 if (!x->skip_encode && *eob) |
638 vp9_short_idct32x32_add(dqcoeff, dst, pd->dst.stride); | 617 vp9_short_idct32x32_add(dqcoeff, dst, pd->dst.stride); |
639 break; | 618 break; |
640 case TX_16X16: | 619 case TX_16X16: |
(...skipping 13 matching lines...) Expand all Loading... |
654 src, p->src.stride, dst, pd->dst.stride); | 633 src, p->src.stride, dst, pd->dst.stride); |
655 if (tx_type != DCT_DCT) | 634 if (tx_type != DCT_DCT) |
656 vp9_short_fht16x16(src_diff, coeff, bw * 4, tx_type); | 635 vp9_short_fht16x16(src_diff, coeff, bw * 4, tx_type); |
657 else | 636 else |
658 x->fwd_txm16x16(src_diff, coeff, bw * 8); | 637 x->fwd_txm16x16(src_diff, coeff, bw * 8); |
659 vp9_quantize_b(coeff, 256, x->skip_block, p->zbin, p->round, p->quant, | 638 vp9_quantize_b(coeff, 256, x->skip_block, p->zbin, p->round, p->quant, |
660 p->quant_shift, qcoeff, dqcoeff, | 639 p->quant_shift, qcoeff, dqcoeff, |
661 pd->dequant, p->zbin_extra, eob, scan, iscan); | 640 pd->dequant, p->zbin_extra, eob, scan, iscan); |
662 if (!x->skip_encode && *eob) { | 641 if (!x->skip_encode && *eob) { |
663 if (tx_type == DCT_DCT) | 642 if (tx_type == DCT_DCT) |
664 vp9_short_idct16x16_add(dqcoeff, dst, pd->dst.stride); | 643 inverse_transform_b_16x16_add(*eob, dqcoeff, dst, pd->dst.stride); |
665 else | 644 else |
666 vp9_short_iht16x16_add(dqcoeff, dst, pd->dst.stride, tx_type); | 645 vp9_short_iht16x16_add(dqcoeff, dst, pd->dst.stride, tx_type); |
667 } | 646 } |
668 break; | 647 break; |
669 case TX_8X8: | 648 case TX_8X8: |
670 tx_type = get_tx_type_8x8(pd->plane_type, xd); | 649 tx_type = get_tx_type_8x8(pd->plane_type, xd); |
671 scan = get_scan_8x8(tx_type); | 650 scan = get_scan_8x8(tx_type); |
672 iscan = get_iscan_8x8(tx_type); | 651 iscan = get_iscan_8x8(tx_type); |
673 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; | 652 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; |
674 block >>= 2; | 653 block >>= 2; |
675 xoff = 8 * (block & twmask); | 654 xoff = 8 * (block & twmask); |
676 yoff = 8 * (block >> twl); | 655 yoff = 8 * (block >> twl); |
677 dst = pd->dst.buf + yoff * pd->dst.stride + xoff; | 656 dst = pd->dst.buf + yoff * pd->dst.stride + xoff; |
678 src = p->src.buf + yoff * p->src.stride + xoff; | 657 src = p->src.buf + yoff * p->src.stride + xoff; |
679 src_diff = p->src_diff + 4 * bw * yoff + xoff; | 658 src_diff = p->src_diff + 4 * bw * yoff + xoff; |
680 vp9_predict_intra_block(xd, block, bwl, TX_8X8, mode, | 659 vp9_predict_intra_block(xd, block, bwl, TX_8X8, mode, |
681 dst, pd->dst.stride, dst, pd->dst.stride); | 660 dst, pd->dst.stride, dst, pd->dst.stride); |
682 vp9_subtract_block(8, 8, src_diff, bw * 4, | 661 vp9_subtract_block(8, 8, src_diff, bw * 4, |
683 src, p->src.stride, dst, pd->dst.stride); | 662 src, p->src.stride, dst, pd->dst.stride); |
684 if (tx_type != DCT_DCT) | 663 if (tx_type != DCT_DCT) |
685 vp9_short_fht8x8(src_diff, coeff, bw * 4, tx_type); | 664 vp9_short_fht8x8(src_diff, coeff, bw * 4, tx_type); |
686 else | 665 else |
687 x->fwd_txm8x8(src_diff, coeff, bw * 8); | 666 x->fwd_txm8x8(src_diff, coeff, bw * 8); |
688 vp9_quantize_b(coeff, 64, x->skip_block, p->zbin, p->round, p->quant, | 667 vp9_quantize_b(coeff, 64, x->skip_block, p->zbin, p->round, p->quant, |
689 p->quant_shift, qcoeff, dqcoeff, | 668 p->quant_shift, qcoeff, dqcoeff, |
690 pd->dequant, p->zbin_extra, eob, scan, iscan); | 669 pd->dequant, p->zbin_extra, eob, scan, iscan); |
691 if (!x->skip_encode && *eob) { | 670 if (!x->skip_encode && *eob) { |
692 if (tx_type == DCT_DCT) | 671 if (tx_type == DCT_DCT) |
693 vp9_short_idct8x8_add(dqcoeff, dst, pd->dst.stride); | 672 inverse_transform_b_8x8_add(*eob, dqcoeff, dst, pd->dst.stride); |
694 else | 673 else |
695 vp9_short_iht8x8_add(dqcoeff, dst, pd->dst.stride, tx_type); | 674 vp9_short_iht8x8_add(dqcoeff, dst, pd->dst.stride, tx_type); |
696 } | 675 } |
697 break; | 676 break; |
698 case TX_4X4: | 677 case TX_4X4: |
699 tx_type = get_tx_type_4x4(pd->plane_type, xd, block); | 678 tx_type = get_tx_type_4x4(pd->plane_type, xd, block); |
700 scan = get_scan_4x4(tx_type); | 679 scan = get_scan_4x4(tx_type); |
701 iscan = get_iscan_4x4(tx_type); | 680 iscan = get_iscan_4x4(tx_type); |
702 if (mbmi->sb_type < BLOCK_SIZE_SB8X8 && plane == 0) { | 681 if (mbmi->sb_type < BLOCK_8X8 && plane == 0) |
703 mode = xd->mode_info_context->bmi[block].as_mode; | 682 mode = xd->mode_info_context->bmi[block].as_mode; |
704 } else { | 683 else |
705 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; | 684 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; |
706 } | 685 |
707 xoff = 4 * (block & twmask); | 686 xoff = 4 * (block & twmask); |
708 yoff = 4 * (block >> twl); | 687 yoff = 4 * (block >> twl); |
709 dst = pd->dst.buf + yoff * pd->dst.stride + xoff; | 688 dst = pd->dst.buf + yoff * pd->dst.stride + xoff; |
710 src = p->src.buf + yoff * p->src.stride + xoff; | 689 src = p->src.buf + yoff * p->src.stride + xoff; |
711 src_diff = p->src_diff + 4 * bw * yoff + xoff; | 690 src_diff = p->src_diff + 4 * bw * yoff + xoff; |
712 vp9_predict_intra_block(xd, block, bwl, TX_4X4, mode, | 691 vp9_predict_intra_block(xd, block, bwl, TX_4X4, mode, |
713 dst, pd->dst.stride, dst, pd->dst.stride); | 692 dst, pd->dst.stride, dst, pd->dst.stride); |
714 vp9_subtract_block(4, 4, src_diff, bw * 4, | 693 vp9_subtract_block(4, 4, src_diff, bw * 4, |
715 src, p->src.stride, dst, pd->dst.stride); | 694 src, p->src.stride, dst, pd->dst.stride); |
716 if (tx_type != DCT_DCT) | 695 if (tx_type != DCT_DCT) |
717 vp9_short_fht4x4(src_diff, coeff, bw * 4, tx_type); | 696 vp9_short_fht4x4(src_diff, coeff, bw * 4, tx_type); |
718 else | 697 else |
719 x->fwd_txm4x4(src_diff, coeff, bw * 8); | 698 x->fwd_txm4x4(src_diff, coeff, bw * 8); |
720 vp9_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round, p->quant, | 699 vp9_quantize_b(coeff, 16, x->skip_block, p->zbin, p->round, p->quant, |
721 p->quant_shift, qcoeff, dqcoeff, | 700 p->quant_shift, qcoeff, dqcoeff, |
722 pd->dequant, p->zbin_extra, eob, scan, iscan); | 701 pd->dequant, p->zbin_extra, eob, scan, iscan); |
723 if (!x->skip_encode && *eob) { | 702 if (!x->skip_encode && *eob) { |
724 if (tx_type == DCT_DCT) | 703 if (tx_type == DCT_DCT) |
725 // this is like vp9_short_idct4x4 but has a special case around eob<=1 | 704 // this is like vp9_short_idct4x4 but has a special case around eob<=1 |
726 // which is significant (not just an optimization) for the lossless | 705 // which is significant (not just an optimization) for the lossless |
727 // case. | 706 // case. |
728 inverse_transform_b_4x4_add(xd, *eob, dqcoeff, | 707 inverse_transform_b_4x4_add(xd, *eob, dqcoeff, dst, pd->dst.stride); |
729 dst, pd->dst.stride); | |
730 else | 708 else |
731 vp9_short_iht4x4_add(dqcoeff, dst, pd->dst.stride, tx_type); | 709 vp9_short_iht4x4_add(dqcoeff, dst, pd->dst.stride, tx_type); |
732 } | 710 } |
733 break; | 711 break; |
734 default: | 712 default: |
735 assert(0); | 713 assert(0); |
736 } | 714 } |
737 } | 715 } |
738 | 716 |
739 void vp9_encode_intra_block_y(VP9_COMMON *cm, MACROBLOCK *x, | 717 void vp9_encode_intra_block_y(MACROBLOCK *x, BLOCK_SIZE bsize) { |
740 BLOCK_SIZE_TYPE bsize) { | |
741 MACROBLOCKD* const xd = &x->e_mbd; | 718 MACROBLOCKD* const xd = &x->e_mbd; |
742 struct optimize_ctx ctx; | 719 struct optimize_ctx ctx; |
743 struct encode_b_args arg = {cm, x, &ctx}; | 720 struct encode_b_args arg = {x, &ctx}; |
744 | 721 |
745 foreach_transformed_block_in_plane(xd, bsize, 0, | 722 foreach_transformed_block_in_plane(xd, bsize, 0, vp9_encode_block_intra, |
746 encode_block_intra, &arg); | 723 &arg); |
747 } | 724 } |
748 void vp9_encode_intra_block_uv(VP9_COMMON *cm, MACROBLOCK *x, | 725 void vp9_encode_intra_block_uv(MACROBLOCK *x, BLOCK_SIZE bsize) { |
749 BLOCK_SIZE_TYPE bsize) { | |
750 MACROBLOCKD* const xd = &x->e_mbd; | 726 MACROBLOCKD* const xd = &x->e_mbd; |
751 struct optimize_ctx ctx; | 727 struct optimize_ctx ctx; |
752 struct encode_b_args arg = {cm, x, &ctx}; | 728 struct encode_b_args arg = {x, &ctx}; |
753 foreach_transformed_block_uv(xd, bsize, encode_block_intra, &arg); | 729 foreach_transformed_block_uv(xd, bsize, vp9_encode_block_intra, &arg); |
754 } | 730 } |
755 | 731 |
OLD | NEW |