Git init
[framework/multimedia/ffmpeg.git] / libavcodec / vp6.c
1 /**
2  * @file
3  * VP6 compatible video decoder
4  *
5  * Copyright (C) 2006  Aurelien Jacobs <aurel@gnuage.org>
6  *
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  *
11  * This file is part of FFmpeg.
12  *
13  * FFmpeg is free software; you can redistribute it and/or
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  *
18  * FFmpeg is distributed in the hope that it will be useful,
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
24  * License along with FFmpeg; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26  */
27
28 #include <stdlib.h>
29
30 #include "avcodec.h"
31 #include "dsputil.h"
32 #include "get_bits.h"
33 #include "huffman.h"
34
35 #include "vp56.h"
36 #include "vp56data.h"
37 #include "vp6data.h"
38
39 #define VP6_MAX_HUFF_SIZE 12
40
41 static void vp6_parse_coeff(VP56Context *s);
42 static void vp6_parse_coeff_huffman(VP56Context *s);
43
44 static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
45                             int *golden_frame)
46 {
47     VP56RangeCoder *c = &s->c;
48     int parse_filter_info = 0;
49     int coeff_offset = 0;
50     int vrt_shift = 0;
51     int sub_version;
52     int rows, cols;
53     int res = 1;
54     int separated_coeff = buf[0] & 1;
55
56     s->framep[VP56_FRAME_CURRENT]->key_frame = !(buf[0] & 0x80);
57     ff_vp56_init_dequant(s, (buf[0] >> 1) & 0x3F);
58
59     if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
60         sub_version = buf[1] >> 3;
61         if (sub_version > 8)
62             return 0;
63         s->filter_header = buf[1] & 0x06;
64         if (buf[1] & 1) {
65             av_log(s->avctx, AV_LOG_ERROR, "interlacing not supported\n");
66             return 0;
67         }
68         if (separated_coeff || !s->filter_header) {
69             coeff_offset = AV_RB16(buf+2) - 2;
70             buf += 2;
71             buf_size -= 2;
72         }
73
74         rows = buf[2];  /* number of stored macroblock rows */
75         cols = buf[3];  /* number of stored macroblock cols */
76         /* buf[4] is number of displayed macroblock rows */
77         /* buf[5] is number of displayed macroblock cols */
78
79         if (!s->macroblocks || /* first frame */
80             16*cols != s->avctx->coded_width ||
81             16*rows != s->avctx->coded_height) {
82             avcodec_set_dimensions(s->avctx, 16*cols, 16*rows);
83             if (s->avctx->extradata_size == 1) {
84                 s->avctx->width  -= s->avctx->extradata[0] >> 4;
85                 s->avctx->height -= s->avctx->extradata[0] & 0x0F;
86             }
87             res = 2;
88         }
89
90         ff_vp56_init_range_decoder(c, buf+6, buf_size-6);
91         vp56_rac_gets(c, 2);
92
93         parse_filter_info = s->filter_header;
94         if (sub_version < 8)
95             vrt_shift = 5;
96         s->sub_version = sub_version;
97     } else {
98         if (!s->sub_version)
99             return 0;
100
101         if (separated_coeff || !s->filter_header) {
102             coeff_offset = AV_RB16(buf+1) - 2;
103             buf += 2;
104             buf_size -= 2;
105         }
106         ff_vp56_init_range_decoder(c, buf+1, buf_size-1);
107
108         *golden_frame = vp56_rac_get(c);
109         if (s->filter_header) {
110             s->deblock_filtering = vp56_rac_get(c);
111             if (s->deblock_filtering)
112                 vp56_rac_get(c);
113             if (s->sub_version > 7)
114                 parse_filter_info = vp56_rac_get(c);
115         }
116     }
117
118     if (parse_filter_info) {
119         if (vp56_rac_get(c)) {
120             s->filter_mode = 2;
121             s->sample_variance_threshold = vp56_rac_gets(c, 5) << vrt_shift;
122             s->max_vector_length = 2 << vp56_rac_gets(c, 3);
123         } else if (vp56_rac_get(c)) {
124             s->filter_mode = 1;
125         } else {
126             s->filter_mode = 0;
127         }
128         if (s->sub_version > 7)
129             s->filter_selection = vp56_rac_gets(c, 4);
130         else
131             s->filter_selection = 16;
132     }
133
134     s->use_huffman = vp56_rac_get(c);
135
136     s->parse_coeff = vp6_parse_coeff;
137     if (coeff_offset) {
138         buf      += coeff_offset;
139         buf_size -= coeff_offset;
140         if (buf_size < 0) {
141             if (s->framep[VP56_FRAME_CURRENT]->key_frame)
142                 avcodec_set_dimensions(s->avctx, 0, 0);
143             return 0;
144         }
145         if (s->use_huffman) {
146             s->parse_coeff = vp6_parse_coeff_huffman;
147             init_get_bits(&s->gb, buf, buf_size<<3);
148         } else {
149             ff_vp56_init_range_decoder(&s->cc, buf, buf_size);
150             s->ccp = &s->cc;
151         }
152     } else {
153         s->ccp = &s->c;
154     }
155
156     return res;
157 }
158
159 static void vp6_coeff_order_table_init(VP56Context *s)
160 {
161     int i, pos, idx = 1;
162
163     s->modelp->coeff_index_to_pos[0] = 0;
164     for (i=0; i<16; i++)
165         for (pos=1; pos<64; pos++)
166             if (s->modelp->coeff_reorder[pos] == i)
167                 s->modelp->coeff_index_to_pos[idx++] = pos;
168 }
169
170 static void vp6_default_models_init(VP56Context *s)
171 {
172     VP56Model *model = s->modelp;
173
174     model->vector_dct[0] = 0xA2;
175     model->vector_dct[1] = 0xA4;
176     model->vector_sig[0] = 0x80;
177     model->vector_sig[1] = 0x80;
178
179     memcpy(model->mb_types_stats, vp56_def_mb_types_stats, sizeof(model->mb_types_stats));
180     memcpy(model->vector_fdv, vp6_def_fdv_vector_model, sizeof(model->vector_fdv));
181     memcpy(model->vector_pdv, vp6_def_pdv_vector_model, sizeof(model->vector_pdv));
182     memcpy(model->coeff_runv, vp6_def_runv_coeff_model, sizeof(model->coeff_runv));
183     memcpy(model->coeff_reorder, vp6_def_coeff_reorder, sizeof(model->coeff_reorder));
184
185     vp6_coeff_order_table_init(s);
186 }
187
188 static void vp6_parse_vector_models(VP56Context *s)
189 {
190     VP56RangeCoder *c = &s->c;
191     VP56Model *model = s->modelp;
192     int comp, node;
193
194     for (comp=0; comp<2; comp++) {
195         if (vp56_rac_get_prob(c, vp6_sig_dct_pct[comp][0]))
196             model->vector_dct[comp] = vp56_rac_gets_nn(c, 7);
197         if (vp56_rac_get_prob(c, vp6_sig_dct_pct[comp][1]))
198             model->vector_sig[comp] = vp56_rac_gets_nn(c, 7);
199     }
200
201     for (comp=0; comp<2; comp++)
202         for (node=0; node<7; node++)
203             if (vp56_rac_get_prob(c, vp6_pdv_pct[comp][node]))
204                 model->vector_pdv[comp][node] = vp56_rac_gets_nn(c, 7);
205
206     for (comp=0; comp<2; comp++)
207         for (node=0; node<8; node++)
208             if (vp56_rac_get_prob(c, vp6_fdv_pct[comp][node]))
209                 model->vector_fdv[comp][node] = vp56_rac_gets_nn(c, 7);
210 }
211
212 /* nodes must ascend by count, but with descending symbol order */
213 static int vp6_huff_cmp(const void *va, const void *vb)
214 {
215     const Node *a = va, *b = vb;
216     return (a->count - b->count)*16 + (b->sym - a->sym);
217 }
218
219 static int vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
220                                const uint8_t *map, unsigned size, VLC *vlc)
221 {
222     Node nodes[2*VP6_MAX_HUFF_SIZE], *tmp = &nodes[size];
223     int a, b, i;
224
225     /* first compute probabilities from model */
226     tmp[0].count = 256;
227     for (i=0; i<size-1; i++) {
228         a = tmp[i].count *        coeff_model[i]  >> 8;
229         b = tmp[i].count * (255 - coeff_model[i]) >> 8;
230         nodes[map[2*i  ]].count = a + !a;
231         nodes[map[2*i+1]].count = b + !b;
232     }
233
234     free_vlc(vlc);
235     /* then build the huffman tree according to probabilities */
236     return ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,
237                               FF_HUFFMAN_FLAG_HNODE_FIRST);
238 }
239
240 static int vp6_parse_coeff_models(VP56Context *s)
241 {
242     VP56RangeCoder *c = &s->c;
243     VP56Model *model = s->modelp;
244     int def_prob[11];
245     int node, cg, ctx, pos;
246     int ct;    /* code type */
247     int pt;    /* plane type (0 for Y, 1 for U or V) */
248
249     memset(def_prob, 0x80, sizeof(def_prob));
250
251     for (pt=0; pt<2; pt++)
252         for (node=0; node<11; node++)
253             if (vp56_rac_get_prob(c, vp6_dccv_pct[pt][node])) {
254                 def_prob[node] = vp56_rac_gets_nn(c, 7);
255                 model->coeff_dccv[pt][node] = def_prob[node];
256             } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
257                 model->coeff_dccv[pt][node] = def_prob[node];
258             }
259
260     if (vp56_rac_get(c)) {
261         for (pos=1; pos<64; pos++)
262             if (vp56_rac_get_prob(c, vp6_coeff_reorder_pct[pos]))
263                 model->coeff_reorder[pos] = vp56_rac_gets(c, 4);
264         vp6_coeff_order_table_init(s);
265     }
266
267     for (cg=0; cg<2; cg++)
268         for (node=0; node<14; node++)
269             if (vp56_rac_get_prob(c, vp6_runv_pct[cg][node]))
270                 model->coeff_runv[cg][node] = vp56_rac_gets_nn(c, 7);
271
272     for (ct=0; ct<3; ct++)
273         for (pt=0; pt<2; pt++)
274             for (cg=0; cg<6; cg++)
275                 for (node=0; node<11; node++)
276                     if (vp56_rac_get_prob(c, vp6_ract_pct[ct][pt][cg][node])) {
277                         def_prob[node] = vp56_rac_gets_nn(c, 7);
278                         model->coeff_ract[pt][ct][cg][node] = def_prob[node];
279                     } else if (s->framep[VP56_FRAME_CURRENT]->key_frame) {
280                         model->coeff_ract[pt][ct][cg][node] = def_prob[node];
281                     }
282
283     if (s->use_huffman) {
284         for (pt=0; pt<2; pt++) {
285             if (vp6_build_huff_tree(s, model->coeff_dccv[pt],
286                                     vp6_huff_coeff_map, 12, &s->dccv_vlc[pt]))
287                 return -1;
288             if (vp6_build_huff_tree(s, model->coeff_runv[pt],
289                                     vp6_huff_run_map, 9, &s->runv_vlc[pt]))
290                 return -1;
291             for (ct=0; ct<3; ct++)
292                 for (cg = 0; cg < 6; cg++)
293                     if (vp6_build_huff_tree(s, model->coeff_ract[pt][ct][cg],
294                                             vp6_huff_coeff_map, 12,
295                                             &s->ract_vlc[pt][ct][cg]))
296                         return -1;
297         }
298         memset(s->nb_null, 0, sizeof(s->nb_null));
299     } else {
300     /* coeff_dcct is a linear combination of coeff_dccv */
301     for (pt=0; pt<2; pt++)
302         for (ctx=0; ctx<3; ctx++)
303             for (node=0; node<5; node++)
304                 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);
305     }
306     return 0;
307 }
308
309 static void vp6_parse_vector_adjustment(VP56Context *s, VP56mv *vect)
310 {
311     VP56RangeCoder *c = &s->c;
312     VP56Model *model = s->modelp;
313     int comp;
314
315     *vect = (VP56mv) {0,0};
316     if (s->vector_candidate_pos < 2)
317         *vect = s->vector_candidate[0];
318
319     for (comp=0; comp<2; comp++) {
320         int i, delta = 0;
321
322         if (vp56_rac_get_prob(c, model->vector_dct[comp])) {
323             static const uint8_t prob_order[] = {0, 1, 2, 7, 6, 5, 4};
324             for (i=0; i<sizeof(prob_order); i++) {
325                 int j = prob_order[i];
326                 delta |= vp56_rac_get_prob(c, model->vector_fdv[comp][j])<<j;
327             }
328             if (delta & 0xF0)
329                 delta |= vp56_rac_get_prob(c, model->vector_fdv[comp][3])<<3;
330             else
331                 delta |= 8;
332         } else {
333             delta = vp56_rac_get_tree(c, vp56_pva_tree,
334                                       model->vector_pdv[comp]);
335         }
336
337         if (delta && vp56_rac_get_prob(c, model->vector_sig[comp]))
338             delta = -delta;
339
340         if (!comp)
341             vect->x += delta;
342         else
343             vect->y += delta;
344     }
345 }
346
347 /**
348  * Read number of consecutive blocks with null DC or AC.
349  * This value is < 74.
350  */
351 static unsigned vp6_get_nb_null(VP56Context *s)
352 {
353     unsigned val = get_bits(&s->gb, 2);
354     if (val == 2)
355         val += get_bits(&s->gb, 2);
356     else if (val == 3) {
357         val = get_bits1(&s->gb) << 2;
358         val = 6+val + get_bits(&s->gb, 2+val);
359     }
360     return val;
361 }
362
363 static void vp6_parse_coeff_huffman(VP56Context *s)
364 {
365     VP56Model *model = s->modelp;
366     uint8_t *permute = s->scantable.permutated;
367     VLC *vlc_coeff;
368     int coeff, sign, coeff_idx;
369     int b, cg, idx;
370     int pt = 0;    /* plane type (0 for Y, 1 for U or V) */
371
372     for (b=0; b<6; b++) {
373         int ct = 0;    /* code type */
374         if (b > 3) pt = 1;
375         vlc_coeff = &s->dccv_vlc[pt];
376
377         for (coeff_idx=0; coeff_idx<64; ) {
378             int run = 1;
379             if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) {
380                 s->nb_null[coeff_idx][pt]--;
381                 if (coeff_idx)
382                     break;
383             } else {
384                 if (get_bits_count(&s->gb) >= s->gb.size_in_bits)
385                     return;
386                 coeff = get_vlc2(&s->gb, vlc_coeff->table, 9, 3);
387                 if (coeff == 0) {
388                     if (coeff_idx) {
389                         int pt = (coeff_idx >= 6);
390                         run += get_vlc2(&s->gb, s->runv_vlc[pt].table, 9, 3);
391                         if (run >= 9)
392                             run += get_bits(&s->gb, 6);
393                     } else
394                         s->nb_null[0][pt] = vp6_get_nb_null(s);
395                     ct = 0;
396                 } else if (coeff == 11) {  /* end of block */
397                     if (coeff_idx == 1)    /* first AC coeff ? */
398                         s->nb_null[1][pt] = vp6_get_nb_null(s);
399                     break;
400                 } else {
401                     int coeff2 = vp56_coeff_bias[coeff];
402                     if (coeff > 4)
403                         coeff2 += get_bits(&s->gb, coeff <= 9 ? coeff - 4 : 11);
404                     ct = 1 + (coeff2 > 1);
405                     sign = get_bits1(&s->gb);
406                     coeff2 = (coeff2 ^ -sign) + sign;
407                     if (coeff_idx)
408                         coeff2 *= s->dequant_ac;
409                     idx = model->coeff_index_to_pos[coeff_idx];
410                     s->block_coeff[b][permute[idx]] = coeff2;
411                 }
412             }
413             coeff_idx+=run;
414             cg = FFMIN(vp6_coeff_groups[coeff_idx], 3);
415             vlc_coeff = &s->ract_vlc[pt][ct][cg];
416         }
417     }
418 }
419
420 static void vp6_parse_coeff(VP56Context *s)
421 {
422     VP56RangeCoder *c = s->ccp;
423     VP56Model *model = s->modelp;
424     uint8_t *permute = s->scantable.permutated;
425     uint8_t *model1, *model2, *model3;
426     int coeff, sign, coeff_idx;
427     int b, i, cg, idx, ctx;
428     int pt = 0;    /* plane type (0 for Y, 1 for U or V) */
429
430     for (b=0; b<6; b++) {
431         int ct = 1;    /* code type */
432         int run = 1;
433
434         if (b > 3) pt = 1;
435
436         ctx = s->left_block[vp56_b6to4[b]].not_null_dc
437               + s->above_blocks[s->above_block_idx[b]].not_null_dc;
438         model1 = model->coeff_dccv[pt];
439         model2 = model->coeff_dcct[pt][ctx];
440
441         for (coeff_idx=0; coeff_idx<64; ) {
442             if ((coeff_idx>1 && ct==0) || vp56_rac_get_prob(c, model2[0])) {
443                 /* parse a coeff */
444                 if (vp56_rac_get_prob(c, model2[2])) {
445                     if (vp56_rac_get_prob(c, model2[3])) {
446                         idx = vp56_rac_get_tree(c, vp56_pc_tree, model1);
447                         coeff = vp56_coeff_bias[idx+5];
448                         for (i=vp56_coeff_bit_length[idx]; i>=0; i--)
449                             coeff += vp56_rac_get_prob(c, vp56_coeff_parse_table[idx][i]) << i;
450                     } else {
451                         if (vp56_rac_get_prob(c, model2[4]))
452                             coeff = 3 + vp56_rac_get_prob(c, model1[5]);
453                         else
454                             coeff = 2;
455                     }
456                     ct = 2;
457                 } else {
458                     ct = 1;
459                     coeff = 1;
460                 }
461                 sign = vp56_rac_get(c);
462                 coeff = (coeff ^ -sign) + sign;
463                 if (coeff_idx)
464                     coeff *= s->dequant_ac;
465                 idx = model->coeff_index_to_pos[coeff_idx];
466                 s->block_coeff[b][permute[idx]] = coeff;
467                 run = 1;
468             } else {
469                 /* parse a run */
470                 ct = 0;
471                 if (coeff_idx > 0) {
472                     if (!vp56_rac_get_prob(c, model2[1]))
473                         break;
474
475                     model3 = model->coeff_runv[coeff_idx >= 6];
476                     run = vp56_rac_get_tree(c, vp6_pcr_tree, model3);
477                     if (!run)
478                         for (run=9, i=0; i<6; i++)
479                             run += vp56_rac_get_prob(c, model3[i+8]) << i;
480                 }
481             }
482
483             cg = vp6_coeff_groups[coeff_idx+=run];
484             model1 = model2 = model->coeff_ract[pt][ct][cg];
485         }
486
487         s->left_block[vp56_b6to4[b]].not_null_dc =
488         s->above_blocks[s->above_block_idx[b]].not_null_dc = !!s->block_coeff[b][0];
489     }
490 }
491
492 static int vp6_block_variance(uint8_t *src, int stride)
493 {
494     int sum = 0, square_sum = 0;
495     int y, x;
496
497     for (y=0; y<8; y+=2) {
498         for (x=0; x<8; x+=2) {
499             sum += src[x];
500             square_sum += src[x]*src[x];
501         }
502         src += 2*stride;
503     }
504     return (16*square_sum - sum*sum) >> 8;
505 }
506
507 static void vp6_filter_hv4(uint8_t *dst, uint8_t *src, int stride,
508                            int delta, const int16_t *weights)
509 {
510     int x, y;
511
512     for (y=0; y<8; y++) {
513         for (x=0; x<8; x++) {
514             dst[x] = av_clip_uint8((  src[x-delta  ] * weights[0]
515                                  + src[x        ] * weights[1]
516                                  + src[x+delta  ] * weights[2]
517                                  + src[x+2*delta] * weights[3] + 64) >> 7);
518         }
519         src += stride;
520         dst += stride;
521     }
522 }
523
524 static void vp6_filter_diag2(VP56Context *s, uint8_t *dst, uint8_t *src,
525                              int stride, int h_weight, int v_weight)
526 {
527     uint8_t *tmp = s->edge_emu_buffer+16;
528     s->dsp.put_h264_chroma_pixels_tab[0](tmp, src, stride, 9, h_weight, 0);
529     s->dsp.put_h264_chroma_pixels_tab[0](dst, tmp, stride, 8, 0, v_weight);
530 }
531
532 static void vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src,
533                        int offset1, int offset2, int stride,
534                        VP56mv mv, int mask, int select, int luma)
535 {
536     int filter4 = 0;
537     int x8 = mv.x & mask;
538     int y8 = mv.y & mask;
539
540     if (luma) {
541         x8 *= 2;
542         y8 *= 2;
543         filter4 = s->filter_mode;
544         if (filter4 == 2) {
545             if (s->max_vector_length &&
546                 (FFABS(mv.x) > s->max_vector_length ||
547                  FFABS(mv.y) > s->max_vector_length)) {
548                 filter4 = 0;
549             } else if (s->sample_variance_threshold
550                        && (vp6_block_variance(src+offset1, stride)
551                            < s->sample_variance_threshold)) {
552                 filter4 = 0;
553             }
554         }
555     }
556
557     if ((y8 && (offset2-offset1)*s->flip<0) || (!y8 && offset1 > offset2)) {
558         offset1 = offset2;
559     }
560
561     if (filter4) {
562         if (!y8) {                      /* left or right combine */
563             vp6_filter_hv4(dst, src+offset1, stride, 1,
564                            vp6_block_copy_filter[select][x8]);
565         } else if (!x8) {               /* above or below combine */
566             vp6_filter_hv4(dst, src+offset1, stride, stride,
567                            vp6_block_copy_filter[select][y8]);
568         } else {
569             s->vp56dsp.vp6_filter_diag4(dst, src+offset1+((mv.x^mv.y)>>31), stride,
570                              vp6_block_copy_filter[select][x8],
571                              vp6_block_copy_filter[select][y8]);
572         }
573     } else {
574         if (!x8 || !y8) {
575             s->dsp.put_h264_chroma_pixels_tab[0](dst, src+offset1, stride, 8, x8, y8);
576         } else {
577             vp6_filter_diag2(s, dst, src+offset1 + ((mv.x^mv.y)>>31), stride, x8, y8);
578         }
579     }
580 }
581
582 static av_cold int vp6_decode_init(AVCodecContext *avctx)
583 {
584     VP56Context *s = avctx->priv_data;
585
586     ff_vp56_init(avctx, avctx->codec->id == CODEC_ID_VP6,
587                         avctx->codec->id == CODEC_ID_VP6A);
588     s->vp56_coord_div = vp6_coord_div;
589     s->parse_vector_adjustment = vp6_parse_vector_adjustment;
590     s->filter = vp6_filter;
591     s->default_models_init = vp6_default_models_init;
592     s->parse_vector_models = vp6_parse_vector_models;
593     s->parse_coeff_models = vp6_parse_coeff_models;
594     s->parse_header = vp6_parse_header;
595
596     return 0;
597 }
598
599 static av_cold int vp6_decode_free(AVCodecContext *avctx)
600 {
601     VP56Context *s = avctx->priv_data;
602     int pt, ct, cg;
603
604     ff_vp56_free(avctx);
605
606     for (pt=0; pt<2; pt++) {
607         free_vlc(&s->dccv_vlc[pt]);
608         free_vlc(&s->runv_vlc[pt]);
609         for (ct=0; ct<3; ct++)
610             for (cg=0; cg<6; cg++)
611                 free_vlc(&s->ract_vlc[pt][ct][cg]);
612     }
613     return 0;
614 }
615
616 AVCodec ff_vp6_decoder = {
617     "vp6",
618     AVMEDIA_TYPE_VIDEO,
619     CODEC_ID_VP6,
620     sizeof(VP56Context),
621     vp6_decode_init,
622     NULL,
623     vp6_decode_free,
624     ff_vp56_decode_frame,
625     CODEC_CAP_DR1,
626     .long_name = NULL_IF_CONFIG_SMALL("On2 VP6"),
627 };
628
629 /* flash version, not flipped upside-down */
630 AVCodec ff_vp6f_decoder = {
631     "vp6f",
632     AVMEDIA_TYPE_VIDEO,
633     CODEC_ID_VP6F,
634     sizeof(VP56Context),
635     vp6_decode_init,
636     NULL,
637     vp6_decode_free,
638     ff_vp56_decode_frame,
639     CODEC_CAP_DR1,
640     .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version)"),
641 };
642
643 /* flash version, not flipped upside-down, with alpha channel */
644 AVCodec ff_vp6a_decoder = {
645     "vp6a",
646     AVMEDIA_TYPE_VIDEO,
647     CODEC_ID_VP6A,
648     sizeof(VP56Context),
649     vp6_decode_init,
650     NULL,
651     vp6_decode_free,
652     ff_vp56_decode_frame,
653     CODEC_CAP_DR1,
654     .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version, with alpha channel)"),
655 };