Mercurial > libavcodec.hg
annotate vp6.c @ 5739:832a3152d38e libavcodec
unroll finite differences to avoid swapping registers.
1.5x faster encode_residual_fixed().
overall flac encoding: 3% faster at compression_levels 0-2.
author | lorenm |
---|---|
date | Sat, 29 Sep 2007 23:44:34 +0000 |
parents | 314be1cfdcb0 |
children | 51918cb97f6f |
rev | line source |
---|---|
3695 | 1 /** |
2 * @file vp6.c | |
3 * VP6 compatible video decoder | |
4 * | |
5 * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> | |
6 * | |
5214 | 7 * The VP6F decoder accepts an optional 1 byte extradata. It is composed of: |
8 * - upper 4bits: difference between encoded width and visible width | |
9 * - lower 4bits: difference between encoded height and visible height | |
10 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3697
diff
changeset
|
11 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3697
diff
changeset
|
12 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3697
diff
changeset
|
13 * FFmpeg is free software; you can redistribute it and/or |
3695 | 14 * modify it under the terms of the GNU Lesser General Public |
15 * License as published by the Free Software Foundation; either | |
16 * version 2.1 of the License, or (at your option) any later version. | |
17 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3697
diff
changeset
|
18 * FFmpeg is distributed in the hope that it will be useful, |
3695 | 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 * Lesser General Public License for more details. | |
22 * | |
23 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3697
diff
changeset
|
24 * License along with FFmpeg; if not, write to the Free Software |
5214 | 25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
3695 | 26 */ |
27 | |
28 #include <stdlib.h> | |
29 | |
30 #include "avcodec.h" | |
31 #include "dsputil.h" | |
32 #include "bitstream.h" | |
33 #include "mpegvideo.h" | |
34 | |
35 #include "vp56.h" | |
36 #include "vp56data.h" | |
37 #include "vp6data.h" | |
38 | |
39 | |
40 static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size, | |
41 int *golden_frame) | |
42 { | |
43 vp56_range_coder_t *c = &s->c; | |
4308 | 44 int parse_filter_info = 0; |
4348 | 45 int coeff_offset = 0; |
4308 | 46 int vrt_shift = 0; |
47 int sub_version; | |
3695 | 48 int rows, cols; |
49 int res = 1; | |
4348 | 50 int separated_coeff = buf[0] & 1; |
3695 | 51 |
4595 | 52 s->framep[VP56_FRAME_CURRENT]->key_frame = !(buf[0] & 0x80); |
3695 | 53 vp56_init_dequant(s, (buf[0] >> 1) & 0x3F); |
54 | |
4595 | 55 if (s->framep[VP56_FRAME_CURRENT]->key_frame) { |
4308 | 56 sub_version = buf[1] >> 3; |
57 if (sub_version > 8) | |
58 return 0; | |
4348 | 59 s->filter_header = buf[1] & 0x06; |
3695 | 60 if (buf[1] & 1) { |
61 av_log(s->avctx, AV_LOG_ERROR, "interlacing not supported\n"); | |
62 return 0; | |
63 } | |
4348 | 64 if (separated_coeff || !s->filter_header) { |
4364 | 65 coeff_offset = AV_RB16(buf+2) - 2; |
4348 | 66 buf += 2; |
67 buf_size -= 2; | |
68 } | |
3695 | 69 |
70 rows = buf[2]; /* number of stored macroblock rows */ | |
71 cols = buf[3]; /* number of stored macroblock cols */ | |
72 /* buf[4] is number of displayed macroblock rows */ | |
73 /* buf[5] is number of displayed macroblock cols */ | |
74 | |
75 if (16*cols != s->avctx->coded_width || | |
76 16*rows != s->avctx->coded_height) { | |
77 avcodec_set_dimensions(s->avctx, 16*cols, 16*rows); | |
4062
683d458a251f
use the adjustment value present in FLV to crop VP6 video
aurel
parents:
4001
diff
changeset
|
78 if (s->avctx->extradata_size == 1) { |
683d458a251f
use the adjustment value present in FLV to crop VP6 video
aurel
parents:
4001
diff
changeset
|
79 s->avctx->width -= s->avctx->extradata[0] >> 4; |
683d458a251f
use the adjustment value present in FLV to crop VP6 video
aurel
parents:
4001
diff
changeset
|
80 s->avctx->height -= s->avctx->extradata[0] & 0x0F; |
683d458a251f
use the adjustment value present in FLV to crop VP6 video
aurel
parents:
4001
diff
changeset
|
81 } |
3695 | 82 res = 2; |
83 } | |
84 | |
85 vp56_init_range_decoder(c, buf+6, buf_size-6); | |
86 vp56_rac_gets(c, 2); | |
87 | |
4348 | 88 parse_filter_info = s->filter_header; |
4308 | 89 if (sub_version < 8) |
90 vrt_shift = 5; | |
91 s->sub_version = sub_version; | |
3695 | 92 } else { |
4308 | 93 if (!s->sub_version) |
94 return 0; | |
95 | |
4348 | 96 if (separated_coeff || !s->filter_header) { |
4364 | 97 coeff_offset = AV_RB16(buf+1) - 2; |
4348 | 98 buf += 2; |
99 buf_size -= 2; | |
100 } | |
3695 | 101 vp56_init_range_decoder(c, buf+1, buf_size-1); |
102 | |
103 *golden_frame = vp56_rac_get(c); | |
4348 | 104 if (s->filter_header) { |
4349 | 105 s->deblock_filtering = vp56_rac_get(c); |
106 if (s->deblock_filtering) | |
107 vp56_rac_get(c); | |
108 if (s->sub_version > 7) | |
109 parse_filter_info = vp56_rac_get(c); | |
4348 | 110 } |
3695 | 111 } |
112 | |
113 if (parse_filter_info) { | |
114 if (vp56_rac_get(c)) { | |
115 s->filter_mode = 2; | |
4308 | 116 s->sample_variance_threshold = vp56_rac_gets(c, 5) << vrt_shift; |
3695 | 117 s->max_vector_length = 2 << vp56_rac_gets(c, 3); |
118 } else if (vp56_rac_get(c)) { | |
119 s->filter_mode = 1; | |
120 } else { | |
121 s->filter_mode = 0; | |
122 } | |
4308 | 123 if (s->sub_version > 7) |
124 s->filter_selection = vp56_rac_gets(c, 4); | |
125 else | |
126 s->filter_selection = 16; | |
3695 | 127 } |
128 | |
5626
09fb7275a6bf
add a warning message for unsupported kind of encoding
aurel
parents:
5214
diff
changeset
|
129 if (vp56_rac_get(c)) |
09fb7275a6bf
add a warning message for unsupported kind of encoding
aurel
parents:
5214
diff
changeset
|
130 av_log(s->avctx, AV_LOG_WARNING, |
09fb7275a6bf
add a warning message for unsupported kind of encoding
aurel
parents:
5214
diff
changeset
|
131 "alternative entropy decoding not supported\n"); |
4348 | 132 |
133 if (coeff_offset) { | |
134 vp56_init_range_decoder(&s->cc, buf+coeff_offset, | |
135 buf_size-coeff_offset); | |
136 s->ccp = &s->cc; | |
137 } else { | |
138 s->ccp = &s->c; | |
139 } | |
140 | |
3695 | 141 return res; |
142 } | |
143 | |
144 static void vp6_coeff_order_table_init(vp56_context_t *s) | |
145 { | |
146 int i, pos, idx = 1; | |
147 | |
5711 | 148 s->modelp->coeff_index_to_pos[0] = 0; |
3695 | 149 for (i=0; i<16; i++) |
150 for (pos=1; pos<64; pos++) | |
5711 | 151 if (s->modelp->coeff_reorder[pos] == i) |
152 s->modelp->coeff_index_to_pos[idx++] = pos; | |
3695 | 153 } |
154 | |
155 static void vp6_default_models_init(vp56_context_t *s) | |
156 { | |
5711 | 157 vp56_model_t *model = s->modelp; |
3695 | 158 |
5711 | 159 model->vector_dct[0] = 0xA2; |
160 model->vector_dct[1] = 0xA4; | |
161 model->vector_sig[0] = 0x80; | |
162 model->vector_sig[1] = 0x80; | |
163 | |
164 memcpy(model->mb_types_stats, vp56_def_mb_types_stats, sizeof(model->mb_types_stats)); | |
165 memcpy(model->vector_fdv, vp6_def_fdv_vector_model, sizeof(model->vector_fdv)); | |
166 memcpy(model->vector_pdv, vp6_def_pdv_vector_model, sizeof(model->vector_pdv)); | |
167 memcpy(model->coeff_runv, vp6_def_runv_coeff_model, sizeof(model->coeff_runv)); | |
168 memcpy(model->coeff_reorder, vp6_def_coeff_reorder, sizeof(model->coeff_reorder)); | |
3695 | 169 |
170 vp6_coeff_order_table_init(s); | |
171 } | |
172 | |
173 static void vp6_parse_vector_models(vp56_context_t *s) | |
174 { | |
175 vp56_range_coder_t *c = &s->c; | |
5711 | 176 vp56_model_t *model = s->modelp; |
3695 | 177 int comp, node; |
178 | |
179 for (comp=0; comp<2; comp++) { | |
180 if (vp56_rac_get_prob(c, vp6_sig_dct_pct[comp][0])) | |
5711 | 181 model->vector_dct[comp] = vp56_rac_gets_nn(c, 7); |
3695 | 182 if (vp56_rac_get_prob(c, vp6_sig_dct_pct[comp][1])) |
5711 | 183 model->vector_sig[comp] = vp56_rac_gets_nn(c, 7); |
3695 | 184 } |
185 | |
186 for (comp=0; comp<2; comp++) | |
187 for (node=0; node<7; node++) | |
188 if (vp56_rac_get_prob(c, vp6_pdv_pct[comp][node])) | |
5711 | 189 model->vector_pdv[comp][node] = vp56_rac_gets_nn(c, 7); |
3695 | 190 |
191 for (comp=0; comp<2; comp++) | |
192 for (node=0; node<8; node++) | |
193 if (vp56_rac_get_prob(c, vp6_fdv_pct[comp][node])) | |
5711 | 194 model->vector_fdv[comp][node] = vp56_rac_gets_nn(c, 7); |
3695 | 195 } |
196 | |
197 static void vp6_parse_coeff_models(vp56_context_t *s) | |
198 { | |
199 vp56_range_coder_t *c = &s->c; | |
5711 | 200 vp56_model_t *model = s->modelp; |
3695 | 201 int def_prob[11]; |
202 int node, cg, ctx, pos; | |
203 int ct; /* code type */ | |
204 int pt; /* plane type (0 for Y, 1 for U or V) */ | |
205 | |
206 memset(def_prob, 0x80, sizeof(def_prob)); | |
207 | |
208 for (pt=0; pt<2; pt++) | |
209 for (node=0; node<11; node++) | |
210 if (vp56_rac_get_prob(c, vp6_dccv_pct[pt][node])) { | |
211 def_prob[node] = vp56_rac_gets_nn(c, 7); | |
5711 | 212 model->coeff_dccv[pt][node] = def_prob[node]; |
4595 | 213 } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) { |
5711 | 214 model->coeff_dccv[pt][node] = def_prob[node]; |
3695 | 215 } |
216 | |
217 if (vp56_rac_get(c)) { | |
218 for (pos=1; pos<64; pos++) | |
219 if (vp56_rac_get_prob(c, vp6_coeff_reorder_pct[pos])) | |
5711 | 220 model->coeff_reorder[pos] = vp56_rac_gets(c, 4); |
3695 | 221 vp6_coeff_order_table_init(s); |
222 } | |
223 | |
224 for (cg=0; cg<2; cg++) | |
225 for (node=0; node<14; node++) | |
226 if (vp56_rac_get_prob(c, vp6_runv_pct[cg][node])) | |
5711 | 227 model->coeff_runv[cg][node] = vp56_rac_gets_nn(c, 7); |
3695 | 228 |
229 for (ct=0; ct<3; ct++) | |
230 for (pt=0; pt<2; pt++) | |
231 for (cg=0; cg<6; cg++) | |
232 for (node=0; node<11; node++) | |
233 if (vp56_rac_get_prob(c, vp6_ract_pct[ct][pt][cg][node])) { | |
234 def_prob[node] = vp56_rac_gets_nn(c, 7); | |
5711 | 235 model->coeff_ract[pt][ct][cg][node] = def_prob[node]; |
4595 | 236 } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) { |
5711 | 237 model->coeff_ract[pt][ct][cg][node] = def_prob[node]; |
3695 | 238 } |
239 | |
5711 | 240 /* coeff_dcct is a linear combination of coeff_dccv */ |
3695 | 241 for (pt=0; pt<2; pt++) |
242 for (ctx=0; ctx<3; ctx++) | |
243 for (node=0; node<5; node++) | |
5711 | 244 model->coeff_dcct[pt][ctx][node] = av_clip(((model->coeff_dccv[pt][node] * vp6_dccv_lc[ctx][node][0] + 128) >> 8) + vp6_dccv_lc[ctx][node][1], 1, 255); |
3695 | 245 } |
246 | |
3697 | 247 static void vp6_parse_vector_adjustment(vp56_context_t *s, vp56_mv_t *vect) |
3695 | 248 { |
249 vp56_range_coder_t *c = &s->c; | |
5711 | 250 vp56_model_t *model = s->modelp; |
3695 | 251 int comp; |
252 | |
3697 | 253 *vect = (vp56_mv_t) {0,0}; |
3695 | 254 if (s->vector_candidate_pos < 2) |
3697 | 255 *vect = s->vector_candidate[0]; |
3695 | 256 |
257 for (comp=0; comp<2; comp++) { | |
258 int i, delta = 0; | |
259 | |
5711 | 260 if (vp56_rac_get_prob(c, model->vector_dct[comp])) { |
3695 | 261 static const uint8_t prob_order[] = {0, 1, 2, 7, 6, 5, 4}; |
262 for (i=0; i<sizeof(prob_order); i++) { | |
263 int j = prob_order[i]; | |
5711 | 264 delta |= vp56_rac_get_prob(c, model->vector_fdv[comp][j])<<j; |
3695 | 265 } |
266 if (delta & 0xF0) | |
5711 | 267 delta |= vp56_rac_get_prob(c, model->vector_fdv[comp][3])<<3; |
3695 | 268 else |
269 delta |= 8; | |
270 } else { | |
271 delta = vp56_rac_get_tree(c, vp56_pva_tree, | |
5711 | 272 model->vector_pdv[comp]); |
3695 | 273 } |
274 | |
5711 | 275 if (delta && vp56_rac_get_prob(c, model->vector_sig[comp])) |
3695 | 276 delta = -delta; |
277 | |
278 if (!comp) | |
3697 | 279 vect->x += delta; |
3695 | 280 else |
3697 | 281 vect->y += delta; |
3695 | 282 } |
283 } | |
284 | |
285 static void vp6_parse_coeff(vp56_context_t *s) | |
286 { | |
4348 | 287 vp56_range_coder_t *c = s->ccp; |
5711 | 288 vp56_model_t *model = s->modelp; |
3695 | 289 uint8_t *permute = s->scantable.permutated; |
5711 | 290 uint8_t *model1, *model2, *model3; |
3695 | 291 int coeff, sign, coeff_idx; |
292 int b, i, cg, idx, ctx; | |
293 int pt = 0; /* plane type (0 for Y, 1 for U or V) */ | |
294 | |
295 for (b=0; b<6; b++) { | |
296 int ct = 1; /* code type */ | |
297 int run = 1; | |
298 | |
299 if (b > 3) pt = 1; | |
300 | |
301 ctx = s->left_block[vp56_b6to4[b]].not_null_dc | |
302 + s->above_blocks[s->above_block_idx[b]].not_null_dc; | |
5711 | 303 model1 = model->coeff_dccv[pt]; |
304 model2 = model->coeff_dcct[pt][ctx]; | |
3695 | 305 |
306 for (coeff_idx=0; coeff_idx<64; ) { | |
307 if ((coeff_idx>1 && ct==0) || vp56_rac_get_prob(c, model2[0])) { | |
308 /* parse a coeff */ | |
309 if (vp56_rac_get_prob(c, model2[2])) { | |
310 if (vp56_rac_get_prob(c, model2[3])) { | |
5711 | 311 idx = vp56_rac_get_tree(c, vp56_pc_tree, model1); |
3695 | 312 coeff = vp56_coeff_bias[idx]; |
313 for (i=vp56_coeff_bit_length[idx]; i>=0; i--) | |
314 coeff += vp56_rac_get_prob(c, vp56_coeff_parse_table[idx][i]) << i; | |
315 } else { | |
316 if (vp56_rac_get_prob(c, model2[4])) | |
5711 | 317 coeff = 3 + vp56_rac_get_prob(c, model1[5]); |
3695 | 318 else |
319 coeff = 2; | |
320 } | |
321 ct = 2; | |
322 } else { | |
323 ct = 1; | |
324 coeff = 1; | |
325 } | |
326 sign = vp56_rac_get(c); | |
327 coeff = (coeff ^ -sign) + sign; | |
328 if (coeff_idx) | |
329 coeff *= s->dequant_ac; | |
5711 | 330 idx = model->coeff_index_to_pos[coeff_idx]; |
3695 | 331 s->block_coeff[b][permute[idx]] = coeff; |
332 run = 1; | |
333 } else { | |
334 /* parse a run */ | |
335 ct = 0; | |
4925 | 336 if (coeff_idx > 0) { |
3695 | 337 if (!vp56_rac_get_prob(c, model2[1])) |
338 break; | |
339 | |
5711 | 340 model3 = model->coeff_runv[coeff_idx >= 6]; |
3695 | 341 run = vp56_rac_get_tree(c, vp6_pcr_tree, model3); |
342 if (!run) | |
343 for (run=9, i=0; i<6; i++) | |
344 run += vp56_rac_get_prob(c, model3[i+8]) << i; | |
345 } | |
346 } | |
347 | |
348 cg = vp6_coeff_groups[coeff_idx+=run]; | |
5711 | 349 model1 = model2 = model->coeff_ract[pt][ct][cg]; |
3695 | 350 } |
4925 | 351 |
352 s->left_block[vp56_b6to4[b]].not_null_dc = | |
353 s->above_blocks[s->above_block_idx[b]].not_null_dc = !!s->block_coeff[b][0]; | |
3695 | 354 } |
355 } | |
356 | |
357 static int vp6_adjust(int v, int t) | |
358 { | |
359 int V = v, s = v >> 31; | |
360 V ^= s; | |
361 V -= s; | |
362 if (V-t-1 >= (unsigned)(t-1)) | |
363 return v; | |
364 V = 2*t - V; | |
365 V += s; | |
366 V ^= s; | |
367 return V; | |
368 } | |
369 | |
370 static int vp6_block_variance(uint8_t *src, int stride) | |
371 { | |
372 int sum = 0, square_sum = 0; | |
373 int y, x; | |
374 | |
375 for (y=0; y<8; y+=2) { | |
376 for (x=0; x<8; x+=2) { | |
377 sum += src[x]; | |
378 square_sum += src[x]*src[x]; | |
379 } | |
380 src += 2*stride; | |
381 } | |
4306 | 382 return (16*square_sum - sum*sum) >> 8; |
3695 | 383 } |
384 | |
385 static void vp6_filter_hv4(uint8_t *dst, uint8_t *src, int stride, | |
386 int delta, const int16_t *weights) | |
387 { | |
388 int x, y; | |
389 | |
390 for (y=0; y<8; y++) { | |
391 for (x=0; x<8; x++) { | |
4594 | 392 dst[x] = av_clip_uint8(( src[x-delta ] * weights[0] |
3695 | 393 + src[x ] * weights[1] |
394 + src[x+delta ] * weights[2] | |
395 + src[x+2*delta] * weights[3] + 64) >> 7); | |
396 } | |
397 src += stride; | |
398 dst += stride; | |
399 } | |
400 } | |
401 | |
402 static void vp6_filter_diag2(vp56_context_t *s, uint8_t *dst, uint8_t *src, | |
403 int stride, int h_weight, int v_weight) | |
404 { | |
405 uint8_t *tmp = s->edge_emu_buffer+16; | |
4921 | 406 s->dsp.put_h264_chroma_pixels_tab[0](tmp, src, stride, 9, h_weight, 0); |
407 s->dsp.put_h264_chroma_pixels_tab[0](dst, tmp, stride, 8, 0, v_weight); | |
3695 | 408 } |
409 | |
410 static void vp6_filter_diag4(uint8_t *dst, uint8_t *src, int stride, | |
411 const int16_t *h_weights,const int16_t *v_weights) | |
412 { | |
413 int x, y; | |
414 int tmp[8*11]; | |
415 int *t = tmp; | |
416 | |
417 src -= stride; | |
418 | |
419 for (y=0; y<11; y++) { | |
420 for (x=0; x<8; x++) { | |
4594 | 421 t[x] = av_clip_uint8(( src[x-1] * h_weights[0] |
3695 | 422 + src[x ] * h_weights[1] |
423 + src[x+1] * h_weights[2] | |
424 + src[x+2] * h_weights[3] + 64) >> 7); | |
425 } | |
426 src += stride; | |
427 t += 8; | |
428 } | |
429 | |
430 t = tmp + 8; | |
431 for (y=0; y<8; y++) { | |
432 for (x=0; x<8; x++) { | |
4594 | 433 dst[x] = av_clip_uint8(( t[x-8 ] * v_weights[0] |
3695 | 434 + t[x ] * v_weights[1] |
435 + t[x+8 ] * v_weights[2] | |
436 + t[x+16] * v_weights[3] + 64) >> 7); | |
437 } | |
438 dst += stride; | |
439 t += 8; | |
440 } | |
441 } | |
442 | |
443 static void vp6_filter(vp56_context_t *s, uint8_t *dst, uint8_t *src, | |
444 int offset1, int offset2, int stride, | |
445 vp56_mv_t mv, int mask, int select, int luma) | |
446 { | |
447 int filter4 = 0; | |
448 int x8 = mv.x & mask; | |
449 int y8 = mv.y & mask; | |
450 | |
451 if (luma) { | |
452 x8 *= 2; | |
453 y8 *= 2; | |
454 filter4 = s->filter_mode; | |
455 if (filter4 == 2) { | |
456 if (s->max_vector_length && | |
4001 | 457 (FFABS(mv.x) > s->max_vector_length || |
458 FFABS(mv.y) > s->max_vector_length)) { | |
3695 | 459 filter4 = 0; |
4308 | 460 } else if (s->sample_variance_threshold |
461 && (vp6_block_variance(src+offset1, stride) | |
3695 | 462 < s->sample_variance_threshold)) { |
463 filter4 = 0; | |
464 } | |
465 } | |
466 } | |
467 | |
468 if ((y8 && (offset2-offset1)*s->flip<0) || (!y8 && offset1 > offset2)) { | |
469 offset1 = offset2; | |
470 } | |
471 | |
472 if (filter4) { | |
473 if (!y8) { /* left or right combine */ | |
474 vp6_filter_hv4(dst, src+offset1, stride, 1, | |
475 vp6_block_copy_filter[select][x8]); | |
476 } else if (!x8) { /* above or below combine */ | |
477 vp6_filter_hv4(dst, src+offset1, stride, stride, | |
478 vp6_block_copy_filter[select][y8]); | |
4922 | 479 } else { |
480 vp6_filter_diag4(dst, src+offset1 + ((mv.x^mv.y)>>31), stride, | |
3695 | 481 vp6_block_copy_filter[select][x8], |
482 vp6_block_copy_filter[select][y8]); | |
483 } | |
484 } else { | |
4921 | 485 if (!x8 || !y8) { |
486 s->dsp.put_h264_chroma_pixels_tab[0](dst, src+offset1, stride, 8, x8, y8); | |
4922 | 487 } else { |
488 vp6_filter_diag2(s, dst, src+offset1 + ((mv.x^mv.y)>>31), stride, x8, y8); | |
3695 | 489 } |
490 } | |
491 } | |
492 | |
493 static int vp6_decode_init(AVCodecContext *avctx) | |
494 { | |
495 vp56_context_t *s = avctx->priv_data; | |
496 | |
5714
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
497 vp56_init(avctx, avctx->codec->id == CODEC_ID_VP6, |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
498 avctx->codec->id == CODEC_ID_VP6A); |
3695 | 499 s->vp56_coord_div = vp6_coord_div; |
500 s->parse_vector_adjustment = vp6_parse_vector_adjustment; | |
501 s->adjust = vp6_adjust; | |
502 s->filter = vp6_filter; | |
503 s->parse_coeff = vp6_parse_coeff; | |
504 s->default_models_init = vp6_default_models_init; | |
505 s->parse_vector_models = vp6_parse_vector_models; | |
506 s->parse_coeff_models = vp6_parse_coeff_models; | |
507 s->parse_header = vp6_parse_header; | |
508 | |
509 return 0; | |
510 } | |
511 | |
512 AVCodec vp6_decoder = { | |
513 "vp6", | |
514 CODEC_TYPE_VIDEO, | |
515 CODEC_ID_VP6, | |
516 sizeof(vp56_context_t), | |
517 vp6_decode_init, | |
518 NULL, | |
519 vp56_free, | |
520 vp56_decode_frame, | |
4910 | 521 CODEC_CAP_DR1, |
3695 | 522 }; |
523 | |
524 /* flash version, not flipped upside-down */ | |
525 AVCodec vp6f_decoder = { | |
526 "vp6f", | |
527 CODEC_TYPE_VIDEO, | |
528 CODEC_ID_VP6F, | |
529 sizeof(vp56_context_t), | |
530 vp6_decode_init, | |
531 NULL, | |
532 vp56_free, | |
533 vp56_decode_frame, | |
4910 | 534 CODEC_CAP_DR1, |
3695 | 535 }; |
5714
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
536 |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
537 /* flash version, not flipped upside-down, with alpha channel */ |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
538 AVCodec vp6a_decoder = { |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
539 "vp6a", |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
540 CODEC_TYPE_VIDEO, |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
541 CODEC_ID_VP6A, |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
542 sizeof(vp56_context_t), |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
543 vp6_decode_init, |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
544 NULL, |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
545 vp56_free, |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
546 vp56_decode_frame, |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
547 CODEC_CAP_DR1, |
314be1cfdcb0
add a new vp6a codec (add alpha plan support to vp6)
aurel
parents:
5711
diff
changeset
|
548 }; |