From 73cd22f8d4bdaeb005b05348f3e39e784eff7074 Mon Sep 17 00:00:00 2001 From: Jim Bankoski Date: Tue, 14 Jan 2014 17:58:25 -0800 Subject: [PATCH] As you go mbmi->skip_coeff Calculate the skip_coeff as part of the encode process, rather than checking the eobs after the fact with another pass. Change-Id: Ib41b139e96a97dee30e4b993b4cc53d86337128d --- vp9/encoder/vp9_encodeframe.c | 2 ++ vp9/encoder/vp9_encodemb.c | 18 +++++++++++++----- vp9/encoder/vp9_encodemb.h | 1 + vp9/encoder/vp9_rdopt.c | 4 +++- vp9/encoder/vp9_tokenize.c | 2 -- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 4c66c2075..b0fae6593 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -2543,6 +2543,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled, } if (!is_inter_block(mbmi)) { + mbmi->skip_coeff = 1; vp9_encode_intra_block_y(x, MAX(bsize, BLOCK_8X8)); vp9_encode_intra_block_uv(x, MAX(bsize, BLOCK_8X8)); if (output_enabled) @@ -2561,6 +2562,7 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled, if (!is_inter_block(mbmi)) { vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); } else if (!x->skip) { + mbmi->skip_coeff = 1; vp9_encode_sb(x, MAX(bsize, BLOCK_8X8)); vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); } else { diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 21bc5886d..4bef67501 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -451,6 +451,9 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize, ctx->tl[plane][j] = p->eobs[block] > 0; } + if (p->eobs[block]) + *(args->skip_coeff) = 0; + if (x->skip_encode || p->eobs[block] == 0) return; @@ -474,7 +477,6 @@ static void encode_block(int plane, int block, BLOCK_SIZE plane_bsize, assert(0 && "Invalid transform size"); } } - 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; @@ -499,7 +501,8 @@ static void encode_block_pass1(int plane, int block, BLOCK_SIZE plane_bsize, void vp9_encode_sby(MACROBLOCK *x, BLOCK_SIZE bsize) { MACROBLOCKD *const xd = &x->e_mbd; struct optimize_ctx ctx; - struct encode_b_args arg = {x, &ctx}; + MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; + struct encode_b_args arg = {x, &ctx, &mbmi->skip_coeff}; vp9_subtract_sby(x, bsize); if (x->optimize) @@ -511,7 +514,8 @@ void vp9_encode_sby(MACROBLOCK *x, BLOCK_SIZE bsize) { void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize) { MACROBLOCKD *const xd = &x->e_mbd; struct optimize_ctx ctx; - struct encode_b_args arg = {x, &ctx}; + MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; + struct encode_b_args arg = {x, &ctx, &mbmi->skip_coeff}; if (!x->skip_recode) vp9_subtract_sb(x, bsize); @@ -655,12 +659,15 @@ void vp9_encode_block_intra(int plane, int block, BLOCK_SIZE plane_bsize, default: assert(0); } + if (*eob) + *(args->skip_coeff) = 0; } void vp9_encode_intra_block_y(MACROBLOCK *x, BLOCK_SIZE bsize) { MACROBLOCKD* const xd = &x->e_mbd; struct optimize_ctx ctx; - struct encode_b_args arg = {x, &ctx}; + MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; + struct encode_b_args arg = {x, &ctx, &mbmi->skip_coeff}; foreach_transformed_block_in_plane(xd, bsize, 0, vp9_encode_block_intra, &arg); @@ -668,7 +675,8 @@ void vp9_encode_intra_block_y(MACROBLOCK *x, BLOCK_SIZE bsize) { void vp9_encode_intra_block_uv(MACROBLOCK *x, BLOCK_SIZE bsize) { MACROBLOCKD* const xd = &x->e_mbd; struct optimize_ctx ctx; - struct encode_b_args arg = {x, &ctx}; + MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; + struct encode_b_args arg = {x, &ctx, &mbmi->skip_coeff}; foreach_transformed_block_uv(xd, bsize, vp9_encode_block_intra, &arg); } diff --git a/vp9/encoder/vp9_encodemb.h b/vp9/encoder/vp9_encodemb.h index cb872a7d6..207d573a5 100644 --- a/vp9/encoder/vp9_encodemb.h +++ b/vp9/encoder/vp9_encodemb.h @@ -24,6 +24,7 @@ struct optimize_ctx { struct encode_b_args { MACROBLOCK *x; struct optimize_ctx *ctx; + unsigned char *skip_coeff; }; void vp9_encode_sb(MACROBLOCK *x, BLOCK_SIZE bsize); diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index b46e80891..6671d153f 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -640,7 +640,9 @@ static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize, struct rdcost_block_args *args = arg; MACROBLOCK *const x = args->x; MACROBLOCKD *const xd = &x->e_mbd; - struct encode_b_args encode_args = {x, NULL}; + MB_MODE_INFO *mbmi = &xd->mi_8x8[0]->mbmi; + struct encode_b_args encode_args = {x, NULL, &mbmi->skip_coeff}; + int64_t rd1, rd2, rd; if (args->skip) diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index 4ccead834..b04e3fe30 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -299,8 +299,6 @@ void vp9_tokenize_sb(VP9_COMP *cpi, TOKENEXTRA **t, int dry_run, const int skip_inc = !vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP); struct tokenize_b_args arg = {cpi, xd, t, mbmi->tx_size, cpi->mb.token_cache}; - - mbmi->skip_coeff = sb_is_skippable(&cpi->mb, bsize); if (mbmi->skip_coeff) { if (!dry_run) cm->counts.mbskip[ctx][1] += skip_inc;