Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(992)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_block.h

Issue 54923004: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_bitstream.c ('k') | source/libvpx/vp9/encoder/vp9_boolhuff.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef VP9_ENCODER_VP9_BLOCK_H_ 11 #ifndef VP9_ENCODER_VP9_BLOCK_H_
12 #define VP9_ENCODER_VP9_BLOCK_H_ 12 #define VP9_ENCODER_VP9_BLOCK_H_
13 13
14 #include "vp9/common/vp9_onyx.h" 14 #include "vp9/common/vp9_onyx.h"
15 #include "vp9/common/vp9_entropymv.h" 15 #include "vp9/common/vp9_entropymv.h"
16 #include "vp9/common/vp9_entropy.h" 16 #include "vp9/common/vp9_entropy.h"
17 #include "vpx_ports/mem.h" 17 #include "vpx_ports/mem.h"
18 #include "vp9/common/vp9_onyxc_int.h" 18 #include "vp9/common/vp9_onyxc_int.h"
19 19
20 // motion search site 20 // motion search site
21 typedef struct { 21 typedef struct {
22 MV mv; 22 MV mv;
23 int offset; 23 int offset;
24 } search_site; 24 } search_site;
25 25
26 typedef 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 26 // Structure to hold snapshot of coding context during the mode picking process
33 // TODO Do we need all of these?
34 typedef struct { 27 typedef struct {
35 MODE_INFO mic; 28 MODE_INFO mic;
36 PARTITION_INFO partition_info; 29 uint8_t *zcoeff_blk;
30 int num_4x4_blk;
37 int skip; 31 int skip;
38 int_mv best_ref_mv; 32 int_mv best_ref_mv;
39 int_mv second_best_ref_mv; 33 int_mv second_best_ref_mv;
40 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; 34 int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
41 int rate; 35 int rate;
42 int distortion; 36 int distortion;
43 int64_t intra_error; 37 int64_t intra_error;
44 int best_mode_index; 38 int best_mode_index;
45 int rddiv; 39 int rddiv;
46 int rdmult; 40 int rdmult;
47 int hybrid_pred_diff; 41 int hybrid_pred_diff;
48 int comp_pred_diff; 42 int comp_pred_diff;
49 int single_pred_diff; 43 int single_pred_diff;
50 int64_t tx_rd_diff[TX_MODES]; 44 int64_t tx_rd_diff[TX_MODES];
51 int64_t best_filter_diff[SWITCHABLE_FILTERS + 1]; 45 int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS];
52 46
53 // motion vector cache for adaptive motion search control in partition 47 // motion vector cache for adaptive motion search control in partition
54 // search loop 48 // search loop
55 int_mv pred_mv[MAX_REF_FRAMES]; 49 int_mv pred_mv[MAX_REF_FRAMES];
56 50
57 // Bit flag for each mode whether it has high error in comparison to others. 51 // Bit flag for each mode whether it has high error in comparison to others.
58 unsigned int modes_with_high_error; 52 unsigned int modes_with_high_error;
59 53
60 // Bit flag for each ref frame whether it has high error compared to others. 54 // Bit flag for each ref frame whether it has high error compared to others.
61 unsigned int frames_with_high_error; 55 unsigned int frames_with_high_error;
62 } PICK_MODE_CONTEXT; 56 } PICK_MODE_CONTEXT;
63 57
64 struct macroblock_plane { 58 struct macroblock_plane {
65 DECLARE_ALIGNED(16, int16_t, src_diff[64*64]); 59 DECLARE_ALIGNED(16, int16_t, src_diff[64 * 64]);
66 DECLARE_ALIGNED(16, int16_t, coeff[64*64]); 60 DECLARE_ALIGNED(16, int16_t, coeff[64 * 64]);
67 struct buf_2d src; 61 struct buf_2d src;
68 62
69 // Quantizer setings 63 // Quantizer setings
70 int16_t *quant; 64 int16_t *quant;
71 int16_t *quant_shift; 65 int16_t *quant_shift;
72 int16_t *zbin; 66 int16_t *zbin;
73 int16_t *round; 67 int16_t *round;
74 68
75 // Zbin Over Quant value 69 // Zbin Over Quant value
76 int16_t zbin_extra; 70 int16_t zbin_extra;
77 }; 71 };
78 72
79 /* The [2] dimension is for whether we skip the EOB node (i.e. if previous 73 /* The [2] dimension is for whether we skip the EOB node (i.e. if previous
80 * coefficient in this block was zero) or not. */ 74 * coefficient in this block was zero) or not. */
81 typedef unsigned int vp9_coeff_cost[BLOCK_TYPES][REF_TYPES][COEF_BANDS][2] 75 typedef unsigned int vp9_coeff_cost[BLOCK_TYPES][REF_TYPES][COEF_BANDS][2]
82 [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; 76 [PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS];
83 77
84 typedef struct macroblock MACROBLOCK; 78 typedef struct macroblock MACROBLOCK;
85 struct macroblock { 79 struct macroblock {
86 struct macroblock_plane plane[MAX_MB_PLANE]; 80 struct macroblock_plane plane[MAX_MB_PLANE];
87 81
88 MACROBLOCKD e_mbd; 82 MACROBLOCKD e_mbd;
89 int skip_block; 83 int skip_block;
90 PARTITION_INFO *partition_info; /* work pointer */
91 PARTITION_INFO *pi; /* Corresponds to upper left visible macroblock */
92 PARTITION_INFO *pip; /* Base of allocated array */
93 84
94 search_site *ss; 85 search_site *ss;
95 int ss_count; 86 int ss_count;
96 int searches_per_step; 87 int searches_per_step;
97 88
98 int errorperbit; 89 int errorperbit;
99 int sadperbit16; 90 int sadperbit16;
100 int sadperbit4; 91 int sadperbit4;
101 int rddiv; 92 int rddiv;
102 int rdmult; 93 int rdmult;
94 unsigned int mb_energy;
103 unsigned int *mb_activity_ptr; 95 unsigned int *mb_activity_ptr;
104 int *mb_norm_activity_ptr; 96 int *mb_norm_activity_ptr;
105 signed int act_zbin_adj; 97 signed int act_zbin_adj;
106 98
107 int mv_best_ref_index[MAX_REF_FRAMES]; 99 int mv_best_ref_index[MAX_REF_FRAMES];
108 unsigned int max_mv_context[MAX_REF_FRAMES]; 100 unsigned int max_mv_context[MAX_REF_FRAMES];
109 unsigned int source_variance; 101 unsigned int source_variance;
110 102
111 int nmvjointcost[MV_JOINTS]; 103 int nmvjointcost[MV_JOINTS];
112 int nmvcosts[2][MV_VALS]; 104 int nmvcosts[2][MV_VALS];
113 int *nmvcost[2]; 105 int *nmvcost[2];
114 int nmvcosts_hp[2][MV_VALS]; 106 int nmvcosts_hp[2][MV_VALS];
115 int *nmvcost_hp[2]; 107 int *nmvcost_hp[2];
116 int **mvcost; 108 int **mvcost;
117 109
118 int nmvjointsadcost[MV_JOINTS]; 110 int nmvjointsadcost[MV_JOINTS];
119 int nmvsadcosts[2][MV_VALS]; 111 int nmvsadcosts[2][MV_VALS];
120 int *nmvsadcost[2]; 112 int *nmvsadcost[2];
121 int nmvsadcosts_hp[2][MV_VALS]; 113 int nmvsadcosts_hp[2][MV_VALS];
122 int *nmvsadcost_hp[2]; 114 int *nmvsadcost_hp[2];
123 int **mvsadcost; 115 int **mvsadcost;
124 116
125 int mbmode_cost[MB_MODE_COUNT]; 117 int mbmode_cost[MB_MODE_COUNT];
126 unsigned inter_mode_cost[INTER_MODE_CONTEXTS][MB_MODE_COUNT - NEARESTMV]; 118 unsigned inter_mode_cost[INTER_MODE_CONTEXTS][INTER_MODES];
127 int intra_uv_mode_cost[2][MB_MODE_COUNT]; 119 int intra_uv_mode_cost[2][MB_MODE_COUNT];
128 int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES]; 120 int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES];
129 int switchable_interp_costs[SWITCHABLE_FILTERS + 1] 121 int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
130 [SWITCHABLE_FILTERS];
131 122
132 // These define limits to motion vector components to prevent them 123 // These define limits to motion vector components to prevent them
133 // from extending outside the UMV borders 124 // from extending outside the UMV borders
134 int mv_col_min; 125 int mv_col_min;
135 int mv_col_max; 126 int mv_col_max;
136 int mv_row_min; 127 int mv_row_min;
137 int mv_row_max; 128 int mv_row_max;
138 129
130 uint8_t zcoeff_blk[TX_SIZES][256];
139 int skip; 131 int skip;
140 132
141 int encode_breakout; 133 int encode_breakout;
142 134
143 unsigned char *active_ptr; 135 unsigned char *active_ptr;
144 136
145 // note that token_costs is the cost when eob node is skipped 137 // note that token_costs is the cost when eob node is skipped
146 vp9_coeff_cost token_costs[TX_SIZES]; 138 vp9_coeff_cost token_costs[TX_SIZES];
139 uint8_t token_cache[1024];
147 140
148 int optimize; 141 int optimize;
149 142
150 // indicate if it is in the rd search loop or encoding process 143 // indicate if it is in the rd search loop or encoding process
151 int use_lp32x32fdct; 144 int use_lp32x32fdct;
152 int skip_encode; 145 int skip_encode;
153 146
154 // Used to store sub partition's choices. 147 // Used to store sub partition's choices.
155 int fast_ms; 148 int fast_ms;
156 int_mv pred_mv[MAX_REF_FRAMES]; 149 int_mv pred_mv[MAX_REF_FRAMES];
157 int subblock_ref; 150 int subblock_ref;
158 151
159 // TODO(jingning): Need to refactor the structure arrays that buffers the 152 // TODO(jingning): Need to refactor the structure arrays that buffers the
160 // coding mode decisions of each partition type. 153 // coding mode decisions of each partition type.
161 PICK_MODE_CONTEXT ab4x4_context[4][4][4]; 154 PICK_MODE_CONTEXT ab4x4_context[4][4][4];
162 PICK_MODE_CONTEXT sb8x4_context[4][4][4]; 155 PICK_MODE_CONTEXT sb8x4_context[4][4][4];
163 PICK_MODE_CONTEXT sb4x8_context[4][4][4]; 156 PICK_MODE_CONTEXT sb4x8_context[4][4][4];
164 PICK_MODE_CONTEXT sb8x8_context[4][4][4]; 157 PICK_MODE_CONTEXT sb8x8_context[4][4][4];
165 PICK_MODE_CONTEXT sb8x16_context[4][4][2]; 158 PICK_MODE_CONTEXT sb8x16_context[4][4][2];
166 PICK_MODE_CONTEXT sb16x8_context[4][4][2]; 159 PICK_MODE_CONTEXT sb16x8_context[4][4][2];
167 PICK_MODE_CONTEXT mb_context[4][4]; 160 PICK_MODE_CONTEXT mb_context[4][4];
168 PICK_MODE_CONTEXT sb32x16_context[4][2]; 161 PICK_MODE_CONTEXT sb32x16_context[4][2];
169 PICK_MODE_CONTEXT sb16x32_context[4][2]; 162 PICK_MODE_CONTEXT sb16x32_context[4][2];
170 // when 4 MBs share coding parameters: 163 // when 4 MBs share coding parameters:
171 PICK_MODE_CONTEXT sb32_context[4]; 164 PICK_MODE_CONTEXT sb32_context[4];
172 PICK_MODE_CONTEXT sb32x64_context[2]; 165 PICK_MODE_CONTEXT sb32x64_context[2];
173 PICK_MODE_CONTEXT sb64x32_context[2]; 166 PICK_MODE_CONTEXT sb64x32_context[2];
174 PICK_MODE_CONTEXT sb64_context; 167 PICK_MODE_CONTEXT sb64_context;
175 int partition_cost[NUM_PARTITION_CONTEXTS][PARTITION_TYPES]; 168 int partition_cost[PARTITION_CONTEXTS][PARTITION_TYPES];
176 169
177 BLOCK_SIZE b_partitioning[4][4][4]; 170 BLOCK_SIZE b_partitioning[4][4][4];
178 BLOCK_SIZE mb_partitioning[4][4]; 171 BLOCK_SIZE mb_partitioning[4][4];
179 BLOCK_SIZE sb_partitioning[4]; 172 BLOCK_SIZE sb_partitioning[4];
180 BLOCK_SIZE sb64_partitioning; 173 BLOCK_SIZE sb64_partitioning;
181 174
182 void (*fwd_txm4x4)(int16_t *input, int16_t *output, int pitch); 175 void (*fwd_txm4x4)(const int16_t *input, int16_t *output, int stride);
183 void (*fwd_txm8x4)(int16_t *input, int16_t *output, int pitch); 176 };
184 void (*fwd_txm8x8)(int16_t *input, int16_t *output, int pitch); 177
185 void (*fwd_txm16x16)(int16_t *input, int16_t *output, int pitch); 178 // TODO(jingning): the variables used here are little complicated. need further
186 void (*quantize_b_4x4)(MACROBLOCK *x, int b_idx, TX_TYPE tx_type, 179 // refactoring on organizing the temporary buffers, when recursive
187 int y_blocks); 180 // partition down to 4x4 block size is enabled.
181 static PICK_MODE_CONTEXT *get_block_context(MACROBLOCK *x, BLOCK_SIZE bsize) {
182 MACROBLOCKD *const xd = &x->e_mbd;
183
184 switch (bsize) {
185 case BLOCK_64X64:
186 return &x->sb64_context;
187 case BLOCK_64X32:
188 return &x->sb64x32_context[xd->sb_index];
189 case BLOCK_32X64:
190 return &x->sb32x64_context[xd->sb_index];
191 case BLOCK_32X32:
192 return &x->sb32_context[xd->sb_index];
193 case BLOCK_32X16:
194 return &x->sb32x16_context[xd->sb_index][xd->mb_index];
195 case BLOCK_16X32:
196 return &x->sb16x32_context[xd->sb_index][xd->mb_index];
197 case BLOCK_16X16:
198 return &x->mb_context[xd->sb_index][xd->mb_index];
199 case BLOCK_16X8:
200 return &x->sb16x8_context[xd->sb_index][xd->mb_index][xd->b_index];
201 case BLOCK_8X16:
202 return &x->sb8x16_context[xd->sb_index][xd->mb_index][xd->b_index];
203 case BLOCK_8X8:
204 return &x->sb8x8_context[xd->sb_index][xd->mb_index][xd->b_index];
205 case BLOCK_8X4:
206 return &x->sb8x4_context[xd->sb_index][xd->mb_index][xd->b_index];
207 case BLOCK_4X8:
208 return &x->sb4x8_context[xd->sb_index][xd->mb_index][xd->b_index];
209 case BLOCK_4X4:
210 return &x->ab4x4_context[xd->sb_index][xd->mb_index][xd->b_index];
211 default:
212 assert(0);
213 return NULL;
214 }
215 }
216
217 struct rdcost_block_args {
218 MACROBLOCK *x;
219 ENTROPY_CONTEXT t_above[16];
220 ENTROPY_CONTEXT t_left[16];
221 TX_SIZE tx_size;
222 int bw;
223 int bh;
224 int rate;
225 int64_t dist;
226 int64_t sse;
227 int this_rate;
228 int64_t this_dist;
229 int64_t this_sse;
230 int64_t this_rd;
231 int64_t best_rd;
232 int skip;
233 const int16_t *scan, *nb;
188 }; 234 };
189 235
190 #endif // VP9_ENCODER_VP9_BLOCK_H_ 236 #endif // VP9_ENCODER_VP9_BLOCK_H_
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_bitstream.c ('k') | source/libvpx/vp9/encoder/vp9_boolhuff.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698