*@brief Decode channel transformation parameters *@param s codec context *@return 0 in case of success, < 0 in case of bitstream errors */
| 650 | *@return 0 in case of success, < 0 in case of bitstream errors |
| 651 | */ |
| 652 | static int decode_channel_transform(WMAProDecodeCtx* s) |
| 653 | { |
| 654 | int i; |
| 655 | /* should never consume more than 1921 bits for the 8 channel case |
| 656 | * 1 + MAX_CHANNELS * (MAX_CHANNELS + 2 + 3 * MAX_CHANNELS * MAX_CHANNELS |
| 657 | * + MAX_CHANNELS + MAX_BANDS + 1) |
| 658 | */ |
| 659 | |
| 660 | /** in the one channel case channel transforms are pointless */ |
| 661 | s->num_chgroups = 0; |
| 662 | if (s->num_channels > 1) { |
| 663 | int remaining_channels = s->channels_for_cur_subframe; |
| 664 | |
| 665 | if (get_bits1(&s->gb)) { |
| 666 | av_log_ask_for_sample(s->avctx, |
| 667 | "unsupported channel transform bit\n"); |
| 668 | return AVERROR_INVALIDDATA; |
| 669 | } |
| 670 | |
| 671 | for (s->num_chgroups = 0; remaining_channels && |
| 672 | s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) { |
| 673 | WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups]; |
| 674 | float** channel_data = chgroup->channel_data; |
| 675 | chgroup->num_channels = 0; |
| 676 | chgroup->transform = 0; |
| 677 | |
| 678 | /** decode channel mask */ |
| 679 | if (remaining_channels > 2) { |
| 680 | for (i = 0; i < s->channels_for_cur_subframe; i++) { |
| 681 | int channel_idx = s->channel_indexes_for_cur_subframe[i]; |
| 682 | if (!s->channel[channel_idx].grouped |
| 683 | && get_bits1(&s->gb)) { |
| 684 | ++chgroup->num_channels; |
| 685 | s->channel[channel_idx].grouped = 1; |
| 686 | *channel_data++ = s->channel[channel_idx].coeffs; |
| 687 | } |
| 688 | } |
| 689 | } else { |
| 690 | chgroup->num_channels = remaining_channels; |
| 691 | for (i = 0; i < s->channels_for_cur_subframe; i++) { |
| 692 | int channel_idx = s->channel_indexes_for_cur_subframe[i]; |
| 693 | if (!s->channel[channel_idx].grouped) |
| 694 | *channel_data++ = s->channel[channel_idx].coeffs; |
| 695 | s->channel[channel_idx].grouped = 1; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | /** decode transform type */ |
| 700 | if (chgroup->num_channels == 2) { |
| 701 | if (get_bits1(&s->gb)) { |
| 702 | if (get_bits1(&s->gb)) { |
| 703 | av_log_ask_for_sample(s->avctx, |
| 704 | "unsupported channel transform type\n"); |
| 705 | } |
| 706 | } else { |
| 707 | chgroup->transform = 1; |
| 708 | if (s->num_channels == 2) { |
| 709 | chgroup->decorrelation_matrix[0] = 1.0; |
no test coverage detected