Doing so gets rid of a stupid GCC -Wstringop-overflow= warning (GCC somehow believes that fbw_channels can be 7 with the old form of the code, so that channel_uses_spx[7] would be written to, but now it no longer believes so).
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -854,16 +854,18 @@ static void decode_band_structure(GetBitContext *gbc, int blk, int eac3, · 853 unmodified lines | ||
| 854 | 854 | static inline int spx_strategy(AC3DecodeContext *s, int blk) |
| 855 | 855 | { |
| 856 | 856 | GetBitContext *bc = &s->gbc; |
| 857 | − int fbw_channels = s->fbw_channels; | |
| 858 | 857 | int dst_start_freq, dst_end_freq, src_start_freq, |
| 859 | − start_subband, end_subband, ch; | |
| 858 | + start_subband, end_subband; | |
| 860 | 859 | |
| 861 | 860 | /* determine which channels use spx */ |
| 862 | 861 | if (s->channel_mode == AC3_CHMODE_MONO) { |
| 863 | 862 | s->channel_uses_spx[1] = 1; |
| 864 | 863 | } else { |
| 865 | − for (ch = 1; ch <= fbw_channels; ch++) | |
| 866 | − s->channel_uses_spx[ch] = get_bits1(bc); | |
| 864 | + unsigned channel_uses_spx = get_bits(bc, s->fbw_channels); | |
| 865 | + for (int ch = s->fbw_channels; ch >= 1; --ch) { | |
| 866 | + s->channel_uses_spx[ch] = channel_uses_spx & 1; | |
| 867 | + channel_uses_spx >>= 1; | |
| 868 | + } | |
| 867 | 869 | } |
| 868 | 870 | |
| 869 | 871 | /* get the frequency bins of the spx copy region and the spx start |