~ubuntu-branches/ubuntu/utopic/ffmpeg-debian/utopic

« back to all changes in this revision

Viewing changes to libavcodec/vp6.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-01-20 09:20:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120092053-izz63p40hc98qfgp
Tags: 3:0.svn20090119-1ubuntu1
* merge from debian. LP: #318501
* new version fixes CVE-2008-3230, LP: #253767

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "vp6data.h"
38
38
 
39
39
 
40
 
static void vp6_parse_coeff(vp56_context_t *s);
41
 
static void vp6_parse_coeff_huffman(vp56_context_t *s);
 
40
static void vp6_parse_coeff(VP56Context *s);
 
41
static void vp6_parse_coeff_huffman(VP56Context *s);
42
42
 
43
 
static int vp6_parse_header(vp56_context_t *s, const uint8_t *buf, int buf_size,
 
43
static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
44
44
                            int *golden_frame)
45
45
{
46
 
    vp56_range_coder_t *c = &s->c;
 
46
    VP56RangeCoder *c = &s->c;
47
47
    int parse_filter_info = 0;
48
48
    int coeff_offset = 0;
49
49
    int vrt_shift = 0;
75
75
        /* buf[4] is number of displayed macroblock rows */
76
76
        /* buf[5] is number of displayed macroblock cols */
77
77
 
78
 
        if (16*cols != s->avctx->coded_width ||
 
78
        if (!s->macroblocks || /* first frame */
 
79
            16*cols != s->avctx->coded_width ||
79
80
            16*rows != s->avctx->coded_height) {
80
81
            avcodec_set_dimensions(s->avctx, 16*cols, 16*rows);
81
82
            if (s->avctx->extradata_size == 1) {
151
152
    return res;
152
153
}
153
154
 
154
 
static void vp6_coeff_order_table_init(vp56_context_t *s)
 
155
static void vp6_coeff_order_table_init(VP56Context *s)
155
156
{
156
157
    int i, pos, idx = 1;
157
158
 
162
163
                s->modelp->coeff_index_to_pos[idx++] = pos;
163
164
}
164
165
 
165
 
static void vp6_default_models_init(vp56_context_t *s)
 
166
static void vp6_default_models_init(VP56Context *s)
166
167
{
167
 
    vp56_model_t *model = s->modelp;
 
168
    VP56Model *model = s->modelp;
168
169
 
169
170
    model->vector_dct[0] = 0xA2;
170
171
    model->vector_dct[1] = 0xA4;
180
181
    vp6_coeff_order_table_init(s);
181
182
}
182
183
 
183
 
static void vp6_parse_vector_models(vp56_context_t *s)
 
184
static void vp6_parse_vector_models(VP56Context *s)
184
185
{
185
 
    vp56_range_coder_t *c = &s->c;
186
 
    vp56_model_t *model = s->modelp;
 
186
    VP56RangeCoder *c = &s->c;
 
187
    VP56Model *model = s->modelp;
187
188
    int comp, node;
188
189
 
189
190
    for (comp=0; comp<2; comp++) {
211
212
    return (a->count - b->count)*16 + (b->sym - a->sym);
212
213
}
213
214
 
214
 
static void vp6_build_huff_tree(vp56_context_t *s, uint8_t coeff_model[],
 
215
static void vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
215
216
                                const uint8_t *map, unsigned size, VLC *vlc)
216
217
{
217
218
    Node nodes[2*size], *tmp = &nodes[size];
231
232
                       FF_HUFFMAN_FLAG_HNODE_FIRST);
232
233
}
233
234
 
234
 
static void vp6_parse_coeff_models(vp56_context_t *s)
 
235
static void vp6_parse_coeff_models(VP56Context *s)
235
236
{
236
 
    vp56_range_coder_t *c = &s->c;
237
 
    vp56_model_t *model = s->modelp;
 
237
    VP56RangeCoder *c = &s->c;
 
238
    VP56Model *model = s->modelp;
238
239
    int def_prob[11];
239
240
    int node, cg, ctx, pos;
240
241
    int ct;    /* code type */
296
297
    }
297
298
}
298
299
 
299
 
static void vp6_parse_vector_adjustment(vp56_context_t *s, vp56_mv_t *vect)
 
300
static void vp6_parse_vector_adjustment(VP56Context *s, VP56mv *vect)
300
301
{
301
 
    vp56_range_coder_t *c = &s->c;
302
 
    vp56_model_t *model = s->modelp;
 
302
    VP56RangeCoder *c = &s->c;
 
303
    VP56Model *model = s->modelp;
303
304
    int comp;
304
305
 
305
 
    *vect = (vp56_mv_t) {0,0};
 
306
    *vect = (VP56mv) {0,0};
306
307
    if (s->vector_candidate_pos < 2)
307
308
        *vect = s->vector_candidate[0];
308
309
 
338
339
 * Read number of consecutive blocks with null DC or AC.
339
340
 * This value is < 74.
340
341
 */
341
 
static unsigned vp6_get_nb_null(vp56_context_t *s)
 
342
static unsigned vp6_get_nb_null(VP56Context *s)
342
343
{
343
344
    unsigned val = get_bits(&s->gb, 2);
344
345
    if (val == 2)
350
351
    return val;
351
352
}
352
353
 
353
 
static void vp6_parse_coeff_huffman(vp56_context_t *s)
 
354
static void vp6_parse_coeff_huffman(VP56Context *s)
354
355
{
355
 
    vp56_model_t *model = s->modelp;
 
356
    VP56Model *model = s->modelp;
356
357
    uint8_t *permute = s->scantable.permutated;
357
358
    VLC *vlc_coeff;
358
359
    int coeff, sign, coeff_idx;
405
406
    }
406
407
}
407
408
 
408
 
static void vp6_parse_coeff(vp56_context_t *s)
 
409
static void vp6_parse_coeff(VP56Context *s)
409
410
{
410
 
    vp56_range_coder_t *c = s->ccp;
411
 
    vp56_model_t *model = s->modelp;
 
411
    VP56RangeCoder *c = s->ccp;
 
412
    VP56Model *model = s->modelp;
412
413
    uint8_t *permute = s->scantable.permutated;
413
414
    uint8_t *model1, *model2, *model3;
414
415
    int coeff, sign, coeff_idx;
522
523
    }
523
524
}
524
525
 
525
 
static void vp6_filter_diag2(vp56_context_t *s, uint8_t *dst, uint8_t *src,
 
526
static void vp6_filter_diag2(VP56Context *s, uint8_t *dst, uint8_t *src,
526
527
                             int stride, int h_weight, int v_weight)
527
528
{
528
529
    uint8_t *tmp = s->edge_emu_buffer+16;
563
564
    }
564
565
}
565
566
 
566
 
static void vp6_filter(vp56_context_t *s, uint8_t *dst, uint8_t *src,
 
567
static void vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src,
567
568
                       int offset1, int offset2, int stride,
568
 
                       vp56_mv_t mv, int mask, int select, int luma)
 
569
                       VP56mv mv, int mask, int select, int luma)
