*@brief Decode channel transformation parameters *@param s codec context *@return >= 0 in case of success, < 0 in case of bitstream errors */
| 803 | *@return >= 0 in case of success, < 0 in case of bitstream errors |
| 804 | */ |
| 805 | static int decode_channel_transform(WMAProDecodeCtx* s) |
| 806 | { |
| 807 | int i; |
| 808 | /* should never consume more than 1921 bits for the 8 channel case |
| 809 | * 1 + MAX_CHANNELS * (MAX_CHANNELS + 2 + 3 * MAX_CHANNELS * MAX_CHANNELS |
| 810 | * + MAX_CHANNELS + MAX_BANDS + 1) |
| 811 | */ |
| 812 | |
| 813 | /** in the one channel case channel transforms are pointless */ |
| 814 | s->num_chgroups = 0; |
| 815 | if (s->nb_channels > 1) { |
| 816 | int remaining_channels = s->channels_for_cur_subframe; |
| 817 | |
| 818 | if (get_bits1(&s->gb)) { |
| 819 | avpriv_request_sample(s->avctx, |
| 820 | "Channel transform bit"); |
| 821 | return AVERROR_PATCHWELCOME; |
| 822 | } |
| 823 | |
| 824 | for (s->num_chgroups = 0; remaining_channels && |
| 825 | s->num_chgroups < s->channels_for_cur_subframe; s->num_chgroups++) { |
| 826 | WMAProChannelGrp* chgroup = &s->chgroup[s->num_chgroups]; |
| 827 | float** channel_data = chgroup->channel_data; |
| 828 | chgroup->num_channels = 0; |
| 829 | chgroup->transform = 0; |
| 830 | |
| 831 | /** decode channel mask */ |
| 832 | if (remaining_channels > 2) { |
| 833 | for (i = 0; i < s->channels_for_cur_subframe; i++) { |
| 834 | int channel_idx = s->channel_indexes_for_cur_subframe[i]; |
| 835 | if (!s->channel[channel_idx].grouped |
| 836 | && get_bits1(&s->gb)) { |
| 837 | ++chgroup->num_channels; |
| 838 | s->channel[channel_idx].grouped = 1; |
| 839 | *channel_data++ = s->channel[channel_idx].coeffs; |
| 840 | } |
| 841 | } |
| 842 | } else { |
| 843 | chgroup->num_channels = remaining_channels; |
| 844 | for (i = 0; i < s->channels_for_cur_subframe; i++) { |
| 845 | int channel_idx = s->channel_indexes_for_cur_subframe[i]; |
| 846 | if (!s->channel[channel_idx].grouped) |
| 847 | *channel_data++ = s->channel[channel_idx].coeffs; |
| 848 | s->channel[channel_idx].grouped = 1; |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | /** decode transform type */ |
| 853 | if (chgroup->num_channels == 2) { |
| 854 | if (get_bits1(&s->gb)) { |
| 855 | if (get_bits1(&s->gb)) { |
| 856 | avpriv_request_sample(s->avctx, |
| 857 | "Unknown channel transform type"); |
| 858 | return AVERROR_PATCHWELCOME; |
| 859 | } |
| 860 | } else { |
| 861 | chgroup->transform = 1; |
| 862 | if (s->nb_channels == 2) { |
no test coverage detected