comparison flacdec.c @ 9229:aec6d4ca45a3 libavcodec

flacdec: cosmetics: rename 3 variables
author jbr
date Sun, 22 Mar 2009 18:56:07 +0000
parents 2b7bc08cf831
children 35370ebfbeeb
comparison
equal deleted inserted replaced
9228:2b7bc08cf831 9229:aec6d4ca45a3
480 return 0; 480 return 0;
481 } 481 }
482 482
483 static int decode_frame(FLACContext *s, int alloc_data_size) 483 static int decode_frame(FLACContext *s, int alloc_data_size)
484 { 484 {
485 int blocksize_code, sample_rate_code, sample_size_code, i, crc8; 485 int bs_code, sr_code, bps_code, i, crc8;
486 int ch_mode, bps, blocksize, samplerate; 486 int ch_mode, bps, blocksize, samplerate;
487 GetBitContext *gb = &s->gb; 487 GetBitContext *gb = &s->gb;
488 488
489 blocksize_code = get_bits(gb, 4); 489 bs_code = get_bits(gb, 4);
490 490
491 sample_rate_code = get_bits(gb, 4); 491 sr_code = get_bits(gb, 4);
492 492
493 ch_mode = get_bits(gb, 4); /* channel assignment */ 493 ch_mode = get_bits(gb, 4); /* channel assignment */
494 if (ch_mode < FLAC_MAX_CHANNELS && s->channels == ch_mode+1) { 494 if (ch_mode < FLAC_MAX_CHANNELS && s->channels == ch_mode+1) {
495 ch_mode = FLAC_CHMODE_INDEPENDENT; 495 ch_mode = FLAC_CHMODE_INDEPENDENT;
496 } else if (ch_mode > FLAC_CHMODE_MID_SIDE || s->channels != 2) { 496 } else if (ch_mode > FLAC_CHMODE_MID_SIDE || s->channels != 2) {
497 av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n", 497 av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n",
498 ch_mode, s->channels); 498 ch_mode, s->channels);
499 return -1; 499 return -1;
500 } 500 }
501 501
502 sample_size_code = get_bits(gb, 3); 502 bps_code = get_bits(gb, 3);
503 if (sample_size_code == 0) 503 if (bps_code == 0)
504 bps= s->bps; 504 bps= s->bps;
505 else if ((sample_size_code != 3) && (sample_size_code != 7)) 505 else if ((bps_code != 3) && (bps_code != 7))
506 bps = sample_size_table[sample_size_code]; 506 bps = sample_size_table[bps_code];
507 else { 507 else {
508 av_log(s->avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n", 508 av_log(s->avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n",
509 sample_size_code); 509 bps_code);
510 return -1; 510 return -1;
511 } 511 }
512 if (bps > 16) { 512 if (bps > 16) {
513 s->avctx->sample_fmt = SAMPLE_FMT_S32; 513 s->avctx->sample_fmt = SAMPLE_FMT_S32;
514 s->sample_shift = 32 - bps; 514 s->sample_shift = 32 - bps;
528 if (get_utf8(gb) < 0) { 528 if (get_utf8(gb) < 0) {
529 av_log(s->avctx, AV_LOG_ERROR, "utf8 fscked\n"); 529 av_log(s->avctx, AV_LOG_ERROR, "utf8 fscked\n");
530 return -1; 530 return -1;
531 } 531 }
532 532
533 if (blocksize_code == 0) { 533 if (bs_code == 0) {
534 av_log(s->avctx, AV_LOG_ERROR, "reserved blocksize code: 0\n"); 534 av_log(s->avctx, AV_LOG_ERROR, "reserved blocksize code: 0\n");
535 return -1; 535 return -1;
536 } else if (blocksize_code == 6) 536 } else if (bs_code == 6)
537 blocksize = get_bits(gb, 8)+1; 537 blocksize = get_bits(gb, 8)+1;
538 else if (blocksize_code == 7) 538 else if (bs_code == 7)
539 blocksize = get_bits(gb, 16)+1; 539 blocksize = get_bits(gb, 16)+1;
540 else 540 else
541 blocksize = ff_flac_blocksize_table[blocksize_code]; 541 blocksize = ff_flac_blocksize_table[bs_code];
542 542
543 if (blocksize > s->max_blocksize) { 543 if (blocksize > s->max_blocksize) {
544 av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", blocksize, 544 av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", blocksize,
545 s->max_blocksize); 545 s->max_blocksize);
546 return -1; 546 return -1;
547 } 547 }
548 548
549 if (blocksize * s->channels * (s->is32 ? 4 : 2) > alloc_data_size) 549 if (blocksize * s->channels * (s->is32 ? 4 : 2) > alloc_data_size)
550 return -1; 550 return -1;
551 551
552 if (sample_rate_code == 0) 552 if (sr_code == 0)
553 samplerate= s->samplerate; 553 samplerate= s->samplerate;
554 else if (sample_rate_code < 12) 554 else if (sr_code < 12)
555 samplerate = ff_flac_sample_rate_table[sample_rate_code]; 555 samplerate = ff_flac_sample_rate_table[sr_code];
556 else if (sample_rate_code == 12) 556 else if (sr_code == 12)
557 samplerate = get_bits(gb, 8) * 1000; 557 samplerate = get_bits(gb, 8) * 1000;
558 else if (sample_rate_code == 13) 558 else if (sr_code == 13)
559 samplerate = get_bits(gb, 16); 559 samplerate = get_bits(gb, 16);
560 else if (sample_rate_code == 14) 560 else if (sr_code == 14)
561 samplerate = get_bits(gb, 16) * 10; 561 samplerate = get_bits(gb, 16) * 10;
562 else { 562 else {
563 av_log(s->avctx, AV_LOG_ERROR, "illegal sample rate code %d\n", 563 av_log(s->avctx, AV_LOG_ERROR, "illegal sample rate code %d\n",
564 sample_rate_code); 564 sr_code);
565 return -1; 565 return -1;
566 } 566 }
567 567
568 skip_bits(gb, 8); 568 skip_bits(gb, 8);
569 crc8 = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, 569 crc8 = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0,