Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
michael@0 | 3 | * |
michael@0 | 4 | * Use of this source code is governed by a BSD-style license |
michael@0 | 5 | * that can be found in the LICENSE file in the root of the source |
michael@0 | 6 | * tree. An additional intellectual property rights grant can be found |
michael@0 | 7 | * in the file PATENTS. All contributing project authors may |
michael@0 | 8 | * be found in the AUTHORS file in the root of the source tree. |
michael@0 | 9 | */ |
michael@0 | 10 | |
michael@0 | 11 | |
michael@0 | 12 | #ifndef __INC_BLOCKD_H |
michael@0 | 13 | #define __INC_BLOCKD_H |
michael@0 | 14 | |
michael@0 | 15 | void vpx_log(const char *format, ...); |
michael@0 | 16 | |
michael@0 | 17 | #include "vpx_config.h" |
michael@0 | 18 | #include "vpx_scale/yv12config.h" |
michael@0 | 19 | #include "mv.h" |
michael@0 | 20 | #include "treecoder.h" |
michael@0 | 21 | #include "vpx_ports/mem.h" |
michael@0 | 22 | |
michael@0 | 23 | /*#define DCPRED 1*/ |
michael@0 | 24 | #define DCPREDSIMTHRESH 0 |
michael@0 | 25 | #define DCPREDCNTTHRESH 3 |
michael@0 | 26 | |
michael@0 | 27 | #define MB_FEATURE_TREE_PROBS 3 |
michael@0 | 28 | #define MAX_MB_SEGMENTS 4 |
michael@0 | 29 | |
michael@0 | 30 | #define MAX_REF_LF_DELTAS 4 |
michael@0 | 31 | #define MAX_MODE_LF_DELTAS 4 |
michael@0 | 32 | |
michael@0 | 33 | /* Segment Feature Masks */ |
michael@0 | 34 | #define SEGMENT_DELTADATA 0 |
michael@0 | 35 | #define SEGMENT_ABSDATA 1 |
michael@0 | 36 | |
michael@0 | 37 | typedef struct |
michael@0 | 38 | { |
michael@0 | 39 | int r, c; |
michael@0 | 40 | } POS; |
michael@0 | 41 | |
michael@0 | 42 | #define PLANE_TYPE_Y_NO_DC 0 |
michael@0 | 43 | #define PLANE_TYPE_Y2 1 |
michael@0 | 44 | #define PLANE_TYPE_UV 2 |
michael@0 | 45 | #define PLANE_TYPE_Y_WITH_DC 3 |
michael@0 | 46 | |
michael@0 | 47 | |
michael@0 | 48 | typedef char ENTROPY_CONTEXT; |
michael@0 | 49 | typedef struct |
michael@0 | 50 | { |
michael@0 | 51 | ENTROPY_CONTEXT y1[4]; |
michael@0 | 52 | ENTROPY_CONTEXT u[2]; |
michael@0 | 53 | ENTROPY_CONTEXT v[2]; |
michael@0 | 54 | ENTROPY_CONTEXT y2; |
michael@0 | 55 | } ENTROPY_CONTEXT_PLANES; |
michael@0 | 56 | |
michael@0 | 57 | extern const unsigned char vp8_block2left[25]; |
michael@0 | 58 | extern const unsigned char vp8_block2above[25]; |
michael@0 | 59 | |
michael@0 | 60 | #define VP8_COMBINEENTROPYCONTEXTS( Dest, A, B) \ |
michael@0 | 61 | Dest = (A)+(B); |
michael@0 | 62 | |
michael@0 | 63 | |
michael@0 | 64 | typedef enum |
michael@0 | 65 | { |
michael@0 | 66 | KEY_FRAME = 0, |
michael@0 | 67 | INTER_FRAME = 1 |
michael@0 | 68 | } FRAME_TYPE; |
michael@0 | 69 | |
michael@0 | 70 | typedef enum |
michael@0 | 71 | { |
michael@0 | 72 | DC_PRED, /* average of above and left pixels */ |
michael@0 | 73 | V_PRED, /* vertical prediction */ |
michael@0 | 74 | H_PRED, /* horizontal prediction */ |
michael@0 | 75 | TM_PRED, /* Truemotion prediction */ |
michael@0 | 76 | B_PRED, /* block based prediction, each block has its own prediction mode */ |
michael@0 | 77 | |
michael@0 | 78 | NEARESTMV, |
michael@0 | 79 | NEARMV, |
michael@0 | 80 | ZEROMV, |
michael@0 | 81 | NEWMV, |
michael@0 | 82 | SPLITMV, |
michael@0 | 83 | |
michael@0 | 84 | MB_MODE_COUNT |
michael@0 | 85 | } MB_PREDICTION_MODE; |
michael@0 | 86 | |
michael@0 | 87 | /* Macroblock level features */ |
michael@0 | 88 | typedef enum |
michael@0 | 89 | { |
michael@0 | 90 | MB_LVL_ALT_Q = 0, /* Use alternate Quantizer .... */ |
michael@0 | 91 | MB_LVL_ALT_LF = 1, /* Use alternate loop filter value... */ |
michael@0 | 92 | MB_LVL_MAX = 2 /* Number of MB level features supported */ |
michael@0 | 93 | |
michael@0 | 94 | } MB_LVL_FEATURES; |
michael@0 | 95 | |
michael@0 | 96 | /* Segment Feature Masks */ |
michael@0 | 97 | #define SEGMENT_ALTQ 0x01 |
michael@0 | 98 | #define SEGMENT_ALT_LF 0x02 |
michael@0 | 99 | |
michael@0 | 100 | #define VP8_YMODES (B_PRED + 1) |
michael@0 | 101 | #define VP8_UV_MODES (TM_PRED + 1) |
michael@0 | 102 | |
michael@0 | 103 | #define VP8_MVREFS (1 + SPLITMV - NEARESTMV) |
michael@0 | 104 | |
michael@0 | 105 | typedef enum |
michael@0 | 106 | { |
michael@0 | 107 | B_DC_PRED, /* average of above and left pixels */ |
michael@0 | 108 | B_TM_PRED, |
michael@0 | 109 | |
michael@0 | 110 | B_VE_PRED, /* vertical prediction */ |
michael@0 | 111 | B_HE_PRED, /* horizontal prediction */ |
michael@0 | 112 | |
michael@0 | 113 | B_LD_PRED, |
michael@0 | 114 | B_RD_PRED, |
michael@0 | 115 | |
michael@0 | 116 | B_VR_PRED, |
michael@0 | 117 | B_VL_PRED, |
michael@0 | 118 | B_HD_PRED, |
michael@0 | 119 | B_HU_PRED, |
michael@0 | 120 | |
michael@0 | 121 | LEFT4X4, |
michael@0 | 122 | ABOVE4X4, |
michael@0 | 123 | ZERO4X4, |
michael@0 | 124 | NEW4X4, |
michael@0 | 125 | |
michael@0 | 126 | B_MODE_COUNT |
michael@0 | 127 | } B_PREDICTION_MODE; |
michael@0 | 128 | |
michael@0 | 129 | #define VP8_BINTRAMODES (B_HU_PRED + 1) /* 10 */ |
michael@0 | 130 | #define VP8_SUBMVREFS (1 + NEW4X4 - LEFT4X4) |
michael@0 | 131 | |
michael@0 | 132 | /* For keyframes, intra block modes are predicted by the (already decoded) |
michael@0 | 133 | modes for the Y blocks to the left and above us; for interframes, there |
michael@0 | 134 | is a single probability table. */ |
michael@0 | 135 | |
michael@0 | 136 | union b_mode_info |
michael@0 | 137 | { |
michael@0 | 138 | B_PREDICTION_MODE as_mode; |
michael@0 | 139 | int_mv mv; |
michael@0 | 140 | }; |
michael@0 | 141 | |
michael@0 | 142 | typedef enum |
michael@0 | 143 | { |
michael@0 | 144 | INTRA_FRAME = 0, |
michael@0 | 145 | LAST_FRAME = 1, |
michael@0 | 146 | GOLDEN_FRAME = 2, |
michael@0 | 147 | ALTREF_FRAME = 3, |
michael@0 | 148 | MAX_REF_FRAMES = 4 |
michael@0 | 149 | } MV_REFERENCE_FRAME; |
michael@0 | 150 | |
michael@0 | 151 | typedef struct |
michael@0 | 152 | { |
michael@0 | 153 | uint8_t mode, uv_mode; |
michael@0 | 154 | uint8_t ref_frame; |
michael@0 | 155 | uint8_t is_4x4; |
michael@0 | 156 | int_mv mv; |
michael@0 | 157 | |
michael@0 | 158 | uint8_t partitioning; |
michael@0 | 159 | uint8_t mb_skip_coeff; /* does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens */ |
michael@0 | 160 | uint8_t need_to_clamp_mvs; |
michael@0 | 161 | uint8_t segment_id; /* Which set of segmentation parameters should be used for this MB */ |
michael@0 | 162 | } MB_MODE_INFO; |
michael@0 | 163 | |
michael@0 | 164 | typedef struct modeinfo |
michael@0 | 165 | { |
michael@0 | 166 | MB_MODE_INFO mbmi; |
michael@0 | 167 | union b_mode_info bmi[16]; |
michael@0 | 168 | } MODE_INFO; |
michael@0 | 169 | |
michael@0 | 170 | #if CONFIG_MULTI_RES_ENCODING |
michael@0 | 171 | /* The mb-level information needed to be stored for higher-resolution encoder */ |
michael@0 | 172 | typedef struct |
michael@0 | 173 | { |
michael@0 | 174 | MB_PREDICTION_MODE mode; |
michael@0 | 175 | MV_REFERENCE_FRAME ref_frame; |
michael@0 | 176 | int_mv mv; |
michael@0 | 177 | int dissim; /* dissimilarity level of the macroblock */ |
michael@0 | 178 | } LOWER_RES_MB_INFO; |
michael@0 | 179 | |
michael@0 | 180 | /* The frame-level information needed to be stored for higher-resolution |
michael@0 | 181 | * encoder */ |
michael@0 | 182 | typedef struct |
michael@0 | 183 | { |
michael@0 | 184 | FRAME_TYPE frame_type; |
michael@0 | 185 | int is_frame_dropped; |
michael@0 | 186 | /* The frame number of each reference frames */ |
michael@0 | 187 | unsigned int low_res_ref_frames[MAX_REF_FRAMES]; |
michael@0 | 188 | LOWER_RES_MB_INFO *mb_info; |
michael@0 | 189 | } LOWER_RES_FRAME_INFO; |
michael@0 | 190 | #endif |
michael@0 | 191 | |
michael@0 | 192 | typedef struct blockd |
michael@0 | 193 | { |
michael@0 | 194 | short *qcoeff; |
michael@0 | 195 | short *dqcoeff; |
michael@0 | 196 | unsigned char *predictor; |
michael@0 | 197 | short *dequant; |
michael@0 | 198 | |
michael@0 | 199 | int offset; |
michael@0 | 200 | char *eob; |
michael@0 | 201 | |
michael@0 | 202 | union b_mode_info bmi; |
michael@0 | 203 | } BLOCKD; |
michael@0 | 204 | |
michael@0 | 205 | typedef void (*vp8_subpix_fn_t)(unsigned char *src, int src_pitch, int xofst, int yofst, unsigned char *dst, int dst_pitch); |
michael@0 | 206 | |
michael@0 | 207 | typedef struct macroblockd |
michael@0 | 208 | { |
michael@0 | 209 | DECLARE_ALIGNED(16, unsigned char, predictor[384]); |
michael@0 | 210 | DECLARE_ALIGNED(16, short, qcoeff[400]); |
michael@0 | 211 | DECLARE_ALIGNED(16, short, dqcoeff[400]); |
michael@0 | 212 | DECLARE_ALIGNED(16, char, eobs[25]); |
michael@0 | 213 | |
michael@0 | 214 | DECLARE_ALIGNED(16, short, dequant_y1[16]); |
michael@0 | 215 | DECLARE_ALIGNED(16, short, dequant_y1_dc[16]); |
michael@0 | 216 | DECLARE_ALIGNED(16, short, dequant_y2[16]); |
michael@0 | 217 | DECLARE_ALIGNED(16, short, dequant_uv[16]); |
michael@0 | 218 | |
michael@0 | 219 | /* 16 Y blocks, 4 U, 4 V, 1 DC 2nd order block, each with 16 entries. */ |
michael@0 | 220 | BLOCKD block[25]; |
michael@0 | 221 | int fullpixel_mask; |
michael@0 | 222 | |
michael@0 | 223 | YV12_BUFFER_CONFIG pre; /* Filtered copy of previous frame reconstruction */ |
michael@0 | 224 | YV12_BUFFER_CONFIG dst; |
michael@0 | 225 | |
michael@0 | 226 | MODE_INFO *mode_info_context; |
michael@0 | 227 | int mode_info_stride; |
michael@0 | 228 | |
michael@0 | 229 | FRAME_TYPE frame_type; |
michael@0 | 230 | |
michael@0 | 231 | int up_available; |
michael@0 | 232 | int left_available; |
michael@0 | 233 | |
michael@0 | 234 | unsigned char *recon_above[3]; |
michael@0 | 235 | unsigned char *recon_left[3]; |
michael@0 | 236 | int recon_left_stride[2]; |
michael@0 | 237 | |
michael@0 | 238 | /* Y,U,V,Y2 */ |
michael@0 | 239 | ENTROPY_CONTEXT_PLANES *above_context; |
michael@0 | 240 | ENTROPY_CONTEXT_PLANES *left_context; |
michael@0 | 241 | |
michael@0 | 242 | /* 0 indicates segmentation at MB level is not enabled. Otherwise the individual bits indicate which features are active. */ |
michael@0 | 243 | unsigned char segmentation_enabled; |
michael@0 | 244 | |
michael@0 | 245 | /* 0 (do not update) 1 (update) the macroblock segmentation map. */ |
michael@0 | 246 | unsigned char update_mb_segmentation_map; |
michael@0 | 247 | |
michael@0 | 248 | /* 0 (do not update) 1 (update) the macroblock segmentation feature data. */ |
michael@0 | 249 | unsigned char update_mb_segmentation_data; |
michael@0 | 250 | |
michael@0 | 251 | /* 0 (do not update) 1 (update) the macroblock segmentation feature data. */ |
michael@0 | 252 | unsigned char mb_segement_abs_delta; |
michael@0 | 253 | |
michael@0 | 254 | /* Per frame flags that define which MB level features (such as quantizer or loop filter level) */ |
michael@0 | 255 | /* are enabled and when enabled the proabilities used to decode the per MB flags in MB_MODE_INFO */ |
michael@0 | 256 | vp8_prob mb_segment_tree_probs[MB_FEATURE_TREE_PROBS]; /* Probability Tree used to code Segment number */ |
michael@0 | 257 | |
michael@0 | 258 | signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS]; /* Segment parameters */ |
michael@0 | 259 | |
michael@0 | 260 | /* mode_based Loop filter adjustment */ |
michael@0 | 261 | unsigned char mode_ref_lf_delta_enabled; |
michael@0 | 262 | unsigned char mode_ref_lf_delta_update; |
michael@0 | 263 | |
michael@0 | 264 | /* Delta values have the range +/- MAX_LOOP_FILTER */ |
michael@0 | 265 | signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS]; /* 0 = Intra, Last, GF, ARF */ |
michael@0 | 266 | signed char ref_lf_deltas[MAX_REF_LF_DELTAS]; /* 0 = Intra, Last, GF, ARF */ |
michael@0 | 267 | signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS]; /* 0 = BPRED, ZERO_MV, MV, SPLIT */ |
michael@0 | 268 | signed char mode_lf_deltas[MAX_MODE_LF_DELTAS]; /* 0 = BPRED, ZERO_MV, MV, SPLIT */ |
michael@0 | 269 | |
michael@0 | 270 | /* Distance of MB away from frame edges */ |
michael@0 | 271 | int mb_to_left_edge; |
michael@0 | 272 | int mb_to_right_edge; |
michael@0 | 273 | int mb_to_top_edge; |
michael@0 | 274 | int mb_to_bottom_edge; |
michael@0 | 275 | |
michael@0 | 276 | |
michael@0 | 277 | |
michael@0 | 278 | vp8_subpix_fn_t subpixel_predict; |
michael@0 | 279 | vp8_subpix_fn_t subpixel_predict8x4; |
michael@0 | 280 | vp8_subpix_fn_t subpixel_predict8x8; |
michael@0 | 281 | vp8_subpix_fn_t subpixel_predict16x16; |
michael@0 | 282 | |
michael@0 | 283 | void *current_bc; |
michael@0 | 284 | |
michael@0 | 285 | int corrupted; |
michael@0 | 286 | |
michael@0 | 287 | #if ARCH_X86 || ARCH_X86_64 |
michael@0 | 288 | /* This is an intermediate buffer currently used in sub-pixel motion search |
michael@0 | 289 | * to keep a copy of the reference area. This buffer can be used for other |
michael@0 | 290 | * purpose. |
michael@0 | 291 | */ |
michael@0 | 292 | DECLARE_ALIGNED(32, unsigned char, y_buf[22*32]); |
michael@0 | 293 | #endif |
michael@0 | 294 | } MACROBLOCKD; |
michael@0 | 295 | |
michael@0 | 296 | |
michael@0 | 297 | extern void vp8_build_block_doffsets(MACROBLOCKD *x); |
michael@0 | 298 | extern void vp8_setup_block_dptrs(MACROBLOCKD *x); |
michael@0 | 299 | |
michael@0 | 300 | #endif /* __INC_BLOCKD_H */ |