1ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang/*
2ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *
4ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  Use of this source code is governed by a BSD-style license
5ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  that can be found in the LICENSE file in the root of the source
6ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  tree. An additional intellectual property rights grant can be found
7ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  in the file PATENTS.  All contributing project authors may
8ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang *  be found in the AUTHORS file in the root of the source tree.
9ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang */
10ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
11ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#ifndef VP9_ENCODER_VP9_BLOCK_H_
12ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#define VP9_ENCODER_VP9_BLOCK_H_
13ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
14ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#include "vp9/common/vp9_entropymv.h"
15ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#include "vp9/common/vp9_entropy.h"
16ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#include "vpx_ports/mem.h"
17ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#include "vp9/common/vp9_onyxc_int.h"
18ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
19b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#ifdef __cplusplus
20b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanianextern "C" {
21b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#endif
22b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian
23ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// motion search site
24ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangtypedef struct {
25ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  MV mv;
26ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int offset;
27ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang} search_site;
28ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
29ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang// Structure to hold snapshot of coding context during the mode picking process
30ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangtypedef struct {
31ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  MODE_INFO mic;
325ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  uint8_t *zcoeff_blk;
339b35249446b07f40ac5fcc3205f2c048616efacchkuang  int16_t *coeff[MAX_MB_PLANE][3];
349b35249446b07f40ac5fcc3205f2c048616efacchkuang  int16_t *qcoeff[MAX_MB_PLANE][3];
359b35249446b07f40ac5fcc3205f2c048616efacchkuang  int16_t *dqcoeff[MAX_MB_PLANE][3];
369b35249446b07f40ac5fcc3205f2c048616efacchkuang  uint16_t *eobs[MAX_MB_PLANE][3];
379b35249446b07f40ac5fcc3205f2c048616efacchkuang
389b35249446b07f40ac5fcc3205f2c048616efacchkuang  // dual buffer pointers, 0: in use, 1: best in store
399b35249446b07f40ac5fcc3205f2c048616efacchkuang  int16_t *coeff_pbuf[MAX_MB_PLANE][3];
409b35249446b07f40ac5fcc3205f2c048616efacchkuang  int16_t *qcoeff_pbuf[MAX_MB_PLANE][3];
419b35249446b07f40ac5fcc3205f2c048616efacchkuang  int16_t *dqcoeff_pbuf[MAX_MB_PLANE][3];
429b35249446b07f40ac5fcc3205f2c048616efacchkuang  uint16_t *eobs_pbuf[MAX_MB_PLANE][3];
439b35249446b07f40ac5fcc3205f2c048616efacchkuang
449b35249446b07f40ac5fcc3205f2c048616efacchkuang  int is_coded;
455ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  int num_4x4_blk;
46ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int skip;
47b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian  int_mv best_ref_mv[2];
48ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
49ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int rate;
50ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int distortion;
51ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int best_mode_index;
52ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int rddiv;
53ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int rdmult;
54ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int hybrid_pred_diff;
55ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int comp_pred_diff;
56ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int single_pred_diff;
57f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang  int64_t tx_rd_diff[TX_MODES];
585ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS];
591184aebb761cbeac9124c37189a80a1a58f04b6bhkuang
601184aebb761cbeac9124c37189a80a1a58f04b6bhkuang  // motion vector cache for adaptive motion search control in partition
611184aebb761cbeac9124c37189a80a1a58f04b6bhkuang  // search loop
621184aebb761cbeac9124c37189a80a1a58f04b6bhkuang  int_mv pred_mv[MAX_REF_FRAMES];
63b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian  INTERP_FILTER pred_interp_filter;
64ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang} PICK_MODE_CONTEXT;
65ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
66ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangstruct macroblock_plane {
675ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  DECLARE_ALIGNED(16, int16_t, src_diff[64 * 64]);
68b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian  int16_t *qcoeff;
699b35249446b07f40ac5fcc3205f2c048616efacchkuang  int16_t *coeff;
70b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian  uint16_t *eobs;
71ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  struct buf_2d src;
72ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
73ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  // Quantizer setings
74ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int16_t *quant;
7591037db265ecdd914a26e056cf69207b4f50924ehkuang  int16_t *quant_shift;
76ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int16_t *zbin;
77ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int16_t *round;
78ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
79ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  // Zbin Over Quant value
80ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int16_t zbin_extra;
81ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang};
82ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
83f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang/* The [2] dimension is for whether we skip the EOB node (i.e. if previous
84f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang * coefficient in this block was zero) or not. */
85b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramaniantypedef unsigned int vp9_coeff_cost[PLANE_TYPES][REF_TYPES][COEF_BANDS][2]
86b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian                                   [COEFF_CONTEXTS][ENTROPY_TOKENS];
87f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang
88ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangtypedef struct macroblock MACROBLOCK;
89ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuangstruct macroblock {
90ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  struct macroblock_plane plane[MAX_MB_PLANE];
91ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
92ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  MACROBLOCKD e_mbd;
93ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int skip_block;
949b35249446b07f40ac5fcc3205f2c048616efacchkuang  int select_txfm_size;
959b35249446b07f40ac5fcc3205f2c048616efacchkuang  int skip_recode;
969b35249446b07f40ac5fcc3205f2c048616efacchkuang  int skip_optimize;
979b35249446b07f40ac5fcc3205f2c048616efacchkuang  int q_index;
98ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
99ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  search_site *ss;
100ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int ss_count;
101ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int searches_per_step;
102ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
103ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int errorperbit;
104ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int sadperbit16;
105ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int sadperbit4;
106ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int rddiv;
107ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int rdmult;
1085ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  unsigned int mb_energy;
109ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  unsigned int *mb_activity_ptr;
110ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int *mb_norm_activity_ptr;
111ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  signed int act_zbin_adj;
112ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
113ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int mv_best_ref_index[MAX_REF_FRAMES];
11491037db265ecdd914a26e056cf69207b4f50924ehkuang  unsigned int max_mv_context[MAX_REF_FRAMES];
115f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang  unsigned int source_variance;
116b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian  unsigned int pred_sse[MAX_REF_FRAMES];
117b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian  int pred_mv_sad[MAX_REF_FRAMES];
118ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
119ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int nmvjointcost[MV_JOINTS];
120ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int nmvcosts[2][MV_VALS];
121ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int *nmvcost[2];
122ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int nmvcosts_hp[2][MV_VALS];
123ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int *nmvcost_hp[2];
124ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int **mvcost;
125ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
126ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int nmvjointsadcost[MV_JOINTS];
127ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int nmvsadcosts[2][MV_VALS];
128ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int *nmvsadcost[2];
129ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int nmvsadcosts_hp[2][MV_VALS];
130ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int *nmvsadcost_hp[2];
131ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int **mvsadcost;
132ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
133b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian  int mbmode_cost[INTRA_MODES];
1345ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  unsigned inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES];
135b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian  int intra_uv_mode_cost[FRAME_TYPES][INTRA_MODES];
1361184aebb761cbeac9124c37189a80a1a58f04b6bhkuang  int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES];
1375ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
138ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
1399b35249446b07f40ac5fcc3205f2c048616efacchkuang  unsigned char sb_index;   // index of 32x32 block inside the 64x64 block
1409b35249446b07f40ac5fcc3205f2c048616efacchkuang  unsigned char mb_index;   // index of 16x16 block inside the 32x32 block
1419b35249446b07f40ac5fcc3205f2c048616efacchkuang  unsigned char b_index;    // index of 8x8 block inside the 16x16 block
1429b35249446b07f40ac5fcc3205f2c048616efacchkuang  unsigned char ab_index;   // index of 4x4 block inside the 8x8 block
1439b35249446b07f40ac5fcc3205f2c048616efacchkuang
144ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  // These define limits to motion vector components to prevent them
145ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  // from extending outside the UMV borders
146ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int mv_col_min;
147ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int mv_col_max;
148ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int mv_row_min;
149ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int mv_row_max;
150ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
1515ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  uint8_t zcoeff_blk[TX_SIZES][256];
152ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int skip;
153ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
154ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int encode_breakout;
155ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
156a72801d7d92ababb50eecf27a36bd222d031d2feVignesh Venkatasubramanian  int in_active_map;
157ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
158ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  // note that token_costs is the cost when eob node is skipped
159f3bed9137f66ef693bd406e43b17e9a1114f1e14hkuang  vp9_coeff_cost token_costs[TX_SIZES];
160ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
161ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  int optimize;
162ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
163ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  // indicate if it is in the rd search loop or encoding process
1641184aebb761cbeac9124c37189a80a1a58f04b6bhkuang  int use_lp32x32fdct;
16591037db265ecdd914a26e056cf69207b4f50924ehkuang  int skip_encode;
16691037db265ecdd914a26e056cf69207b4f50924ehkuang
16791037db265ecdd914a26e056cf69207b4f50924ehkuang  // Used to store sub partition's choices.
1681184aebb761cbeac9124c37189a80a1a58f04b6bhkuang  int_mv pred_mv[MAX_REF_FRAMES];
169ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
170ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  // TODO(jingning): Need to refactor the structure arrays that buffers the
171ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  // coding mode decisions of each partition type.
172ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT ab4x4_context[4][4][4];
173ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb8x4_context[4][4][4];
174ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb4x8_context[4][4][4];
175ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb8x8_context[4][4][4];
176ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb8x16_context[4][4][2];
177ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb16x8_context[4][4][2];
178ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT mb_context[4][4];
179ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb32x16_context[4][2];
180ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb16x32_context[4][2];
181ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  // when 4 MBs share coding parameters:
182ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb32_context[4];
183ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb32x64_context[2];
184ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb64x32_context[2];
185ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang  PICK_MODE_CONTEXT sb64_context;
1865ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  int partition_cost[PARTITION_CONTEXTS][PARTITION_TYPES];
187ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
1881184aebb761cbeac9124c37189a80a1a58f04b6bhkuang  BLOCK_SIZE b_partitioning[4][4][4];
1891184aebb761cbeac9124c37189a80a1a58f04b6bhkuang  BLOCK_SIZE mb_partitioning[4][4];
1901184aebb761cbeac9124c37189a80a1a58f04b6bhkuang  BLOCK_SIZE sb_partitioning[4];
1911184aebb761cbeac9124c37189a80a1a58f04b6bhkuang  BLOCK_SIZE sb64_partitioning;
192ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
1935ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  void (*fwd_txm4x4)(const int16_t *input, int16_t *output, int stride);
1945ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang};
1955ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang
1965ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang// TODO(jingning): the variables used here are little complicated. need further
1975ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang// refactoring on organizing the temporary buffers, when recursive
1985ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang// partition down to 4x4 block size is enabled.
1996ac915abcdb404a00d927fe6308a47fcf09d9519hkuangstatic INLINE PICK_MODE_CONTEXT *get_block_context(MACROBLOCK *x,
2006ac915abcdb404a00d927fe6308a47fcf09d9519hkuang                                                   BLOCK_SIZE bsize) {
2015ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  switch (bsize) {
2025ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_64X64:
2035ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang      return &x->sb64_context;
2045ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_64X32:
2059b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->sb64x32_context[x->sb_index];
2065ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_32X64:
2079b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->sb32x64_context[x->sb_index];
2085ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_32X32:
2099b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->sb32_context[x->sb_index];
2105ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_32X16:
2119b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->sb32x16_context[x->sb_index][x->mb_index];
2125ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_16X32:
2139b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->sb16x32_context[x->sb_index][x->mb_index];
2145ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_16X16:
2159b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->mb_context[x->sb_index][x->mb_index];
2165ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_16X8:
2179b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->sb16x8_context[x->sb_index][x->mb_index][x->b_index];
2185ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_8X16:
2199b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->sb8x16_context[x->sb_index][x->mb_index][x->b_index];
2205ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_8X8:
2219b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->sb8x8_context[x->sb_index][x->mb_index][x->b_index];
2225ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_8X4:
2239b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->sb8x4_context[x->sb_index][x->mb_index][x->b_index];
2245ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_4X8:
2259b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->sb4x8_context[x->sb_index][x->mb_index][x->b_index];
2265ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    case BLOCK_4X4:
2279b35249446b07f40ac5fcc3205f2c048616efacchkuang      return &x->ab4x4_context[x->sb_index][x->mb_index][x->b_index];
2285ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang    default:
2295ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang      assert(0);
2305ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang      return NULL;
2315ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang  }
2325ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang}
2335ae7ac49f08a179e4f054d99fcfc9dce78d26e58hkuang
234b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#ifdef __cplusplus
235b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian}  // extern "C"
236b08e2e23eec181e9951df33cd704ac294c5407b6Vignesh Venkatasubramanian#endif
237ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang
238ba164dffc5a6795bce97fae02b51ccf3330e15e4hkuang#endif  // VP9_ENCODER_VP9_BLOCK_H_
239