Revision 7e00bd84

View differences:

libavcodec/flacdec.c
484 484
{
485 485
    int blocksize_code, sample_rate_code, sample_size_code, i, crc8;
486 486
    int ch_mode, bps, blocksize, samplerate;
487
    GetBitContext *gb = &s->gb;
487 488

  
488
    blocksize_code = get_bits(&s->gb, 4);
489
    blocksize_code = get_bits(gb, 4);
489 490

  
490
    sample_rate_code = get_bits(&s->gb, 4);
491
    sample_rate_code = get_bits(gb, 4);
491 492

  
492
    ch_mode = get_bits(&s->gb, 4); /* channel assignment */
493
    ch_mode = get_bits(gb, 4); /* channel assignment */
493 494
    if (ch_mode < FLAC_MAX_CHANNELS && s->channels == ch_mode+1) {
494 495
        ch_mode = FLAC_CHMODE_INDEPENDENT;
495 496
    } else if (ch_mode > FLAC_CHMODE_MID_SIDE || s->channels != 2) {
......
498 499
        return -1;
499 500
    }
500 501

  
501
    sample_size_code = get_bits(&s->gb, 3);
502
    sample_size_code = get_bits(gb, 3);
502 503
    if (sample_size_code == 0)
503 504
        bps= s->bps;
504 505
    else if ((sample_size_code != 3) && (sample_size_code != 7))
......
519 520
    }
520 521
    s->bps = s->avctx->bits_per_raw_sample = bps;
521 522

  
522
    if (get_bits1(&s->gb)) {
523
    if (get_bits1(gb)) {
523 524
        av_log(s->avctx, AV_LOG_ERROR, "broken stream, invalid padding\n");
524 525
        return -1;
525 526
    }
526 527

  
527
    if (get_utf8(&s->gb) < 0) {
528
    if (get_utf8(gb) < 0) {
528 529
        av_log(s->avctx, AV_LOG_ERROR, "utf8 fscked\n");
529 530
        return -1;
530 531
    }
......
533 534
        av_log(s->avctx, AV_LOG_ERROR, "reserved blocksize code: 0\n");
534 535
        return -1;
535 536
    } else if (blocksize_code == 6)
536
        blocksize = get_bits(&s->gb, 8)+1;
537
        blocksize = get_bits(gb, 8)+1;
537 538
    else if (blocksize_code == 7)
538
        blocksize = get_bits(&s->gb, 16)+1;
539
        blocksize = get_bits(gb, 16)+1;
539 540
    else
540 541
        blocksize = ff_flac_blocksize_table[blocksize_code];
541 542

  
......
553 554
    else if (sample_rate_code < 12)
554 555
        samplerate = ff_flac_sample_rate_table[sample_rate_code];
555 556
    else if (sample_rate_code == 12)
556
        samplerate = get_bits(&s->gb, 8) * 1000;
557
        samplerate = get_bits(gb, 8) * 1000;
557 558
    else if (sample_rate_code == 13)
558
        samplerate = get_bits(&s->gb, 16);
559
        samplerate = get_bits(gb, 16);
559 560
    else if (sample_rate_code == 14)
560
        samplerate = get_bits(&s->gb, 16) * 10;
561
        samplerate = get_bits(gb, 16) * 10;
561 562
    else {
562 563
        av_log(s->avctx, AV_LOG_ERROR, "illegal sample rate code %d\n",
563 564
               sample_rate_code);
564 565
        return -1;
565 566
    }
566 567

  
567
    skip_bits(&s->gb, 8);
568
    skip_bits(gb, 8);
568 569
    crc8 = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0,
569
                  s->gb.buffer, get_bits_count(&s->gb)/8);
570
                  gb->buffer, get_bits_count(gb)/8);
570 571
    if (crc8) {
571 572
        av_log(s->avctx, AV_LOG_ERROR, "header crc mismatch crc=%2X\n", crc8);
572 573
        return -1;
......
585 586
            return -1;
586 587
    }
587 588

  
588
    align_get_bits(&s->gb);
589
    align_get_bits(gb);
589 590

  
590 591
    /* frame footer */
591
    skip_bits(&s->gb, 16); /* data crc */
592
    skip_bits(gb, 16); /* data crc */
592 593

  
593 594
    return 0;
594 595
}

Also available in: Unified diff