Mercurial > libavcodec.hg
comparison ra288.c @ 8094:36671e6689c7 libavcodec
Use ff_dot_productf() in ra288.c
author | vitor |
---|---|
date | Thu, 30 Oct 2008 22:24:40 +0000 |
parents | 5b81784c5fe6 |
children | 19bbd1457372 |
comparison
equal
deleted
inserted
replaced
8093:408d200a6179 | 8094:36671e6689c7 |
---|---|
22 #include "avcodec.h" | 22 #include "avcodec.h" |
23 #define ALT_BITSTREAM_READER_LE | 23 #define ALT_BITSTREAM_READER_LE |
24 #include "bitstream.h" | 24 #include "bitstream.h" |
25 #include "ra288.h" | 25 #include "ra288.h" |
26 #include "lpc.h" | 26 #include "lpc.h" |
27 #include "celp_math.h" | |
27 | 28 |
28 typedef struct { | 29 typedef struct { |
29 float sp_lpc[36]; ///< LPC coefficients for speech data (spec: A) | 30 float sp_lpc[36]; ///< LPC coefficients for speech data (spec: A) |
30 float gain_lpc[10]; ///< LPC coefficients for gain (spec: GB) | 31 float gain_lpc[10]; ///< LPC coefficients for gain (spec: GB) |
31 | 32 |
50 { | 51 { |
51 avctx->sample_fmt = SAMPLE_FMT_FLT; | 52 avctx->sample_fmt = SAMPLE_FMT_FLT; |
52 return 0; | 53 return 0; |
53 } | 54 } |
54 | 55 |
55 static inline float scalar_product_float(const float * v1, const float * v2, | |
56 int size) | |
57 { | |
58 float res = 0.; | |
59 | |
60 while (size--) | |
61 res += *v1++ * *v2++; | |
62 | |
63 return res; | |
64 } | |
65 | |
66 static void apply_window(float *tgt, const float *m1, const float *m2, int n) | 56 static void apply_window(float *tgt, const float *m1, const float *m2, int n) |
67 { | 57 { |
68 while (n--) | 58 while (n--) |
69 *tgt++ = *m1++ * *m2++; | 59 *tgt++ = *m1++ * *m2++; |
70 } | 60 } |
71 | 61 |
72 static void convolve(float *tgt, const float *src, int len, int n) | 62 static void convolve(float *tgt, const float *src, int len, int n) |
73 { | 63 { |
74 for (; n >= 0; n--) | 64 for (; n >= 0; n--) |
75 tgt[n] = scalar_product_float(src, src - n, len); | 65 tgt[n] = ff_dot_productf(src, src - n, len); |
76 | 66 |
77 } | 67 } |
78 | 68 |
79 static void decode(RA288Context *ractx, float gain, int cb_coef) | 69 static void decode(RA288Context *ractx, float gain, int cb_coef) |
80 { | 70 { |
99 sumsum = exp(sum * 0.1151292546497) * gain * (1.0/(1<<23)); | 89 sumsum = exp(sum * 0.1151292546497) * gain * (1.0/(1<<23)); |
100 | 90 |
101 for (i=0; i < 5; i++) | 91 for (i=0; i < 5; i++) |
102 buffer[i] = codetable[cb_coef][i] * sumsum; | 92 buffer[i] = codetable[cb_coef][i] * sumsum; |
103 | 93 |
104 sum = scalar_product_float(buffer, buffer, 5) * ((1<<24)/5.); | 94 sum = ff_dot_productf(buffer, buffer, 5) * ((1<<24)/5.); |
105 | 95 |
106 sum = FFMAX(sum, 1); | 96 sum = FFMAX(sum, 1); |
107 | 97 |
108 /* shift and store */ | 98 /* shift and store */ |
109 memmove(gain_block, gain_block + 1, 9 * sizeof(*gain_block)); | 99 memmove(gain_block, gain_block + 1, 9 * sizeof(*gain_block)); |