comparison alac.c @ 5361:3c0a5cb7fc6b libavcodec

Cosmetics: indentation
author vitor
date Wed, 18 Jul 2007 06:27:37 +0000
parents 6648c82e15c7
children e0b7c248c33e
comparison
equal deleted inserted replaced
5360:6648c82e15c7 5361:3c0a5cb7fc6b
490 490
491 init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8); 491 init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
492 492
493 channels = get_bits(&alac->gb, 3) + 1; 493 channels = get_bits(&alac->gb, 3) + 1;
494 494
495 /* 2^result = something to do with output waiting. 495 /* 2^result = something to do with output waiting.
496 * perhaps matters if we read > 1 frame in a pass? 496 * perhaps matters if we read > 1 frame in a pass?
497 */ 497 */
498 get_bits(&alac->gb, 4); 498 get_bits(&alac->gb, 4);
499 499
500 get_bits(&alac->gb, 12); /* unknown, skip 12 bits */ 500 get_bits(&alac->gb, 12); /* unknown, skip 12 bits */
501 501
502 hassize = get_bits(&alac->gb, 1); /* the output sample size is stored soon */ 502 /* the output sample size is stored soon */
503 503 hassize = get_bits(&alac->gb, 1);
504 wasted_bytes = get_bits(&alac->gb, 2); /* unknown ? */ 504
505 505 wasted_bytes = get_bits(&alac->gb, 2); /* unknown ? */
506 isnotcompressed = get_bits(&alac->gb, 1); /* whether the frame is compressed */ 506
507 507 /* whether the frame is compressed */
508 if (hassize) { 508 isnotcompressed = get_bits(&alac->gb, 1);
509 /* now read the number of samples, 509
510 * as a 32bit integer */ 510 if (hassize) {
511 outputsamples = get_bits(&alac->gb, 32); 511 /* now read the number of samples as a 32bit integer */
512 } else 512 outputsamples = get_bits(&alac->gb, 32);
513 outputsamples = alac->setinfo_max_samples_per_frame; 513 } else
514 514 outputsamples = alac->setinfo_max_samples_per_frame;
515 *outputsize = outputsamples * alac->bytespersample; 515
516 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + channels - 1; 516 *outputsize = outputsamples * alac->bytespersample;
517 517 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + channels - 1;
518 if (!isnotcompressed) { 518
519 /* so it is compressed */ 519 if (!isnotcompressed) {
520 int16_t predictor_coef_table[channels][32]; 520 /* so it is compressed */
521 int predictor_coef_num[channels]; 521 int16_t predictor_coef_table[channels][32];
522 int prediction_type[channels]; 522 int predictor_coef_num[channels];
523 int prediction_quantitization[channels]; 523 int prediction_type[channels];
524 int ricemodifier[channels]; 524 int prediction_quantitization[channels];
525 525 int ricemodifier[channels];
526 int i, chan; 526 int i, chan;
527 527
528 interlacing_shift = get_bits(&alac->gb, 8); 528 interlacing_shift = get_bits(&alac->gb, 8);
529 interlacing_leftweight = get_bits(&alac->gb, 8); 529 interlacing_leftweight = get_bits(&alac->gb, 8);
530 530
531 for (chan = 0; chan < channels; chan++) { 531 for (chan = 0; chan < channels; chan++) {
532 prediction_type[chan] = get_bits(&alac->gb, 4); 532 prediction_type[chan] = get_bits(&alac->gb, 4);
533 prediction_quantitization[chan] = get_bits(&alac->gb, 4); 533 prediction_quantitization[chan] = get_bits(&alac->gb, 4);
534 534
535 ricemodifier[chan] = get_bits(&alac->gb, 3); 535 ricemodifier[chan] = get_bits(&alac->gb, 3);
536 predictor_coef_num[chan] = get_bits(&alac->gb, 5); 536 predictor_coef_num[chan] = get_bits(&alac->gb, 5);
537 537
538 /* read the predictor table */ 538 /* read the predictor table */
539 for (i = 0; i < predictor_coef_num[chan]; i++) { 539 for (i = 0; i < predictor_coef_num[chan]; i++) {
540 predictor_coef_table[chan][i] = (int16_t)get_bits(&alac->gb, 16); 540 predictor_coef_table[chan][i] = (int16_t)get_bits(&alac->gb, 16);
541 } 541 }
542 } 542 }
543 543
544 if (wasted_bytes) { 544 if (wasted_bytes) {
545 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n"); 545 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n");
546 } 546 }
547 547
548 for (chan = 0; chan < channels; chan++) { 548 for (chan = 0; chan < channels; chan++) {
549 bastardized_rice_decompress(alac, 549 bastardized_rice_decompress(alac,
550 alac->predicterror_buffer[chan], 550 alac->predicterror_buffer[chan],
551 outputsamples, 551 outputsamples,
552 readsamplesize, 552 readsamplesize,
553 alac->setinfo_rice_initialhistory, 553 alac->setinfo_rice_initialhistory,
554 alac->setinfo_rice_kmodifier, 554 alac->setinfo_rice_kmodifier,
555 ricemodifier[chan] * alac->setinfo_rice_historymult / 4, 555 ricemodifier[chan] * alac->setinfo_rice_historymult / 4,
556 (1 << alac->setinfo_rice_kmodifier) - 1); 556 (1 << alac->setinfo_rice_kmodifier) - 1);
557 557
558 if (prediction_type[chan] == 0) { 558 if (prediction_type[chan] == 0) {
559 /* adaptive fir */ 559 /* adaptive fir */
560 predictor_decompress_fir_adapt(alac->predicterror_buffer[chan], 560 predictor_decompress_fir_adapt(alac->predicterror_buffer[chan],
561 alac->outputsamples_buffer[chan], 561 alac->outputsamples_buffer[chan],
562 outputsamples, 562 outputsamples,
563 readsamplesize, 563 readsamplesize,
564 predictor_coef_table[chan], 564 predictor_coef_table[chan],
571 * predictor_decompress_fir_adapt(predictor_error, tempout, ...) 571 * predictor_decompress_fir_adapt(predictor_error, tempout, ...)
572 * predictor_decompress_fir_adapt(predictor_error, outputsamples ...) 572 * predictor_decompress_fir_adapt(predictor_error, outputsamples ...)
573 * little strange.. 573 * little strange..
574 */ 574 */
575 } 575 }
576 } 576 }
577 } else { 577 } else {
578 /* not compressed, easy case */ 578 /* not compressed, easy case */
579 if (alac->setinfo_sample_size <= 16) { 579 if (alac->setinfo_sample_size <= 16) {
580 int i, chan; 580 int i, chan;
581 for (chan = 0; chan < channels; chan++) { 581 for (chan = 0; chan < channels; chan++) {
582 for (i = 0; i < outputsamples; i++) { 582 for (i = 0; i < outputsamples; i++) {
583 int32_t audiobits; 583 int32_t audiobits;
584 584
585 audiobits = get_bits(&alac->gb, alac->setinfo_sample_size); 585 audiobits = get_bits(&alac->gb, alac->setinfo_sample_size);
586 audiobits = SIGN_EXTENDED32(audiobits, readsamplesize); 586 audiobits = SIGN_EXTENDED32(audiobits, readsamplesize);
587 587
588 alac->outputsamples_buffer[chan][i] = audiobits; 588 alac->outputsamples_buffer[chan][i] = audiobits;
589 } 589 }
590 } 590 }
591 } else { 591 } else {
592 int i, chan; 592 int i, chan;
593 for (chan = 0; chan < channels; chan++) { 593 for (chan = 0; chan < channels; chan++) {
594 for (i = 0; i < outputsamples; i++) { 594 for (i = 0; i < outputsamples; i++) {
595 int32_t audiobits; 595 int32_t audiobits;
596 596
597 audiobits = get_bits(&alac->gb, 16); 597 audiobits = get_bits(&alac->gb, 16);
598 /* special case of sign extension.. 598 /* special case of sign extension..
601 audiobits = audiobits >> (32 - alac->setinfo_sample_size); 601 audiobits = audiobits >> (32 - alac->setinfo_sample_size);
602 audiobits |= get_bits(&alac->gb, alac->setinfo_sample_size - 16); 602 audiobits |= get_bits(&alac->gb, alac->setinfo_sample_size - 16);
603 603
604 alac->outputsamples_buffer[chan][i] = audiobits; 604 alac->outputsamples_buffer[chan][i] = audiobits;
605 } 605 }
606 } 606 }
607 } 607 }
608 /* wasted_bytes = 0; */ 608 /* wasted_bytes = 0; */
609 interlacing_shift = 0; 609 interlacing_shift = 0;
610 interlacing_leftweight = 0; 610 interlacing_leftweight = 0;
611 } 611 }
612 612
613 switch(alac->setinfo_sample_size) { 613 switch(alac->setinfo_sample_size) {
614 case 16: { 614 case 16: {
615 if (channels == 2) { 615 if (channels == 2) {
616 deinterlace_16(alac->outputsamples_buffer[0], 616 deinterlace_16(alac->outputsamples_buffer[0],
617 alac->outputsamples_buffer[1], 617 alac->outputsamples_buffer[1],
618 (int16_t*)outbuffer, 618 (int16_t*)outbuffer,
619 alac->numchannels, 619 alac->numchannels,
620 outputsamples, 620 outputsamples,
621 interlacing_shift, 621 interlacing_shift,
622 interlacing_leftweight); 622 interlacing_leftweight);
623 } else { 623 } else {
624 int i; 624 int i;
625 for (i = 0; i < outputsamples; i++) { 625 for (i = 0; i < outputsamples; i++) {
626 int16_t sample = alac->outputsamples_buffer[0][i]; 626 int16_t sample = alac->outputsamples_buffer[0][i];
627 ((int16_t*)outbuffer)[i * alac->numchannels] = sample; 627 ((int16_t*)outbuffer)[i * alac->numchannels] = sample;
628 } 628 }
629 } 629 }
630 break; 630 break;
631 } 631 }
632 case 20: 632 case 20:
633 case 24: 633 case 24:
634 case 32: 634 case 32:
635 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size); 635 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size);
636 break; 636 break;
637 default: 637 default:
638 break; 638 break;
639 } 639 }
640
641 640
642 return input_buffer_size; 641 return input_buffer_size;
643 } 642 }
644 643
645 static int alac_decode_init(AVCodecContext * avctx) 644 static int alac_decode_init(AVCodecContext * avctx)