Mercurial > libavcodec.hg
comparison alac.c @ 3135:41a01cea8885 libavcodec
explain extradata and pass avctx to av_log's
author | alex |
---|---|
date | Tue, 21 Feb 2006 00:03:10 +0000 |
parents | cc0357a90e8f |
children | 32e634e0d5cc |
comparison
equal
deleted
inserted
replaced
3134:03af25454cc3 | 3135:41a01cea8885 |
---|---|
30 * passed through the extradata[_size] fields. This atom is tacked onto | 30 * passed through the extradata[_size] fields. This atom is tacked onto |
31 * the end of an 'alac' stsd atom and has the following format: | 31 * the end of an 'alac' stsd atom and has the following format: |
32 * bytes 0-3 atom size (0x24), big-endian | 32 * bytes 0-3 atom size (0x24), big-endian |
33 * bytes 4-7 atom type ('alac', not the 'alac' tag from start of stsd) | 33 * bytes 4-7 atom type ('alac', not the 'alac' tag from start of stsd) |
34 * bytes 8-35 data bytes needed by decoder | 34 * bytes 8-35 data bytes needed by decoder |
35 * | |
36 * Extradata: | |
37 * 32bit size | |
38 * 32bit tag (=alac) | |
39 * 32bit zero? | |
40 * 32bit max sample per frame | |
41 * 8bit ?? (zero?) | |
42 * 8bit sample size | |
43 * 8bit history mult | |
44 * 8bit initial history | |
45 * 8bit kmodifier | |
46 * 8bit channels? | |
47 * 16bit ?? | |
48 * 32bit max coded frame size | |
49 * 32bit bitrate? | |
50 * 32bit samplerate | |
35 */ | 51 */ |
36 | 52 |
37 | 53 |
38 #include "avcodec.h" | 54 #include "avcodec.h" |
39 #include "bitstream.h" | 55 #include "bitstream.h" |
97 alac->setinfo_7a = *ptr++; | 113 alac->setinfo_7a = *ptr++; |
98 alac->setinfo_sample_size = *ptr++; | 114 alac->setinfo_sample_size = *ptr++; |
99 alac->setinfo_rice_historymult = *ptr++; | 115 alac->setinfo_rice_historymult = *ptr++; |
100 alac->setinfo_rice_initialhistory = *ptr++; | 116 alac->setinfo_rice_initialhistory = *ptr++; |
101 alac->setinfo_rice_kmodifier = *ptr++; | 117 alac->setinfo_rice_kmodifier = *ptr++; |
102 alac->setinfo_7f = *ptr++; | 118 alac->setinfo_7f = *ptr++; // channels? |
103 alac->setinfo_80 = BE_16(ptr); | 119 alac->setinfo_80 = BE_16(ptr); |
104 ptr += 2; | 120 ptr += 2; |
105 alac->setinfo_82 = BE_32(ptr); | 121 alac->setinfo_82 = BE_32(ptr); // max coded frame size |
106 ptr += 4; | 122 ptr += 4; |
107 alac->setinfo_86 = BE_32(ptr); | 123 alac->setinfo_86 = BE_32(ptr); // bitrate ? |
108 ptr += 4; | 124 ptr += 4; |
109 alac->setinfo_8a_rate = BE_32(ptr); | 125 alac->setinfo_8a_rate = BE_32(ptr); // samplerate |
110 ptr += 4; | 126 ptr += 4; |
111 | 127 |
112 allocate_buffers(alac); | 128 allocate_buffers(alac); |
113 } | 129 } |
114 | 130 |
442 return input_buffer_size; | 458 return input_buffer_size; |
443 | 459 |
444 /* initialize from the extradata */ | 460 /* initialize from the extradata */ |
445 if (!alac->context_initialized) { | 461 if (!alac->context_initialized) { |
446 if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) { | 462 if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) { |
447 av_log(NULL, AV_LOG_ERROR, "alac: expected %d extradata bytes\n", | 463 av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n", |
448 ALAC_EXTRADATA_SIZE); | 464 ALAC_EXTRADATA_SIZE); |
449 return input_buffer_size; | 465 return input_buffer_size; |
450 } | 466 } |
451 alac_set_info(alac); | 467 alac_set_info(alac); |
452 alac->context_initialized = 1; | 468 alac->context_initialized = 1; |
498 int predictor_coef_num; | 514 int predictor_coef_num; |
499 int prediction_type; | 515 int prediction_type; |
500 int prediction_quantitization; | 516 int prediction_quantitization; |
501 int i; | 517 int i; |
502 | 518 |
503 /* skip 16 bits, not sure what they are. seem to be used in | 519 /* FIXME: skip 16 bits, not sure what they are. seem to be used in |
504 * two channel case */ | 520 * two channel case */ |
505 get_bits(&alac->gb, 8); | 521 get_bits(&alac->gb, 8); |
506 get_bits(&alac->gb, 8); | 522 get_bits(&alac->gb, 8); |
507 | 523 |
508 prediction_type = get_bits(&alac->gb, 4); | 524 prediction_type = get_bits(&alac->gb, 4); |
518 | 534 |
519 if (wasted_bytes) { | 535 if (wasted_bytes) { |
520 /* these bytes seem to have something to do with | 536 /* these bytes seem to have something to do with |
521 * > 2 channel files. | 537 * > 2 channel files. |
522 */ | 538 */ |
523 av_log(NULL, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n"); | 539 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n"); |
524 } | 540 } |
525 | 541 |
526 bastardized_rice_decompress(alac, | 542 bastardized_rice_decompress(alac, |
527 alac->predicterror_buffer_a, | 543 alac->predicterror_buffer_a, |
528 outputsamples, | 544 outputsamples, |
540 readsamplesize, | 556 readsamplesize, |
541 predictor_coef_table, | 557 predictor_coef_table, |
542 predictor_coef_num, | 558 predictor_coef_num, |
543 prediction_quantitization); | 559 prediction_quantitization); |
544 } else { | 560 } else { |
545 av_log(NULL, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type); | 561 av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type); |
546 /* i think the only other prediction type (or perhaps this is just a | 562 /* i think the only other prediction type (or perhaps this is just a |
547 * boolean?) runs adaptive fir twice.. like: | 563 * boolean?) runs adaptive fir twice.. like: |
548 * predictor_decompress_fir_adapt(predictor_error, tempout, ...) | 564 * predictor_decompress_fir_adapt(predictor_error, tempout, ...) |
549 * predictor_decompress_fir_adapt(predictor_error, outputsamples ...) | 565 * predictor_decompress_fir_adapt(predictor_error, outputsamples ...) |
550 * little strange.. | 566 * little strange.. |
592 break; | 608 break; |
593 } | 609 } |
594 case 20: | 610 case 20: |
595 case 24: | 611 case 24: |
596 case 32: | 612 case 32: |
597 av_log(NULL, AV_LOG_ERROR, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size); | 613 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size); |
598 break; | 614 break; |
599 default: | 615 default: |
600 break; | 616 break; |
601 } | 617 } |
602 break; | 618 break; |
677 } | 693 } |
678 | 694 |
679 /*********************/ | 695 /*********************/ |
680 if (wasted_bytes) { | 696 if (wasted_bytes) { |
681 /* see mono case */ | 697 /* see mono case */ |
682 av_log(NULL, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n"); | 698 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n"); |
683 } | 699 } |
684 | 700 |
685 /* channel 1 */ | 701 /* channel 1 */ |
686 bastardized_rice_decompress(alac, | 702 bastardized_rice_decompress(alac, |
687 alac->predicterror_buffer_a, | 703 alac->predicterror_buffer_a, |
701 predictor_coef_table_a, | 717 predictor_coef_table_a, |
702 predictor_coef_num_a, | 718 predictor_coef_num_a, |
703 prediction_quantitization_a); | 719 prediction_quantitization_a); |
704 } else { | 720 } else { |
705 /* see mono case */ | 721 /* see mono case */ |
706 av_log(NULL, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type_a); | 722 av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type_a); |
707 } | 723 } |
708 | 724 |
709 /* channel 2 */ | 725 /* channel 2 */ |
710 bastardized_rice_decompress(alac, | 726 bastardized_rice_decompress(alac, |
711 alac->predicterror_buffer_b, | 727 alac->predicterror_buffer_b, |
724 readsamplesize, | 740 readsamplesize, |
725 predictor_coef_table_b, | 741 predictor_coef_table_b, |
726 predictor_coef_num_b, | 742 predictor_coef_num_b, |
727 prediction_quantitization_b); | 743 prediction_quantitization_b); |
728 } else { | 744 } else { |
729 av_log(NULL, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type_b); | 745 av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type_b); |
730 } | 746 } |
731 } else { | 747 } else { |
732 /* not compressed, easy case */ | 748 /* not compressed, easy case */ |
733 if (alac->setinfo_sample_size <= 16) { | 749 if (alac->setinfo_sample_size <= 16) { |
734 int i; | 750 int i; |
780 break; | 796 break; |
781 } | 797 } |
782 case 20: | 798 case 20: |
783 case 24: | 799 case 24: |
784 case 32: | 800 case 32: |
785 av_log(NULL, AV_LOG_ERROR, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size); | 801 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size); |
786 break; | 802 break; |
787 default: | 803 default: |
788 break; | 804 break; |
789 } | 805 } |
790 | 806 |