| OLD | NEW |
| 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 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // 1 scratch frame for the new frame, 3 for scaled references on the encoder | 32 // 1 scratch frame for the new frame, 3 for scaled references on the encoder |
| 33 // TODO(jkoleszar): These 3 extra references could probably come from the | 33 // TODO(jkoleszar): These 3 extra references could probably come from the |
| 34 // normal reference pool. | 34 // normal reference pool. |
| 35 #define NUM_YV12_BUFFERS (NUM_REF_FRAMES + 4) | 35 #define NUM_YV12_BUFFERS (NUM_REF_FRAMES + 4) |
| 36 | 36 |
| 37 #define NUM_FRAME_CONTEXTS_LOG2 2 | 37 #define NUM_FRAME_CONTEXTS_LOG2 2 |
| 38 #define NUM_FRAME_CONTEXTS (1 << NUM_FRAME_CONTEXTS_LOG2) | 38 #define NUM_FRAME_CONTEXTS (1 << NUM_FRAME_CONTEXTS_LOG2) |
| 39 | 39 |
| 40 typedef struct frame_contexts { | 40 typedef struct frame_contexts { |
| 41 vp9_prob y_mode_prob[BLOCK_SIZE_GROUPS][VP9_INTRA_MODES - 1]; | 41 vp9_prob y_mode_prob[BLOCK_SIZE_GROUPS][INTRA_MODES - 1]; |
| 42 vp9_prob uv_mode_prob[VP9_INTRA_MODES][VP9_INTRA_MODES - 1]; | 42 vp9_prob uv_mode_prob[INTRA_MODES][INTRA_MODES - 1]; |
| 43 vp9_prob partition_prob[NUM_FRAME_TYPES][NUM_PARTITION_CONTEXTS] | 43 vp9_prob partition_prob[NUM_FRAME_TYPES][NUM_PARTITION_CONTEXTS] |
| 44 [PARTITION_TYPES - 1]; | 44 [PARTITION_TYPES - 1]; |
| 45 vp9_coeff_probs_model coef_probs[TX_SIZE_MAX_SB][BLOCK_TYPES]; | 45 vp9_coeff_probs_model coef_probs[TX_SIZES][BLOCK_TYPES]; |
| 46 vp9_prob switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1] | 46 vp9_prob switchable_interp_prob[SWITCHABLE_FILTERS + 1] |
| 47 [VP9_SWITCHABLE_FILTERS - 1]; | 47 [SWITCHABLE_FILTERS - 1]; |
| 48 vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1]; | 48 vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1]; |
| 49 vp9_prob intra_inter_prob[INTRA_INTER_CONTEXTS]; | 49 vp9_prob intra_inter_prob[INTRA_INTER_CONTEXTS]; |
| 50 vp9_prob comp_inter_prob[COMP_INTER_CONTEXTS]; | 50 vp9_prob comp_inter_prob[COMP_INTER_CONTEXTS]; |
| 51 vp9_prob single_ref_prob[REF_CONTEXTS][2]; | 51 vp9_prob single_ref_prob[REF_CONTEXTS][2]; |
| 52 vp9_prob comp_ref_prob[REF_CONTEXTS]; | 52 vp9_prob comp_ref_prob[REF_CONTEXTS]; |
| 53 struct tx_probs tx_probs; | 53 struct tx_probs tx_probs; |
| 54 vp9_prob mbskip_probs[MBSKIP_CONTEXTS]; | 54 vp9_prob mbskip_probs[MBSKIP_CONTEXTS]; |
| 55 nmv_context nmvc; | 55 nmv_context nmvc; |
| 56 } FRAME_CONTEXT; | 56 } FRAME_CONTEXT; |
| 57 | 57 |
| 58 typedef struct { | 58 typedef struct { |
| 59 unsigned int y_mode[BLOCK_SIZE_GROUPS][VP9_INTRA_MODES]; | 59 unsigned int y_mode[BLOCK_SIZE_GROUPS][INTRA_MODES]; |
| 60 unsigned int uv_mode[VP9_INTRA_MODES][VP9_INTRA_MODES]; | 60 unsigned int uv_mode[INTRA_MODES][INTRA_MODES]; |
| 61 unsigned int partition[NUM_PARTITION_CONTEXTS][PARTITION_TYPES]; | 61 unsigned int partition[NUM_PARTITION_CONTEXTS][PARTITION_TYPES]; |
| 62 vp9_coeff_count_model coef[TX_SIZE_MAX_SB][BLOCK_TYPES]; | 62 vp9_coeff_count_model coef[TX_SIZES][BLOCK_TYPES]; |
| 63 unsigned int eob_branch[TX_SIZE_MAX_SB][BLOCK_TYPES][REF_TYPES] | 63 unsigned int eob_branch[TX_SIZES][BLOCK_TYPES][REF_TYPES] |
| 64 [COEF_BANDS][PREV_COEF_CONTEXTS]; | 64 [COEF_BANDS][PREV_COEF_CONTEXTS]; |
| 65 unsigned int switchable_interp[VP9_SWITCHABLE_FILTERS + 1] | 65 unsigned int switchable_interp[SWITCHABLE_FILTERS + 1] |
| 66 [VP9_SWITCHABLE_FILTERS]; | 66 [SWITCHABLE_FILTERS]; |
| 67 unsigned int inter_mode[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1][2]; | 67 unsigned int inter_mode[INTER_MODE_CONTEXTS][INTER_MODES]; |
| 68 unsigned int intra_inter[INTRA_INTER_CONTEXTS][2]; | 68 unsigned int intra_inter[INTRA_INTER_CONTEXTS][2]; |
| 69 unsigned int comp_inter[COMP_INTER_CONTEXTS][2]; | 69 unsigned int comp_inter[COMP_INTER_CONTEXTS][2]; |
| 70 unsigned int single_ref[REF_CONTEXTS][2][2]; | 70 unsigned int single_ref[REF_CONTEXTS][2][2]; |
| 71 unsigned int comp_ref[REF_CONTEXTS][2]; | 71 unsigned int comp_ref[REF_CONTEXTS][2]; |
| 72 struct tx_counts tx; | 72 struct tx_counts tx; |
| 73 unsigned int mbskip[MBSKIP_CONTEXTS][2]; | 73 unsigned int mbskip[MBSKIP_CONTEXTS][2]; |
| 74 nmv_context_counts mv; | 74 nmv_context_counts mv; |
| 75 } FRAME_COUNTS; | 75 } FRAME_COUNTS; |
| 76 | 76 |
| 77 | 77 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 unsigned char *last_frame_seg_map; | 169 unsigned char *last_frame_seg_map; |
| 170 | 170 |
| 171 INTERPOLATIONFILTERTYPE mcomp_filter_type; | 171 INTERPOLATIONFILTERTYPE mcomp_filter_type; |
| 172 | 172 |
| 173 loop_filter_info_n lf_info; | 173 loop_filter_info_n lf_info; |
| 174 | 174 |
| 175 int refresh_frame_context; /* Two state 0 = NO, 1 = YES */ | 175 int refresh_frame_context; /* Two state 0 = NO, 1 = YES */ |
| 176 | 176 |
| 177 int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */ | 177 int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */ |
| 178 | 178 |
| 179 struct loopfilter lf; |
| 180 struct segmentation seg; |
| 181 |
| 179 /* Y,U,V */ | 182 /* Y,U,V */ |
| 180 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; | 183 ENTROPY_CONTEXT *above_context[MAX_MB_PLANE]; |
| 181 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; | 184 ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16]; |
| 182 | 185 |
| 183 // partition contexts | 186 // partition contexts |
| 184 PARTITION_CONTEXT *above_seg_context; | 187 PARTITION_CONTEXT *above_seg_context; |
| 185 PARTITION_CONTEXT left_seg_context[8]; | 188 PARTITION_CONTEXT left_seg_context[8]; |
| 186 | 189 |
| 187 // Context probabilities for reference frame prediction | 190 // Context probabilities for reference frame prediction |
| 188 int allow_comp_inter_inter; | 191 int allow_comp_inter_inter; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 static void ref_cnt_fb(int *buf, int *idx, int new_idx) { | 227 static void ref_cnt_fb(int *buf, int *idx, int new_idx) { |
| 225 if (buf[*idx] > 0) | 228 if (buf[*idx] > 0) |
| 226 buf[*idx]--; | 229 buf[*idx]--; |
| 227 | 230 |
| 228 *idx = new_idx; | 231 *idx = new_idx; |
| 229 | 232 |
| 230 buf[new_idx]++; | 233 buf[new_idx]++; |
| 231 } | 234 } |
| 232 | 235 |
| 233 static int mi_cols_aligned_to_sb(int n_mis) { | 236 static int mi_cols_aligned_to_sb(int n_mis) { |
| 234 return ALIGN_POWER_OF_TWO(n_mis, LOG2_MI_BLOCK_SIZE); | 237 return ALIGN_POWER_OF_TWO(n_mis, MI_BLOCK_SIZE_LOG2); |
| 238 } |
| 239 |
| 240 static INLINE void set_skip_context(VP9_COMMON *cm, MACROBLOCKD *xd, |
| 241 int mi_row, int mi_col) { |
| 242 const int above_idx = mi_col * 2; |
| 243 const int left_idx = (mi_row * 2) & 15; |
| 244 int i; |
| 245 for (i = 0; i < MAX_MB_PLANE; i++) { |
| 246 struct macroblockd_plane *const pd = &xd->plane[i]; |
| 247 pd->above_context = cm->above_context[i] + (above_idx >> pd->subsampling_x); |
| 248 pd->left_context = cm->left_context[i] + (left_idx >> pd->subsampling_y); |
| 249 } |
| 235 } | 250 } |
| 236 | 251 |
| 237 static INLINE void set_partition_seg_context(VP9_COMMON *cm, MACROBLOCKD *xd, | 252 static INLINE void set_partition_seg_context(VP9_COMMON *cm, MACROBLOCKD *xd, |
| 238 int mi_row, int mi_col) { | 253 int mi_row, int mi_col) { |
| 239 xd->above_seg_context = cm->above_seg_context + mi_col; | 254 xd->above_seg_context = cm->above_seg_context + mi_col; |
| 240 xd->left_seg_context = cm->left_seg_context + (mi_row & MI_MASK); | 255 xd->left_seg_context = cm->left_seg_context + (mi_row & MI_MASK); |
| 241 } | 256 } |
| 242 | 257 |
| 243 static int check_bsize_coverage(VP9_COMMON *cm, MACROBLOCKD *xd, | 258 // return the node index in the prob tree for binary coding |
| 244 int mi_row, int mi_col, | 259 static int check_bsize_coverage(int bs, int mi_rows, int mi_cols, |
| 245 BLOCK_SIZE_TYPE bsize) { | 260 int mi_row, int mi_col) { |
| 246 int bsl = mi_width_log2(bsize), bs = 1 << bsl; | 261 const int r = (mi_row + bs < mi_rows); |
| 247 int ms = bs / 2; | 262 const int c = (mi_col + bs < mi_cols); |
| 248 | 263 |
| 249 if ((mi_row + ms < cm->mi_rows) && (mi_col + ms < cm->mi_cols)) | 264 if (r && c) |
| 250 return 0; | 265 return 0; |
| 251 | 266 |
| 252 // frame width/height are multiples of 8, hence 8x8 block should always | 267 if (c && !r) |
| 253 // pass the above check | 268 return 1; // only allow horizontal/split partition types |
| 254 assert(bsize > BLOCK_SIZE_SB8X8); | |
| 255 | 269 |
| 256 // return the node index in the prob tree for binary coding | 270 if (r && !c) |
| 257 // only allow horizontal/split partition types | 271 return 2; // only allow vertical/split partition types |
| 258 if ((mi_col + ms < cm->mi_cols) && (mi_row + ms >= cm->mi_rows)) | |
| 259 return 1; | |
| 260 // only allow vertical/split partition types | |
| 261 if ((mi_row + ms < cm->mi_rows) && (mi_col + ms >= cm->mi_cols)) | |
| 262 return 2; | |
| 263 | 272 |
| 264 return -1; | 273 return -1; |
| 265 } | 274 } |
| 266 | 275 |
| 267 static void set_mi_row_col(VP9_COMMON *cm, MACROBLOCKD *xd, | 276 static void set_mi_row_col(VP9_COMMON *cm, MACROBLOCKD *xd, |
| 268 int mi_row, int bh, | 277 int mi_row, int bh, |
| 269 int mi_col, int bw) { | 278 int mi_col, int bw) { |
| 270 xd->mb_to_top_edge = -((mi_row * MI_SIZE) << 3); | 279 xd->mb_to_top_edge = -((mi_row * MI_SIZE) << 3); |
| 271 xd->mb_to_bottom_edge = ((cm->mi_rows - bh - mi_row) * MI_SIZE) << 3; | 280 xd->mb_to_bottom_edge = ((cm->mi_rows - bh - mi_row) * MI_SIZE) << 3; |
| 272 xd->mb_to_left_edge = -((mi_col * MI_SIZE) << 3); | 281 xd->mb_to_left_edge = -((mi_col * MI_SIZE) << 3); |
| 273 xd->mb_to_right_edge = ((cm->mi_cols - bw - mi_col) * MI_SIZE) << 3; | 282 xd->mb_to_right_edge = ((cm->mi_cols - bw - mi_col) * MI_SIZE) << 3; |
| 274 | 283 |
| 275 // Are edges available for intra prediction? | 284 // Are edges available for intra prediction? |
| 276 xd->up_available = (mi_row != 0); | 285 xd->up_available = (mi_row != 0); |
| 277 xd->left_available = (mi_col > cm->cur_tile_mi_col_start); | 286 xd->left_available = (mi_col > cm->cur_tile_mi_col_start); |
| 278 xd->right_available = (mi_col + bw < cm->cur_tile_mi_col_end); | 287 xd->right_available = (mi_col + bw < cm->cur_tile_mi_col_end); |
| 279 } | 288 } |
| 280 | 289 |
| 281 static int get_mi_row(const MACROBLOCKD *xd) { | |
| 282 return ((-xd->mb_to_top_edge) >> (3 + LOG2_MI_SIZE)); | |
| 283 } | |
| 284 | |
| 285 static int get_mi_col(const MACROBLOCKD *xd) { | |
| 286 return ((-xd->mb_to_left_edge) >> (3 + LOG2_MI_SIZE)); | |
| 287 } | |
| 288 | |
| 289 static int get_token_alloc(int mb_rows, int mb_cols) { | 290 static int get_token_alloc(int mb_rows, int mb_cols) { |
| 290 return mb_rows * mb_cols * (48 * 16 + 4); | 291 return mb_rows * mb_cols * (48 * 16 + 4); |
| 291 } | 292 } |
| 292 | 293 |
| 293 static void set_prev_mi(VP9_COMMON *cm) { | 294 static void set_prev_mi(VP9_COMMON *cm) { |
| 294 const int use_prev_in_find_mv_refs = cm->width == cm->last_width && | 295 const int use_prev_in_find_mv_refs = cm->width == cm->last_width && |
| 295 cm->height == cm->last_height && | 296 cm->height == cm->last_height && |
| 296 !cm->error_resilient_mode && | 297 !cm->error_resilient_mode && |
| 297 !cm->intra_only && | 298 !cm->intra_only && |
| 298 cm->last_show_frame; | 299 cm->last_show_frame; |
| 299 // Special case: set prev_mi to NULL when the previous mode info | 300 // Special case: set prev_mi to NULL when the previous mode info |
| 300 // context cannot be used. | 301 // context cannot be used. |
| 301 cm->prev_mi = use_prev_in_find_mv_refs ? | 302 cm->prev_mi = use_prev_in_find_mv_refs ? |
| 302 cm->prev_mip + cm->mode_info_stride + 1 : NULL; | 303 cm->prev_mip + cm->mode_info_stride + 1 : NULL; |
| 303 } | 304 } |
| 304 #endif // VP9_COMMON_VP9_ONYXC_INT_H_ | 305 #endif // VP9_COMMON_VP9_ONYXC_INT_H_ |
| OLD | NEW |