From: Jingning Han Date: Wed, 23 Oct 2013 18:09:27 +0000 (-0700) Subject: Separate encode_block for pass 1 and 2 X-Git-Tag: v1.3.0~142^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4e2732c3c3bdeca417008c361a2387399719b3a2;p=libvpx Separate encode_block for pass 1 and 2 The encode_block for pass 1 takes simpler functionalities and can save a few branches. The main reason is to make encode_block only used after running rate-distortion optimization search in pass 2, hence allowing dual buffer stack approach later. Change-Id: I9e549ffb758e554fe185e48a07d6e0e01e475bcf --- diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 3358fbbe9..b7d1c2998 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -461,6 +461,27 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize, } } +static void encode_block_pass1(int plane, int block, BLOCK_SIZE plane_bsize, + TX_SIZE tx_size, void *arg) { + struct encode_b_args *const args = arg; + MACROBLOCK *const x = args->x; + MACROBLOCKD *const xd = &x->e_mbd; + struct macroblockd_plane *const pd = &xd->plane[plane]; + const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size, + block); + + int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); + uint8_t *const dst = raster_block_offset_uint8(plane_bsize, raster_block, + pd->dst.buf, pd->dst.stride); + + vp9_xform_quant(plane, block, plane_bsize, tx_size, arg); + + if (pd->eobs[block] == 0) + return; + + xd->itxm_add(dqcoeff, dst, pd->dst.stride, pd->eobs[block]); +} + void vp9_encode_sby(MACROBLOCK *x, BLOCK_SIZE bsize) { MACROBLOCKD *const xd = &x->e_mbd; struct optimize_ctx ctx; @@ -470,7 +491,7 @@ void vp9_encode_sby(MACROBLOCK *x, BLOCK_SIZE bsize) { if (x->optimize) optimize_init_b(0, bsize, &arg); - foreach_transformed_block_in_plane(xd, bsize, 0, encode_block, &arg); + foreach_transformed_block_in_plane(xd, bsize, 0, encode_block_pass1, &arg); } void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) {