Mercurial > libavcodec.hg
comparison mlpdec.c @ 9507:7e156421dcbc libavcodec
mlpdec: {}- and whitespace-related cosmetics.
author | ramiro |
---|---|
date | Sat, 18 Apr 2009 19:52:52 +0000 |
parents | 50feb15cbf2a |
children | 41ab6db265d0 |
comparison
equal
deleted
inserted
replaced
9506:50feb15cbf2a | 9507:7e156421dcbc |
---|---|
424 cp->sign_huff_offset = (-1) << 23; | 424 cp->sign_huff_offset = (-1) << 23; |
425 cp->codebook = 0; | 425 cp->codebook = 0; |
426 cp->huff_lsbs = 24; | 426 cp->huff_lsbs = 24; |
427 } | 427 } |
428 | 428 |
429 if (substr == m->max_decoded_substream) { | 429 if (substr == m->max_decoded_substream) |
430 m->avctx->channels = s->max_matrix_channel + 1; | 430 m->avctx->channels = s->max_matrix_channel + 1; |
431 } | |
432 | 431 |
433 return 0; | 432 return 0; |
434 } | 433 } |
435 | 434 |
436 /** Read parameters for one of the prediction filters. */ | 435 /** Read parameters for one of the prediction filters. */ |
622 { | 621 { |
623 SubStream *s = &m->substream[substr]; | 622 SubStream *s = &m->substream[substr]; |
624 unsigned int ch; | 623 unsigned int ch; |
625 | 624 |
626 if (s->param_presence_flags & PARAM_PRESENCE) | 625 if (s->param_presence_flags & PARAM_PRESENCE) |
627 if (get_bits1(gbp)) | 626 if (get_bits1(gbp)) |
628 s->param_presence_flags = get_bits(gbp, 8); | 627 s->param_presence_flags = get_bits(gbp, 8); |
629 | 628 |
630 if (s->param_presence_flags & PARAM_BLOCKSIZE) | 629 if (s->param_presence_flags & PARAM_BLOCKSIZE) |
631 if (get_bits1(gbp)) { | 630 if (get_bits1(gbp)) { |
632 s->blocksize = get_bits(gbp, 9); | 631 s->blocksize = get_bits(gbp, 9); |
633 if (s->blocksize < 8 || s->blocksize > m->access_unit_size) { | 632 if (s->blocksize < 8 || s->blocksize > m->access_unit_size) { |
636 return -1; | 635 return -1; |
637 } | 636 } |
638 } | 637 } |
639 | 638 |
640 if (s->param_presence_flags & PARAM_MATRIX) | 639 if (s->param_presence_flags & PARAM_MATRIX) |
641 if (get_bits1(gbp)) { | 640 if (get_bits1(gbp)) |
642 if (read_matrix_params(m, substr, gbp) < 0) | 641 if (read_matrix_params(m, substr, gbp) < 0) |
643 return -1; | 642 return -1; |
644 } | |
645 | 643 |
646 if (s->param_presence_flags & PARAM_OUTSHIFT) | 644 if (s->param_presence_flags & PARAM_OUTSHIFT) |
647 if (get_bits1(gbp)) | 645 if (get_bits1(gbp)) |
648 for (ch = 0; ch <= s->max_matrix_channel; ch++) { | 646 for (ch = 0; ch <= s->max_matrix_channel; ch++) |
649 s->output_shift[ch] = get_sbits(gbp, 4); | 647 s->output_shift[ch] = get_sbits(gbp, 4); |
650 } | |
651 | 648 |
652 if (s->param_presence_flags & PARAM_QUANTSTEP) | 649 if (s->param_presence_flags & PARAM_QUANTSTEP) |
653 if (get_bits1(gbp)) | 650 if (get_bits1(gbp)) |
654 for (ch = 0; ch <= s->max_channel; ch++) { | 651 for (ch = 0; ch <= s->max_channel; ch++) { |
655 ChannelParams *cp = &m->channel_params[ch]; | 652 ChannelParams *cp = &m->channel_params[ch]; |
658 | 655 |
659 cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); | 656 cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); |
660 } | 657 } |
661 | 658 |
662 for (ch = s->min_channel; ch <= s->max_channel; ch++) | 659 for (ch = s->min_channel; ch <= s->max_channel; ch++) |
663 if (get_bits1(gbp)) { | 660 if (get_bits1(gbp)) |
664 if (read_channel_params(m, substr, gbp, ch) < 0) | 661 if (read_channel_params(m, substr, gbp, ch) < 0) |
665 return -1; | 662 return -1; |
666 } | |
667 | 663 |
668 return 0; | 664 return 0; |
669 } | 665 } |
670 | 666 |
671 #define MSB_MASK(bits) (-1u << bits) | 667 #define MSB_MASK(bits) (-1u << bits) |
738 } | 734 } |
739 | 735 |
740 memset(&m->bypassed_lsbs[s->blockpos][0], 0, | 736 memset(&m->bypassed_lsbs[s->blockpos][0], 0, |
741 s->blocksize * sizeof(m->bypassed_lsbs[0])); | 737 s->blocksize * sizeof(m->bypassed_lsbs[0])); |
742 | 738 |
743 for (i = 0; i < s->blocksize; i++) { | 739 for (i = 0; i < s->blocksize; i++) |
744 if (read_huff_channels(m, gbp, substr, i) < 0) | 740 if (read_huff_channels(m, gbp, substr, i) < 0) |
745 return -1; | 741 return -1; |
746 } | 742 |
747 | 743 for (ch = s->min_channel; ch <= s->max_channel; ch++) |
748 for (ch = s->min_channel; ch <= s->max_channel; ch++) { | |
749 filter_channel(m, substr, ch); | 744 filter_channel(m, substr, ch); |
750 } | |
751 | 745 |
752 s->blockpos += s->blocksize; | 746 s->blockpos += s->blocksize; |
753 | 747 |
754 if (s->data_check_present) { | 748 if (s->data_check_present) { |
755 if (get_bits_count(gbp) != expected_stream_pos) | 749 if (get_bits_count(gbp) != expected_stream_pos) |
855 /* TODO: DSPContext? */ | 849 /* TODO: DSPContext? */ |
856 | 850 |
857 for (i = 0; i < s->blockpos; i++) { | 851 for (i = 0; i < s->blockpos; i++) { |
858 int32_t *samples = m->sample_buffer[i]; | 852 int32_t *samples = m->sample_buffer[i]; |
859 int64_t accum = 0; | 853 int64_t accum = 0; |
860 for (src_ch = 0; src_ch <= maxchan; src_ch++) { | 854 |
861 accum += (int64_t)samples[src_ch] | 855 for (src_ch = 0; src_ch <= maxchan; src_ch++) |
862 * coeffs[src_ch]; | 856 accum += (int64_t) samples[src_ch] * coeffs[src_ch]; |
863 } | 857 |
864 if (matrix_noise_shift) { | 858 if (matrix_noise_shift) { |
865 index &= m->access_unit_size_pow2 - 1; | 859 index &= m->access_unit_size_pow2 - 1; |
866 accum += m->noise_buffer[index] << (matrix_noise_shift + 7); | 860 accum += m->noise_buffer[index] << (matrix_noise_shift + 7); |
867 index += index2; | 861 index += index2; |
868 } | 862 } |
863 | |
869 samples[dest_ch] = ((accum >> 14) & mask) | 864 samples[dest_ch] = ((accum >> 14) & mask) |
870 + m->bypassed_lsbs[i][mat]; | 865 + m->bypassed_lsbs[i][mat]; |
871 } | 866 } |
872 } | 867 } |
873 } | 868 } |
874 | 869 |
875 /** Write the audio data into the output buffer. */ | 870 /** Write the audio data into the output buffer. */ |
1031 if (read_restart_header(m, &gb, buf, substr) < 0) | 1026 if (read_restart_header(m, &gb, buf, substr) < 0) |
1032 goto next_substr; | 1027 goto next_substr; |
1033 s->restart_seen = 1; | 1028 s->restart_seen = 1; |
1034 } | 1029 } |
1035 | 1030 |
1036 if (!s->restart_seen) { | 1031 if (!s->restart_seen) |
1037 goto next_substr; | 1032 goto next_substr; |
1038 } | |
1039 | |
1040 if (read_decoding_params(m, &gb, substr) < 0) | 1033 if (read_decoding_params(m, &gb, substr) < 0) |
1041 goto next_substr; | 1034 goto next_substr; |
1042 } | 1035 } |
1043 | 1036 |
1044 if (!s->restart_seen) { | 1037 if (!s->restart_seen) |
1045 goto next_substr; | 1038 goto next_substr; |
1046 } | |
1047 | 1039 |
1048 if (read_block_data(m, &gb, substr) < 0) | 1040 if (read_block_data(m, &gb, substr) < 0) |
1049 return -1; | 1041 return -1; |
1050 | 1042 |
1051 if (get_bits_count(&gb) >= substream_data_len[substr] * 8) | 1043 if (get_bits_count(&gb) >= substream_data_len[substr] * 8) |
1052 goto substream_length_mismatch; | 1044 goto substream_length_mismatch; |
1053 | 1045 |
1054 } while (!get_bits1(&gb)); | 1046 } while (!get_bits1(&gb)); |
1055 | 1047 |
1056 skip_bits(&gb, (-get_bits_count(&gb)) & 15); | 1048 skip_bits(&gb, (-get_bits_count(&gb)) & 15); |
1049 | |
1057 if (substream_data_len[substr] * 8 - get_bits_count(&gb) >= 32) { | 1050 if (substream_data_len[substr] * 8 - get_bits_count(&gb) >= 32) { |
1058 int shorten_by; | 1051 int shorten_by; |
1059 | 1052 |
1060 if (get_bits(&gb, 16) != 0xD234) | 1053 if (get_bits(&gb, 16) != 0xD234) |
1061 return -1; | 1054 return -1; |
1067 return -1; | 1060 return -1; |
1068 | 1061 |
1069 if (substr == m->max_decoded_substream) | 1062 if (substr == m->max_decoded_substream) |
1070 av_log(m->avctx, AV_LOG_INFO, "End of stream indicated.\n"); | 1063 av_log(m->avctx, AV_LOG_INFO, "End of stream indicated.\n"); |
1071 } | 1064 } |
1065 | |
1072 if (substream_parity_present[substr]) { | 1066 if (substream_parity_present[substr]) { |
1073 uint8_t parity, checksum; | 1067 uint8_t parity, checksum; |
1074 | 1068 |
1075 if (substream_data_len[substr] * 8 - get_bits_count(&gb) != 16) | 1069 if (substream_data_len[substr] * 8 - get_bits_count(&gb) != 16) |
1076 goto substream_length_mismatch; | 1070 goto substream_length_mismatch; |
1081 if ((get_bits(&gb, 8) ^ parity) != 0xa9 ) | 1075 if ((get_bits(&gb, 8) ^ parity) != 0xa9 ) |
1082 av_log(m->avctx, AV_LOG_ERROR, "Substream %d parity check failed.\n", substr); | 1076 av_log(m->avctx, AV_LOG_ERROR, "Substream %d parity check failed.\n", substr); |
1083 if ( get_bits(&gb, 8) != checksum) | 1077 if ( get_bits(&gb, 8) != checksum) |
1084 av_log(m->avctx, AV_LOG_ERROR, "Substream %d checksum failed.\n" , substr); | 1078 av_log(m->avctx, AV_LOG_ERROR, "Substream %d checksum failed.\n" , substr); |
1085 } | 1079 } |
1086 if (substream_data_len[substr] * 8 != get_bits_count(&gb)) { | 1080 |
1081 if (substream_data_len[substr] * 8 != get_bits_count(&gb)) | |
1087 goto substream_length_mismatch; | 1082 goto substream_length_mismatch; |
1088 } | |
1089 | 1083 |
1090 next_substr: | 1084 next_substr: |
1091 if (!s->restart_seen) { | 1085 if (!s->restart_seen) |
1092 av_log(m->avctx, AV_LOG_ERROR, | 1086 av_log(m->avctx, AV_LOG_ERROR, |
1093 "No restart header present in substream %d.\n", substr); | 1087 "No restart header present in substream %d.\n", substr); |
1094 } | |
1095 | 1088 |
1096 buf += substream_data_len[substr]; | 1089 buf += substream_data_len[substr]; |
1097 } | 1090 } |
1098 | 1091 |
1099 rematrix_channels(m, m->max_decoded_substream); | 1092 rematrix_channels(m, m->max_decoded_substream); |