Merge "makefile: fix error message due to missing quotes"
[libvpx.git] / vp8 / common / blockd.h
blob84ed53ad25f063b863646279f03611b49bd8a0f7
1 /*
2 * Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license and patent
5 * grant that can be found in the LICENSE file in the root of the source
6 * tree. All contributing project authors may be found in the AUTHORS
7 * file in the root of the source tree.
8 */
11 #ifndef __INC_BLOCKD_H
12 #define __INC_BLOCKD_H
14 void vpx_log(const char *format, ...);
16 #include "vpx_ports/config.h"
17 #include "vpx_scale/yv12config.h"
18 #include "mv.h"
19 #include "treecoder.h"
20 #include "subpixel.h"
21 #include "vpx_ports/mem.h"
23 #define TRUE 1
24 #define FALSE 0
26 //#define DCPRED 1
27 #define DCPREDSIMTHRESH 0
28 #define DCPREDCNTTHRESH 3
30 #define Y1CONTEXT 0
31 #define UCONTEXT 1
32 #define VCONTEXT 2
33 #define Y2CONTEXT 3
35 #define MB_FEATURE_TREE_PROBS 3
36 #define MAX_MB_SEGMENTS 4
38 #define MAX_REF_LF_DELTAS 4
39 #define MAX_MODE_LF_DELTAS 4
41 // Segment Feature Masks
42 #define SEGMENT_DELTADATA 0
43 #define SEGMENT_ABSDATA 1
45 typedef struct
47 int r, c;
48 } POS;
51 typedef int ENTROPY_CONTEXT;
53 typedef struct
55 ENTROPY_CONTEXT l[4];
56 ENTROPY_CONTEXT a[4];
57 } TEMP_CONTEXT;
59 extern void vp8_setup_temp_context(TEMP_CONTEXT *t, ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, int count);
60 extern const int vp8_block2left[25];
61 extern const int vp8_block2above[25];
62 extern const int vp8_block2type[25];
63 extern const int vp8_block2context[25];
65 #define VP8_COMBINEENTROPYCONTEXTS( Dest, A, B) \
66 Dest = ((A)!=0) + ((B)!=0);
69 typedef enum
71 KEY_FRAME = 0,
72 INTER_FRAME = 1
73 } FRAME_TYPE;
75 typedef enum
77 DC_PRED, // average of above and left pixels
78 V_PRED, // vertical prediction
79 H_PRED, // horizontal prediction
80 TM_PRED, // Truemotion prediction
81 B_PRED, // block based prediction, each block has its own prediction mode
83 NEARESTMV,
84 NEARMV,
85 ZEROMV,
86 NEWMV,
87 SPLITMV,
89 MB_MODE_COUNT
90 } MB_PREDICTION_MODE;
92 // Macroblock level features
93 typedef enum
95 MB_LVL_ALT_Q = 0, // Use alternate Quantizer ....
96 MB_LVL_ALT_LF = 1, // Use alternate loop filter value...
97 MB_LVL_MAX = 2, // Number of MB level features supported
99 } MB_LVL_FEATURES;
101 // Segment Feature Masks
102 #define SEGMENT_ALTQ 0x01
103 #define SEGMENT_ALT_LF 0x02
105 #define VP8_YMODES (B_PRED + 1)
106 #define VP8_UV_MODES (TM_PRED + 1)
108 #define VP8_MVREFS (1 + SPLITMV - NEARESTMV)
110 typedef enum
112 B_DC_PRED, // average of above and left pixels
113 B_TM_PRED,
115 B_VE_PRED, // vertical prediction
116 B_HE_PRED, // horizontal prediction
118 B_LD_PRED,
119 B_RD_PRED,
121 B_VR_PRED,
122 B_VL_PRED,
123 B_HD_PRED,
124 B_HU_PRED,
126 LEFT4X4,
127 ABOVE4X4,
128 ZERO4X4,
129 NEW4X4,
131 B_MODE_COUNT
132 } B_PREDICTION_MODE;
134 #define VP8_BINTRAMODES (B_HU_PRED + 1) /* 10 */
135 #define VP8_SUBMVREFS (1 + NEW4X4 - LEFT4X4)
137 /* For keyframes, intra block modes are predicted by the (already decoded)
138 modes for the Y blocks to the left and above us; for interframes, there
139 is a single probability table. */
141 typedef struct
143 B_PREDICTION_MODE mode;
144 union
146 int as_int;
147 MV as_mv;
148 } mv;
149 } B_MODE_INFO;
152 typedef enum
154 INTRA_FRAME = 0,
155 LAST_FRAME = 1,
156 GOLDEN_FRAME = 2,
157 ALTREF_FRAME = 3,
158 MAX_REF_FRAMES = 4
159 } MV_REFERENCE_FRAME;
161 typedef struct
163 MB_PREDICTION_MODE mode, uv_mode;
164 MV_REFERENCE_FRAME ref_frame;
165 union
167 int as_int;
168 MV as_mv;
169 } mv;
170 int partitioning;
171 int partition_count;
172 int mb_skip_coeff; //does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens
173 int dc_diff;
174 unsigned char segment_id; // Which set of segmentation parameters should be used for this MB
175 int force_no_skip;
177 B_MODE_INFO partition_bmi[16];
179 } MB_MODE_INFO;
182 typedef struct
184 MB_MODE_INFO mbmi;
185 B_MODE_INFO bmi[16];
186 } MODE_INFO;
189 typedef struct
191 short *qcoeff;
192 short *dqcoeff;
193 unsigned char *predictor;
194 short *diff;
195 short *reference;
197 short(*dequant)[4];
199 // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
200 unsigned char **base_pre;
201 int pre;
202 int pre_stride;
204 unsigned char **base_dst;
205 int dst;
206 int dst_stride;
208 int eob;
210 B_MODE_INFO bmi;
212 } BLOCKD;
214 typedef struct
216 DECLARE_ALIGNED(16, short, diff[400]); // from idct diff
217 DECLARE_ALIGNED(16, unsigned char, predictor[384]);
218 DECLARE_ALIGNED(16, short, reference[384]);
219 DECLARE_ALIGNED(16, short, qcoeff[400]);
220 DECLARE_ALIGNED(16, short, dqcoeff[400]);
222 // 16 Y blocks, 4 U, 4 V, 1 DC 2nd order block, each with 16 entries.
223 BLOCKD block[25];
225 YV12_BUFFER_CONFIG pre; // Filtered copy of previous frame reconstruction
226 YV12_BUFFER_CONFIG dst;
228 MODE_INFO *mode_info_context;
229 MODE_INFO *mode_info;
231 int mode_info_stride;
233 FRAME_TYPE frame_type;
235 MB_MODE_INFO mbmi;
237 int up_available;
238 int left_available;
240 // Y,U,V,Y2
241 ENTROPY_CONTEXT *above_context[4]; // row of context for each plane
242 ENTROPY_CONTEXT(*left_context)[4]; // (up to) 4 contexts ""
244 // 0 indicates segmentation at MB level is not enabled. Otherwise the individual bits indicate which features are active.
245 unsigned char segmentation_enabled;
247 // 0 (do not update) 1 (update) the macroblock segmentation map.
248 unsigned char update_mb_segmentation_map;
250 // 0 (do not update) 1 (update) the macroblock segmentation feature data.
251 unsigned char update_mb_segmentation_data;
253 // 0 (do not update) 1 (update) the macroblock segmentation feature data.
254 unsigned char mb_segement_abs_delta;
256 // Per frame flags that define which MB level features (such as quantizer or loop filter level)
257 // are enabled and when enabled the proabilities used to decode the per MB flags in MB_MODE_INFO
258 vp8_prob mb_segment_tree_probs[MB_FEATURE_TREE_PROBS]; // Probability Tree used to code Segment number
260 signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS]; // Segment parameters
262 // mode_based Loop filter adjustment
263 unsigned char mode_ref_lf_delta_enabled;
264 unsigned char mode_ref_lf_delta_update;
266 // Delta values have the range +/- MAX_LOOP_FILTER
267 //char ref_lf_deltas[MAX_REF_LF_DELTAS]; // 0 = Intra, Last, GF, ARF
268 //char mode_lf_deltas[MAX_MODE_LF_DELTAS]; // 0 = BPRED, ZERO_MV, MV, SPLIT
269 signed char ref_lf_deltas[MAX_REF_LF_DELTAS]; // 0 = Intra, Last, GF, ARF
270 signed char mode_lf_deltas[MAX_MODE_LF_DELTAS]; // 0 = BPRED, ZERO_MV, MV, SPLIT
272 // Distance of MB away from frame edges
273 int mb_to_left_edge;
274 int mb_to_right_edge;
275 int mb_to_top_edge;
276 int mb_to_bottom_edge;
278 //char * gf_active_ptr;
279 signed char *gf_active_ptr;
281 unsigned int frames_since_golden;
282 unsigned int frames_till_alt_ref_frame;
283 vp8_subpix_fn_t subpixel_predict;
284 vp8_subpix_fn_t subpixel_predict8x4;
285 vp8_subpix_fn_t subpixel_predict8x8;
286 vp8_subpix_fn_t subpixel_predict16x16;
288 void *current_bc;
290 #if CONFIG_RUNTIME_CPU_DETECT
291 struct VP8_COMMON_RTCD *rtcd;
292 #endif
293 } MACROBLOCKD;
296 extern void vp8_build_block_doffsets(MACROBLOCKD *x);
297 extern void vp8_setup_block_dptrs(MACROBLOCKD *x);
299 #endif /* __INC_BLOCKD_H */