comparison acelp_filters.c @ 9792:05ea4942df9b libavcodec

cosmetics: K&R style reformatting
author diego
date Thu, 04 Jun 2009 10:37:29 +0000
parents 611a21e4b01b
children cfb009484d2d
comparison
equal deleted inserted replaced
9791:de4a8f76b1b9 9792:05ea4942df9b
23 #include <inttypes.h> 23 #include <inttypes.h>
24 24
25 #include "avcodec.h" 25 #include "avcodec.h"
26 #include "acelp_filters.h" 26 #include "acelp_filters.h"
27 27
28 const int16_t ff_acelp_interp_filter[61] = 28 const int16_t ff_acelp_interp_filter[61] = { /* (0.15) */
29 { /* (0.15) */
30 29443, 28346, 25207, 20449, 14701, 8693, 29 29443, 28346, 25207, 20449, 14701, 8693,
31 3143, -1352, -4402, -5865, -5850, -4673, 30 3143, -1352, -4402, -5865, -5850, -4673,
32 -2783, -672, 1211, 2536, 3130, 2991, 31 -2783, -672, 1211, 2536, 3130, 2991,
33 2259, 1170, 0, -1001, -1652, -1868, 32 2259, 1170, 0, -1001, -1652, -1868,
34 -1666, -1147, -464, 218, 756, 1060, 33 -1666, -1147, -464, 218, 756, 1060,
38 -120, -163, -165, -132, -79, -19, 37 -120, -163, -165, -132, -79, -19,
39 34, 73, 91, 89, 70, 38, 38 34, 73, 91, 89, 70, 38,
40 0, 39 0,
41 }; 40 };
42 41
43 void ff_acelp_interpolate( 42 void ff_acelp_interpolate(int16_t* out, const int16_t* in,
44 int16_t* out, 43 const int16_t* filter_coeffs, int precision,
45 const int16_t* in, 44 int frac_pos, int filter_length, int length)
46 const int16_t* filter_coeffs,
47 int precision,
48 int frac_pos,
49 int filter_length,
50 int length)
51 { 45 {
52 int n, i; 46 int n, i;
53 47
54 assert(pitch_delay_frac >= 0 && pitch_delay_frac < precision); 48 assert(pitch_delay_frac >= 0 && pitch_delay_frac < precision);
55 49
56 for(n=0; n<length; n++) 50 for (n = 0; n < length; n++) {
57 {
58 int idx = 0; 51 int idx = 0;
59 int v = 0x4000; 52 int v = 0x4000;
60 53
61 for(i=0; i<filter_length;) 54 for (i = 0; i < filter_length;) {
62 {
63 55
64 /* The reference G.729 and AMR fixed point code performs clipping after 56 /* The reference G.729 and AMR fixed point code performs clipping after
65 each of the two following accumulations. 57 each of the two following accumulations.
66 Since clipping affects only the synthetic OVERFLOW test without 58 Since clipping affects only the synthetic OVERFLOW test without
67 causing an int type overflow, it was moved outside the loop. */ 59 causing an int type overflow, it was moved outside the loop. */
73 v += in[n + i] * filter_coeffs[idx + frac_pos]; 65 v += in[n + i] * filter_coeffs[idx + frac_pos];
74 idx += precision; 66 idx += precision;
75 i++; 67 i++;
76 v += in[n - i] * filter_coeffs[idx - frac_pos]; 68 v += in[n - i] * filter_coeffs[idx - frac_pos];
77 } 69 }
78 if(av_clip_int16(v>>15) != (v>>15)) 70 if (av_clip_int16(v >> 15) != (v >> 15))
79 av_log(NULL, AV_LOG_WARNING, "overflow that would need cliping in ff_acelp_interpolate()\n"); 71 av_log(NULL, AV_LOG_WARNING, "overflow that would need cliping in ff_acelp_interpolate()\n");
80 out[n] = v >> 15; 72 out[n] = v >> 15;
81 } 73 }
82 } 74 }
83 75
84 76
85 void ff_acelp_high_pass_filter( 77 void ff_acelp_high_pass_filter(int16_t* out, int hpf_f[2],
86 int16_t* out, 78 const int16_t* in, int length)
87 int hpf_f[2],
88 const int16_t* in,
89 int length)
90 { 79 {
91 int i; 80 int i;
92 int tmp; 81 int tmp;
93 82
94 for(i=0; i<length; i++) 83 for (i = 0; i < length; i++) {
95 { 84 tmp = (hpf_f[0]* 15836LL) >> 13;
96 tmp = (hpf_f[0]* 15836LL)>>13; 85 tmp += (hpf_f[1]* -7667LL) >> 13;
97 tmp += (hpf_f[1]* -7667LL)>>13;
98 tmp += 7699 * (in[i] - 2*in[i-1] + in[i-2]); 86 tmp += 7699 * (in[i] - 2*in[i-1] + in[i-2]);
99 87
100 /* With "+0x800" rounding, clipping is needed 88 /* With "+0x800" rounding, clipping is needed
101 for ALGTHM and SPEECH tests. */ 89 for ALGTHM and SPEECH tests. */
102 out[i] = av_clip_int16((tmp + 0x800) >> 12); 90 out[i] = av_clip_int16((tmp + 0x800) >> 12);