Mercurial > libavcodec.hg
comparison mlpdec.c @ 9278:41e285948ffc libavcodec
mlpdec: Max filter orders for FIR and IIR are 8 and 4 respectively.
author | ramiro |
---|---|
date | Mon, 30 Mar 2009 02:54:19 +0000 |
parents | 3020588d4312 |
children | b65ab36734f8 |
comparison
equal
deleted
inserted
replaced
9277:b8e5b7edb2d5 | 9278:41e285948ffc |
---|---|
431 | 431 |
432 static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp, | 432 static int read_filter_params(MLPDecodeContext *m, GetBitContext *gbp, |
433 unsigned int channel, unsigned int filter) | 433 unsigned int channel, unsigned int filter) |
434 { | 434 { |
435 FilterParams *fp = &m->channel_params[channel].filter_params[filter]; | 435 FilterParams *fp = &m->channel_params[channel].filter_params[filter]; |
436 const int max_order = filter ? MAX_IIR_ORDER : MAX_FIR_ORDER; | |
436 const char fchar = filter ? 'I' : 'F'; | 437 const char fchar = filter ? 'I' : 'F'; |
437 int i, order; | 438 int i, order; |
438 | 439 |
439 // Filter is 0 for FIR, 1 for IIR. | 440 // Filter is 0 for FIR, 1 for IIR. |
440 assert(filter < 2); | 441 assert(filter < 2); |
441 | 442 |
442 order = get_bits(gbp, 4); | 443 order = get_bits(gbp, 4); |
443 if (order > MAX_FILTER_ORDER) { | 444 if (order > max_order) { |
444 av_log(m->avctx, AV_LOG_ERROR, | 445 av_log(m->avctx, AV_LOG_ERROR, |
445 "%cIR filter order %d is greater than maximum %d.\n", | 446 "%cIR filter order %d is greater than maximum %d.\n", |
446 fchar, order, MAX_FILTER_ORDER); | 447 fchar, order, max_order); |
447 return -1; | 448 return -1; |
448 } | 449 } |
449 fp->order = order; | 450 fp->order = order; |
450 | 451 |
451 if (order > 0) { | 452 if (order > 0) { |
649 | 650 |
650 static void filter_channel(MLPDecodeContext *m, unsigned int substr, | 651 static void filter_channel(MLPDecodeContext *m, unsigned int substr, |
651 unsigned int channel) | 652 unsigned int channel) |
652 { | 653 { |
653 SubStream *s = &m->substream[substr]; | 654 SubStream *s = &m->substream[substr]; |
654 int32_t filter_state_buffer[NUM_FILTERS][MAX_BLOCKSIZE + MAX_FILTER_ORDER]; | 655 int32_t filter_state_buffer[NUM_FILTERS][MAX_BLOCKSIZE + MAX_FIR_ORDER]; |
655 FilterParams *fp[NUM_FILTERS] = { &m->channel_params[channel].filter_params[FIR], | 656 FilterParams *fp[NUM_FILTERS] = { &m->channel_params[channel].filter_params[FIR], |
656 &m->channel_params[channel].filter_params[IIR], }; | 657 &m->channel_params[channel].filter_params[IIR], }; |
657 unsigned int filter_shift = fp[FIR]->shift; | 658 unsigned int filter_shift = fp[FIR]->shift; |
658 int32_t mask = MSB_MASK(s->quant_step_size[channel]); | 659 int32_t mask = MSB_MASK(s->quant_step_size[channel]); |
659 int index = MAX_BLOCKSIZE; | 660 int index = MAX_BLOCKSIZE; |
660 int j, i; | 661 int j, i; |
661 | 662 |
662 for (j = 0; j < NUM_FILTERS; j++) { | 663 for (j = 0; j < NUM_FILTERS; j++) { |
663 memcpy(&filter_state_buffer[j][MAX_BLOCKSIZE], &fp[j]->state[0], | 664 memcpy(&filter_state_buffer[j][MAX_BLOCKSIZE], &fp[j]->state[0], |
664 MAX_FILTER_ORDER * sizeof(int32_t)); | 665 MAX_FIR_ORDER * sizeof(int32_t)); |
665 } | 666 } |
666 | 667 |
667 for (i = 0; i < s->blocksize; i++) { | 668 for (i = 0; i < s->blocksize; i++) { |
668 int32_t residual = m->sample_buffer[i + s->blockpos][channel]; | 669 int32_t residual = m->sample_buffer[i + s->blockpos][channel]; |
669 unsigned int order; | 670 unsigned int order; |
688 m->sample_buffer[i + s->blockpos][channel] = result; | 689 m->sample_buffer[i + s->blockpos][channel] = result; |
689 } | 690 } |
690 | 691 |
691 for (j = 0; j < NUM_FILTERS; j++) { | 692 for (j = 0; j < NUM_FILTERS; j++) { |
692 memcpy(&fp[j]->state[0], &filter_state_buffer[j][index], | 693 memcpy(&fp[j]->state[0], &filter_state_buffer[j][index], |
693 MAX_FILTER_ORDER * sizeof(int32_t)); | 694 MAX_FIR_ORDER * sizeof(int32_t)); |
694 } | 695 } |
695 } | 696 } |
696 | 697 |
697 /** Read a block of PCM residual data (or actual if no filtering active). */ | 698 /** Read a block of PCM residual data (or actual if no filtering active). */ |
698 | 699 |