From b75e4d0f13e5a09d2c3d79aab8f6ba8924d0eb6d Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Mon, 29 Jun 2015 10:53:02 -0700 Subject: [PATCH] Set up decoder end coding statistics tracker This commit allows the decoder to track the percentage of intra coding mode and sub pixel filter usage, when it is configured. This provides a measurable approach to generate the VP9 decoder performance test suite. Change-Id: I26d40b991f41b1408de2b206ecb0a322cdb561b8 --- vp9/decoder/vp9_decodeframe.c | 26 ++++++++++++++++++++++++++ vp9/decoder/vp9_decodemv.c | 29 ++++++++++++++++++++++++++++- vp9/decoder/vp9_decoder.h | 11 +++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c index 9311d8dad..a0a2fb82a 100644 --- a/vp9/decoder/vp9_decodeframe.c +++ b/vp9/decoder/vp9_decodeframe.c @@ -746,6 +746,12 @@ static void decode_block(VP9Decoder *const pbi, MACROBLOCKD *const xd, if (less8x8) bsize = BLOCK_8X8; +#if CONFIG_INTERNAL_STATS + pbi->total_block_in_8x8 += (1 << (num_pels_log2_lookup[bsize] - 6)); + if (!is_inter_block(mbmi)) + pbi->intra_block_in_8x8 += (1 << (num_pels_log2_lookup[bsize] - 6)); +#endif + if (mbmi->skip) { reset_skip_context(xd, bsize); } @@ -2008,6 +2014,12 @@ void vp9_decode_frame(VP9Decoder *pbi, "Uninitialized entropy context."); vp9_zero(cm->counts); +#if CONFIG_INTERNAL_STATS + // Reset internal stats + pbi->total_block_in_8x8 = 0; + pbi->subpel_mc_block_in_4x4 = 0; + pbi->intra_block_in_8x8 = 0; +#endif xd->corrupted = 0; new_fb->corrupted = read_compressed_header(pbi, data, first_partition_size); @@ -2076,4 +2088,18 @@ void vp9_decode_frame(VP9Decoder *pbi, // Non frame parallel update frame context here. if (cm->refresh_frame_context && !context_updated) cm->frame_contexts[cm->frame_context_idx] = *cm->fc; + +#if CONFIG_INTERNAL_STATS + vp9_clear_system_state(); + { + FILE *pf = fopen("frame_level_stats.stt", "a"); + double subpel_mc = (double)pbi->subpel_mc_block_in_4x4 / + (double)pbi->total_block_in_8x8; + double intra_mode = (double)pbi->intra_block_in_8x8 / + (double)pbi->total_block_in_8x8; + fprintf(pf, "frame index %d, sub-pel mc %7.3f\tintra mode%7.3f\n", + cm->current_video_frame, 25 * subpel_mc, 100 * intra_mode); + fclose(pf); + } +#endif } diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 8a8d8ddd8..7aed5a276 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -547,7 +547,22 @@ static void read_inter_block_mode_info(VP9Decoder *const pbi, mi->bmi[j].as_mv[0].as_int = block[0].as_int; if (is_compound) mi->bmi[j].as_mv[1].as_int = block[1].as_int; - +#if CONFIG_INTERNAL_STATS + if (mi->bmi[j].as_mv[0].as_mv.row & 0x07) + pbi->subpel_mc_block_in_4x4 += + (1 << (num_pels_log2_lookup[bsize] - 4)); + if (mi->bmi[j].as_mv[0].as_mv.col & 0x07) + pbi->subpel_mc_block_in_4x4 += + (1 << (num_pels_log2_lookup[bsize] - 4)); + if (is_compound) { + if (mi->bmi[j].as_mv[1].as_mv.row & 0x07) + pbi->subpel_mc_block_in_4x4 += + (1 << (num_pels_log2_lookup[bsize] - 4)); + if (mi->bmi[j].as_mv[1].as_mv.col & 0x07) + pbi->subpel_mc_block_in_4x4 += + (1 << (num_pels_log2_lookup[bsize] - 4)); + } +#endif if (num_4x4_h == 2) mi->bmi[j + 2] = mi->bmi[j]; if (num_4x4_w == 2) @@ -562,6 +577,18 @@ static void read_inter_block_mode_info(VP9Decoder *const pbi, } else { xd->corrupted |= !assign_mv(cm, xd, mbmi->mode, mbmi->mv, nearestmv, nearestmv, nearmv, is_compound, allow_hp, r); +#if CONFIG_INTERNAL_STATS + if (mbmi->mv[0].as_mv.row & 0x07) + pbi->subpel_mc_block_in_4x4 += (1 << (num_pels_log2_lookup[bsize] - 4)); + if (mbmi->mv[0].as_mv.col & 0x07) + pbi->subpel_mc_block_in_4x4 += (1 << (num_pels_log2_lookup[bsize] - 4)); + if (is_compound) { + if (mbmi->mv[1].as_mv.row & 0x07) + pbi->subpel_mc_block_in_4x4 += (1 << (num_pels_log2_lookup[bsize] - 4)); + if (mbmi->mv[1].as_mv.col & 0x07) + pbi->subpel_mc_block_in_4x4 += (1 << (num_pels_log2_lookup[bsize] - 4)); + } +#endif } } diff --git a/vp9/decoder/vp9_decoder.h b/vp9/decoder/vp9_decoder.h index c19f0ac3b..216698e9b 100644 --- a/vp9/decoder/vp9_decoder.h +++ b/vp9/decoder/vp9_decoder.h @@ -75,6 +75,17 @@ typedef struct VP9Decoder { int inv_tile_order; int need_resync; // wait for key/intra-only frame. int hold_ref_buf; // hold the reference buffer. + +#if CONFIG_INTERNAL_STATS + // total blocks in unit of 8x8 inside the frame. + int total_block_in_8x8; + // number of blocks using 1-D sub-pixel filtering for motion compensated + // prediction. if a block is using sub-pixel filter in both vertical and + // horizontal directions, it counts as using 1-D sub-pixel filter twice. + int subpel_mc_block_in_4x4; + // nubmer of blocks using intra prediction mode. + int intra_block_in_8x8; +#endif } VP9Decoder; int vp9_receive_compressed_data(struct VP9Decoder *pbi, -- 2.50.0