vp9_block.h revision f3bed9137f66ef693bd406e43b17e9a1114f1e14
1cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)/* 2cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * 4cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * Use of this source code is governed by a BSD-style license 5cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * that can be found in the LICENSE file in the root of the source 6cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * tree. An additional intellectual property rights grant can be found 7cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * in the file PATENTS. All contributing project authors may 8cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) * be found in the AUTHORS file in the root of the source tree. 9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) */ 10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#ifndef VP9_ENCODER_VP9_BLOCK_H_ 12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define VP9_ENCODER_VP9_BLOCK_H_ 13cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 14cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "vp9/common/vp9_onyx.h" 15cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "vp9/common/vp9_entropymv.h" 16cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "vp9/common/vp9_entropy.h" 17cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "vpx_ports/mem.h" 18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "vp9/common/vp9_onyxc_int.h" 19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// motion search site 21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)typedef struct { 22 MV mv; 23 int offset; 24} search_site; 25 26typedef struct { 27 struct { 28 MB_PREDICTION_MODE mode; 29 } bmi[4]; 30} PARTITION_INFO; 31 32// Structure to hold snapshot of coding context during the mode picking process 33// TODO Do we need all of these? 34typedef struct { 35 MODE_INFO mic; 36 PARTITION_INFO partition_info; 37 int skip; 38 int_mv best_ref_mv; 39 int_mv second_best_ref_mv; 40 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; 41 int rate; 42 int distortion; 43 int64_t intra_error; 44 int best_mode_index; 45 int rddiv; 46 int rdmult; 47 int hybrid_pred_diff; 48 int comp_pred_diff; 49 int single_pred_diff; 50 int64_t tx_rd_diff[TX_MODES]; 51 int64_t best_filter_diff[VP9_SWITCHABLE_FILTERS + 1]; 52 53 // Bit flag for each mode whether it has high error in comparison to others. 54 unsigned int modes_with_high_error; 55 56 // Bit flag for each ref frame whether it has high error compared to others. 57 unsigned int frames_with_high_error; 58} PICK_MODE_CONTEXT; 59 60struct macroblock_plane { 61 DECLARE_ALIGNED(16, int16_t, src_diff[64*64]); 62 DECLARE_ALIGNED(16, int16_t, coeff[64*64]); 63 struct buf_2d src; 64 65 // Quantizer setings 66 int16_t *quant; 67 int16_t *quant_shift; 68 int16_t *zbin; 69 int16_t *round; 70 71 // Zbin Over Quant value 72 int16_t zbin_extra; 73}; 74 75/* The [2] dimension is for whether we skip the EOB node (i.e. if previous 76 * coefficient in this block was zero) or not. */ 77typedef unsigned int vp9_coeff_cost[BLOCK_TYPES][REF_TYPES][COEF_BANDS][2] 78 [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; 79 80typedef struct macroblock MACROBLOCK; 81struct macroblock { 82 struct macroblock_plane plane[MAX_MB_PLANE]; 83 84 MACROBLOCKD e_mbd; 85 int skip_block; 86 PARTITION_INFO *partition_info; /* work pointer */ 87 PARTITION_INFO *pi; /* Corresponds to upper left visible macroblock */ 88 PARTITION_INFO *pip; /* Base of allocated array */ 89 90 search_site *ss; 91 int ss_count; 92 int searches_per_step; 93 94 int errorperbit; 95 int sadperbit16; 96 int sadperbit4; 97 int rddiv; 98 int rdmult; 99 unsigned int *mb_activity_ptr; 100 int *mb_norm_activity_ptr; 101 signed int act_zbin_adj; 102 103 int mv_best_ref_index[MAX_REF_FRAMES]; 104 unsigned int max_mv_context[MAX_REF_FRAMES]; 105 unsigned int source_variance; 106 107 int nmvjointcost[MV_JOINTS]; 108 int nmvcosts[2][MV_VALS]; 109 int *nmvcost[2]; 110 int nmvcosts_hp[2][MV_VALS]; 111 int *nmvcost_hp[2]; 112 int **mvcost; 113 114 int nmvjointsadcost[MV_JOINTS]; 115 int nmvsadcosts[2][MV_VALS]; 116 int *nmvsadcost[2]; 117 int nmvsadcosts_hp[2][MV_VALS]; 118 int *nmvsadcost_hp[2]; 119 int **mvsadcost; 120 121 int mbmode_cost[MB_MODE_COUNT]; 122 unsigned inter_mode_cost[INTER_MODE_CONTEXTS][MB_MODE_COUNT - NEARESTMV]; 123 int intra_uv_mode_cost[2][MB_MODE_COUNT]; 124 int y_mode_costs[VP9_INTRA_MODES][VP9_INTRA_MODES][VP9_INTRA_MODES]; 125 int switchable_interp_costs[VP9_SWITCHABLE_FILTERS + 1] 126 [VP9_SWITCHABLE_FILTERS]; 127 128 // These define limits to motion vector components to prevent them 129 // from extending outside the UMV borders 130 int mv_col_min; 131 int mv_col_max; 132 int mv_row_min; 133 int mv_row_max; 134 135 int skip; 136 137 int encode_breakout; 138 139 unsigned char *active_ptr; 140 141 // note that token_costs is the cost when eob node is skipped 142 vp9_coeff_cost token_costs[TX_SIZES]; 143 144 int optimize; 145 146 // indicate if it is in the rd search loop or encoding process 147 int rd_search; 148 int skip_encode; 149 150 // Used to store sub partition's choices. 151 int fast_ms; 152 int_mv pred_mv; 153 int subblock_ref; 154 155 // TODO(jingning): Need to refactor the structure arrays that buffers the 156 // coding mode decisions of each partition type. 157 PICK_MODE_CONTEXT ab4x4_context[4][4][4]; 158 PICK_MODE_CONTEXT sb8x4_context[4][4][4]; 159 PICK_MODE_CONTEXT sb4x8_context[4][4][4]; 160 PICK_MODE_CONTEXT sb8x8_context[4][4][4]; 161 PICK_MODE_CONTEXT sb8x16_context[4][4][2]; 162 PICK_MODE_CONTEXT sb16x8_context[4][4][2]; 163 PICK_MODE_CONTEXT mb_context[4][4]; 164 PICK_MODE_CONTEXT sb32x16_context[4][2]; 165 PICK_MODE_CONTEXT sb16x32_context[4][2]; 166 // when 4 MBs share coding parameters: 167 PICK_MODE_CONTEXT sb32_context[4]; 168 PICK_MODE_CONTEXT sb32x64_context[2]; 169 PICK_MODE_CONTEXT sb64x32_context[2]; 170 PICK_MODE_CONTEXT sb64_context; 171 int partition_cost[NUM_PARTITION_CONTEXTS][PARTITION_TYPES]; 172 173 BLOCK_SIZE_TYPE b_partitioning[4][4][4]; 174 BLOCK_SIZE_TYPE mb_partitioning[4][4]; 175 BLOCK_SIZE_TYPE sb_partitioning[4]; 176 BLOCK_SIZE_TYPE sb64_partitioning; 177 178 void (*fwd_txm4x4)(int16_t *input, int16_t *output, int pitch); 179 void (*fwd_txm8x4)(int16_t *input, int16_t *output, int pitch); 180 void (*fwd_txm8x8)(int16_t *input, int16_t *output, int pitch); 181 void (*fwd_txm16x16)(int16_t *input, int16_t *output, int pitch); 182 void (*quantize_b_4x4)(MACROBLOCK *x, int b_idx, TX_TYPE tx_type, 183 int y_blocks); 184}; 185 186#endif // VP9_ENCODER_VP9_BLOCK_H_ 187