Mercurial > libavcodec.hg
comparison vorbis_enc.c @ 3848:4d9aba494478 libavcodec
Original Commit: r46 | ods15 | 2006-09-23 11:36:32 +0300 (Sat, 23 Sep 2006) | 2 lines
fix normalization, output is (roughly?) same volume as input
author | ods15 |
---|---|
date | Mon, 02 Oct 2006 05:56:40 +0000 |
parents | 9cf71c2ff770 |
children | ead3ae56d1b6 |
comparison
equal
deleted
inserted
replaced
3847:9cf71c2ff770 | 3848:4d9aba494478 |
---|---|
615 | 615 |
616 static int window(venc_context_t * venc, signed short * audio, int samples) { | 616 static int window(venc_context_t * venc, signed short * audio, int samples) { |
617 int i, j, channel; | 617 int i, j, channel; |
618 const float * win = venc->win[0]; | 618 const float * win = venc->win[0]; |
619 int window_len = 1 << (venc->blocksize[0] - 1); | 619 int window_len = 1 << (venc->blocksize[0] - 1); |
620 float n = (float)(1 << venc->blocksize[0]) / 4.; | |
620 // FIXME use dsp | 621 // FIXME use dsp |
621 | 622 |
622 if (!venc->have_saved && !samples) return 0; | 623 if (!venc->have_saved && !samples) return 0; |
623 | 624 |
624 if (venc->have_saved) { | 625 if (venc->have_saved) { |
634 if (samples) { | 635 if (samples) { |
635 for (channel = 0; channel < venc->channels; channel++) { | 636 for (channel = 0; channel < venc->channels; channel++) { |
636 float * offset = venc->samples + channel*window_len*2 + window_len; | 637 float * offset = venc->samples + channel*window_len*2 + window_len; |
637 j = channel; | 638 j = channel; |
638 for (i = 0; i < samples; i++, j += venc->channels) | 639 for (i = 0; i < samples; i++, j += venc->channels) |
639 offset[i] = audio[j] / 32768. * win[window_len - i]; | 640 offset[i] = audio[j] / 32768. * win[window_len - i] / n; |
640 } | 641 } |
641 } else { | 642 } else { |
642 for (channel = 0; channel < venc->channels; channel++) { | 643 for (channel = 0; channel < venc->channels; channel++) { |
643 memset(venc->samples + channel*window_len*2 + window_len, 0, sizeof(float)*window_len); | 644 memset(venc->samples + channel*window_len*2 + window_len, 0, sizeof(float)*window_len); |
644 } | 645 } |
651 if (samples) { | 652 if (samples) { |
652 for (channel = 0; channel < venc->channels; channel++) { | 653 for (channel = 0; channel < venc->channels; channel++) { |
653 float * offset = venc->saved + channel*window_len; | 654 float * offset = venc->saved + channel*window_len; |
654 j = channel; | 655 j = channel; |
655 for (i = 0; i < samples; i++, j += venc->channels) | 656 for (i = 0; i < samples; i++, j += venc->channels) |
656 offset[i] = audio[j] / 32768. * win[i]; | 657 offset[i] = audio[j] / 32768. * win[i] / n; |
657 } | 658 } |
658 venc->have_saved = 1; | 659 venc->have_saved = 1; |
659 } else { | 660 } else { |
660 venc->have_saved = 0; | 661 venc->have_saved = 0; |
661 } | 662 } |
757 put_bits(&pb, book->entries[entry].len, book->entries[entry].codeword); | 758 put_bits(&pb, book->entries[entry].len, book->entries[entry].codeword); |
758 } | 759 } |
759 } | 760 } |
760 | 761 |
761 for (j = 0; j < samples; j++) { | 762 for (j = 0; j < samples; j++) { |
762 venc->floor[i * samples + j] = floor1_inverse_db_table[220]; | 763 venc->floor[i * samples + j] = floor1_inverse_db_table[113]; |
763 } | 764 } |
764 } | 765 } |
765 | 766 |
766 for (i = 0; i < venc->channels; i++) { | 767 for (i = 0; i < venc->channels; i++) { |
767 int j; | 768 int j; |