Mercurial > libavcodec.hg
comparison parser.c @ 4501:665d7cd95fd3 libavcodec
fix parsing of RealAudio AC-3/DolbyNet
| author | jbr |
|---|---|
| date | Fri, 09 Feb 2007 02:02:09 +0000 |
| parents | d8ccac15e9d3 |
| children | 056127e5df89 |
comparison
equal
deleted
inserted
replaced
| 4500:18a88f830d1a | 4501:665d7cd95fd3 |
|---|---|
| 655 | 655 |
| 656 #ifdef CONFIG_AC3_PARSER | 656 #ifdef CONFIG_AC3_PARSER |
| 657 static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate, | 657 static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate, |
| 658 int *bit_rate, int *samples) | 658 int *bit_rate, int *samples) |
| 659 { | 659 { |
| 660 unsigned int fscod, frmsizecod, acmod, bsid, lfeon; | 660 unsigned int fscod, frmsizecod, acmod, bsid, lfeon, halfratecod; |
| 661 unsigned int strmtyp, substreamid, frmsiz, fscod2, numblkscod; | 661 unsigned int strmtyp, substreamid, frmsiz, fscod2, numblkscod; |
| 662 GetBitContext bits; | 662 GetBitContext bits; |
| 663 | 663 |
| 664 init_get_bits(&bits, buf, AC3_HEADER_SIZE * 8); | 664 init_get_bits(&bits, buf, AC3_HEADER_SIZE * 8); |
| 665 | 665 |
| 666 if(get_bits(&bits, 16) != 0x0b77) | 666 if(get_bits(&bits, 16) != 0x0b77) |
| 667 return 0; | 667 return 0; |
| 668 | 668 |
| 669 bsid = show_bits_long(&bits, 29) & 0x1f; | 669 bsid = show_bits_long(&bits, 29) & 0x1f; |
| 670 if(bsid <= 8) { /* Normal AC-3 */ | 670 if(bsid <= 10) { /* Normal AC-3 */ |
| 671 skip_bits(&bits, 16); /* crc */ | 671 skip_bits(&bits, 16); /* crc */ |
| 672 fscod = get_bits(&bits, 2); | 672 fscod = get_bits(&bits, 2); |
| 673 frmsizecod = get_bits(&bits, 6); | 673 frmsizecod = get_bits(&bits, 6); |
| 674 | 674 |
| 675 if(fscod == 3) | 675 if(fscod == 3) |
| 684 skip_bits(&bits, 2); /* surmixlev */ | 684 skip_bits(&bits, 2); /* surmixlev */ |
| 685 if(acmod & 2) | 685 if(acmod & 2) |
| 686 skip_bits(&bits, 2); /* dsurmod */ | 686 skip_bits(&bits, 2); /* dsurmod */ |
| 687 lfeon = get_bits1(&bits); | 687 lfeon = get_bits1(&bits); |
| 688 | 688 |
| 689 *sample_rate = ac3_sample_rates[fscod]; | 689 halfratecod = FFMAX(bsid, 8) - 8; |
| 690 *bit_rate = ac3_bitrates[frmsizecod] * 1000; | 690 *sample_rate = ac3_sample_rates[fscod] >> halfratecod; |
| 691 *bit_rate = (ac3_bitrates[frmsizecod] * 1000) >> halfratecod; | |
| 691 *channels = ac3_channels[acmod] + lfeon; | 692 *channels = ac3_channels[acmod] + lfeon; |
| 692 *samples = 6 * 256; | 693 *samples = 6 * 256; |
| 693 | 694 |
| 694 return ac3_frame_sizes[frmsizecod][fscod] * 2; | 695 return ac3_frame_sizes[frmsizecod][fscod] * 2; |
| 695 } else if (bsid >= 10 && bsid <= 16) { /* Enhanced AC-3 */ | 696 } else if (bsid > 10 && bsid <= 16) { /* Enhanced AC-3 */ |
| 696 strmtyp = get_bits(&bits, 2); | 697 strmtyp = get_bits(&bits, 2); |
| 697 substreamid = get_bits(&bits, 3); | 698 substreamid = get_bits(&bits, 3); |
| 698 | 699 |
| 699 if (strmtyp != 0 || substreamid != 0) | 700 if (strmtyp != 0 || substreamid != 0) |
| 700 return 0; /* Currently don't support additional streams */ | 701 return 0; /* Currently don't support additional streams */ |
