comparison apedec.c @ 7203:87b1dfb5a98d libavcodec

Add several vector functions used by Monkey's Audio decoder to dsputil
author kostya
date Sun, 06 Jul 2008 06:06:55 +0000
parents e943e1409077
children 85ab7655ad4d
comparison
equal deleted inserted replaced
7202:2a4ac127112c 7203:87b1dfb5a98d
159 159
160 int error; 160 int error;
161 } APEContext; 161 } APEContext;
162 162
163 // TODO: dsputilize 163 // TODO: dsputilize
164 static inline void vector_add(int16_t * v1, int16_t * v2, int order)
165 {
166 while (order--)
167 *v1++ += *v2++;
168 }
169
170 // TODO: dsputilize
171 static inline void vector_sub(int16_t * v1, int16_t * v2, int order)
172 {
173 while (order--)
174 *v1++ -= *v2++;
175 }
176
177 // TODO: dsputilize
178 static inline int32_t scalarproduct(int16_t * v1, int16_t * v2, int order)
179 {
180 int res = 0;
181
182 while (order--)
183 res += *v1++ * *v2++;
184
185 return res;
186 }
187 164
188 static av_cold int ape_decode_init(AVCodecContext * avctx) 165 static av_cold int ape_decode_init(AVCodecContext * avctx)
189 { 166 {
190 APEContext *s = avctx->priv_data; 167 APEContext *s = avctx->priv_data;
191 int i; 168 int i;
670 { 647 {
671 do_init_filter(&f[0], buf, order); 648 do_init_filter(&f[0], buf, order);
672 do_init_filter(&f[1], buf + order * 3 + HISTORY_SIZE, order); 649 do_init_filter(&f[1], buf + order * 3 + HISTORY_SIZE, order);
673 } 650 }
674 651
675 static inline void do_apply_filter(int version, APEFilter *f, int32_t *data, int count, int order, int fracbits) 652 static inline void do_apply_filter(APEContext * ctx, int version, APEFilter *f, int32_t *data, int count, int order, int fracbits)
676 { 653 {
677 int res; 654 int res;
678 int absres; 655 int absres;
679 656
680 while (count--) { 657 while (count--) {
681 /* round fixedpoint scalar product */ 658 /* round fixedpoint scalar product */
682 res = (scalarproduct(f->delay - order, f->coeffs, order) + (1 << (fracbits - 1))) >> fracbits; 659 res = (ctx->dsp.scalarproduct_int16(f->delay - order, f->coeffs, order, 0) + (1 << (fracbits - 1))) >> fracbits;
683 660
684 if (*data < 0) 661 if (*data < 0)
685 vector_add(f->coeffs, f->adaptcoeffs - order, order); 662 ctx->dsp.add_int16(f->coeffs, f->adaptcoeffs - order, order);
686 else if (*data > 0) 663 else if (*data > 0)
687 vector_sub(f->coeffs, f->adaptcoeffs - order, order); 664 ctx->dsp.sub_int16(f->coeffs, f->adaptcoeffs - order, order);
688 665
689 res += *data; 666 res += *data;
690 667
691 *data++ = res; 668 *data++ = res;
692 669
734 711
735 static void apply_filter(APEContext * ctx, APEFilter *f, 712 static void apply_filter(APEContext * ctx, APEFilter *f,
736 int32_t * data0, int32_t * data1, 713 int32_t * data0, int32_t * data1,
737 int count, int order, int fracbits) 714 int count, int order, int fracbits)
738 { 715 {
739 do_apply_filter(ctx->fileversion, &f[0], data0, count, order, fracbits); 716 do_apply_filter(ctx, ctx->fileversion, &f[0], data0, count, order, fracbits);
740 if (data1) 717 if (data1)
741 do_apply_filter(ctx->fileversion, &f[1], data1, count, order, fracbits); 718 do_apply_filter(ctx, ctx->fileversion, &f[1], data1, count, order, fracbits);
742 } 719 }
743 720
744 static void ape_apply_filters(APEContext * ctx, int32_t * decoded0, 721 static void ape_apply_filters(APEContext * ctx, int32_t * decoded0,
745 int32_t * decoded1, int count) 722 int32_t * decoded1, int count)
746 { 723 {