Revision 5b29af62 libavcodec/aacenc.c

View differences:

libavcodec/aacenc.c
489 489
    AACEncContext *s = avctx->priv_data;
490 490
    int16_t *samples = s->samples, *samples2, *la;
491 491
    ChannelElement *cpe;
492
    int i, j, chans, tag, start_ch;
492
    int i, ch, w, chans, tag, start_ch;
493 493
    const uint8_t *chan_map = aac_chan_configs[avctx->channels-1];
494 494
    int chan_el_counter[4];
495 495
    FFPsyWindowInfo windows[AAC_MAX_CHANNELS];
......
524 524
        tag      = chan_map[i+1];
525 525
        chans    = tag == TYPE_CPE ? 2 : 1;
526 526
        cpe      = &s->cpe[i];
527
        for (j = 0; j < chans; j++) {
528
            IndividualChannelStream *ics = &cpe->ch[j].ics;
529
            int k;
530
            int cur_channel = start_ch + j;
527
        for (ch = 0; ch < chans; ch++) {
528
            IndividualChannelStream *ics = &cpe->ch[ch].ics;
529
            int cur_channel = start_ch + ch;
531 530
            samples2 = samples + cur_channel;
532 531
            la       = samples2 + (448+64) * avctx->channels;
533 532
            if (!data)
534 533
                la = NULL;
535 534
            if (tag == TYPE_LFE) {
536
                wi[j].window_type[0] = ONLY_LONG_SEQUENCE;
537
                wi[j].window_shape   = 0;
538
                wi[j].num_windows    = 1;
539
                wi[j].grouping[0]    = 1;
535
                wi[ch].window_type[0] = ONLY_LONG_SEQUENCE;
536
                wi[ch].window_shape   = 0;
537
                wi[ch].num_windows    = 1;
538
                wi[ch].grouping[0]    = 1;
540 539
            } else {
541
                wi[j] = ff_psy_suggest_window(&s->psy, samples2, la, cur_channel,
542
                                              ics->window_sequence[0]);
540
                wi[ch] = ff_psy_suggest_window(&s->psy, samples2, la, cur_channel,
541
                                               ics->window_sequence[0]);
543 542
            }
544 543
            ics->window_sequence[1] = ics->window_sequence[0];
545
            ics->window_sequence[0] = wi[j].window_type[0];
544
            ics->window_sequence[0] = wi[ch].window_type[0];
546 545
            ics->use_kb_window[1]   = ics->use_kb_window[0];
547
            ics->use_kb_window[0]   = wi[j].window_shape;
548
            ics->num_windows        = wi[j].num_windows;
546
            ics->use_kb_window[0]   = wi[ch].window_shape;
547
            ics->num_windows        = wi[ch].num_windows;
549 548
            ics->swb_sizes          = s->psy.bands    [ics->num_windows == 8];
550 549
            ics->num_swb            = tag == TYPE_LFE ? 12 : s->psy.num_bands[ics->num_windows == 8];
551
            for (k = 0; k < ics->num_windows; k++)
552
                ics->group_len[k] = wi[j].grouping[k];
550
            for (w = 0; w < ics->num_windows; w++)
551
                ics->group_len[w] = wi[ch].grouping[w];
553 552

  
554
            apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2);
553
            apply_window_and_mdct(avctx, s, &cpe->ch[ch], samples2);
555 554
        }
556 555
        start_ch += chans;
557 556
    }
......
569 568
            cpe      = &s->cpe[i];
570 569
            put_bits(&s->pb, 3, tag);
571 570
            put_bits(&s->pb, 4, chan_el_counter[tag]++);
572
            for (j = 0; j < chans; j++) {
573
                s->cur_channel = start_ch + j;
574
                ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[j].coeffs, &wi[j]);
575
                s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda);
571
            for (ch = 0; ch < chans; ch++) {
572
                s->cur_channel = start_ch + ch;
573
                ff_psy_set_band_info(&s->psy, s->cur_channel, cpe->ch[ch].coeffs, &wi[ch]);
574
                s->coder->search_for_quantizers(avctx, s, &cpe->ch[ch], s->lambda);
576 575
            }
577 576
            cpe->common_window = 0;
578 577
            if (chans > 1
......
580 579
                && wi[0].window_shape   == wi[1].window_shape) {
581 580

  
582 581
                cpe->common_window = 1;
583
                for (j = 0; j < wi[0].num_windows; j++) {
584
                    if (wi[0].grouping[j] != wi[1].grouping[j]) {
582
                for (w = 0; w < wi[0].num_windows; w++) {
583
                    if (wi[0].grouping[w] != wi[1].grouping[w]) {
585 584
                        cpe->common_window = 0;
586 585
                        break;
587 586
                    }
......
598 597
                    encode_ms_info(&s->pb, cpe);
599 598
                }
600 599
            }
601
            for (j = 0; j < chans; j++) {
602
                s->cur_channel = start_ch + j;
603
                encode_individual_channel(avctx, s, &cpe->ch[j], cpe->common_window);
600
            for (ch = 0; ch < chans; ch++) {
601
                s->cur_channel = start_ch + ch;
602
                encode_individual_channel(avctx, s, &cpe->ch[ch], cpe->common_window);
604 603
            }
605 604
            start_ch += chans;
606 605
        }

Also available in: Unified diff