~ubuntu-branches/ubuntu/raring/libav/raring-security

« back to all changes in this revision

Viewing changes to libavcodec/wavpack.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2011-09-28 09:18:34 UTC
  • mfrom: (1.3.7 sid)
  • Revision ID: package-import@ubuntu.com-20110928091834-w415mnuh06h4zpvc
Tags: 4:0.7.1-7ubuntu2
Revert "Convert package to include multiarch support."

Show diffs side-by-side

added added

removed removed

Lines of Context:
292
292
            }
293
293
        }else{
294
294
            t = get_unary_0_33(gb);
295
 
            if(t >= 2) t = get_bits(gb, t - 1) | (1 << (t-1));
 
295
            if(t >= 2){
 
296
                if(get_bits_left(gb) < t-1)
 
297
                    goto error;
 
298
                t = get_bits(gb, t - 1) | (1 << (t-1));
 
299
            }else{
 
300
                if(get_bits_left(gb) < 0)
 
301
                    goto error;
 
302
            }
296
303
            ctx->zeroes = t;
297
304
            if(ctx->zeroes){
298
305
                memset(ctx->ch[0].median, 0, sizeof(ctx->ch[0].median));
303
310
        }
304
311
    }
305
312
 
306
 
    if(get_bits_count(gb) >= ctx->data_size){
307
 
        *last = 1;
308
 
        return 0;
309
 
    }
310
 
 
311
313
    if(ctx->zero){
312
314
        t = 0;
313
315
        ctx->zero = 0;
314
316
    }else{
315
317
        t = get_unary_0_33(gb);
316
 
        if(get_bits_count(gb) >= ctx->data_size){
317
 
            *last = 1;
318
 
            return 0;
319
 
        }
 
318
        if(get_bits_left(gb) < 0)
 
319
            goto error;
320
320
        if(t == 16) {
321
321
            t2 = get_unary_0_33(gb);
322
 
            if(t2 < 2) t += t2;
323
 
            else t += get_bits(gb, t2 - 1) | (1 << (t2 - 1));
 
322
            if(t2 < 2){
 
323
                if(get_bits_left(gb) < 0)
 
324
                    goto error;
 
325
                t += t2;
 
326
            }else{
 
327
                if(get_bits_left(gb) < t2 - 1)
 
328
                    goto error;
 
329
                t += get_bits(gb, t2 - 1) | (1 << (t2 - 1));
 
330
            }
324
331
        }
325
332
 
326
333
        if(ctx->one){
360
367
    }
361
368
    if(!c->error_limit){
362
369
        ret = base + get_tail(gb, add);
 
370
        if (get_bits_left(gb) <= 0)
 
371
            goto error;
363
372
    }else{
364
373
        int mid = (base*2 + add + 1) >> 1;
365
374
        while(add > c->error_limit){
 
375
            if(get_bits_left(gb) <= 0)
 
376
                goto error;
366
377
            if(get_bits1(gb)){
367
378
                add -= (mid - base);
368
379
                base = mid;
376
387
    if(ctx->hybrid_bitrate)
377
388
        c->slow_level += wp_log2(ret) - LEVEL_DECAY(c->slow_level);
378
389
    return sign ? ~ret : ret;
 
390
 
 
391
error:
 
392
    *last = 1;
 
393
    return 0;
379
394
}
380
395
 
381
396
static inline int wv_get_value_integer(WavpackFrameContext *s, uint32_t *crc, int S)
385
400
    if(s->extra_bits){
386
401
        S <<= s->extra_bits;
387
402
 
388
 
        if(s->got_extra_bits){
 
403
        if(s->got_extra_bits && get_bits_left(&s->gb_extra_bits) >= s->extra_bits){
389
404
            S |= get_bits(&s->gb_extra_bits, s->extra_bits);
390
405
            *crc = *crc * 9 + (S&0xffff) * 3 + ((unsigned)S>>16);
391
406
        }
580
595
        count++;
581
596
    }while(!last && count < s->max_samples);
582
597
 
583
 
    s->samples_left -= count;
 
598
    if (last)
 
599
        s->samples_left = 0;
 
600
    else
 
601
        s->samples_left -= count;
584
602
    if(!s->samples_left){
585
603
        if(crc != s->CRC){
586
604
            av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
658
676
        count++;
659
677
    }while(!last && count < s->max_samples);
660
678
 
661
 
    s->samples_left -= count;
 
679
    if (last)
 
680
        s->samples_left = 0;
 
681
    else
 
682
        s->samples_left -= count;
662
683
    if(!s->samples_left){
663
684
        if(crc != s->CRC){
664
685
            av_log(s->avctx, AV_LOG_ERROR, "CRC error\n");
841
862
        }
842
863
        switch(id & WP_IDF_MASK){
843
864
        case WP_ID_DECTERMS:
 
865
            if(size > MAX_TERMS){
 
866
                av_log(avctx, AV_LOG_ERROR, "Too many decorrelation terms\n");
 
867
                s->terms = 0;
 
868
                buf += ssize;
 
869
                continue;
 
870
            }
844
871
            s->terms = size;
845
 
            if(s->terms > MAX_TERMS){
846
 
                av_log(avctx, AV_LOG_ERROR, "Too many decorrelation terms\n");
847
 
                buf += ssize;
848
 
                continue;
849
 
            }
850
872
            for(i = 0; i < s->terms; i++) {
851
873
                s->decorr[s->terms - i - 1].value = (*buf & 0x1F) - 5;
852
874
                s->decorr[s->terms - i - 1].delta = *buf >> 5;
1098
1120
            samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_S32);
1099
1121
        else
1100
1122
            samplecount = wv_unpack_stereo(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
 
1123
 
 
1124
        if (samplecount < 0)
 
1125
            return -1;
 
1126
 
1101
1127
        samplecount >>= 1;
1102
1128
    }else{
1103
1129
        const int channel_stride = avctx->channels;
1109
1135
        else
1110
1136
            samplecount = wv_unpack_mono(s, &s->gb, samples, AV_SAMPLE_FMT_FLT);
1111
1137
 
 
1138
        if (samplecount < 0)
 
1139
            return -1;
 
1140
 
1112
1141
        if(s->stereo && avctx->sample_fmt == AV_SAMPLE_FMT_S16){
1113
1142
            int16_t *dst = (int16_t*)samples + 1;
1114
1143
            int16_t *src = (int16_t*)samples;