comparison aacenc.c @ 9940:580fad942ae6 libavcodec

Refactor windowing and early psy from bitstream writing parts of the AAC encoder.
author alexc
date Wed, 08 Jul 2009 23:10:13 +0000
parents 6c5a58b34997
children a7b6bbf19002
comparison
equal deleted inserted replaced
9939:6c5a58b34997 9940:580fad942ae6
483 int16_t *samples = s->samples, *samples2, *la; 483 int16_t *samples = s->samples, *samples2, *la;
484 ChannelElement *cpe; 484 ChannelElement *cpe;
485 int i, j, chans, tag, start_ch; 485 int i, j, chans, tag, start_ch;
486 const uint8_t *chan_map = aac_chan_configs[avctx->channels-1]; 486 const uint8_t *chan_map = aac_chan_configs[avctx->channels-1];
487 int chan_el_counter[4]; 487 int chan_el_counter[4];
488 FFPsyWindowInfo windows[avctx->channels];
488 489
489 if (s->last_frame) 490 if (s->last_frame)
490 return 0; 491 return 0;
491 if (data) { 492 if (data) {
492 if (!s->psypp) { 493 if (!s->psypp) {
508 memcpy(s->samples, s->samples + 1024 * avctx->channels, 509 memcpy(s->samples, s->samples + 1024 * avctx->channels,
509 1024 * avctx->channels * sizeof(s->samples[0])); 510 1024 * avctx->channels * sizeof(s->samples[0]));
510 return 0; 511 return 0;
511 } 512 }
512 513
513 init_put_bits(&s->pb, frame, buf_size*8);
514 if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT))
515 put_bitstream_info(avctx, s, LIBAVCODEC_IDENT);
516 start_ch = 0; 514 start_ch = 0;
517 memset(chan_el_counter, 0, sizeof(chan_el_counter));
518 for (i = 0; i < chan_map[0]; i++) { 515 for (i = 0; i < chan_map[0]; i++) {
519 FFPsyWindowInfo wi[2]; 516 FFPsyWindowInfo* wi = windows + start_ch;
520 tag = chan_map[i+1]; 517 tag = chan_map[i+1];
521 chans = tag == TYPE_CPE ? 2 : 1; 518 chans = tag == TYPE_CPE ? 2 : 1;
522 cpe = &s->cpe[i]; 519 cpe = &s->cpe[i];
523 samples2 = samples + start_ch; 520 samples2 = samples + start_ch;
524 la = samples2 + 1024 * avctx->channels + start_ch; 521 la = samples2 + 1024 * avctx->channels + start_ch;
538 for (k = 0; k < ics->num_windows; k++) 535 for (k = 0; k < ics->num_windows; k++)
539 ics->group_len[k] = wi[j].grouping[k]; 536 ics->group_len[k] = wi[j].grouping[k];
540 537
541 s->cur_channel = start_ch + j; 538 s->cur_channel = start_ch + j;
542 apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2, j); 539 apply_window_and_mdct(avctx, s, &cpe->ch[j], samples2, j);
540 }
541 start_ch += chans;
542 }
543 init_put_bits(&s->pb, frame, buf_size*8);
544 if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT))
545 put_bitstream_info(avctx, s, LIBAVCODEC_IDENT);
546 start_ch = 0;
547 memset(chan_el_counter, 0, sizeof(chan_el_counter));
548 for (i = 0; i < chan_map[0]; i++) {
549 FFPsyWindowInfo* wi = windows + start_ch;
550 tag = chan_map[i+1];
551 chans = tag == TYPE_CPE ? 2 : 1;
552 cpe = &s->cpe[i];
553 for (j = 0; j < chans; j++) {
543 s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda); 554 s->coder->search_for_quantizers(avctx, s, &cpe->ch[j], s->lambda);
544 } 555 }
545 cpe->common_window = 0; 556 cpe->common_window = 0;
546 if (chans > 1 557 if (chans > 1
547 && wi[0].window_type[0] == wi[1].window_type[0] 558 && wi[0].window_type[0] == wi[1].window_type[0]