OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 |
| 12 #ifndef VP9_COMMON_VP9_ONYXC_INT_H_ |
| 13 #define VP9_COMMON_VP9_ONYXC_INT_H_ |
| 14 |
| 15 #include "vpx_config.h" |
| 16 #include "vpx/internal/vpx_codec_internal.h" |
| 17 #include "vp9_rtcd.h" |
| 18 #include "vp9/common/vp9_loopfilter.h" |
| 19 #include "vp9/common/vp9_entropymv.h" |
| 20 #include "vp9/common/vp9_entropy.h" |
| 21 #include "vp9/common/vp9_entropymode.h" |
| 22 #if CONFIG_POSTPROC |
| 23 #include "vp9/common/vp9_postproc.h" |
| 24 #endif |
| 25 |
| 26 /*#ifdef PACKET_TESTING*/ |
| 27 #include "vp9/common/vp9_header.h" |
| 28 /*#endif*/ |
| 29 |
| 30 /* Create/destroy static data structures. */ |
| 31 |
| 32 void vp9_initialize_common(void); |
| 33 |
| 34 #define MINQ 0 |
| 35 |
| 36 #define MAXQ 255 |
| 37 #define QINDEX_BITS 8 |
| 38 |
| 39 #define QINDEX_RANGE (MAXQ + 1) |
| 40 |
| 41 #define NUM_YV12_BUFFERS 4 |
| 42 |
| 43 #define COMP_PRED_CONTEXTS 2 |
| 44 |
| 45 typedef struct frame_contexts { |
| 46 vp9_prob bmode_prob[VP9_NKF_BINTRAMODES - 1]; |
| 47 vp9_prob ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */ |
| 48 #if CONFIG_SUPERBLOCKS |
| 49 vp9_prob sb_ymode_prob[VP9_I32X32_MODES - 1]; |
| 50 #endif |
| 51 vp9_prob uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1]; |
| 52 vp9_prob i8x8_mode_prob[VP9_I8X8_MODES - 1]; |
| 53 vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1]; |
| 54 vp9_prob mbsplit_prob[VP9_NUMMBSPLITS - 1]; |
| 55 vp9_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_N
ODES]; |
| 56 vp9_prob hybrid_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [EN
TROPY_NODES]; |
| 57 vp9_prob coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [E
NTROPY_NODES]; |
| 58 vp9_prob hybrid_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTE
XTS] [ENTROPY_NODES]; |
| 59 vp9_prob coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS
] [ENTROPY_NODES]; |
| 60 vp9_prob hybrid_coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_C
ONTEXTS] [ENTROPY_NODES]; |
| 61 |
| 62 nmv_context nmvc; |
| 63 nmv_context pre_nmvc; |
| 64 vp9_prob pre_bmode_prob[VP9_NKF_BINTRAMODES - 1]; |
| 65 vp9_prob pre_ymode_prob[VP9_YMODES - 1]; /* interframe intra mode probs */ |
| 66 #if CONFIG_SUPERBLOCKS |
| 67 vp9_prob pre_sb_ymode_prob[VP9_I32X32_MODES - 1]; |
| 68 #endif |
| 69 vp9_prob pre_uv_mode_prob[VP9_YMODES][VP9_UV_MODES - 1]; |
| 70 vp9_prob pre_i8x8_mode_prob[VP9_I8X8_MODES - 1]; |
| 71 vp9_prob pre_sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1]; |
| 72 vp9_prob pre_mbsplit_prob[VP9_NUMMBSPLITS - 1]; |
| 73 unsigned int bmode_counts[VP9_NKF_BINTRAMODES]; |
| 74 unsigned int ymode_counts[VP9_YMODES]; /* interframe intra mode probs */ |
| 75 #if CONFIG_SUPERBLOCKS |
| 76 unsigned int sb_ymode_counts[VP9_I32X32_MODES]; |
| 77 #endif |
| 78 unsigned int uv_mode_counts[VP9_YMODES][VP9_UV_MODES]; |
| 79 unsigned int i8x8_mode_counts[VP9_I8X8_MODES]; /* interframe intra probs */ |
| 80 unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS]; |
| 81 unsigned int mbsplit_counts[VP9_NUMMBSPLITS]; |
| 82 |
| 83 vp9_prob pre_coef_probs [BLOCK_TYPES] [COEF_BANDS] |
| 84 [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; |
| 85 vp9_prob pre_hybrid_coef_probs [BLOCK_TYPES] [COEF_BANDS] |
| 86 [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; |
| 87 |
| 88 vp9_prob pre_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] |
| 89 [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; |
| 90 vp9_prob pre_hybrid_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] |
| 91 [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; |
| 92 |
| 93 vp9_prob pre_coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] |
| 94 [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; |
| 95 vp9_prob pre_hybrid_coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] |
| 96 [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; |
| 97 |
| 98 unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] |
| 99 [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; |
| 100 unsigned int hybrid_coef_counts [BLOCK_TYPES] [COEF_BANDS] |
| 101 [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; |
| 102 |
| 103 unsigned int coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] |
| 104 [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; |
| 105 unsigned int hybrid_coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] |
| 106 [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; |
| 107 |
| 108 unsigned int coef_counts_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] |
| 109 [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; |
| 110 unsigned int hybrid_coef_counts_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] |
| 111 [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; |
| 112 |
| 113 nmv_context_counts NMVcount; |
| 114 vp9_prob switchable_interp_prob[VP9_SWITCHABLE_FILTERS + 1] |
| 115 [VP9_SWITCHABLE_FILTERS - 1]; |
| 116 #if CONFIG_COMP_INTERINTRA_PRED |
| 117 unsigned int interintra_counts[2]; |
| 118 vp9_prob interintra_prob; |
| 119 vp9_prob pre_interintra_prob; |
| 120 #endif |
| 121 |
| 122 int vp9_mode_contexts[INTER_MODE_CONTEXTS][4]; |
| 123 unsigned int mv_ref_ct[INTER_MODE_CONTEXTS][4][2]; |
| 124 } FRAME_CONTEXT; |
| 125 |
| 126 typedef enum { |
| 127 RECON_CLAMP_REQUIRED = 0, |
| 128 RECON_CLAMP_NOTREQUIRED = 1 |
| 129 } CLAMP_TYPE; |
| 130 |
| 131 typedef enum { |
| 132 SINGLE_PREDICTION_ONLY = 0, |
| 133 COMP_PREDICTION_ONLY = 1, |
| 134 HYBRID_PREDICTION = 2, |
| 135 NB_PREDICTION_TYPES = 3, |
| 136 } COMPPREDMODE_TYPE; |
| 137 |
| 138 typedef enum { |
| 139 ONLY_4X4 = 0, |
| 140 ALLOW_8X8 = 1, |
| 141 ALLOW_16X16 = 2, |
| 142 TX_MODE_SELECT = 3, |
| 143 NB_TXFM_MODES = 4, |
| 144 } TXFM_MODE; |
| 145 |
| 146 typedef struct VP9Common { |
| 147 struct vpx_internal_error_info error; |
| 148 |
| 149 DECLARE_ALIGNED(16, short, Y1dequant[QINDEX_RANGE][16]); |
| 150 DECLARE_ALIGNED(16, short, Y2dequant[QINDEX_RANGE][16]); |
| 151 DECLARE_ALIGNED(16, short, UVdequant[QINDEX_RANGE][16]); |
| 152 |
| 153 int Width; |
| 154 int Height; |
| 155 int horiz_scale; |
| 156 int vert_scale; |
| 157 |
| 158 YUV_TYPE clr_type; |
| 159 CLAMP_TYPE clamp_type; |
| 160 |
| 161 YV12_BUFFER_CONFIG *frame_to_show; |
| 162 |
| 163 YV12_BUFFER_CONFIG yv12_fb[NUM_YV12_BUFFERS]; |
| 164 int fb_idx_ref_cnt[NUM_YV12_BUFFERS]; |
| 165 int new_fb_idx, lst_fb_idx, gld_fb_idx, alt_fb_idx; |
| 166 |
| 167 YV12_BUFFER_CONFIG post_proc_buffer; |
| 168 YV12_BUFFER_CONFIG temp_scale_frame; |
| 169 |
| 170 |
| 171 FRAME_TYPE last_frame_type; /* Save last frame's frame type for motion search
. */ |
| 172 FRAME_TYPE frame_type; |
| 173 |
| 174 int show_frame; |
| 175 |
| 176 int frame_flags; |
| 177 int MBs; |
| 178 int mb_rows; |
| 179 int mb_cols; |
| 180 int mode_info_stride; |
| 181 |
| 182 /* profile settings */ |
| 183 int experimental; |
| 184 int mb_no_coeff_skip; |
| 185 TXFM_MODE txfm_mode; |
| 186 COMPPREDMODE_TYPE comp_pred_mode; |
| 187 int no_lpf; |
| 188 int use_bilinear_mc_filter; |
| 189 int full_pixel; |
| 190 |
| 191 int base_qindex; |
| 192 int last_kf_gf_q; /* Q used on the last GF or KF */ |
| 193 |
| 194 int y1dc_delta_q; |
| 195 int y2dc_delta_q; |
| 196 int y2ac_delta_q; |
| 197 int uvdc_delta_q; |
| 198 int uvac_delta_q; |
| 199 |
| 200 unsigned int frames_since_golden; |
| 201 unsigned int frames_till_alt_ref_frame; |
| 202 |
| 203 /* We allocate a MODE_INFO struct for each macroblock, together with |
| 204 an extra row on top and column on the left to simplify prediction. */ |
| 205 |
| 206 MODE_INFO *mip; /* Base of allocated array */ |
| 207 MODE_INFO *mi; /* Corresponds to upper left visible macroblock */ |
| 208 MODE_INFO *prev_mip; /* MODE_INFO array 'mip' from last decoded frame */ |
| 209 MODE_INFO *prev_mi; /* 'mi' from last frame (points into prev_mip) */ |
| 210 |
| 211 |
| 212 // Persistent mb segment id map used in prediction. |
| 213 unsigned char *last_frame_seg_map; |
| 214 |
| 215 INTERPOLATIONFILTERTYPE mcomp_filter_type; |
| 216 LOOPFILTERTYPE filter_type; |
| 217 |
| 218 loop_filter_info_n lf_info; |
| 219 |
| 220 int filter_level; |
| 221 int last_sharpness_level; |
| 222 int sharpness_level; |
| 223 |
| 224 int refresh_last_frame; /* Two state 0 = NO, 1 = YES */ |
| 225 int refresh_golden_frame; /* Two state 0 = NO, 1 = YES */ |
| 226 int refresh_alt_ref_frame; /* Two state 0 = NO, 1 = YES */ |
| 227 |
| 228 int copy_buffer_to_gf; /* 0 none, 1 Last to GF, 2 ARF to GF */ |
| 229 int copy_buffer_to_arf; /* 0 none, 1 Last to ARF, 2 GF to ARF */ |
| 230 |
| 231 int refresh_entropy_probs; /* Two state 0 = NO, 1 = YES */ |
| 232 |
| 233 int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */ |
| 234 |
| 235 /* Y,U,V,Y2 */ |
| 236 ENTROPY_CONTEXT_PLANES *above_context; /* row of context for each plane */ |
| 237 ENTROPY_CONTEXT_PLANES left_context[2]; /* (up to) 4 contexts "" */ |
| 238 |
| 239 /* keyframe block modes are predicted by their above, left neighbors */ |
| 240 |
| 241 vp9_prob kf_bmode_prob[VP9_KF_BINTRAMODES] |
| 242 [VP9_KF_BINTRAMODES] |
| 243 [VP9_KF_BINTRAMODES - 1]; |
| 244 vp9_prob kf_ymode_prob[8][VP9_YMODES - 1]; /* keyframe "" */ |
| 245 #if CONFIG_SUPERBLOCKS |
| 246 vp9_prob sb_kf_ymode_prob[8][VP9_I32X32_MODES - 1]; |
| 247 #endif |
| 248 int kf_ymode_probs_index; |
| 249 int kf_ymode_probs_update; |
| 250 vp9_prob kf_uv_mode_prob[VP9_YMODES] [VP9_UV_MODES - 1]; |
| 251 |
| 252 vp9_prob prob_intra_coded; |
| 253 vp9_prob prob_last_coded; |
| 254 vp9_prob prob_gf_coded; |
| 255 #if CONFIG_SUPERBLOCKS |
| 256 vp9_prob sb_coded; |
| 257 #endif |
| 258 |
| 259 // Context probabilities when using predictive coding of segment id |
| 260 vp9_prob segment_pred_probs[PREDICTION_PROBS]; |
| 261 unsigned char temporal_update; |
| 262 |
| 263 // Context probabilities for reference frame prediction |
| 264 unsigned char ref_scores[MAX_REF_FRAMES]; |
| 265 vp9_prob ref_pred_probs[PREDICTION_PROBS]; |
| 266 vp9_prob mod_refprobs[MAX_REF_FRAMES][PREDICTION_PROBS]; |
| 267 |
| 268 vp9_prob prob_comppred[COMP_PRED_CONTEXTS]; |
| 269 |
| 270 // FIXME contextualize |
| 271 vp9_prob prob_tx[TX_SIZE_MAX - 1]; |
| 272 |
| 273 vp9_prob mbskip_pred_probs[MBSKIP_CONTEXTS]; |
| 274 |
| 275 FRAME_CONTEXT lfc_a; /* last alt ref entropy */ |
| 276 FRAME_CONTEXT lfc; /* last frame entropy */ |
| 277 FRAME_CONTEXT fc; /* this frame entropy */ |
| 278 |
| 279 unsigned int current_video_frame; |
| 280 int near_boffset[3]; |
| 281 int version; |
| 282 |
| 283 #ifdef PACKET_TESTING |
| 284 VP9_HEADER oh; |
| 285 #endif |
| 286 double bitrate; |
| 287 double framerate; |
| 288 |
| 289 #if CONFIG_POSTPROC |
| 290 struct postproc_state postproc_state; |
| 291 #endif |
| 292 |
| 293 #if CONFIG_PRED_FILTER |
| 294 /* Prediction filter variables */ |
| 295 int pred_filter_mode; // 0=disabled at the frame level (no MB filtered) |
| 296 // 1=enabled at the frame level (all MB filtered) |
| 297 // 2=specified per MB (1=filtered, 0=non-filtered) |
| 298 vp9_prob prob_pred_filter_off; |
| 299 #endif |
| 300 #if CONFIG_COMP_INTERINTRA_PRED |
| 301 int use_interintra; |
| 302 #endif |
| 303 |
| 304 } VP9_COMMON; |
| 305 |
| 306 #endif // __INC_ONYX_INT_H |
OLD | NEW |