~ubuntu-branches/ubuntu/lucid/ffmpeg/lucid-security

« back to all changes in this revision

Viewing changes to libavcodec/h263.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2009-03-13 09:18:28 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090313091828-n4ktby5eca487uhv
Tags: 3:0.svn20090303-1ubuntu1+unstripped1
merge from ubuntu.jaunty branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
#define H263_MBTYPE_B_VLC_BITS 6
56
56
#define CBPC_B_VLC_BITS 3
57
57
 
58
 
#if CONFIG_ENCODERS
59
58
static void h263_encode_block(MpegEncContext * s, DCTELEM * block,
60
59
                              int n);
61
60
static void h263p_encode_umotion(MpegEncContext * s, int val);
64
63
                               PutBitContext *dc_pb, PutBitContext *ac_pb);
65
64
static int mpeg4_get_block_length(MpegEncContext * s, DCTELEM * block, int n, int intra_dc,
66
65
                                  uint8_t *scan_table);
67
 
#endif
68
66
 
69
67
static int h263_decode_motion(MpegEncContext * s, int pred, int fcode);
70
68
static int h263p_decode_umotion(MpegEncContext * s, int pred);
73
71
static inline int mpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr);
74
72
static inline int mpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
75
73
                              int n, int coded, int intra, int rvlc);
76
 
#if CONFIG_ENCODERS
 
74
 
77
75
static int h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr);
78
76
static void mpeg4_encode_visual_object_header(MpegEncContext * s);
79
77
static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number);
80
 
#endif //CONFIG_ENCODERS
 
78
 
81
79
static void mpeg4_decode_sprite_trajectory(MpegEncContext * s, GetBitContext *gb);
82
80
static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, int level, int *dir_ptr, int encoding);
83
81
 
3295
3293
}
3296
3294
 
3297
3295
/**
 
3296
 * finds the next resync_marker
 
3297
 * @param p pointer to buffer to scan
 
3298
 * @param end pointer to the end of the buffer
 
3299
 * @return pointer to the next resync_marker, or \p end if none was found
 
3300
 */
 
3301
const uint8_t *ff_h263_find_resync_marker(const uint8_t *restrict p, const uint8_t * restrict end)
 
3302
{
 
3303
    assert(p < end);
 
3304
 
 
3305
    end-=2;
 
3306
    p++;
 
3307
    for(;p<end; p+=2){
 
3308
        if(!*p){
 
3309
            if     (!p[-1] && p[1]) return p - 1;
 
3310
            else if(!p[ 1] && p[2]) return p;
 
3311
        }
 
3312
    }
 
3313
    return end+2;
 
3314
}
 
3315
 
 
3316
/**
3298
3317
 * decodes the group of blocks / video packet header.
3299
3318
 * @return bit position of the resync_marker, or <0 if none was found
3300
3319
 */
6185
6204
        return -1;      /* SAC: off */
6186
6205
    }
6187
6206
    s->obmc= get_bits1(&s->gb);
6188
 
    if (get_bits1(&s->gb) != 0) {
 
6207
    s->pb_frame = get_bits1(&s->gb);
 
6208
 
 
6209
    if(format == 7){
 
6210
        format = get_bits(&s->gb, 3);
 
6211
        if(format == 0 || format == 7){
 
6212
            av_log(s->avctx, AV_LOG_ERROR, "Wrong Intel H263 format\n");
 
6213
            return -1;
 
6214
        }
 
6215
        if(get_bits(&s->gb, 2))
 
6216
            av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
 
6217
        s->loop_filter = get_bits1(&s->gb);
 
6218
        if(get_bits1(&s->gb))
 
6219
            av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
 
6220
        if(get_bits1(&s->gb))
 
6221
            s->pb_frame = 2;
 
6222
        if(get_bits(&s->gb, 5))
 
6223
            av_log(s->avctx, AV_LOG_ERROR, "Bad value for reserved field\n");
 
6224
        if(get_bits(&s->gb, 5) != 1)
 
6225
            av_log(s->avctx, AV_LOG_ERROR, "Invalid marker\n");
 
6226
    }
 
6227
    if(format == 6){
 
6228
        int ar = get_bits(&s->gb, 4);
 
6229
        skip_bits(&s->gb, 9); // display width
 
6230
        skip_bits1(&s->gb);
 
6231
        skip_bits(&s->gb, 9); // display height
 
6232
        if(ar == 15){
 
6233
            skip_bits(&s->gb, 8); // aspect ratio - width
 
6234
            skip_bits(&s->gb, 8); // aspect ratio - height
 
6235
        }
 
6236
    }
 
6237
 
 
6238
    s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
 
6239
    skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
 
6240
 
 
6241
    if(s->pb_frame){
 
6242
        skip_bits(&s->gb, 3); //temporal reference for B-frame
 
6243
        skip_bits(&s->gb, 2); //dbquant
 
6244
    }
 
6245
 
 
6246
    /* PEI */
 
6247
    while (get_bits1(&s->gb) != 0) {
 
6248
        skip_bits(&s->gb, 8);
 
6249
    }
 
6250
    s->f_code = 1;
 
6251
 
 
6252
    s->y_dc_scale_table=
 
6253
    s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
 
6254
 
 
6255
    if(s->avctx->debug&FF_DEBUG_PICT_INFO)
 
6256
        show_pict_info(s);
 
6257
 
 
6258
    if(s->pb_frame){
6189
6259
        av_log(s->avctx, AV_LOG_ERROR, "PB frame mode no supported\n");
6190
6260
        return -1;      /* PB frame mode */
6191
6261
    }
6192
 
 
6193
 
    /* skip unknown header garbage */
6194
 
    skip_bits(&s->gb, 41);
6195
 
 
6196
 
    s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
6197
 
    skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
6198
 
 
6199
 
    /* PEI */
6200
 
    while (get_bits1(&s->gb) != 0) {
6201
 
        skip_bits(&s->gb, 8);
6202
 
    }
6203
 
    s->f_code = 1;
6204
 
 
6205
 
    s->y_dc_scale_table=
6206
 
    s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
6207
 
 
6208
 
    if(s->avctx->debug&FF_DEBUG_PICT_INFO)
6209
 
        show_pict_info(s);
6210
 
 
6211
6262
    return 0;
6212
6263
}
6213
6264