When both M/S coding and PNS are enabled, scalefactors and coding books would be mistakenly clobbered when setting the M/S flag on PNS'd bands. The flag needs to be set to signal the generation of correlated noise, but the scalefactors, coefficients and the coding books need to be kept intact.
Showing the changes to libavcodec/aaccoder.c (1 of 2 files). Show all
Unified · Split
| @@ -887,8 +887,8 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) · 886 unmodified lines | ||
| 887 | 887 | } |
| 888 | 888 | cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0; |
| 889 | 889 | if (cpe->ms_mask[w*16+g]) { |
| 890 | − /* Setting the M/S mask is useful with I/S, but only the flag */ | |
| 891 | − if (!cpe->is_mask[w*16+g]) { | |
| 890 | + /* Setting the M/S mask is useful with I/S or PNS, but only the flag */ | |
| 891 | + if (!cpe->is_mask[w*16+g] && sce0->band_type[w*16+g] != NOISE_BT && sce1->band_type[w*16+g] != NOISE_BT) { | |
| 892 | 892 | sce0->sf_idx[w*16+g] = mididx; |
| 893 | 893 | sce1->sf_idx[w*16+g] = sididx; |
| 894 | 894 | sce0->band_type[w*16+g] = midcb; |