comparison mlpdec.c @ 9279:b65ab36734f8 libavcodec

mlpdec: Unroll copying filter state data and filtering for the two filters.
author ramiro
date Mon, 30 Mar 2009 02:59:45 +0000
parents 41e285948ffc
children e3eff8a463ec
comparison
equal deleted inserted replaced
9278:41e285948ffc 9279:b65ab36734f8
656 FilterParams *fp[NUM_FILTERS] = { &m->channel_params[channel].filter_params[FIR], 656 FilterParams *fp[NUM_FILTERS] = { &m->channel_params[channel].filter_params[FIR],
657 &m->channel_params[channel].filter_params[IIR], }; 657 &m->channel_params[channel].filter_params[IIR], };
658 unsigned int filter_shift = fp[FIR]->shift; 658 unsigned int filter_shift = fp[FIR]->shift;
659 int32_t mask = MSB_MASK(s->quant_step_size[channel]); 659 int32_t mask = MSB_MASK(s->quant_step_size[channel]);
660 int index = MAX_BLOCKSIZE; 660 int index = MAX_BLOCKSIZE;
661 int j, i; 661 int i;
662 662
663 for (j = 0; j < NUM_FILTERS; j++) { 663 memcpy(&filter_state_buffer[FIR][MAX_BLOCKSIZE], &fp[FIR]->state[0],
664 memcpy(&filter_state_buffer[j][MAX_BLOCKSIZE], &fp[j]->state[0], 664 MAX_FIR_ORDER * sizeof(int32_t));
665 MAX_FIR_ORDER * sizeof(int32_t)); 665 memcpy(&filter_state_buffer[IIR][MAX_BLOCKSIZE], &fp[IIR]->state[0],
666 } 666 MAX_IIR_ORDER * sizeof(int32_t));
667 667
668 for (i = 0; i < s->blocksize; i++) { 668 for (i = 0; i < s->blocksize; i++) {
669 int32_t residual = m->sample_buffer[i + s->blockpos][channel]; 669 int32_t residual = m->sample_buffer[i + s->blockpos][channel];
670 unsigned int order; 670 unsigned int order;
671 int64_t accum = 0; 671 int64_t accum = 0;
672 int32_t result; 672 int32_t result;
673 673
674 /* TODO: Move this code to DSPContext? */ 674 /* TODO: Move this code to DSPContext? */
675 675
676 for (j = 0; j < NUM_FILTERS; j++) 676 for (order = 0; order < fp[FIR]->order; order++)
677 for (order = 0; order < fp[j]->order; order++) 677 accum += (int64_t)filter_state_buffer[FIR][index + order] *
678 accum += (int64_t)filter_state_buffer[j][index + order] * 678 fp[FIR]->coeff[order];
679 fp[j]->coeff[order]; 679 for (order = 0; order < fp[IIR]->order; order++)
680 accum += (int64_t)filter_state_buffer[IIR][index + order] *
681 fp[IIR]->coeff[order];
680 682
681 accum = accum >> filter_shift; 683 accum = accum >> filter_shift;
682 result = (accum + residual) & mask; 684 result = (accum + residual) & mask;
683 685
684 --index; 686 --index;
687 filter_state_buffer[IIR][index] = result - accum; 689 filter_state_buffer[IIR][index] = result - accum;
688 690
689 m->sample_buffer[i + s->blockpos][channel] = result; 691 m->sample_buffer[i + s->blockpos][channel] = result;
690 } 692 }
691 693
692 for (j = 0; j < NUM_FILTERS; j++) { 694 memcpy(&fp[FIR]->state[0], &filter_state_buffer[FIR][index],
693 memcpy(&fp[j]->state[0], &filter_state_buffer[j][index], 695 MAX_FIR_ORDER * sizeof(int32_t));
694 MAX_FIR_ORDER * sizeof(int32_t)); 696 memcpy(&fp[IIR]->state[0], &filter_state_buffer[IIR][index],
695 } 697 MAX_IIR_ORDER * sizeof(int32_t));
696 } 698 }
697 699
698 /** Read a block of PCM residual data (or actual if no filtering active). */ 700 /** Read a block of PCM residual data (or actual if no filtering active). */
699 701
700 static int read_block_data(MLPDecodeContext *m, GetBitContext *gbp, 702 static int read_block_data(MLPDecodeContext *m, GetBitContext *gbp,