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

« back to all changes in this revision

Viewing changes to libavcodec/vp56.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:
28
28
#include "vp56data.h"
29
29
 
30
30
 
31
 
void vp56_init_dequant(vp56_context_t *s, int quantizer)
 
31
void vp56_init_dequant(VP56Context *s, int quantizer)
32
32
{
33
33
    s->quantizer = quantizer;
34
34
    s->dequant_dc = vp56_dc_dequant[quantizer] << 2;
35
35
    s->dequant_ac = vp56_ac_dequant[quantizer] << 2;
36
36
}
37
37
 
38
 
static int vp56_get_vectors_predictors(vp56_context_t *s, int row, int col,
39
 
                                       vp56_frame_t ref_frame)
 
38
static int vp56_get_vectors_predictors(VP56Context *s, int row, int col,
 
39
                                       VP56Frame ref_frame)
40
40
{
41
41
    int nb_pred = 0;
42
 
    vp56_mv_t vect[2] = {{0,0}, {0,0}};
 
42
    VP56mv vect[2] = {{0,0}, {0,0}};
43
43
    int pos, offset;
44
 
    vp56_mv_t mvp;
 
44
    VP56mv mvp;
45
45
 
46
46
    for (pos=0; pos<12; pos++) {
47
47
        mvp.x = col + vp56_candidate_predictor_pos[pos][0];
73
73
    return nb_pred+1;
74
74
}
75
75
 
76
 
static void vp56_parse_mb_type_models(vp56_context_t *s)
 
76
static void vp56_parse_mb_type_models(VP56Context *s)
77
77
{
78
 
    vp56_range_coder_t *c = &s->c;
79
 
    vp56_model_t *model = s->modelp;
 
78
    VP56RangeCoder *c = &s->c;
 
79
    VP56Model *model = s->modelp;
80
80
    int i, ctx, type;
81
81
 
82
82
    for (ctx=0; ctx<3; ctx++) {
144
144
    }
145
145
}
146
146
 
147
 
static vp56_mb_t vp56_parse_mb_type(vp56_context_t *s,
148
 
                                    vp56_mb_t prev_type, int ctx)
 
147
static VP56mb vp56_parse_mb_type(VP56Context *s,
 
148
                                 VP56mb prev_type, int ctx)
149
149
{
150
150
    uint8_t *mb_type_model = s->modelp->mb_type[ctx][prev_type];
151
 
    vp56_range_coder_t *c = &s->c;
 
151
    VP56RangeCoder *c = &s->c;
152
152
 
153
153
    if (vp56_rac_get_prob(c, mb_type_model[0]))
154
154
        return prev_type;
156
156
        return vp56_rac_get_tree(c, vp56_pmbt_tree, mb_type_model);
157
157
}
158
158
 
159
 
static void vp56_decode_4mv(vp56_context_t *s, int row, int col)
 
159
static void vp56_decode_4mv(VP56Context *s, int row, int col)
160
160
{
161
 
    vp56_mv_t mv = {0,0};
 
161
    VP56mv mv = {0,0};
162
162
    int type[4];
163
163
    int b;
164
164
 
173
173
    for (b=0; b<4; b++) {
174
174
        switch (type[b]) {
175
175
            case VP56_MB_INTER_NOVEC_PF:
176
 
                s->mv[b] = (vp56_mv_t) {0,0};
 
176
                s->mv[b] = (VP56mv) {0,0};
177
177
                break;
178
178
            case VP56_MB_INTER_DELTA_PF:
179
179
                s->parse_vector_adjustment(s, &s->mv[b]);
197
197
        s->mv[4].x = s->mv[5].x = RSHIFT(mv.x,2);
198
198
        s->mv[4].y = s->mv[5].y = RSHIFT(mv.y,2);
199
199
    } else {
200
 
        s->mv[4] = s->mv[5] = (vp56_mv_t) {mv.x/4, mv.y/4};
 
200
        s->mv[4] = s->mv[5] = (VP56mv) {mv.x/4, mv.y/4};
201
201
    }
202
202
}
203
203
 
204
 
static vp56_mb_t vp56_decode_mv(vp56_context_t *s, int row, int col)
 
204
static VP56mb vp56_decode_mv(VP56Context *s, int row, int col)
205
205
{
206
 
    vp56_mv_t *mv, vect = {0,0};
 
206
    VP56mv *mv, vect = {0,0};
207
207
    int ctx, b;
208
208
 
209
209
    ctx = vp56_get_vectors_predictors(s, row, col, VP56_FRAME_PREVIOUS);
258
258
    return s->mb_type;
259
259
}
260
260
 
261
 
static void vp56_add_predictors_dc(vp56_context_t *s, vp56_frame_t ref_frame)
 
261
static void vp56_add_predictors_dc(VP56Context *s, VP56Frame ref_frame)
262
262
{
263
263
    int idx = s->scantable.permutated[0];
264
264
    int b;
265
265
 
266
266
    for (b=0; b<6; b++) {
267
 
        vp56_ref_dc_t *ab = &s->above_blocks[s->above_block_idx[b]];
268
 
        vp56_ref_dc_t *lb = &s->left_block[vp56_b6to4[b]];
 
267
        VP56RefDc *ab = &s->above_blocks[s->above_block_idx[b]];
 
268
        VP56RefDc *lb = &s->left_block[vp56_b6to4[b]];
269
269
        int count = 0;
270
270
        int dc = 0;
271
271
        int i;
299
299
    }
300
300
}
301
301
 
302
 
static void vp56_edge_filter(vp56_context_t *s, uint8_t *yuv,
 
302
static void vp56_edge_filter(VP56Context *s, uint8_t *yuv,
303
303
                             int pix_inc, int line_inc, int t)
304
304
{
305
305
    int pix2_inc = 2 * pix_inc;
314
314
    }
315
315
}
316
316
 
317
 
static void vp56_deblock_filter(vp56_context_t *s, uint8_t *yuv,
 
317
static void vp56_deblock_filter(VP56Context *s, uint8_t *yuv,
318
318
                                int stride, int dx, int dy)
319
319
{
320
320
    int t = vp56_filter_threshold[s->quantizer];
322
322
    if (dy)  vp56_edge_filter(s, yuv + stride*(10-dy), stride,      1, t);
323
323
}
324
324
 
325
 
static void vp56_mc(vp56_context_t *s, int b, int plane, uint8_t *src,
 
325
static void vp56_mc(VP56Context *s, int b, int plane, uint8_t *src,
326
326
                    int stride, int x, int y)
327
327
{
328
328
    uint8_t *dst=s->framep[VP56_FRAME_CURRENT]->data[plane]+s->block_offset[b];
392
392
    }
393
393
}
394
394
 
395
 
static void vp56_decode_mb(vp56_context_t *s, int row, int col, int is_alpha)
 
395
static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha)
396
396
{
397
397
    AVFrame *frame_current, *frame_ref;
398
 
    vp56_mb_t mb_type;
399
 
    vp56_frame_t ref_frame;
 
398
    VP56mb mb_type;
 
399
    VP56Frame ref_frame;
400
400
    int b, ab, b_max, plane, off;
401
401
 
402
402
    if (s->framep[VP56_FRAME_CURRENT]->key_frame)
405
405
        mb_type = vp56_decode_mv(s, row, col);
406
406
    ref_frame = vp56_reference_frame[mb_type];
407
407
 
408
 
    memset(s->block_coeff, 0, sizeof(s->block_coeff));
 
408
    s->dsp.clear_blocks(*s->block_coeff);
409
409
 
410
410
    s->parse_coeff(s);
411
411
 
461
461
 
462
462
static int vp56_size_changed(AVCodecContext *avctx)
463
463
{
464
 
    vp56_context_t *s = avctx->priv_data;
 
464
    VP56Context *s = avctx->priv_data;
465
465
    int stride = s->framep[VP56_FRAME_CURRENT]->linesize[0];
466
466
    int i;
467
467
 
497
497
int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
498
498
                      const uint8_t *buf, int buf_size)
499
499
{
500
 
    vp56_context_t *s = avctx->priv_data;
 
500
    VP56Context *s = avctx->priv_data;
501
501
    AVFrame *const p = s->framep[VP56_FRAME_CURRENT];
502
502
    int remaining_buf_size = buf_size;
503
503
    int is_alpha, alpha_offset;
646
646
 
647
647
av_cold void vp56_init(AVCodecContext *avctx, int flip, int has_alpha)
648
648
{
649
 
    vp56_context_t *s = avctx->priv_data;
 
649
    VP56Context *s = avctx->priv_data;
650
650
    int i;
651
651
 
652
652
    s->avctx = avctx;
657
657
    dsputil_init(&s->dsp, avctx);
658
658
    ff_init_scantable(s->dsp.idct_permutation, &s->scantable,ff_zigzag_direct);
659
659
 
660
 
    avcodec_set_dimensions(avctx, 0, 0);
661
 
 
662
660
    for (i=0; i<4; i++)
663
661
        s->framep[i] = &s->frames[i];
664
662
    s->framep[VP56_FRAME_UNUSED] = s->framep[VP56_FRAME_GOLDEN];
686
684
 
687
685
av_cold int vp56_free(AVCodecContext *avctx)
688
686
{
689
 
    vp56_context_t *s = avctx->priv_data;
 
687
    VP56Context *s = avctx->priv_data;
690
688
 
691
689
    av_free(s->above_blocks);
692
690
    av_free(s->macroblocks);