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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 } | 294 } |
295 | 295 |
296 static INLINE void fdct32x32(int rd_transform, | 296 static INLINE void fdct32x32(int rd_transform, |
297 const int16_t *src, int16_t *dst, int src_stride) { | 297 const int16_t *src, int16_t *dst, int src_stride) { |
298 if (rd_transform) | 298 if (rd_transform) |
299 vp9_fdct32x32_rd(src, dst, src_stride); | 299 vp9_fdct32x32_rd(src, dst, src_stride); |
300 else | 300 else |
301 vp9_fdct32x32(src, dst, src_stride); | 301 vp9_fdct32x32(src, dst, src_stride); |
302 } | 302 } |
303 | 303 |
| 304 void vp9_xform_quant_fp(MACROBLOCK *x, int plane, int block, |
| 305 BLOCK_SIZE plane_bsize, TX_SIZE tx_size) { |
| 306 MACROBLOCKD *const xd = &x->e_mbd; |
| 307 const struct macroblock_plane *const p = &x->plane[plane]; |
| 308 const struct macroblockd_plane *const pd = &xd->plane[plane]; |
| 309 int16_t *const coeff = BLOCK_OFFSET(p->coeff, block); |
| 310 int16_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); |
| 311 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); |
| 312 uint16_t *const eob = &p->eobs[block]; |
| 313 const int diff_stride = 4 * num_4x4_blocks_wide_lookup[plane_bsize]; |
| 314 int i, j; |
| 315 const int16_t *src_diff; |
| 316 |
| 317 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); |
| 318 src_diff = &p->src_diff[4 * (j * diff_stride + i)]; |
| 319 |
| 320 switch (tx_size) { |
| 321 case TX_32X32: |
| 322 vp9_fdct32x32_1(src_diff, coeff, diff_stride); |
| 323 vp9_quantize_dc_32x32(coeff, x->skip_block, p->round, |
| 324 p->quant_fp[0], qcoeff, dqcoeff, |
| 325 pd->dequant[0], eob); |
| 326 break; |
| 327 case TX_16X16: |
| 328 vp9_fdct16x16_1(src_diff, coeff, diff_stride); |
| 329 vp9_quantize_dc(coeff, x->skip_block, p->round, |
| 330 p->quant_fp[0], qcoeff, dqcoeff, |
| 331 pd->dequant[0], eob); |
| 332 break; |
| 333 case TX_8X8: |
| 334 vp9_fdct8x8_1(src_diff, coeff, diff_stride); |
| 335 vp9_quantize_dc(coeff, x->skip_block, p->round, |
| 336 p->quant_fp[0], qcoeff, dqcoeff, |
| 337 pd->dequant[0], eob); |
| 338 break; |
| 339 case TX_4X4: |
| 340 x->fwd_txm4x4(src_diff, coeff, diff_stride); |
| 341 vp9_quantize_dc(coeff, x->skip_block, p->round, |
| 342 p->quant_fp[0], qcoeff, dqcoeff, |
| 343 pd->dequant[0], eob); |
| 344 break; |
| 345 default: |
| 346 assert(0); |
| 347 } |
| 348 } |
| 349 |
304 void vp9_xform_quant(MACROBLOCK *x, int plane, int block, | 350 void vp9_xform_quant(MACROBLOCK *x, int plane, int block, |
305 BLOCK_SIZE plane_bsize, TX_SIZE tx_size) { | 351 BLOCK_SIZE plane_bsize, TX_SIZE tx_size) { |
306 MACROBLOCKD *const xd = &x->e_mbd; | 352 MACROBLOCKD *const xd = &x->e_mbd; |
307 const struct macroblock_plane *const p = &x->plane[plane]; | 353 const struct macroblock_plane *const p = &x->plane[plane]; |
308 const struct macroblockd_plane *const pd = &xd->plane[plane]; | 354 const struct macroblockd_plane *const pd = &xd->plane[plane]; |
309 const scan_order *const scan_order = &vp9_default_scan_orders[tx_size]; | 355 const scan_order *const scan_order = &vp9_default_scan_orders[tx_size]; |
310 int16_t *const coeff = BLOCK_OFFSET(p->coeff, block); | 356 int16_t *const coeff = BLOCK_OFFSET(p->coeff, block); |
311 int16_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); | 357 int16_t *const qcoeff = BLOCK_OFFSET(p->qcoeff, block); |
312 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); | 358 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); |
313 uint16_t *const eob = &p->eobs[block]; | 359 uint16_t *const eob = &p->eobs[block]; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 l = &ctx->tl[plane][j]; | 415 l = &ctx->tl[plane][j]; |
370 | 416 |
371 // TODO(jingning): per transformed block zero forcing only enabled for | 417 // TODO(jingning): per transformed block zero forcing only enabled for |
372 // luma component. will integrate chroma components as well. | 418 // luma component. will integrate chroma components as well. |
373 if (x->zcoeff_blk[tx_size][block] && plane == 0) { | 419 if (x->zcoeff_blk[tx_size][block] && plane == 0) { |
374 p->eobs[block] = 0; | 420 p->eobs[block] = 0; |
375 *a = *l = 0; | 421 *a = *l = 0; |
376 return; | 422 return; |
377 } | 423 } |
378 | 424 |
379 if (!x->skip_recode) | 425 if (x->skip_txfm == 0) { |
380 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); | 426 // full forward transform and quantization |
| 427 if (!x->skip_recode) |
| 428 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); |
| 429 } else if (x->skip_txfm == 2) { |
| 430 // fast path forward transform and quantization |
| 431 vp9_xform_quant_fp(x, plane, block, plane_bsize, tx_size); |
| 432 } else { |
| 433 // skip forward transform |
| 434 p->eobs[block] = 0; |
| 435 *a = *l = 0; |
| 436 return; |
| 437 } |
381 | 438 |
382 if (x->optimize && (!x->skip_recode || !x->skip_optimize)) { | 439 if (x->optimize && (!x->skip_recode || !x->skip_optimize)) { |
383 const int ctx = combine_entropy_contexts(*a, *l); | 440 const int ctx = combine_entropy_contexts(*a, *l); |
384 *a = *l = optimize_b(x, plane, block, tx_size, ctx) > 0; | 441 *a = *l = optimize_b(x, plane, block, tx_size, ctx) > 0; |
385 } else { | 442 } else { |
386 *a = *l = p->eobs[block] > 0; | 443 *a = *l = p->eobs[block] > 0; |
387 } | 444 } |
388 | 445 |
389 if (p->eobs[block]) | 446 if (p->eobs[block]) |
390 *(args->skip) = 0; | 447 *(args->skip) = 0; |
391 | 448 |
392 if (x->skip_encode || p->eobs[block] == 0) | 449 if (x->skip_encode || p->eobs[block] == 0) |
393 return; | 450 return; |
394 | 451 |
395 switch (tx_size) { | 452 switch (tx_size) { |
396 case TX_32X32: | 453 case TX_32X32: |
397 vp9_idct32x32_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); | 454 vp9_idct32x32_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); |
398 break; | 455 break; |
399 case TX_16X16: | 456 case TX_16X16: |
400 vp9_idct16x16_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); | 457 vp9_idct16x16_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); |
401 break; | 458 break; |
402 case TX_8X8: | 459 case TX_8X8: |
403 vp9_idct8x8_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); | 460 vp9_idct8x8_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); |
404 break; | 461 break; |
405 case TX_4X4: | 462 case TX_4X4: |
406 // this is like vp9_short_idct4x4 but has a special case around eob<=1 | 463 // this is like vp9_short_idct4x4 but has a special case around eob<=1 |
407 // which is significant (not just an optimization) for the lossless | 464 // which is significant (not just an optimization) for the lossless |
408 // case. | 465 // case. |
409 xd->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); | 466 x->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); |
410 break; | 467 break; |
411 default: | 468 default: |
412 assert(0 && "Invalid transform size"); | 469 assert(0 && "Invalid transform size"); |
413 } | 470 } |
414 } | 471 } |
415 | 472 |
416 static void encode_block_pass1(int plane, int block, BLOCK_SIZE plane_bsize, | 473 static void encode_block_pass1(int plane, int block, BLOCK_SIZE plane_bsize, |
417 TX_SIZE tx_size, void *arg) { | 474 TX_SIZE tx_size, void *arg) { |
418 MACROBLOCK *const x = (MACROBLOCK *)arg; | 475 MACROBLOCK *const x = (MACROBLOCK *)arg; |
419 MACROBLOCKD *const xd = &x->e_mbd; | 476 MACROBLOCKD *const xd = &x->e_mbd; |
420 struct macroblock_plane *const p = &x->plane[plane]; | 477 struct macroblock_plane *const p = &x->plane[plane]; |
421 struct macroblockd_plane *const pd = &xd->plane[plane]; | 478 struct macroblockd_plane *const pd = &xd->plane[plane]; |
422 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); | 479 int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); |
423 int i, j; | 480 int i, j; |
424 uint8_t *dst; | 481 uint8_t *dst; |
425 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); | 482 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &i, &j); |
426 dst = &pd->dst.buf[4 * j * pd->dst.stride + 4 * i]; | 483 dst = &pd->dst.buf[4 * j * pd->dst.stride + 4 * i]; |
427 | 484 |
428 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); | 485 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); |
429 | 486 |
430 if (p->eobs[block] > 0) | 487 if (p->eobs[block] > 0) |
431 xd->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); | 488 x->itxm_add(dqcoeff, dst, pd->dst.stride, p->eobs[block]); |
432 } | 489 } |
433 | 490 |
434 void vp9_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize) { | 491 void vp9_encode_sby_pass1(MACROBLOCK *x, BLOCK_SIZE bsize) { |
435 vp9_subtract_plane(x, bsize, 0); | 492 vp9_subtract_plane(x, bsize, 0); |
436 vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, 0, | 493 vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, 0, |
437 encode_block_pass1, x); | 494 encode_block_pass1, x); |
438 } | 495 } |
439 | 496 |
440 void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { | 497 void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { |
441 MACROBLOCKD *const xd = &x->e_mbd; | 498 MACROBLOCKD *const xd = &x->e_mbd; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 p->quant_shift, qcoeff, dqcoeff, | 624 p->quant_shift, qcoeff, dqcoeff, |
568 pd->dequant, p->zbin_extra, eob, scan_order->scan, | 625 pd->dequant, p->zbin_extra, eob, scan_order->scan, |
569 scan_order->iscan); | 626 scan_order->iscan); |
570 } | 627 } |
571 | 628 |
572 if (!x->skip_encode && *eob) { | 629 if (!x->skip_encode && *eob) { |
573 if (tx_type == DCT_DCT) | 630 if (tx_type == DCT_DCT) |
574 // this is like vp9_short_idct4x4 but has a special case around eob<=1 | 631 // this is like vp9_short_idct4x4 but has a special case around eob<=1 |
575 // which is significant (not just an optimization) for the lossless | 632 // which is significant (not just an optimization) for the lossless |
576 // case. | 633 // case. |
577 xd->itxm_add(dqcoeff, dst, dst_stride, *eob); | 634 x->itxm_add(dqcoeff, dst, dst_stride, *eob); |
578 else | 635 else |
579 vp9_iht4x4_16_add(dqcoeff, dst, dst_stride, tx_type); | 636 vp9_iht4x4_16_add(dqcoeff, dst, dst_stride, tx_type); |
580 } | 637 } |
581 break; | 638 break; |
582 default: | 639 default: |
583 assert(0); | 640 assert(0); |
584 } | 641 } |
585 if (*eob) | 642 if (*eob) |
586 *(args->skip) = 0; | 643 *(args->skip) = 0; |
587 } | 644 } |
588 | 645 |
589 void vp9_encode_block_intra(MACROBLOCK *x, int plane, int block, | 646 void vp9_encode_block_intra(MACROBLOCK *x, int plane, int block, |
590 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, | 647 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, |
591 unsigned char *skip) { | 648 unsigned char *skip) { |
592 struct encode_b_args arg = {x, NULL, skip}; | 649 struct encode_b_args arg = {x, NULL, skip}; |
593 encode_block_intra(plane, block, plane_bsize, tx_size, &arg); | 650 encode_block_intra(plane, block, plane_bsize, tx_size, &arg); |
594 } | 651 } |
595 | 652 |
596 | 653 |
597 void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { | 654 void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { |
598 const MACROBLOCKD *const xd = &x->e_mbd; | 655 const MACROBLOCKD *const xd = &x->e_mbd; |
599 struct encode_b_args arg = {x, NULL, &xd->mi[0]->mbmi.skip}; | 656 struct encode_b_args arg = {x, NULL, &xd->mi[0]->mbmi.skip}; |
600 | 657 |
601 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block_intra, | 658 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block_intra, |
602 &arg); | 659 &arg); |
603 } | 660 } |
OLD | NEW |