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

Side by Side Diff: source/libvpx/vp9/encoder/vp9_encodemb.c

Issue 232133009: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 8 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/encoder/vp9_encodeframe.c ('k') | source/libvpx/vp9/encoder/vp9_encodemv.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
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 uint8_t *token_cache) { 100 uint8_t *token_cache) {
101 int bak = token_cache[scan[idx]], pt; 101 int bak = token_cache[scan[idx]], pt;
102 token_cache[scan[idx]] = vp9_pt_energy_class[token]; 102 token_cache[scan[idx]] = vp9_pt_energy_class[token];
103 pt = get_coef_context(nb, token_cache, idx + 1); 103 pt = get_coef_context(nb, token_cache, idx + 1);
104 token_cache[scan[idx]] = bak; 104 token_cache[scan[idx]] = bak;
105 return pt; 105 return pt;
106 } 106 }
107 107
108 static void optimize_b(int plane, int block, BLOCK_SIZE plane_bsize, 108 static void optimize_b(int plane, int block, BLOCK_SIZE plane_bsize,
109 TX_SIZE tx_size, MACROBLOCK *mb, 109 TX_SIZE tx_size, MACROBLOCK *mb,
110 struct optimize_ctx *ctx) { 110 ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
111 MACROBLOCKD *const xd = &mb->e_mbd; 111 MACROBLOCKD *const xd = &mb->e_mbd;
112 struct macroblock_plane *p = &mb->plane[plane]; 112 struct macroblock_plane *p = &mb->plane[plane];
113 struct macroblockd_plane *pd = &xd->plane[plane]; 113 struct macroblockd_plane *pd = &xd->plane[plane];
114 const int ref = is_inter_block(&xd->mi_8x8[0]->mbmi); 114 const int ref = is_inter_block(&xd->mi[0]->mbmi);
115 vp9_token_state tokens[1025][2]; 115 vp9_token_state tokens[1025][2];
116 unsigned best_index[1025][2]; 116 unsigned best_index[1025][2];
117 const int16_t *coeff = BLOCK_OFFSET(mb->plane[plane].coeff, block); 117 const int16_t *coeff = BLOCK_OFFSET(mb->plane[plane].coeff, block);
118 int16_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); 118 int16_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
119 int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); 119 int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
120 int eob = p->eobs[block], final_eob, sz = 0; 120 int eob = p->eobs[block], final_eob, sz = 0;
121 const int i0 = 0; 121 const int i0 = 0;
122 int rc, x, next, i; 122 int rc, x, next, i;
123 int64_t rdmult, rddiv, rd_cost0, rd_cost1; 123 int64_t rdmult, rddiv, rd_cost0, rd_cost1;
124 int rate0, rate1, error0, error1, t0, t1; 124 int rate0, rate1, error0, error1, t0, t1;
125 int best, band, pt; 125 int best, band, pt;
126 PLANE_TYPE type = pd->plane_type; 126 PLANE_TYPE type = pd->plane_type;
127 int err_mult = plane_rd_mult[type]; 127 int err_mult = plane_rd_mult[type];
128 const int default_eob = 16 << (tx_size << 1); 128 const int default_eob = 16 << (tx_size << 1);
129 const int mul = 1 + (tx_size == TX_32X32); 129 const int mul = 1 + (tx_size == TX_32X32);
130 uint8_t token_cache[1024]; 130 uint8_t token_cache[1024];
131 const int16_t *dequant_ptr = pd->dequant; 131 const int16_t *dequant_ptr = pd->dequant;
132 const uint8_t *const band_translate = get_band_translate(tx_size); 132 const uint8_t *const band_translate = get_band_translate(tx_size);
133 const scan_order *so = get_scan(xd, tx_size, type, block); 133 const scan_order *so = get_scan(xd, tx_size, type, block);
134 const int16_t *scan = so->scan; 134 const int16_t *scan = so->scan;
135 const int16_t *nb = so->neighbors; 135 const int16_t *nb = so->neighbors;
136 ENTROPY_CONTEXT *a, *l;
137 int tx_x, tx_y;
138 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &tx_x, &tx_y);
139 a = &ctx->ta[plane][tx_x];
140 l = &ctx->tl[plane][tx_y];
141 136
142 assert((!type && !plane) || (type && plane)); 137 assert((!type && !plane) || (type && plane));
143 assert(eob <= default_eob); 138 assert(eob <= default_eob);
144 139
145 /* Now set up a Viterbi trellis to evaluate alternative roundings. */ 140 /* Now set up a Viterbi trellis to evaluate alternative roundings. */
146 rdmult = mb->rdmult * err_mult; 141 rdmult = mb->rdmult * err_mult;
147 if (!is_inter_block(&mb->e_mbd.mi_8x8[0]->mbmi)) 142 if (!is_inter_block(&mb->e_mbd.mi[0]->mbmi))
148 rdmult = (rdmult * 9) >> 4; 143 rdmult = (rdmult * 9) >> 4;
149 rddiv = mb->rddiv; 144 rddiv = mb->rddiv;
150 /* Initialize the sentinel node of the trellis. */ 145 /* Initialize the sentinel node of the trellis. */
151 tokens[eob][0].rate = 0; 146 tokens[eob][0].rate = 0;
152 tokens[eob][0].error = 0; 147 tokens[eob][0].error = 0;
153 tokens[eob][0].next = default_eob; 148 tokens[eob][0].next = default_eob;
154 tokens[eob][0].token = EOB_TOKEN; 149 tokens[eob][0].token = EOB_TOKEN;
155 tokens[eob][0].qc = 0; 150 tokens[eob][0].qc = 0;
156 *(tokens[eob] + 1) = *(tokens[eob] + 0); 151 *(tokens[eob] + 1) = *(tokens[eob] + 0);
157 next = eob; 152 next = eob;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 TX_SIZE tx_size, void *arg) { 368 TX_SIZE tx_size, void *arg) {
374 struct encode_b_args *const args = arg; 369 struct encode_b_args *const args = arg;
375 MACROBLOCK *const x = args->x; 370 MACROBLOCK *const x = args->x;
376 MACROBLOCKD *const xd = &x->e_mbd; 371 MACROBLOCKD *const xd = &x->e_mbd;
377 struct optimize_ctx *const ctx = args->ctx; 372 struct optimize_ctx *const ctx = args->ctx;
378 struct macroblock_plane *const p = &x->plane[plane]; 373 struct macroblock_plane *const p = &x->plane[plane];
379 struct macroblockd_plane *const pd = &xd->plane[plane]; 374 struct macroblockd_plane *const pd = &xd->plane[plane];
380 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); 375 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
381 int i, j; 376 int i, j;
382 uint8_t *dst; 377 uint8_t *dst;
378 ENTROPY_CONTEXT *a, *l;
383 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); 379 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j);
384 dst = &pd->dst.buf[4 * j * pd->dst.stride + 4 * i]; 380 dst = &pd->dst.buf[4 * j * pd->dst.stride + 4 * i];
381 a = &ctx->ta[plane][i];
382 l = &ctx->tl[plane][j];
385 383
386 // TODO(jingning): per transformed block zero forcing only enabled for 384 // TODO(jingning): per transformed block zero forcing only enabled for
387 // luma component. will integrate chroma components as well. 385 // luma component. will integrate chroma components as well.
388 if (x->zcoeff_blk[tx_size][block] && plane == 0) { 386 if (x->zcoeff_blk[tx_size][block] && plane == 0) {
389 p->eobs[block] = 0; 387 p->eobs[block] = 0;
390 ctx->ta[plane][i] = 0; 388 *a = *l = 0;
391 ctx->tl[plane][j] = 0;
392 return; 389 return;
393 } 390 }
394 391
395 if (!x->skip_recode) 392 if (!x->skip_recode)
396 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); 393 vp9_xform_quant(x, plane, block, plane_bsize, tx_size);
397 394
398 if (x->optimize && (!x->skip_recode || !x->skip_optimize)) { 395 if (x->optimize && (!x->skip_recode || !x->skip_optimize)) {
399 optimize_b(plane, block, plane_bsize, tx_size, x, ctx); 396 optimize_b(plane, block, plane_bsize, tx_size, x, a, l);
400 } else { 397 } else {
401 ctx->ta[plane][i] = p->eobs[block] > 0; 398 *a = *l = p->eobs[block] > 0;
402 ctx->tl[plane][j] = p->eobs[block] > 0;
403 } 399 }
404 400
405 if (p->eobs[block]) 401 if (p->eobs[block])
406 *(args->skip) = 0; 402 *(args->skip) = 0;
407 403
408 if (x->skip_encode || p->eobs[block] == 0) 404 if (x->skip_encode || p->eobs[block] == 0)
409 return; 405 return;
410 406
411 switch (tx_size) { 407 switch (tx_size) {
412 case TX_32X32: 408 case TX_32X32:
413 vp9_idct32x32_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); 409 vp9_idct32x32_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
414 break; 410 break;
415 case TX_16X16: 411 case TX_16X16:
416 vp9_idct16x16_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); 412 vp9_idct16x16_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
417 break; 413 break;
418 case TX_8X8: 414 case TX_8X8:
419 vp9_idct8x8_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); 415 vp9_idct8x8_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
420 break; 416 break;
421 case TX_4X4: 417 case TX_4X4:
422 // this is like vp9_short_idct4x4 but has a special case around eob<=1 418 // this is like vp9_short_idct4x4 but has a special case around eob<=1
423 // which is significant (not just an optimization) for the lossless 419 // which is significant (not just an optimization) for the lossless
424 // case. 420 // case.
425 xd->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); 421 xd->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
426 break; 422 break;
427 default: 423 default:
428 assert(0 && "Invalid transform size"); 424 assert(0 && "Invalid transform size");
429 } 425 }
430 } 426 }
427
431 static void encode_block_pass1(int plane, int block, BLOCK_SIZE plane_bsize, 428 static void encode_block_pass1(int plane, int block, BLOCK_SIZE plane_bsize,
432 TX_SIZE tx_size, void *arg) { 429 TX_SIZE tx_size, void *arg) {
433 MACROBLOCK *const x = (MACROBLOCK *)arg; 430 MACROBLOCK *const x = (MACROBLOCK *)arg;
434 MACROBLOCKD *const xd = &x->e_mbd; 431 MACROBLOCKD *const xd = &x->e_mbd;
435 struct macroblock_plane *const p = &x->plane[plane]; 432 struct macroblock_plane *const p = &x->plane[plane];
436 struct macroblockd_plane *const pd = &xd->plane[plane]; 433 struct macroblockd_plane *const pd = &xd->plane[plane];
437 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); 434 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
438 int i, j; 435 int i, j;
439 uint8_t *dst; 436 uint8_t *dst;
440 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); 437 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j);
441 dst = &pd->dst.buf[4 * j * pd->dst.stride + 4 * i]; 438 dst = &pd->dst.buf[4 * j * pd->dst.stride + 4 * i];
442 439
443 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); 440 vp9_xform_quant(x, plane, block, plane_bsize, tx_size);
444 441
445 if (p->eobs[block] > 0) 442 if (p->eobs[block] > 0)
446 xd->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); 443 xd->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]);
447 } 444 }
448 445
449 void vp9_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize) { 446 void vp9_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize) {
450 vp9_subtract_plane(x, bsize, 0); 447 vp9_subtract_plane(x, bsize, 0);
451 vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, 0, 448 vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, 0,
452 encode_block_pass1, x); 449 encode_block_pass1, x);
453 } 450 }
454 451
455 void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { 452 void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) {
456 MACROBLOCKD *const xd = &x->e_mbd; 453 MACROBLOCKD *const xd = &x->e_mbd;
457 struct optimize_ctx ctx; 454 struct optimize_ctx ctx;
458 MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; 455 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
459 struct encode_b_args arg = {x, &ctx, &mbmi->skip}; 456 struct encode_b_args arg = {x, &ctx, &mbmi->skip};
460 int plane; 457 int plane;
461 458
462 for (plane = 0; plane < MAX_MB_PLANE; ++plane) { 459 for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
463 if (!x->skip_recode) 460 if (!x->skip_recode)
464 vp9_subtract_plane(x, bsize, plane); 461 vp9_subtract_plane(x, bsize, plane);
465 462
466 if (x->optimize && (!x->skip_recode || !x->skip_optimize)) { 463 if (x->optimize && (!x->skip_recode || !x->skip_optimize)) {
467 const struct macroblockd_plane* const pd = &xd->plane[plane]; 464 const struct macroblockd_plane* const pd = &xd->plane[plane];
468 const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi) : mbmi->tx_size; 465 const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi) : mbmi->tx_size;
469 vp9_get_entropy_contexts(bsize, tx_size, pd, 466 vp9_get_entropy_contexts(bsize, tx_size, pd,
470 ctx.ta[plane], ctx.tl[plane]); 467 ctx.ta[plane], ctx.tl[plane]);
471 } 468 }
472 469
473 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block, 470 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block,
474 &arg); 471 &arg);
475 } 472 }
476 } 473 }
477 474
478 static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, 475 static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
479 TX_SIZE tx_size, void *arg) { 476 TX_SIZE tx_size, void *arg) {
480 struct encode_b_args* const args = arg; 477 struct encode_b_args* const args = arg;
481 MACROBLOCK *const x = args->x; 478 MACROBLOCK *const x = args->x;
482 MACROBLOCKD *const xd = &x->e_mbd; 479 MACROBLOCKD *const xd = &x->e_mbd;
483 MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; 480 MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
484 struct macroblock_plane *const p = &x->plane[plane]; 481 struct macroblock_plane *const p = &x->plane[plane];
485 struct macroblockd_plane *const pd = &xd->plane[plane]; 482 struct macroblockd_plane *const pd = &xd->plane[plane];
486 int16_t *coeff = BLOCK_OFFSET(p->coeff, block); 483 int16_t *coeff = BLOCK_OFFSET(p->coeff, block);
487 int16_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); 484 int16_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
488 int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); 485 int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
489 const scan_order *scan_order; 486 const scan_order *scan_order;
490 TX_TYPE tx_type; 487 TX_TYPE tx_type;
491 MB_PREDICTION_MODE mode; 488 MB_PREDICTION_MODE mode;
492 const int bwl = b_width_log2(plane_bsize); 489 const int bwl = b_width_log2(plane_bsize);
493 const int diff_stride = 4 * (1 << bwl); 490 const int diff_stride = 4 * (1 << bwl);
494 uint8_t *src, *dst; 491 uint8_t *src, *dst;
495 int16_t *src_diff; 492 int16_t *src_diff;
496 uint16_t *eob = &p->eobs[block]; 493 uint16_t *eob = &p->eobs[block];
497 const int src_stride = p->src.stride; 494 const int src_stride = p->src.stride;
498 const int dst_stride = pd->dst.stride; 495 const int dst_stride = pd->dst.stride;
499 int i, j; 496 int i, j;
500 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); 497 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j);
501 dst = &pd->dst.buf[4 * (j * dst_stride + i)]; 498 dst = &pd->dst.buf[4 * (j * dst_stride + i)];
502 src = &p->src.buf[4 * (j * src_stride + i)]; 499 src = &p->src.buf[4 * (j * src_stride + i)];
503 src_diff = &p->src_diff[4 * (j * diff_stride + i)]; 500 src_diff = &p->src_diff[4 * (j * diff_stride + i)];
504 501
505 // if (x->optimize)
506 // optimize_b(plane, block, plane_bsize, tx_size, x, args->ctx);
507
508 switch (tx_size) { 502 switch (tx_size) {
509 case TX_32X32: 503 case TX_32X32:
510 scan_order = &vp9_default_scan_orders[TX_32X32]; 504 scan_order = &vp9_default_scan_orders[TX_32X32];
511 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; 505 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
512 vp9_predict_intra_block(xd, block >> 6, bwl, TX_32X32, mode, 506 vp9_predict_intra_block(xd, block >> 6, bwl, TX_32X32, mode,
513 x->skip_encode ? src : dst, 507 x->skip_encode ? src : dst,
514 x->skip_encode ? src_stride : dst_stride, 508 x->skip_encode ? src_stride : dst_stride,
515 dst, dst_stride, i, j, plane); 509 dst, dst_stride, i, j, plane);
516 if (!x->skip_recode) { 510 if (!x->skip_recode) {
517 vp9_subtract_block(32, 32, src_diff, diff_stride, 511 vp9_subtract_block(32, 32, src_diff, diff_stride,
518 src, src_stride, dst, dst_stride); 512 src, src_stride, dst, dst_stride);
519 fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride); 513 fdct32x32(x->use_lp32x32fdct, src_diff, coeff, diff_stride);
520 vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round, 514 vp9_quantize_b_32x32(coeff, 1024, x->skip_block, p->zbin, p->round,
521 p->quant, p->quant_shift, qcoeff, dqcoeff, 515 p->quant, p->quant_shift, qcoeff, dqcoeff,
522 pd->dequant, p->zbin_extra, eob, scan_order->scan, 516 pd->dequant, p->zbin_extra, eob, scan_order->scan,
523 scan_order->iscan); 517 scan_order->iscan);
524 } 518 }
525 if (!x->skip_encode && *eob) 519 if (!x->skip_encode && *eob)
526 vp9_idct32x32_add(dqcoeff, dst, dst_stride, *eob); 520 vp9_idct32x32_add(dqcoeff, dst, dst_stride, *eob);
527 break; 521 break;
528 case TX_16X16: 522 case TX_16X16:
529 tx_type = get_tx_type_16x16(pd->plane_type, xd); 523 tx_type = get_tx_type(pd->plane_type, xd);
530 scan_order = &vp9_scan_orders[TX_16X16][tx_type]; 524 scan_order = &vp9_scan_orders[TX_16X16][tx_type];
531 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; 525 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
532 vp9_predict_intra_block(xd, block >> 4, bwl, TX_16X16, mode, 526 vp9_predict_intra_block(xd, block >> 4, bwl, TX_16X16, mode,
533 x->skip_encode ? src : dst, 527 x->skip_encode ? src : dst,
534 x->skip_encode ? src_stride : dst_stride, 528 x->skip_encode ? src_stride : dst_stride,
535 dst, dst_stride, i, j, plane); 529 dst, dst_stride, i, j, plane);
536 if (!x->skip_recode) { 530 if (!x->skip_recode) {
537 vp9_subtract_block(16, 16, src_diff, diff_stride, 531 vp9_subtract_block(16, 16, src_diff, diff_stride,
538 src, src_stride, dst, dst_stride); 532 src, src_stride, dst, dst_stride);
539 vp9_fht16x16(src_diff, coeff, diff_stride, tx_type); 533 vp9_fht16x16(src_diff, coeff, diff_stride, tx_type);
540 vp9_quantize_b(coeff, 256, x->skip_block, p->zbin, p->round, 534 vp9_quantize_b(coeff, 256, x->skip_block, p->zbin, p->round,
541 p->quant, p->quant_shift, qcoeff, dqcoeff, 535 p->quant, p->quant_shift, qcoeff, dqcoeff,
542 pd->dequant, p->zbin_extra, eob, scan_order->scan, 536 pd->dequant, p->zbin_extra, eob, scan_order->scan,
543 scan_order->iscan); 537 scan_order->iscan);
544 } 538 }
545 if (!x->skip_encode && *eob) 539 if (!x->skip_encode && *eob)
546 vp9_iht16x16_add(tx_type, dqcoeff, dst, dst_stride, *eob); 540 vp9_iht16x16_add(tx_type, dqcoeff, dst, dst_stride, *eob);
547 break; 541 break;
548 case TX_8X8: 542 case TX_8X8:
549 tx_type = get_tx_type_8x8(pd->plane_type, xd); 543 tx_type = get_tx_type(pd->plane_type, xd);
550 scan_order = &vp9_scan_orders[TX_8X8][tx_type]; 544 scan_order = &vp9_scan_orders[TX_8X8][tx_type];
551 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode; 545 mode = plane == 0 ? mbmi->mode : mbmi->uv_mode;
552 vp9_predict_intra_block(xd, block >> 2, bwl, TX_8X8, mode, 546 vp9_predict_intra_block(xd, block >> 2, bwl, TX_8X8, mode,
553 x->skip_encode ? src : dst, 547 x->skip_encode ? src : dst,
554 x->skip_encode ? src_stride : dst_stride, 548 x->skip_encode ? src_stride : dst_stride,
555 dst, dst_stride, i, j, plane); 549 dst, dst_stride, i, j, plane);
556 if (!x->skip_recode) { 550 if (!x->skip_recode) {
557 vp9_subtract_block(8, 8, src_diff, diff_stride, 551 vp9_subtract_block(8, 8, src_diff, diff_stride,
558 src, src_stride, dst, dst_stride); 552 src, src_stride, dst, dst_stride);
559 vp9_fht8x8(src_diff, coeff, diff_stride, tx_type); 553 vp9_fht8x8(src_diff, coeff, diff_stride, tx_type);
560 vp9_quantize_b(coeff, 64, x->skip_block, p->zbin, p->round, p->quant, 554 vp9_quantize_b(coeff, 64, x->skip_block, p->zbin, p->round, p->quant,
561 p->quant_shift, qcoeff, dqcoeff, 555 p->quant_shift, qcoeff, dqcoeff,
562 pd->dequant, p->zbin_extra, eob, scan_order->scan, 556 pd->dequant, p->zbin_extra, eob, scan_order->scan,
563 scan_order->iscan); 557 scan_order->iscan);
564 } 558 }
565 if (!x->skip_encode && *eob) 559 if (!x->skip_encode && *eob)
566 vp9_iht8x8_add(tx_type, dqcoeff, dst, dst_stride, *eob); 560 vp9_iht8x8_add(tx_type, dqcoeff, dst, dst_stride, *eob);
567 break; 561 break;
568 case TX_4X4: 562 case TX_4X4:
569 tx_type = get_tx_type_4x4(pd->plane_type, xd, block); 563 tx_type = get_tx_type_4x4(pd->plane_type, xd, block);
570 scan_order = &vp9_scan_orders[TX_4X4][tx_type]; 564 scan_order = &vp9_scan_orders[TX_4X4][tx_type];
571 mode = plane == 0 ? get_y_mode(xd->mi_8x8[0], block) : mbmi->uv_mode; 565 mode = plane == 0 ? get_y_mode(xd->mi[0], block) : mbmi->uv_mode;
572 vp9_predict_intra_block(xd, block, bwl, TX_4X4, mode, 566 vp9_predict_intra_block(xd, block, bwl, TX_4X4, mode,
573 x->skip_encode ? src : dst, 567 x->skip_encode ? src : dst,
574 x->skip_encode ? src_stride : dst_stride, 568 x->skip_encode ? src_stride : dst_stride,
575 dst, dst_stride, i, j, plane); 569 dst, dst_stride, i, j, plane);
576 570
577 if (!x->skip_recode) { 571 if (!x->skip_recode) {
578 vp9_subtract_block(4, 4, src_diff, diff_stride, 572 vp9_subtract_block(4, 4, src_diff, diff_stride,
579 src, src_stride, dst, dst_stride); 573 src, src_stride, dst, dst_stride);
580 if (tx_type != DCT_DCT) 574 if (tx_type != DCT_DCT)
581 vp9_fht4x4(src_diff, coeff, diff_stride, tx_type); 575 vp9_fht4x4(src_diff, coeff, diff_stride, tx_type);
(...skipping 25 matching lines...) Expand all
607 void vp9_encode_block_intra(MACROBLOCK *x, int plane, int block, 601 void vp9_encode_block_intra(MACROBLOCK *x, int plane, int block,
608 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, 602 BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
609 unsigned char *skip) { 603 unsigned char *skip) {
610 struct encode_b_args arg = {x, NULL, skip}; 604 struct encode_b_args arg = {x, NULL, skip};
611 encode_block_intra(plane, block, plane_bsize, tx_size, &arg); 605 encode_block_intra(plane, block, plane_bsize, tx_size, &arg);
612 } 606 }
613 607
614 608
615 void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { 609 void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
616 const MACROBLOCKD *const xd = &x->e_mbd; 610 const MACROBLOCKD *const xd = &x->e_mbd;
617 struct encode_b_args arg = {x, NULL, &xd->mi_8x8[0]->mbmi.skip}; 611 struct encode_b_args arg = {x, NULL, &xd->mi[0]->mbmi.skip};
618 612
619 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block_intra, 613 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block_intra,
620 &arg); 614 &arg);
621 } 615 }
622 616
623 int vp9_encode_intra(MACROBLOCK *x, int use_16x16_pred) { 617 int vp9_encode_intra(MACROBLOCK *x, int use_16x16_pred) {
624 MB_MODE_INFO * mbmi = &x->e_mbd.mi_8x8[0]->mbmi; 618 MB_MODE_INFO * mbmi = &x->e_mbd.mi[0]->mbmi;
625 x->skip_encode = 0; 619 x->skip_encode = 0;
626 mbmi->mode = DC_PRED; 620 mbmi->mode = DC_PRED;
627 mbmi->ref_frame[0] = INTRA_FRAME; 621 mbmi->ref_frame[0] = INTRA_FRAME;
628 mbmi->tx_size = use_16x16_pred ? (mbmi->sb_type >= BLOCK_16X16 ? TX_16X16 622 mbmi->tx_size = use_16x16_pred ? (mbmi->sb_type >= BLOCK_16X16 ? TX_16X16
629 : TX_8X8) 623 : TX_8X8)
630 : TX_4X4; 624 : TX_4X4;
631 vp9_encode_intra_block_plane(x, mbmi->sb_type, 0); 625 vp9_encode_intra_block_plane(x, mbmi->sb_type, 0);
632 return vp9_get_mb_ss(x->plane[0].src_diff); 626 return vp9_get_mb_ss(x->plane[0].src_diff);
633 } 627 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_encodeframe.c ('k') | source/libvpx/vp9/encoder/vp9_encodemv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698