comparison alac.c @ 5271:289e5c2a9c98 libavcodec

Remove some duplicated code
author vitor
date Tue, 10 Jul 2007 13:32:22 +0000
parents 8256f8ec2fac
children b51c25603164
comparison
equal deleted inserted replaced
5270:5e6d44208f91 5271:289e5c2a9c98
458 { 458 {
459 ALACContext *alac = avctx->priv_data; 459 ALACContext *alac = avctx->priv_data;
460 460
461 int channels; 461 int channels;
462 int32_t outputsamples; 462 int32_t outputsamples;
463 int hassize;
464 int readsamplesize;
465 int wasted_bytes;
466 int isnotcompressed;
463 467
464 /* short-circuit null buffers */ 468 /* short-circuit null buffers */
465 if (!inbuffer || !input_buffer_size) 469 if (!inbuffer || !input_buffer_size)
466 return input_buffer_size; 470 return input_buffer_size;
467 471
477 return input_buffer_size; 481 return input_buffer_size;
478 } 482 }
479 alac->context_initialized = 1; 483 alac->context_initialized = 1;
480 } 484 }
481 485
482 outputsamples = alac->setinfo_max_samples_per_frame;
483
484 init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8); 486 init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
485 487
486 channels = get_bits(&alac->gb, 3); 488 channels = get_bits(&alac->gb, 3);
487
488 *outputsize = outputsamples * alac->bytespersample;
489
490 switch(channels) {
491 case 0: { /* 1 channel */
492 int hassize;
493 int isnotcompressed;
494 int readsamplesize;
495
496 int wasted_bytes;
497 int ricemodifier;
498
499 489
500 /* 2^result = something to do with output waiting. 490 /* 2^result = something to do with output waiting.
501 * perhaps matters if we read > 1 frame in a pass? 491 * perhaps matters if we read > 1 frame in a pass?
502 */ 492 */
503 get_bits(&alac->gb, 4); 493 get_bits(&alac->gb, 4);
512 502
513 if (hassize) { 503 if (hassize) {
514 /* now read the number of samples, 504 /* now read the number of samples,
515 * as a 32bit integer */ 505 * as a 32bit integer */
516 outputsamples = get_bits(&alac->gb, 32); 506 outputsamples = get_bits(&alac->gb, 32);
517 *outputsize = outputsamples * alac->bytespersample; 507 } else
518 } 508 outputsamples = alac->setinfo_max_samples_per_frame;
519 509
520 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8); 510 *outputsize = outputsamples * alac->bytespersample;
511 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + channels;
512
513 switch(channels) {
514 case 0: { /* 1 channel */
515 int ricemodifier;
521 516
522 if (!isnotcompressed) { 517 if (!isnotcompressed) {
523 /* so it is compressed */ 518 /* so it is compressed */
524 int16_t predictor_coef_table[32]; 519 int16_t predictor_coef_table[32];
525 int predictor_coef_num; 520 int predictor_coef_num;
626 break; 621 break;
627 } 622 }
628 break; 623 break;
629 } 624 }
630 case 1: { /* 2 channels */ 625 case 1: { /* 2 channels */
631 int hassize;
632 int isnotcompressed;
633 int readsamplesize;
634
635 int wasted_bytes;
636
637 uint8_t interlacing_shift; 626 uint8_t interlacing_shift;
638 uint8_t interlacing_leftweight; 627 uint8_t interlacing_leftweight;
639
640 /* 2^result = something to do with output waiting.
641 * perhaps matters if we read > 1 frame in a pass?
642 */
643 get_bits(&alac->gb, 4);
644
645 get_bits(&alac->gb, 12); /* unknown, skip 12 bits */
646
647 hassize = get_bits(&alac->gb, 1); /* the output sample size is stored soon */
648
649 wasted_bytes = get_bits(&alac->gb, 2); /* unknown ? */
650
651 isnotcompressed = get_bits(&alac->gb, 1); /* whether the frame is compressed */
652
653 if (hassize) {
654 /* now read the number of samples,
655 * as a 32bit integer */
656 outputsamples = get_bits(&alac->gb, 32);
657 *outputsize = outputsamples * alac->bytespersample;
658 }
659
660 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + 1;
661 628
662 if (!isnotcompressed) { 629 if (!isnotcompressed) {
663 /* compressed */ 630 /* compressed */
664 int16_t predictor_coef_table_a[32]; 631 int16_t predictor_coef_table_a[32];
665 int predictor_coef_num_a; 632 int predictor_coef_num_a;