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

Side by Side Diff: source/libvpx/vp9/common/vp9_onyxc_int.h

Issue 232133009: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 8 months 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/common/vp9_onyx.h ('k') | source/libvpx/vp9/common/vp9_postproc.h » ('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
(...skipping 30 matching lines...) Expand all
41 #define FRAME_BUFFERS (REF_FRAMES + 4) 41 #define FRAME_BUFFERS (REF_FRAMES + 4)
42 42
43 #define FRAME_CONTEXTS_LOG2 2 43 #define FRAME_CONTEXTS_LOG2 2
44 #define FRAME_CONTEXTS (1 << FRAME_CONTEXTS_LOG2) 44 #define FRAME_CONTEXTS (1 << FRAME_CONTEXTS_LOG2)
45 45
46 extern const struct { 46 extern const struct {
47 PARTITION_CONTEXT above; 47 PARTITION_CONTEXT above;
48 PARTITION_CONTEXT left; 48 PARTITION_CONTEXT left;
49 } partition_context_lookup[BLOCK_SIZES]; 49 } partition_context_lookup[BLOCK_SIZES];
50 50
51 typedef struct frame_contexts {
52 vp9_prob y_mode_prob[BLOCK_SIZE_GROUPS][INTRA_MODES - 1];
53 vp9_prob uv_mode_prob[INTRA_MODES][INTRA_MODES - 1];
54 vp9_prob partition_prob[PARTITION_CONTEXTS][PARTITION_TYPES - 1];
55 vp9_coeff_probs_model coef_probs[TX_SIZES][PLANE_TYPES];
56 vp9_prob switchable_interp_prob[SWITCHABLE_FILTER_CONTEXTS]
57 [SWITCHABLE_FILTERS - 1];
58 vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1];
59 vp9_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
60 vp9_prob comp_inter_prob[COMP_INTER_CONTEXTS];
61 vp9_prob single_ref_prob[REF_CONTEXTS][2];
62 vp9_prob comp_ref_prob[REF_CONTEXTS];
63 struct tx_probs tx_probs;
64 vp9_prob skip_probs[SKIP_CONTEXTS];
65 nmv_context nmvc;
66 } FRAME_CONTEXT;
67
68 typedef struct {
69 unsigned int y_mode[BLOCK_SIZE_GROUPS][INTRA_MODES];
70 unsigned int uv_mode[INTRA_MODES][INTRA_MODES];
71 unsigned int partition[PARTITION_CONTEXTS][PARTITION_TYPES];
72 vp9_coeff_count_model coef[TX_SIZES][PLANE_TYPES];
73 unsigned int eob_branch[TX_SIZES][PLANE_TYPES][REF_TYPES]
74 [COEF_BANDS][COEFF_CONTEXTS];
75 unsigned int switchable_interp[SWITCHABLE_FILTER_CONTEXTS]
76 [SWITCHABLE_FILTERS];
77 unsigned int inter_mode[INTER_MODE_CONTEXTS][INTER_MODES];
78 unsigned int intra_inter[INTRA_INTER_CONTEXTS][2];
79 unsigned int comp_inter[COMP_INTER_CONTEXTS][2];
80 unsigned int single_ref[REF_CONTEXTS][2][2];
81 unsigned int comp_ref[REF_CONTEXTS][2];
82 struct tx_counts tx;
83 unsigned int skip[SKIP_CONTEXTS][2];
84 nmv_context_counts mv;
85 } FRAME_COUNTS;
86
87 51
88 typedef enum { 52 typedef enum {
89 SINGLE_REFERENCE = 0, 53 SINGLE_REFERENCE = 0,
90 COMPOUND_REFERENCE = 1, 54 COMPOUND_REFERENCE = 1,
91 REFERENCE_MODE_SELECT = 2, 55 REFERENCE_MODE_SELECT = 2,
92 REFERENCE_MODES = 3, 56 REFERENCE_MODES = 3,
93 } REFERENCE_MODE; 57 } REFERENCE_MODE;
94 58
95 59
96 typedef struct { 60 typedef struct {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // 0 or 1 implies don't reset, 2 reset just the context specified in the 119 // 0 or 1 implies don't reset, 2 reset just the context specified in the
156 // frame header, 3 reset all contexts. 120 // frame header, 3 reset all contexts.
157 int reset_frame_context; 121 int reset_frame_context;
158 122
159 int frame_flags; 123 int frame_flags;
160 // MBs, mb_rows/cols is in 16-pixel units; mi_rows/cols is in 124 // MBs, mb_rows/cols is in 16-pixel units; mi_rows/cols is in
161 // MODE_INFO (8-pixel) units. 125 // MODE_INFO (8-pixel) units.
162 int MBs; 126 int MBs;
163 int mb_rows, mi_rows; 127 int mb_rows, mi_rows;
164 int mb_cols, mi_cols; 128 int mb_cols, mi_cols;
165 int mode_info_stride; 129 int mi_stride;
166 130
167 /* profile settings */ 131 /* profile settings */
168 TX_MODE tx_mode; 132 TX_MODE tx_mode;
169 133
170 int base_qindex; 134 int base_qindex;
171 int y_dc_delta_q; 135 int y_dc_delta_q;
172 int uv_dc_delta_q; 136 int uv_dc_delta_q;
173 int uv_ac_delta_q; 137 int uv_ac_delta_q;
174 #if CONFIG_ALPHA 138 #if CONFIG_ALPHA
175 int a_dc_delta_q; 139 int a_dc_delta_q;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 MV_REFERENCE_FRAME comp_fixed_ref; 172 MV_REFERENCE_FRAME comp_fixed_ref;
209 MV_REFERENCE_FRAME comp_var_ref[2]; 173 MV_REFERENCE_FRAME comp_var_ref[2];
210 REFERENCE_MODE reference_mode; 174 REFERENCE_MODE reference_mode;
211 175
212 FRAME_CONTEXT fc; /* this frame entropy */ 176 FRAME_CONTEXT fc; /* this frame entropy */
213 FRAME_CONTEXT frame_contexts[FRAME_CONTEXTS]; 177 FRAME_CONTEXT frame_contexts[FRAME_CONTEXTS];
214 unsigned int frame_context_idx; /* Context to use/update */ 178 unsigned int frame_context_idx; /* Context to use/update */
215 FRAME_COUNTS counts; 179 FRAME_COUNTS counts;
216 180
217 unsigned int current_video_frame; 181 unsigned int current_video_frame;
218 int version; 182 BITSTREAM_PROFILE profile;
183
184 // BITS_8 in versions 0 and 1, BITS_10 or BITS_12 in version 2
185 BIT_DEPTH bit_depth;
219 186
220 #if CONFIG_VP9_POSTPROC 187 #if CONFIG_VP9_POSTPROC
221 struct postproc_state postproc_state; 188 struct postproc_state postproc_state;
222 #endif 189 #endif
223 190
224 int error_resilient_mode; 191 int error_resilient_mode;
225 int frame_parallel_decoding_mode; 192 int frame_parallel_decoding_mode;
226 193
227 // Flag indicates if prev_mi can be used in coding: 194 // Flag indicates if prev_mi can be used in coding:
228 // 0: encoder assumes decoder does not have prev_mi 195 // 0: encoder assumes decoder does not have prev_mi
229 // 1: encoder assumes decoder has and uses prev_mi 196 // 1: encoder assumes decoder has and uses prev_mi
230 unsigned int coding_use_prev_mi; 197 unsigned int coding_use_prev_mi;
231 198
232 int log2_tile_cols, log2_tile_rows; 199 int log2_tile_cols, log2_tile_rows;
233 200
234 // Private data associated with the frame buffer callbacks. 201 // Private data associated with the frame buffer callbacks.
235 void *cb_priv; 202 void *cb_priv;
236 vpx_get_frame_buffer_cb_fn_t get_fb_cb; 203 vpx_get_frame_buffer_cb_fn_t get_fb_cb;
237 vpx_release_frame_buffer_cb_fn_t release_fb_cb; 204 vpx_release_frame_buffer_cb_fn_t release_fb_cb;
238 205
239 // Handles memory for the codec. 206 // Handles memory for the codec.
240 InternalFrameBufferList int_frame_buffers; 207 InternalFrameBufferList int_frame_buffers;
208
209 PARTITION_CONTEXT *above_seg_context;
210 ENTROPY_CONTEXT *above_context;
241 } VP9_COMMON; 211 } VP9_COMMON;
242 212
243 static INLINE YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) { 213 static INLINE YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) {
244 return &cm->frame_bufs[cm->new_fb_idx].buf; 214 return &cm->frame_bufs[cm->new_fb_idx].buf;
245 } 215 }
246 216
247 static INLINE int get_free_fb(VP9_COMMON *cm) { 217 static INLINE int get_free_fb(VP9_COMMON *cm) {
248 int i; 218 int i;
249 for (i = 0; i < FRAME_BUFFERS; i++) 219 for (i = 0; i < FRAME_BUFFERS; i++)
250 if (cm->frame_bufs[i].ref_count == 0) 220 if (cm->frame_bufs[i].ref_count == 0)
(...skipping 12 matching lines...) Expand all
263 233
264 *idx = new_idx; 234 *idx = new_idx;
265 235
266 bufs[new_idx].ref_count++; 236 bufs[new_idx].ref_count++;
267 } 237 }
268 238
269 static INLINE int mi_cols_aligned_to_sb(int n_mis) { 239 static INLINE int mi_cols_aligned_to_sb(int n_mis) {
270 return ALIGN_POWER_OF_TWO(n_mis, MI_BLOCK_SIZE_LOG2); 240 return ALIGN_POWER_OF_TWO(n_mis, MI_BLOCK_SIZE_LOG2);
271 } 241 }
272 242
273 static INLINE const vp9_prob* get_partition_probs(VP9_COMMON *cm, int ctx) { 243 static INLINE void init_macroblockd(VP9_COMMON *cm, MACROBLOCKD *xd) {
244 int i;
245
246 for (i = 0; i < MAX_MB_PLANE; ++i) {
247 xd->plane[i].dqcoeff = xd->dqcoeff[i];
248 xd->above_context[i] = cm->above_context +
249 i * sizeof(*cm->above_context) * 2 * mi_cols_aligned_to_sb(cm->mi_cols);
250 }
251
252 xd->above_seg_context = cm->above_seg_context;
253 xd->mi_stride = cm->mi_stride;
254 }
255
256 static INLINE const vp9_prob* get_partition_probs(const VP9_COMMON *cm,
257 int ctx) {
274 return cm->frame_type == KEY_FRAME ? vp9_kf_partition_probs[ctx] 258 return cm->frame_type == KEY_FRAME ? vp9_kf_partition_probs[ctx]
275 : cm->fc.partition_prob[ctx]; 259 : cm->fc.partition_prob[ctx];
276 } 260 }
277 261
278 static INLINE void set_skip_context( 262 static INLINE void set_skip_context(MACROBLOCKD *xd, int mi_row, int mi_col) {
279 MACROBLOCKD *xd,
280 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE],
281 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16],
282 int mi_row, int mi_col) {
283 const int above_idx = mi_col * 2; 263 const int above_idx = mi_col * 2;
284 const int left_idx = (mi_row * 2) & 15; 264 const int left_idx = (mi_row * 2) & 15;
285 int i; 265 int i;
286 for (i = 0; i < MAX_MB_PLANE; i++) { 266 for (i = 0; i < MAX_MB_PLANE; ++i) {
287 struct macroblockd_plane *const pd = &xd->plane[i]; 267 struct macroblockd_plane *const pd = &xd->plane[i];
288 pd->above_context = above_context[i] + (above_idx >> pd->subsampling_x); 268 pd->above_context = &xd->above_context[i][above_idx >> pd->subsampling_x];
289 pd->left_context = left_context[i] + (left_idx >> pd->subsampling_y); 269 pd->left_context = &xd->left_context[i][left_idx >> pd->subsampling_y];
290 } 270 }
291 } 271 }
292 272
293 static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile, 273 static INLINE void set_mi_row_col(MACROBLOCKD *xd, const TileInfo *const tile,
294 int mi_row, int bh, 274 int mi_row, int bh,
295 int mi_col, int bw, 275 int mi_col, int bw,
296 int mi_rows, int mi_cols) { 276 int mi_rows, int mi_cols) {
297 xd->mb_to_top_edge = -((mi_row * MI_SIZE) * 8); 277 xd->mb_to_top_edge = -((mi_row * MI_SIZE) * 8);
298 xd->mb_to_bottom_edge = ((mi_rows - bh - mi_row) * MI_SIZE) * 8; 278 xd->mb_to_bottom_edge = ((mi_rows - bh - mi_row) * MI_SIZE) * 8;
299 xd->mb_to_left_edge = -((mi_col * MI_SIZE) * 8); 279 xd->mb_to_left_edge = -((mi_col * MI_SIZE) * 8);
300 xd->mb_to_right_edge = ((mi_cols - bw - mi_col) * MI_SIZE) * 8; 280 xd->mb_to_right_edge = ((mi_cols - bw - mi_col) * MI_SIZE) * 8;
301 281
302 // Are edges available for intra prediction? 282 // Are edges available for intra prediction?
303 xd->up_available = (mi_row != 0); 283 xd->up_available = (mi_row != 0);
304 xd->left_available = (mi_col > tile->mi_col_start); 284 xd->left_available = (mi_col > tile->mi_col_start);
305 } 285 }
306 286
307 static void set_prev_mi(VP9_COMMON *cm) { 287 static INLINE void set_prev_mi(VP9_COMMON *cm) {
308 const int use_prev_in_find_mv_refs = cm->width == cm->last_width && 288 const int use_prev_in_find_mv_refs = cm->width == cm->last_width &&
309 cm->height == cm->last_height && 289 cm->height == cm->last_height &&
310 !cm->intra_only && 290 !cm->intra_only &&
311 cm->last_show_frame; 291 cm->last_show_frame;
312 // Special case: set prev_mi to NULL when the previous mode info 292 // Special case: set prev_mi to NULL when the previous mode info
313 // context cannot be used. 293 // context cannot be used.
314 cm->prev_mi = use_prev_in_find_mv_refs ? 294 cm->prev_mi = use_prev_in_find_mv_refs ?
315 cm->prev_mip + cm->mode_info_stride + 1 : NULL; 295 cm->prev_mip + cm->mi_stride + 1 : NULL;
316 } 296 }
317 297
318 static INLINE int frame_is_intra_only(const VP9_COMMON *const cm) { 298 static INLINE int frame_is_intra_only(const VP9_COMMON *const cm) {
319 return cm->frame_type == KEY_FRAME || cm->intra_only; 299 return cm->frame_type == KEY_FRAME || cm->intra_only;
320 } 300 }
321 301
322 static INLINE void update_partition_context( 302 static INLINE void update_partition_context(MACROBLOCKD *xd,
323 PARTITION_CONTEXT *above_seg_context, 303 int mi_row, int mi_col,
324 PARTITION_CONTEXT left_seg_context[8], 304 BLOCK_SIZE subsize,
325 int mi_row, int mi_col, BLOCK_SIZE subsize, BLOCK_SIZE bsize) { 305 BLOCK_SIZE bsize) {
326 PARTITION_CONTEXT *const above_ctx = above_seg_context + mi_col; 306 PARTITION_CONTEXT *const above_ctx = xd->above_seg_context + mi_col;
327 PARTITION_CONTEXT *const left_ctx = left_seg_context + (mi_row & MI_MASK); 307 PARTITION_CONTEXT *const left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
328 308
329 // num_4x4_blocks_wide_lookup[bsize] / 2 309 // num_4x4_blocks_wide_lookup[bsize] / 2
330 const int bs = num_8x8_blocks_wide_lookup[bsize]; 310 const int bs = num_8x8_blocks_wide_lookup[bsize];
331 311
332 // update the partition context at the end notes. set partition bits 312 // update the partition context at the end notes. set partition bits
333 // of block sizes larger than the current one to be one, and partition 313 // of block sizes larger than the current one to be one, and partition
334 // bits of smaller block sizes to be zero. 314 // bits of smaller block sizes to be zero.
335 vpx_memset(above_ctx, partition_context_lookup[subsize].above, bs); 315 vpx_memset(above_ctx, partition_context_lookup[subsize].above, bs);
336 vpx_memset(left_ctx, partition_context_lookup[subsize].left, bs); 316 vpx_memset(left_ctx, partition_context_lookup[subsize].left, bs);
337 } 317 }
338 318
339 static INLINE int partition_plane_context( 319 static INLINE int partition_plane_context(const MACROBLOCKD *xd,
340 const PARTITION_CONTEXT *above_seg_context, 320 int mi_row, int mi_col,
341 const PARTITION_CONTEXT left_seg_context[8], 321 BLOCK_SIZE bsize) {
342 int mi_row, int mi_col, BLOCK_SIZE bsize) { 322 const PARTITION_CONTEXT *above_ctx = xd->above_seg_context + mi_col;
343 const PARTITION_CONTEXT *above_ctx = above_seg_context + mi_col; 323 const PARTITION_CONTEXT *left_ctx = xd->left_seg_context + (mi_row & MI_MASK);
344 const PARTITION_CONTEXT *left_ctx = left_seg_context + (mi_row & MI_MASK);
345 324
346 const int bsl = mi_width_log2(bsize); 325 const int bsl = mi_width_log2(bsize);
347 const int bs = 1 << bsl; 326 const int bs = 1 << bsl;
348 int above = 0, left = 0, i; 327 int above = 0, left = 0, i;
349 328
350 assert(b_width_log2(bsize) == b_height_log2(bsize)); 329 assert(b_width_log2(bsize) == b_height_log2(bsize));
351 assert(bsl >= 0); 330 assert(bsl >= 0);
352 331
353 for (i = 0; i < bs; i++) { 332 for (i = 0; i < bs; i++) {
354 above |= above_ctx[i]; 333 above |= above_ctx[i];
355 left |= left_ctx[i]; 334 left |= left_ctx[i];
356 } 335 }
357 above = (above & bs) > 0; 336 above = (above & bs) > 0;
358 left = (left & bs) > 0; 337 left = (left & bs) > 0;
359 338
360 return (left * 2 + above) + bsl * PARTITION_PLOFFSET; 339 return (left * 2 + above) + bsl * PARTITION_PLOFFSET;
361 } 340 }
362 341
363 #ifdef __cplusplus 342 #ifdef __cplusplus
364 } // extern "C" 343 } // extern "C"
365 #endif 344 #endif
366 345
367 #endif // VP9_COMMON_VP9_ONYXC_INT_H_ 346 #endif // VP9_COMMON_VP9_ONYXC_INT_H_
OLDNEW
« no previous file with comments | « source/libvpx/vp9/common/vp9_onyx.h ('k') | source/libvpx/vp9/common/vp9_postproc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698