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

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

Issue 756673003: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years 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_encodemb.h ('k') | source/libvpx/vp9/encoder/vp9_encodemv.c » ('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 11 matching lines...) Expand all
22 #include "vp9/encoder/vp9_encodemb.h" 22 #include "vp9/encoder/vp9_encodemb.h"
23 #include "vp9/encoder/vp9_quantize.h" 23 #include "vp9/encoder/vp9_quantize.h"
24 #include "vp9/encoder/vp9_rd.h" 24 #include "vp9/encoder/vp9_rd.h"
25 #include "vp9/encoder/vp9_tokenize.h" 25 #include "vp9/encoder/vp9_tokenize.h"
26 26
27 struct optimize_ctx { 27 struct optimize_ctx {
28 ENTROPY_CONTEXT ta[MAX_MB_PLANE][16]; 28 ENTROPY_CONTEXT ta[MAX_MB_PLANE][16];
29 ENTROPY_CONTEXT tl[MAX_MB_PLANE][16]; 29 ENTROPY_CONTEXT tl[MAX_MB_PLANE][16];
30 }; 30 };
31 31
32 struct encode_b_args {
33 MACROBLOCK *x;
34 struct optimize_ctx *ctx;
35 int8_t *skip;
36 };
37
38 void vp9_subtract_block_c(int rows, int cols, 32 void vp9_subtract_block_c(int rows, int cols,
39 int16_t *diff, ptrdiff_t diff_stride, 33 int16_t *diff, ptrdiff_t diff_stride,
40 const uint8_t *src, ptrdiff_t src_stride, 34 const uint8_t *src, ptrdiff_t src_stride,
41 const uint8_t *pred, ptrdiff_t pred_stride) { 35 const uint8_t *pred, ptrdiff_t pred_stride) {
42 int r, c; 36 int r, c;
43 37
44 for (r = 0; r < rows; r++) { 38 for (r = 0; r < rows; r++) {
45 for (c = 0; c < cols; c++) 39 for (c = 0; c < cols; c++)
46 diff[c] = src[c] - pred[c]; 40 diff[c] = src[c] - pred[c];
47 41
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 scan_order->iscan); 431 scan_order->iscan);
438 break; 432 break;
439 case TX_16X16: 433 case TX_16X16:
440 vp9_fdct16x16(src_diff, coeff, diff_stride); 434 vp9_fdct16x16(src_diff, coeff, diff_stride);
441 vp9_quantize_fp(coeff, 256, x->skip_block, p->zbin, p->round_fp, 435 vp9_quantize_fp(coeff, 256, x->skip_block, p->zbin, p->round_fp,
442 p->quant_fp, p->quant_shift, qcoeff, dqcoeff, 436 p->quant_fp, p->quant_shift, qcoeff, dqcoeff,
443 pd->dequant, p->zbin_extra, eob, 437 pd->dequant, p->zbin_extra, eob,
444 scan_order->scan, scan_order->iscan); 438 scan_order->scan, scan_order->iscan);
445 break; 439 break;
446 case TX_8X8: 440 case TX_8X8:
447 vp9_fdct8x8(src_diff, coeff, diff_stride); 441 vp9_fdct8x8_quant(src_diff, diff_stride, coeff, 64,
448 vp9_quantize_fp(coeff, 64, x->skip_block, p->zbin, p->round_fp, 442 x->skip_block, p->zbin, p->round_fp,
449 p->quant_fp, p->quant_shift, qcoeff, dqcoeff, 443 p->quant_fp, p->quant_shift, qcoeff, dqcoeff,
450 pd->dequant, p->zbin_extra, eob, 444 pd->dequant, p->zbin_extra, eob,
451 scan_order->scan, scan_order->iscan); 445 scan_order->scan, scan_order->iscan);
452 break; 446 break;
453 case TX_4X4: 447 case TX_4X4:
454 x->fwd_txm4x4(src_diff, coeff, diff_stride); 448 x->fwd_txm4x4(src_diff, coeff, diff_stride);
455 vp9_quantize_fp(coeff, 16, x->skip_block, p->zbin, p->round_fp, 449 vp9_quantize_fp(coeff, 16, x->skip_block, p->zbin, p->round_fp,
456 p->quant_fp, p->quant_shift, qcoeff, dqcoeff, 450 p->quant_fp, p->quant_shift, qcoeff, dqcoeff,
457 pd->dequant, p->zbin_extra, eob, 451 pd->dequant, p->zbin_extra, eob,
458 scan_order->scan, scan_order->iscan); 452 scan_order->scan, scan_order->iscan);
459 break; 453 break;
460 default: 454 default:
461 assert(0); 455 assert(0);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 l = &ctx->tl[plane][j]; 645 l = &ctx->tl[plane][j];
652 646
653 // TODO(jingning): per transformed block zero forcing only enabled for 647 // TODO(jingning): per transformed block zero forcing only enabled for
654 // luma component. will integrate chroma components as well. 648 // luma component. will integrate chroma components as well.
655 if (x->zcoeff_blk[tx_size][block] && plane == 0) { 649 if (x->zcoeff_blk[tx_size][block] && plane == 0) {
656 p->eobs[block] = 0; 650 p->eobs[block] = 0;
657 *a = *l = 0; 651 *a = *l = 0;
658 return; 652 return;
659 } 653 }
660 654
655 #if CONFIG_VP9_HIGHBITDEPTH
656 if (!x->skip_recode)
657 vp9_xform_quant(x, plane, block, plane_bsize, tx_size);
658 #else
661 if (!x->skip_recode) { 659 if (!x->skip_recode) {
662 if (max_txsize_lookup[plane_bsize] == tx_size) { 660 if (max_txsize_lookup[plane_bsize] == tx_size) {
663 if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 0) { 661 if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 0) {
664 // full forward transform and quantization 662 // full forward transform and quantization
665 if (x->quant_fp) 663 if (x->quant_fp)
666 vp9_xform_quant_fp(x, plane, block, plane_bsize, tx_size); 664 vp9_xform_quant_fp(x, plane, block, plane_bsize, tx_size);
667 else 665 else
668 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); 666 vp9_xform_quant(x, plane, block, plane_bsize, tx_size);
669 } else if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 2) { 667 } else if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 2) {
670 // fast path forward transform and quantization 668 // fast path forward transform and quantization
671 vp9_xform_quant_dc(x, plane, block, plane_bsize, tx_size); 669 vp9_xform_quant_dc(x, plane, block, plane_bsize, tx_size);
672 } else { 670 } else {
673 // skip forward transform 671 // skip forward transform
674 p->eobs[block] = 0; 672 p->eobs[block] = 0;
675 *a = *l = 0; 673 *a = *l = 0;
676 return; 674 return;
677 } 675 }
678 } else { 676 } else {
679 vp9_xform_quant(x, plane, block, plane_bsize, tx_size); 677 if (x->quant_fp)
678 vp9_xform_quant_fp(x, plane, block, plane_bsize, tx_size);
679 else
680 vp9_xform_quant(x, plane, block, plane_bsize, tx_size);
680 } 681 }
681 } 682 }
683 #endif
682 684
683 if (x->optimize && (!x->skip_recode || !x->skip_optimize)) { 685 if (x->optimize && (!x->skip_recode || !x->skip_optimize)) {
684 const int ctx = combine_entropy_contexts(*a, *l); 686 const int ctx = combine_entropy_contexts(*a, *l);
685 *a = *l = optimize_b(x, plane, block, tx_size, ctx) > 0; 687 *a = *l = optimize_b(x, plane, block, tx_size, ctx) > 0;
686 } else { 688 } else {
687 *a = *l = p->eobs[block] > 0; 689 *a = *l = p->eobs[block] > 0;
688 } 690 }
689 691
690 if (p->eobs[block]) 692 if (p->eobs[block])
691 *(args->skip) = 0; 693 *(args->skip) = 0;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi, pd) : mbmi->tx_size; 797 const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi, pd) : mbmi->tx_size;
796 vp9_get_entropy_contexts(bsize, tx_size, pd, 798 vp9_get_entropy_contexts(bsize, tx_size, pd,
797 ctx.ta[plane], ctx.tl[plane]); 799 ctx.ta[plane], ctx.tl[plane]);
798 } 800 }
799 801
800 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block, 802 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block,
801 &arg); 803 &arg);
802 } 804 }
803 } 805 }
804 806
805 static void encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, 807 void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize,
806 TX_SIZE tx_size, void *arg) { 808 TX_SIZE tx_size, void *arg) {
807 struct encode_b_args* const args = arg; 809 struct encode_b_args* const args = arg;
808 MACROBLOCK *const x = args->x; 810 MACROBLOCK *const x = args->x;
809 MACROBLOCKD *const xd = &x->e_mbd; 811 MACROBLOCKD *const xd = &x->e_mbd;
810 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi; 812 MB_MODE_INFO *mbmi = &xd->mi[0].src_mi->mbmi;
811 struct macroblock_plane *const p = &x->plane[plane]; 813 struct macroblock_plane *const p = &x->plane[plane];
812 struct macroblockd_plane *const pd = &xd->plane[plane]; 814 struct macroblockd_plane *const pd = &xd->plane[plane];
813 tran_low_t *coeff = BLOCK_OFFSET(p->coeff, block); 815 tran_low_t *coeff = BLOCK_OFFSET(p->coeff, block);
814 tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block); 816 tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
815 tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); 817 tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } 1035 }
1034 break; 1036 break;
1035 default: 1037 default:
1036 assert(0); 1038 assert(0);
1037 break; 1039 break;
1038 } 1040 }
1039 if (*eob) 1041 if (*eob)
1040 *(args->skip) = 0; 1042 *(args->skip) = 0;
1041 } 1043 }
1042 1044
1043 void vp9_encode_block_intra(MACROBLOCK *x, int plane, int block,
1044 BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
1045 int8_t *skip) {
1046 struct encode_b_args arg = {x, NULL, skip};
1047 encode_block_intra(plane, block, plane_bsize, tx_size, &arg);
1048 }
1049
1050
1051 void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) { 1045 void vp9_encode_intra_block_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
1052 const MACROBLOCKD *const xd = &x->e_mbd; 1046 const MACROBLOCKD *const xd = &x->e_mbd;
1053 struct encode_b_args arg = {x, NULL, &xd->mi[0].src_mi->mbmi.skip}; 1047 struct encode_b_args arg = {x, NULL, &xd->mi[0].src_mi->mbmi.skip};
1054 1048
1055 vp9_foreach_transformed_block_in_plane(xd, bsize, plane, encode_block_intra, 1049 vp9_foreach_transformed_block_in_plane(xd, bsize, plane,
1056 &arg); 1050 vp9_encode_block_intra, &arg);
1057 } 1051 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_encodemb.h ('k') | source/libvpx/vp9/encoder/vp9_encodemv.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698