Revision 768c5251

View differences:

libavcodec/vc1.c
605 605
{
606 606
    int pqindex, lowquant, status;
607 607

  
608
    if(v->res_sprite) {
609
        skip_bits(gb, 2); //not yet deciphered
610
    }
611 608
    if(v->finterpflag) v->interpfrm = get_bits1(gb);
612 609
    skip_bits(gb, 2); //framecnt unused
613 610
    v->rangeredfrm = 0;
libavcodec/vc1.h
306 306
    uint8_t range_mapuv;
307 307
    //@}
308 308

  
309
    /** Frame decoding info for sprite modes */
310
    //@{
311
    int new_sprite;
312
    int two_sprites;
313
    //@}
314

  
309 315
    int p_frame_skipped;
310 316
    int bi_type;
311 317
    int x8_type;
libavcodec/vc1dec.c
3097 3097
    }
3098 3098
}
3099 3099

  
3100
static inline float get_float_val(GetBitContext* gb)
3101
{
3102
    return (float)get_bits_long(gb, 30) / (1<<15) - (1<<14);
3103
}
3104

  
3105
static void vc1_sprite_parse_transform(VC1Context *v, GetBitContext* gb, float c[7])
3106
{
3107
    c[1] = c[3] = 0.0f;
3108

  
3109
    switch (get_bits(gb, 2)) {
3110
    case 0:
3111
        c[0] = 1.0f;
3112
        c[2] = get_float_val(gb);
3113
        c[4] = 1.0f;
3114
        break;
3115
    case 1:
3116
        c[0] = c[4] = get_float_val(gb);
3117
        c[2] = get_float_val(gb);
3118
        break;
3119
    case 2:
3120
        c[0] = get_float_val(gb);
3121
        c[2] = get_float_val(gb);
3122
        c[4] = get_float_val(gb);
3123
        break;
3124
    case 3:
3125
        av_log_ask_for_sample(v->s.avctx, NULL);
3126
        c[0] = get_float_val(gb);
3127
        c[1] = get_float_val(gb);
3128
        c[2] = get_float_val(gb);
3129
        c[3] = get_float_val(gb);
3130
        c[4] = get_float_val(gb);
3131
        break;
3132
    }
3133
    c[5] = get_float_val(gb);
3134
    if (get_bits1(gb))
3135
        c[6] = get_float_val(gb);
3136
    else
3137
        c[6] = 1.0f;
3138
}
3139

  
3140
static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb)
3141
{
3142
    int effect_type, effect_flag, effect_pcount1, effect_pcount2, i;
3143
    float effect_params1[14], effect_params2[10];
3144

  
3145
    float coefs[2][7];
3146
    vc1_sprite_parse_transform(v, gb, coefs[0]);
3147
    av_log(v->s.avctx, AV_LOG_DEBUG, "S1:");
3148
    for (i = 0; i < 7; i++)
3149
        av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", coefs[0][i]);
3150
    av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
3151

  
3152
    if (v->two_sprites) {
3153
        vc1_sprite_parse_transform(v, gb, coefs[1]);
3154
        av_log(v->s.avctx, AV_LOG_DEBUG, "S2:");
3155
        for (i = 0; i < 7; i++)
3156
            av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", coefs[1][i]);
3157
        av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
3158
    }
3159
    skip_bits(gb, 2);
3160
    if (effect_type = get_bits_long(gb, 30)){
3161
        switch (effect_pcount1 = get_bits(gb, 4)) {
3162
        case 2:
3163
            effect_params1[0] = get_float_val(gb);
3164
            effect_params1[1] = get_float_val(gb);
3165
            break;
3166
        case 7:
3167
            vc1_sprite_parse_transform(v, gb, effect_params1);
3168
            break;
3169
        case 14:
3170
            vc1_sprite_parse_transform(v, gb, effect_params1);
3171
            vc1_sprite_parse_transform(v, gb, &effect_params1[7]);
3172
            break;
3173
        default:
3174
            av_log_ask_for_sample(v->s.avctx, NULL);
3175
            return;
3176
        }
3177
        if (effect_type != 13 || effect_params1[0] != coefs[0][6]) {
3178
            // effect 13 is simple alpha blending and matches the opacity above
3179
            av_log(v->s.avctx, AV_LOG_DEBUG, "Effect: %d; params: ", effect_type);
3180
            for (i = 0; i < effect_pcount1; i++)
3181
                av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", effect_params1[i]);
3182
            av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
3183
        }
3184

  
3185
        effect_pcount2 = get_bits(gb, 16);
3186
        if (effect_pcount2 > 10) {
3187
            av_log(v->s.avctx, AV_LOG_ERROR, "Too many effect parameters\n");
3188
            return;
3189
        } else if (effect_pcount2) {
3190
            i = 0;
3191
            av_log(v->s.avctx, AV_LOG_DEBUG, "Effect params 2: ");
3192
            while (i < effect_pcount2){
3193
                effect_params2[i] = get_float_val(gb);
3194
                av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", effect_params2[i]);
3195
                i++;
3196
            }
3197
            av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
3198
        }
3199
    }
3200
    if (effect_flag = get_bits1(gb))
3201
        av_log(v->s.avctx, AV_LOG_DEBUG, "Effect flag set\n");
3202

  
3203
    if (get_bits_count(gb) >= gb->size_in_bits +
3204
       (v->s.avctx->codec_id == CODEC_ID_WMV3 ? 64 : 0))
3205
        av_log(v->s.avctx, AV_LOG_ERROR, "Buffer overrun\n");
3206
    if (get_bits_count(gb) < gb->size_in_bits - 8)
3207
        av_log(v->s.avctx, AV_LOG_WARNING, "Buffer not fully read\n");
3208
}
3209

  
3100 3210
/** Initialize a VC1/WMV3 decoder
3101 3211
 * @todo TODO: Handle VC-1 IDUs (Transport level?)
3102 3212
 * @todo TODO: Decypher remaining bits in extra_data
......
3160 3270
        {
3161 3271
            av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
3162 3272
        }
3163
    } else { // VC1/WVC1
3273
    } else { // VC1/WVC1/WVP2
3164 3274
        const uint8_t *start = avctx->extradata;
3165 3275
        uint8_t *end = avctx->extradata + avctx->extradata_size;
3166 3276
        const uint8_t *next;
......
3204 3314
            av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n");
3205 3315
            return -1;
3206 3316
        }
3317
        v->res_sprite = (avctx->codec_tag == MKTAG('W','V','P','2'));
3207 3318
    }
3208 3319
    avctx->profile = v->profile;
3209 3320
    if (v->profile == PROFILE_ADVANCED)
......
3359 3470
        init_get_bits(&s->gb, buf2, buf_size2*8);
3360 3471
    } else
3361 3472
        init_get_bits(&s->gb, buf, buf_size*8);
3473

  
3474
    if (v->res_sprite) {
3475
        v->new_sprite = !get_bits1(&s->gb);
3476
        v->two_sprites = get_bits1(&s->gb);
3477
        if (!v->new_sprite)
3478
            goto end;
3479
    }
3480

  
3362 3481
    // do parse frame header
3363 3482
    if(v->profile < PROFILE_ADVANCED) {
3364 3483
        if(vc1_parse_frame_header(v, &s->gb) == -1) {
......
3370 3489
        }
3371 3490
    }
3372 3491

  
3373
    if(v->res_sprite && (s->pict_type!=FF_I_TYPE)){
3374
        goto err;
3492
    if (v->res_sprite && s->pict_type!=FF_I_TYPE) {
3493
        av_log(v->s.avctx, AV_LOG_WARNING, "Sprite decoder: expected I-frame\n");
3375 3494
    }
3376 3495

  
3377 3496
    // for skipping the frame
......
3455 3574
    }
3456 3575

  
3457 3576
end:
3577
    if (v->res_sprite)
3578
        vc1_parse_sprites(v, &s->gb);
3458 3579
    av_free(buf2);
3459 3580
    for (i = 0; i < n_slices; i++)
3460 3581
        av_free(slices[i].buf);
libavcodec/version.h
22 22

  
23 23
#define LIBAVCODEC_VERSION_MAJOR 52
24 24
#define LIBAVCODEC_VERSION_MINOR 117
25
#define LIBAVCODEC_VERSION_MICRO  0
25
#define LIBAVCODEC_VERSION_MICRO  1
26 26

  
27 27
#define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
28 28
                                               LIBAVCODEC_VERSION_MINOR, \
libavformat/riff.c
232 232
    { CODEC_ID_WMV3,         MKTAG('W', 'M', 'V', 'P') },
233 233
    { CODEC_ID_VC1,          MKTAG('W', 'V', 'C', '1') },
234 234
    { CODEC_ID_VC1,          MKTAG('W', 'M', 'V', 'A') },
235
    { CODEC_ID_VC1,          MKTAG('W', 'V', 'P', '2') },
235 236
    { CODEC_ID_LOCO,         MKTAG('L', 'O', 'C', 'O') },
236 237
    { CODEC_ID_WNV1,         MKTAG('W', 'N', 'V', '1') },
237 238
    { CODEC_ID_AASC,         MKTAG('A', 'A', 'S', 'C') },

Also available in: Unified diff