History

AAC encoder: Fix application of M/S with PNS

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.

Claudio Freire committed 10 years ago

Commit fc36d851 parent 04deaef2 files · +9 −3Browse files

Unified · Split

2 files
  1. libavcodec/aaccoder.c +2 −2
  2. libavcodec/aacenc.c +7 −1
libavcodec/aaccoder.c+2−2
@@ -887,8 +887,8 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) · 886 unmodified lines
887 }887 }
888 cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0;888 cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0;
889 if (cpe->ms_mask[w*16+g]) {889 if (cpe->ms_mask[w*16+g]) {
890 /* Setting the M/S mask is useful with I/S, but only the flag */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]) {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 sce0->sf_idx[w*16+g] = mididx;892 sce0->sf_idx[w*16+g] = mididx;
893 sce1->sf_idx[w*16+g] = sididx;893 sce1->sf_idx[w*16+g] = sididx;
894 sce0->band_type[w*16+g] = midcb;894 sce0->band_type[w*16+g] = midcb;
libavcodec/aacenc.c+7−1
@@ -292,7 +292,13 @@ static void apply_mid_side_stereo(ChannelElement *cpe) · 291 unmodified lines
292 for (w2 = 0; w2 < ics->group_len[w]; w2++) {292 for (w2 = 0; w2 < ics->group_len[w]; w2++) {
293 int start = (w+w2) * 128;293 int start = (w+w2) * 128;
294 for (g = 0; g < ics->num_swb; g++) {294 for (g = 0; g < ics->num_swb; g++) {
295 if (!cpe->ms_mask[w*16 + g] && !cpe->is_mask[w*16 + g]) {295 /* ms_mask can be used for other purposes in PNS and I/S,
296 * so must not apply M/S if any band uses either, even if
297 * ms_mask is set.
298 */
299 if (!cpe->ms_mask[w*16 + g] || cpe->is_mask[w*16 + g]
300 || cpe->ch[0].band_type[w*16 + g] == NOISE_BT
301 || cpe->ch[1].band_type[w*16 + g] == NOISE_BT) {
296 start += ics->swb_sizes[g];302 start += ics->swb_sizes[g];
297 continue;303 continue;
298 }304 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t