569
570
{
570
571
    int filter4 = 0;
571
572
    int x8 = mv.x & mask;
615
616
 
616
617
static av_cold int vp6_decode_init(AVCodecContext *avctx)
617
618
{
618
 
    vp56_context_t *s = avctx->priv_data;
 
619
    VP56Context *s = avctx->priv_data;
619
620
 
620
621
    vp56_init(avctx, avctx->codec->id == CODEC_ID_VP6,
621
622
                     avctx->codec->id == CODEC_ID_VP6A);
635
636
    "vp6",
636
637
    CODEC_TYPE_VIDEO,
637
638
    CODEC_ID_VP6,
638
 
    sizeof(vp56_context_t),
 
639
    sizeof(VP56Context),
639
640
    vp6_decode_init,
640
641
    NULL,
641
642
    vp56_free,
649
650
    "vp6f",
650
651
    CODEC_TYPE_VIDEO,
651
652
    CODEC_ID_VP6F,
652
 
    sizeof(vp56_context_t),
 
653
    sizeof(VP56Context),
653
654
    vp6_decode_init,
654
655
    NULL,
655
656
    vp56_free,
663
664
    "vp6a",
664
665
    CODEC_TYPE_VIDEO,
665
666
    CODEC_ID_VP6A,
666
 
    sizeof(vp56_context_t),
 
667
    sizeof(VP56Context),
667
668
    vp6_decode_init,
668
669
    NULL,
669
670
    vp56_free,