Mercurial > libavcodec.hg
comparison alsdec.c @ 10800:67e430033b14 libavcodec
Optimize short-term prediction by reducing index arithmetic.
author | thilo.borgmann |
---|---|
date | Thu, 07 Jan 2010 22:23:28 +0000 |
parents | fadd5dfac0f0 |
children | 4f614b69b4e5 |
comparison
equal
deleted
inserted
replaced
10799:00a3206c3e42 | 10800:67e430033b14 |
---|---|
710 int sb; | 710 int sb; |
711 int64_t y; | 711 int64_t y; |
712 int32_t *quant_cof = bd->quant_cof; | 712 int32_t *quant_cof = bd->quant_cof; |
713 int32_t *lpc_cof = bd->lpc_cof; | 713 int32_t *lpc_cof = bd->lpc_cof; |
714 int32_t *raw_samples = bd->raw_samples; | 714 int32_t *raw_samples = bd->raw_samples; |
715 int32_t *raw_samples_end = bd->raw_samples + bd->block_length; | |
716 int32_t lpc_cof_reversed[opt_order]; | |
715 | 717 |
716 // reverse long-term prediction | 718 // reverse long-term prediction |
717 if (*bd->use_ltp) { | 719 if (*bd->use_ltp) { |
718 int ltp_smp; | 720 int ltp_smp; |
719 | 721 |
737 if (bd->ra_block) { | 739 if (bd->ra_block) { |
738 for (smp = 0; smp < opt_order; smp++) { | 740 for (smp = 0; smp < opt_order; smp++) { |
739 y = 1 << 19; | 741 y = 1 << 19; |
740 | 742 |
741 for (sb = 0; sb < smp; sb++) | 743 for (sb = 0; sb < smp; sb++) |
742 y += MUL64(lpc_cof[sb], *(raw_samples + smp - (sb + 1))); | 744 y += MUL64(lpc_cof[sb], raw_samples[-(sb + 1)]); |
743 | 745 |
744 raw_samples[smp] -= y >> 20; | 746 *raw_samples++ -= y >> 20; |
745 parcor_to_lpc(smp, quant_cof, lpc_cof); | 747 parcor_to_lpc(smp, quant_cof, lpc_cof); |
746 } | 748 } |
747 } else { | 749 } else { |
748 for (k = 0; k < opt_order; k++) | 750 for (k = 0; k < opt_order; k++) |
749 parcor_to_lpc(k, quant_cof, lpc_cof); | 751 parcor_to_lpc(k, quant_cof, lpc_cof); |
773 if (bd->shift_lsbs) | 775 if (bd->shift_lsbs) |
774 for (sb = -1; sb >= -sconf->max_order; sb--) | 776 for (sb = -1; sb >= -sconf->max_order; sb--) |
775 raw_samples[sb] >>= bd->shift_lsbs; | 777 raw_samples[sb] >>= bd->shift_lsbs; |
776 } | 778 } |
777 | 779 |
780 // reverse linear prediction coefficients for efficiency | |
781 lpc_cof = lpc_cof + opt_order; | |
782 | |
783 for (sb = 0; sb < opt_order; sb++) | |
784 lpc_cof_reversed[sb] = lpc_cof[-(sb + 1)]; | |
785 | |
778 // reconstruct raw samples | 786 // reconstruct raw samples |
779 for (; smp < bd->block_length; smp++) { | 787 raw_samples = bd->raw_samples + smp; |
788 lpc_cof = lpc_cof_reversed + opt_order; | |
789 | |
790 for (; raw_samples < raw_samples_end; raw_samples++) { | |
780 y = 1 << 19; | 791 y = 1 << 19; |
781 | 792 |
782 for (sb = 0; sb < opt_order; sb++) | 793 for (sb = -opt_order; sb < 0; sb++) |
783 y += MUL64(bd->lpc_cof[sb], *(raw_samples + smp - (sb + 1))); | 794 y += MUL64(lpc_cof[sb], raw_samples[sb]); |
784 | 795 |
785 raw_samples[smp] -= y >> 20; | 796 *raw_samples -= y >> 20; |
786 } | 797 } |
798 | |
799 raw_samples = bd->raw_samples; | |
787 | 800 |
788 // restore previous samples in case that they have been altered | 801 // restore previous samples in case that they have been altered |
789 if (bd->store_prev_samples) | 802 if (bd->store_prev_samples) |
790 memcpy(raw_samples - sconf->max_order, bd->prev_raw_samples, | 803 memcpy(raw_samples - sconf->max_order, bd->prev_raw_samples, |
791 sizeof(*raw_samples) * sconf->max_order); | 804 sizeof(*raw_samples) * sconf->max_order); |