comparison parser.c @ 3063:f02d0b59279c libavcodec

Remove all stray tabs and trailing whitespace, this time for good.
author diego
date Tue, 24 Jan 2006 10:33:14 +0000
parents 61b4cc042988
children d85afa120256
comparison
equal deleted inserted replaced
3062:8d05d4036b6a 3063:f02d0b59279c
759 static const int ac3_sample_rates[4] = { 759 static const int ac3_sample_rates[4] = {
760 48000, 44100, 32000, 0 760 48000, 44100, 32000, 0
761 }; 761 };
762 762
763 static const int ac3_frame_sizes[64][3] = { 763 static const int ac3_frame_sizes[64][3] = {
764 { 64, 69, 96 }, 764 { 64, 69, 96 },
765 { 64, 70, 96 }, 765 { 64, 70, 96 },
766 { 80, 87, 120 }, 766 { 80, 87, 120 },
767 { 80, 88, 120 }, 767 { 80, 88, 120 },
768 { 96, 104, 144 }, 768 { 96, 104, 144 },
769 { 96, 105, 144 }, 769 { 96, 105, 144 },
770 { 112, 121, 168 }, 770 { 112, 121, 168 },
771 { 112, 122, 168 }, 771 { 112, 122, 168 },
772 { 128, 139, 192 }, 772 { 128, 139, 192 },
773 { 128, 140, 192 }, 773 { 128, 140, 192 },
774 { 160, 174, 240 }, 774 { 160, 174, 240 },
775 { 160, 175, 240 }, 775 { 160, 175, 240 },
776 { 192, 208, 288 }, 776 { 192, 208, 288 },
777 { 192, 209, 288 }, 777 { 192, 209, 288 },
778 { 224, 243, 336 }, 778 { 224, 243, 336 },
779 { 224, 244, 336 }, 779 { 224, 244, 336 },
780 { 256, 278, 384 }, 780 { 256, 278, 384 },
781 { 256, 279, 384 }, 781 { 256, 279, 384 },
782 { 320, 348, 480 }, 782 { 320, 348, 480 },
783 { 320, 349, 480 }, 783 { 320, 349, 480 },
784 { 384, 417, 576 }, 784 { 384, 417, 576 },
785 { 384, 418, 576 }, 785 { 384, 418, 576 },
786 { 448, 487, 672 }, 786 { 448, 487, 672 },
787 { 448, 488, 672 }, 787 { 448, 488, 672 },
788 { 512, 557, 768 }, 788 { 512, 557, 768 },
789 { 512, 558, 768 }, 789 { 512, 558, 768 },
790 { 640, 696, 960 }, 790 { 640, 696, 960 },
791 { 640, 697, 960 }, 791 { 640, 697, 960 },
792 { 768, 835, 1152 }, 792 { 768, 835, 1152 },
793 { 768, 836, 1152 }, 793 { 768, 836, 1152 },
794 { 896, 975, 1344 }, 794 { 896, 975, 1344 },
795 { 896, 976, 1344 }, 795 { 896, 976, 1344 },
796 { 1024, 1114, 1536 }, 796 { 1024, 1114, 1536 },
797 { 1024, 1115, 1536 }, 797 { 1024, 1115, 1536 },
798 { 1152, 1253, 1728 }, 798 { 1152, 1253, 1728 },
799 { 1152, 1254, 1728 }, 799 { 1152, 1254, 1728 },
800 { 1280, 1393, 1920 }, 800 { 1280, 1393, 1920 },
810 static const int ac3_channels[8] = { 810 static const int ac3_channels[8] = {
811 2, 1, 2, 3, 3, 4, 4, 5 811 2, 1, 2, 3, 3, 4, 4, 5
812 }; 812 };
813 813
814 static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate, 814 static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,
815 int *bit_rate) 815 int *bit_rate)
816 { 816 {
817 unsigned int fscod, frmsizecod, acmod, bsid, lfeon; 817 unsigned int fscod, frmsizecod, acmod, bsid, lfeon;
818 GetBitContext bits; 818 GetBitContext bits;
819 819
820 init_get_bits(&bits, buf, AC3_HEADER_SIZE * 8); 820 init_get_bits(&bits, buf, AC3_HEADER_SIZE * 8);
821 821
822 if(get_bits(&bits, 16) != 0x0b77) 822 if(get_bits(&bits, 16) != 0x0b77)
823 return 0; 823 return 0;
824 824
825 get_bits(&bits, 16); /* crc */ 825 get_bits(&bits, 16); /* crc */
826 fscod = get_bits(&bits, 2); 826 fscod = get_bits(&bits, 2);
827 frmsizecod = get_bits(&bits, 6); 827 frmsizecod = get_bits(&bits, 6);
828 828
829 if(!ac3_sample_rates[fscod]) 829 if(!ac3_sample_rates[fscod])
830 return 0; 830 return 0;
831 831
832 bsid = get_bits(&bits, 5); 832 bsid = get_bits(&bits, 5);
833 if(bsid > 8) 833 if(bsid > 8)
834 return 0; 834 return 0;
835 get_bits(&bits, 3); /* bsmod */ 835 get_bits(&bits, 3); /* bsmod */
836 acmod = get_bits(&bits, 3); 836 acmod = get_bits(&bits, 3);
837 if(acmod & 1 && acmod != 1) 837 if(acmod & 1 && acmod != 1)
838 get_bits(&bits, 2); /* cmixlev */ 838 get_bits(&bits, 2); /* cmixlev */
839 if(acmod & 4) 839 if(acmod & 4)
840 get_bits(&bits, 2); /* surmixlev */ 840 get_bits(&bits, 2); /* surmixlev */
841 if(acmod & 2) 841 if(acmod & 2)
842 get_bits(&bits, 2); /* dsurmod */ 842 get_bits(&bits, 2); /* dsurmod */
843 lfeon = get_bits(&bits, 1); 843 lfeon = get_bits(&bits, 1);
844 844
845 *sample_rate = ac3_sample_rates[fscod]; 845 *sample_rate = ac3_sample_rates[fscod];
846 *bit_rate = ac3_bitrates[frmsizecod] * 1000; 846 *bit_rate = ac3_bitrates[frmsizecod] * 1000;
847 *channels = ac3_channels[acmod] + lfeon; 847 *channels = ac3_channels[acmod] + lfeon;
879 memcpy(s->inbuf_ptr, buf_ptr, len); 879 memcpy(s->inbuf_ptr, buf_ptr, len);
880 buf_ptr += len; 880 buf_ptr += len;
881 s->inbuf_ptr += len; 881 s->inbuf_ptr += len;
882 buf_size -= len; 882 buf_size -= len;
883 if ((s->inbuf_ptr - s->inbuf) == AC3_HEADER_SIZE) { 883 if ((s->inbuf_ptr - s->inbuf) == AC3_HEADER_SIZE) {
884 len = ac3_sync(s->inbuf, &channels, &sample_rate, &bit_rate); 884 len = ac3_sync(s->inbuf, &channels, &sample_rate, &bit_rate);
885 if (len == 0) { 885 if (len == 0) {
886 /* no sync found : move by one byte (inefficient, but simple!) */ 886 /* no sync found : move by one byte (inefficient, but simple!) */
887 memmove(s->inbuf, s->inbuf + 1, AC3_HEADER_SIZE - 1); 887 memmove(s->inbuf, s->inbuf + 1, AC3_HEADER_SIZE - 1);
888 s->inbuf_ptr--; 888 s->inbuf_ptr--;
889 } else { 889 } else {
890 s->frame_size = len; 890 s->frame_size = len;
891 /* update codec info */ 891 /* update codec info */
892 avctx->sample_rate = sample_rate; 892 avctx->sample_rate = sample_rate;
893 /* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */ 893 /* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */
894 if(avctx->channels!=1 && avctx->channels!=2){ 894 if(avctx->channels!=1 && avctx->channels!=2){
895 avctx->channels = channels; 895 avctx->channels = channels;
896 } 896 }
897 avctx->bit_rate = bit_rate; 897 avctx->bit_rate = bit_rate;
898 avctx->frame_size = 6 * 256; 898 avctx->frame_size = 6 * 256;
899 } 899 }
900 } 900 }