Mercurial > libavcodec.hg
comparison vp56.h @ 8299:524cb7f5ad2b libavcodec
avoid POSIX reserved _t suffix
author | aurel |
---|---|
date | Thu, 11 Dec 2008 22:56:19 +0000 |
parents | c4a4495715dd |
children | c47323828269 |
comparison
equal
deleted
inserted
replaced
8298:2dcc437528fa | 8299:524cb7f5ad2b |
---|---|
28 #include "dsputil.h" | 28 #include "dsputil.h" |
29 #include "bitstream.h" | 29 #include "bitstream.h" |
30 #include "bytestream.h" | 30 #include "bytestream.h" |
31 | 31 |
32 | 32 |
33 typedef struct vp56_context vp56_context_t; | 33 typedef struct vp56_context VP56Context; |
34 typedef struct vp56_mv vp56_mv_t; | 34 typedef struct vp56_mv VP56mv; |
35 | 35 |
36 typedef void (*vp56_parse_vector_adjustment_t)(vp56_context_t *s, | 36 typedef void (*VP56ParseVectorAdjustment)(VP56Context *s, |
37 vp56_mv_t *vect); | 37 VP56mv *vect); |
38 typedef int (*vp56_adjust_t)(int v, int t); | 38 typedef int (*VP56Adjust)(int v, int t); |
39 typedef void (*vp56_filter_t)(vp56_context_t *s, uint8_t *dst, uint8_t *src, | 39 typedef void (*VP56Filter)(VP56Context *s, uint8_t *dst, uint8_t *src, |
40 int offset1, int offset2, int stride, | 40 int offset1, int offset2, int stride, |
41 vp56_mv_t mv, int mask, int select, int luma); | 41 VP56mv mv, int mask, int select, int luma); |
42 typedef void (*vp56_parse_coeff_t)(vp56_context_t *s); | 42 typedef void (*VP56ParseCoeff)(VP56Context *s); |
43 typedef void (*vp56_default_models_init_t)(vp56_context_t *s); | 43 typedef void (*VP56DefaultModelsInit)(VP56Context *s); |
44 typedef void (*vp56_parse_vector_models_t)(vp56_context_t *s); | 44 typedef void (*VP56ParseVectorModels)(VP56Context *s); |
45 typedef void (*vp56_parse_coeff_models_t)(vp56_context_t *s); | 45 typedef void (*VP56ParseCoeffModels)(VP56Context *s); |
46 typedef int (*vp56_parse_header_t)(vp56_context_t *s, const uint8_t *buf, | 46 typedef int (*VP56ParseHeader)(VP56Context *s, const uint8_t *buf, |
47 int buf_size, int *golden_frame); | 47 int buf_size, int *golden_frame); |
48 | 48 |
49 typedef struct { | 49 typedef struct { |
50 int high; | 50 int high; |
51 int bits; | 51 int bits; |
52 const uint8_t *buffer; | 52 const uint8_t *buffer; |
53 unsigned long code_word; | 53 unsigned long code_word; |
54 } vp56_range_coder_t; | 54 } VP56RangeCoder; |
55 | 55 |
56 typedef struct { | 56 typedef struct { |
57 uint8_t not_null_dc; | 57 uint8_t not_null_dc; |
58 vp56_frame_t ref_frame; | 58 VP56Frame ref_frame; |
59 DCTELEM dc_coeff; | 59 DCTELEM dc_coeff; |
60 } vp56_ref_dc_t; | 60 } VP56RefDc; |
61 | 61 |
62 struct vp56_mv { | 62 struct vp56_mv { |
63 int x; | 63 int x; |
64 int y; | 64 int y; |
65 }; | 65 }; |
66 | 66 |
67 typedef struct { | 67 typedef struct { |
68 uint8_t type; | 68 uint8_t type; |
69 vp56_mv_t mv; | 69 VP56mv mv; |
70 } vp56_macroblock_t; | 70 } VP56Macroblock; |
71 | 71 |
72 typedef struct { | 72 typedef struct { |
73 uint8_t coeff_reorder[64]; /* used in vp6 only */ | 73 uint8_t coeff_reorder[64]; /* used in vp6 only */ |
74 uint8_t coeff_index_to_pos[64]; /* used in vp6 only */ | 74 uint8_t coeff_index_to_pos[64]; /* used in vp6 only */ |
75 uint8_t vector_sig[2]; /* delta sign */ | 75 uint8_t vector_sig[2]; /* delta sign */ |
82 uint8_t coeff_acct[2][3][3][6][5];/* vp5 only AC coding type for coding group < 3 */ | 82 uint8_t coeff_acct[2][3][3][6][5];/* vp5 only AC coding type for coding group < 3 */ |
83 uint8_t coeff_dcct[2][36][5]; /* DC coeff coding type */ | 83 uint8_t coeff_dcct[2][36][5]; /* DC coeff coding type */ |
84 uint8_t coeff_runv[2][14]; /* run value (vp6 only) */ | 84 uint8_t coeff_runv[2][14]; /* run value (vp6 only) */ |
85 uint8_t mb_type[3][10][10]; /* model for decoding MB type */ | 85 uint8_t mb_type[3][10][10]; /* model for decoding MB type */ |
86 uint8_t mb_types_stats[3][10][2];/* contextual, next MB type stats */ | 86 uint8_t mb_types_stats[3][10][2];/* contextual, next MB type stats */ |
87 } vp56_model_t; | 87 } Vp56Model; |
88 | 88 |
89 struct vp56_context { | 89 struct vp56_context { |
90 AVCodecContext *avctx; | 90 AVCodecContext *avctx; |
91 DSPContext dsp; | 91 DSPContext dsp; |
92 ScanTable scantable; | 92 ScanTable scantable; |
93 AVFrame frames[4]; | 93 AVFrame frames[4]; |
94 AVFrame *framep[6]; | 94 AVFrame *framep[6]; |
95 uint8_t *edge_emu_buffer_alloc; | 95 uint8_t *edge_emu_buffer_alloc; |
96 uint8_t *edge_emu_buffer; | 96 uint8_t *edge_emu_buffer; |
97 vp56_range_coder_t c; | 97 VP56RangeCoder c; |
98 vp56_range_coder_t cc; | 98 VP56RangeCoder cc; |
99 vp56_range_coder_t *ccp; | 99 VP56RangeCoder *ccp; |
100 int sub_version; | 100 int sub_version; |
101 | 101 |
102 /* frame info */ | 102 /* frame info */ |
103 int plane_width[4]; | 103 int plane_width[4]; |
104 int plane_height[4]; | 104 int plane_height[4]; |
109 int quantizer; | 109 int quantizer; |
110 uint16_t dequant_dc; | 110 uint16_t dequant_dc; |
111 uint16_t dequant_ac; | 111 uint16_t dequant_ac; |
112 | 112 |
113 /* DC predictors management */ | 113 /* DC predictors management */ |
114 vp56_ref_dc_t *above_blocks; | 114 VP56RefDc *above_blocks; |
115 vp56_ref_dc_t left_block[4]; | 115 VP56RefDc left_block[4]; |
116 int above_block_idx[6]; | 116 int above_block_idx[6]; |
117 DCTELEM prev_dc[3][3]; /* [plan][ref_frame] */ | 117 DCTELEM prev_dc[3][3]; /* [plan][ref_frame] */ |
118 | 118 |
119 /* blocks / macroblock */ | 119 /* blocks / macroblock */ |
120 vp56_mb_t mb_type; | 120 VP56mb mb_type; |
121 vp56_macroblock_t *macroblocks; | 121 VP56Macroblock *macroblocks; |
122 DECLARE_ALIGNED_16(DCTELEM, block_coeff[6][64]); | 122 DECLARE_ALIGNED_16(DCTELEM, block_coeff[6][64]); |
123 | 123 |
124 /* motion vectors */ | 124 /* motion vectors */ |
125 vp56_mv_t mv[6]; /* vectors for each block in MB */ | 125 VP56mv mv[6]; /* vectors for each block in MB */ |
126 vp56_mv_t vector_candidate[2]; | 126 VP56mv vector_candidate[2]; |
127 int vector_candidate_pos; | 127 int vector_candidate_pos; |
128 | 128 |
129 /* filtering hints */ | 129 /* filtering hints */ |
130 int filter_header; /* used in vp6 only */ | 130 int filter_header; /* used in vp6 only */ |
131 int deblock_filtering; | 131 int deblock_filtering; |
144 int frbi; /* first row block index in MB */ | 144 int frbi; /* first row block index in MB */ |
145 int srbi; /* second row block index in MB */ | 145 int srbi; /* second row block index in MB */ |
146 int stride[4]; /* stride for each plan */ | 146 int stride[4]; /* stride for each plan */ |
147 | 147 |
148 const uint8_t *vp56_coord_div; | 148 const uint8_t *vp56_coord_div; |
149 vp56_parse_vector_adjustment_t parse_vector_adjustment; | 149 VP56ParseVectorAdjustment parse_vector_adjustment; |
150 vp56_adjust_t adjust; | 150 VP56Adjust adjust; |
151 vp56_filter_t filter; | 151 VP56Filter filter; |
152 vp56_parse_coeff_t parse_coeff; | 152 VP56ParseCoeff parse_coeff; |
153 vp56_default_models_init_t default_models_init; | 153 VP56DefaultModelsInit default_models_init; |
154 vp56_parse_vector_models_t parse_vector_models; | 154 VP56ParseVectorModels parse_vector_models; |
155 vp56_parse_coeff_models_t parse_coeff_models; | 155 VP56ParseCoeffModels parse_coeff_models; |
156 vp56_parse_header_t parse_header; | 156 VP56ParseHeader parse_header; |
157 | 157 |
158 vp56_model_t *modelp; | 158 Vp56Model *modelp; |
159 vp56_model_t models[2]; | 159 Vp56Model models[2]; |
160 | 160 |
161 /* huffman decoding */ | 161 /* huffman decoding */ |
162 int use_huffman; | 162 int use_huffman; |
163 GetBitContext gb; | 163 GetBitContext gb; |
164 VLC dccv_vlc[2]; | 164 VLC dccv_vlc[2]; |
168 }; | 168 }; |
169 | 169 |
170 | 170 |
171 void vp56_init(AVCodecContext *avctx, int flip, int has_alpha); | 171 void vp56_init(AVCodecContext *avctx, int flip, int has_alpha); |
172 int vp56_free(AVCodecContext *avctx); | 172 int vp56_free(AVCodecContext *avctx); |
173 void vp56_init_dequant(vp56_context_t *s, int quantizer); | 173 void vp56_init_dequant(VP56Context *s, int quantizer); |
174 int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, | 174 int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
175 const uint8_t *buf, int buf_size); | 175 const uint8_t *buf, int buf_size); |
176 | 176 |
177 | 177 |
178 /** | 178 /** |
179 * vp56 specific range coder implementation | 179 * vp56 specific range coder implementation |
180 */ | 180 */ |
181 | 181 |
182 static inline void vp56_init_range_decoder(vp56_range_coder_t *c, | 182 static inline void vp56_init_range_decoder(VP56RangeCoder *c, |
183 const uint8_t *buf, int buf_size) | 183 const uint8_t *buf, int buf_size) |
184 { | 184 { |
185 c->high = 255; | 185 c->high = 255; |
186 c->bits = 8; | 186 c->bits = 8; |
187 c->buffer = buf; | 187 c->buffer = buf; |
188 c->code_word = bytestream_get_be16(&c->buffer); | 188 c->code_word = bytestream_get_be16(&c->buffer); |
189 } | 189 } |
190 | 190 |
191 static inline int vp56_rac_get_prob(vp56_range_coder_t *c, uint8_t prob) | 191 static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) |
192 { | 192 { |
193 unsigned int low = 1 + (((c->high - 1) * prob) / 256); | 193 unsigned int low = 1 + (((c->high - 1) * prob) / 256); |
194 unsigned int low_shift = low << 8; | 194 unsigned int low_shift = low << 8; |
195 int bit = c->code_word >= low_shift; | 195 int bit = c->code_word >= low_shift; |
196 | 196 |
211 } | 211 } |
212 } | 212 } |
213 return bit; | 213 return bit; |
214 } | 214 } |
215 | 215 |
216 static inline int vp56_rac_get(vp56_range_coder_t *c) | 216 static inline int vp56_rac_get(VP56RangeCoder *c) |
217 { | 217 { |
218 /* equiprobable */ | 218 /* equiprobable */ |
219 int low = (c->high + 1) >> 1; | 219 int low = (c->high + 1) >> 1; |
220 unsigned int low_shift = low << 8; | 220 unsigned int low_shift = low << 8; |
221 int bit = c->code_word >= low_shift; | 221 int bit = c->code_word >= low_shift; |
233 c->code_word |= *c->buffer++; | 233 c->code_word |= *c->buffer++; |
234 } | 234 } |
235 return bit; | 235 return bit; |
236 } | 236 } |
237 | 237 |
238 static inline int vp56_rac_gets(vp56_range_coder_t *c, int bits) | 238 static inline int vp56_rac_gets(VP56RangeCoder *c, int bits) |
239 { | 239 { |
240 int value = 0; | 240 int value = 0; |
241 | 241 |
242 while (bits--) { | 242 while (bits--) { |
243 value = (value << 1) | vp56_rac_get(c); | 243 value = (value << 1) | vp56_rac_get(c); |
244 } | 244 } |
245 | 245 |
246 return value; | 246 return value; |
247 } | 247 } |
248 | 248 |
249 static inline int vp56_rac_gets_nn(vp56_range_coder_t *c, int bits) | 249 static inline int vp56_rac_gets_nn(VP56RangeCoder *c, int bits) |
250 { | 250 { |
251 int v = vp56_rac_gets(c, 7) << 1; | 251 int v = vp56_rac_gets(c, 7) << 1; |
252 return v + !v; | 252 return v + !v; |
253 } | 253 } |
254 | 254 |
255 static inline int vp56_rac_get_tree(vp56_range_coder_t *c, | 255 static inline int vp56_rac_get_tree(VP56RangeCoder *c, |
256 const vp56_tree_t *tree, | 256 const VP56Tree *tree, |
257 const uint8_t *probs) | 257 const uint8_t *probs) |
258 { | 258 { |
259 while (tree->val > 0) { | 259 while (tree->val > 0) { |
260 if (vp56_rac_get_prob(c, probs[tree->prob_idx])) | 260 if (vp56_rac_get_prob(c, probs[tree->prob_idx])) |
261 tree += tree->val; | 261 tree += tree->val; |