Mercurial > libavcodec.hg
comparison g726.c @ 2135:9a481659d7cb libavcodec
make comments doxygen compatible
author | michael |
---|---|
date | Thu, 22 Jul 2004 18:55:36 +0000 |
parents | fac680cf3008 |
children | 582e635cfa08 |
comparison
equal
deleted
inserted
replaced
2134:8afd396fa198 | 2135:9a481659d7cb |
---|---|
21 */ | 21 */ |
22 #include <limits.h> | 22 #include <limits.h> |
23 #include "avcodec.h" | 23 #include "avcodec.h" |
24 #include "common.h" | 24 #include "common.h" |
25 | 25 |
26 /* | 26 /** |
27 * G.726 11bit float. | |
27 * G.726 Standard uses rather odd 11bit floating point arithmentic for | 28 * G.726 Standard uses rather odd 11bit floating point arithmentic for |
28 * numerous occasions. It's a mistery to me why they did it this way | 29 * numerous occasions. It's a mistery to me why they did it this way |
29 * instead of simply using 32bit integer arithmetic. | 30 * instead of simply using 32bit integer arithmetic. |
30 */ | 31 */ |
31 typedef struct Float11 { | 32 typedef struct Float11 { |
32 int sign; /* 1bit sign */ | 33 int sign; /**< 1bit sign */ |
33 int exp; /* 4bit exponent */ | 34 int exp; /**< 4bit exponent */ |
34 int mant; /* 6bit mantissa */ | 35 int mant; /**< 6bit mantissa */ |
35 } Float11; | 36 } Float11; |
36 | 37 |
37 static inline Float11* i2f(int16_t i, Float11* f) | 38 static inline Float11* i2f(int16_t i, Float11* f) |
38 { | 39 { |
39 f->sign = (i < 0); | 40 f->sign = (i < 0); |
59 { | 60 { |
60 return (value < 0) ? -1 : 1; | 61 return (value < 0) ? -1 : 1; |
61 } | 62 } |
62 | 63 |
63 typedef struct G726Tables { | 64 typedef struct G726Tables { |
64 int bits; /* bits per sample */ | 65 int bits; /**< bits per sample */ |
65 int* quant; /* quantization table */ | 66 int* quant; /**< quantization table */ |
66 int* iquant; /* inverse quantization table */ | 67 int* iquant; /**< inverse quantization table */ |
67 int* W; /* special table #1 ;-) */ | 68 int* W; /**< special table #1 ;-) */ |
68 int* F; /* special table #2 */ | 69 int* F; /**< special table #2 */ |
69 } G726Tables; | 70 } G726Tables; |
70 | 71 |
71 typedef struct G726Context { | 72 typedef struct G726Context { |
72 G726Tables* tbls; /* static tables needed for computation */ | 73 G726Tables* tbls; /**< static tables needed for computation */ |
73 | 74 |
74 Float11 sr[2]; /* prev. reconstructed samples */ | 75 Float11 sr[2]; /**< prev. reconstructed samples */ |
75 Float11 dq[6]; /* prev. difference */ | 76 Float11 dq[6]; /**< prev. difference */ |
76 int a[2]; /* second order predictor coeffs */ | 77 int a[2]; /**< second order predictor coeffs */ |
77 int b[6]; /* sixth order predictor coeffs */ | 78 int b[6]; /**< sixth order predictor coeffs */ |
78 int pk[2]; /* signs of prev. 2 sez + dq */ | 79 int pk[2]; /**< signs of prev. 2 sez + dq */ |
79 | 80 |
80 int ap; /* scale factor control */ | 81 int ap; /**< scale factor control */ |
81 int yu; /* fast scale factor */ | 82 int yu; /**< fast scale factor */ |
82 int yl; /* slow scale factor */ | 83 int yl; /**< slow scale factor */ |
83 int dms; /* short average magnitude of F[i] */ | 84 int dms; /**< short average magnitude of F[i] */ |
84 int dml; /* long average magnitude of F[i] */ | 85 int dml; /**< long average magnitude of F[i] */ |
85 int td; /* tone detect */ | 86 int td; /**< tone detect */ |
86 | 87 |
87 int se; /* estimated signal for the next iteration */ | 88 int se; /**< estimated signal for the next iteration */ |
88 int sez; /* estimated second order prediction */ | 89 int sez; /**< estimated second order prediction */ |
89 int y; /* quantizer scaling factor for the next iteration */ | 90 int y; /**< quantizer scaling factor for the next iteration */ |
90 } G726Context; | 91 } G726Context; |
91 | 92 |
92 static int quant_tbl16[] = /* 16kbit/s 2bits per sample */ | 93 static int quant_tbl16[] = /**< 16kbit/s 2bits per sample */ |
93 { 260, INT_MAX }; | 94 { 260, INT_MAX }; |
94 static int iquant_tbl16[] = | 95 static int iquant_tbl16[] = |
95 { 116, 365, 365, 116 }; | 96 { 116, 365, 365, 116 }; |
96 static int W_tbl16[] = | 97 static int W_tbl16[] = |
97 { -22, 439, 439, -22 }; | 98 { -22, 439, 439, -22 }; |
98 static int F_tbl16[] = | 99 static int F_tbl16[] = |
99 { 0, 7, 7, 0 }; | 100 { 0, 7, 7, 0 }; |
100 | 101 |
101 static int quant_tbl24[] = /* 24kbit/s 3bits per sample */ | 102 static int quant_tbl24[] = /**< 24kbit/s 3bits per sample */ |
102 { 7, 217, 330, INT_MAX }; | 103 { 7, 217, 330, INT_MAX }; |
103 static int iquant_tbl24[] = | 104 static int iquant_tbl24[] = |
104 { INT_MIN, 135, 273, 373, 373, 273, 135, INT_MIN }; | 105 { INT_MIN, 135, 273, 373, 373, 273, 135, INT_MIN }; |
105 static int W_tbl24[] = | 106 static int W_tbl24[] = |
106 { -4, 30, 137, 582, 582, 137, 30, -4 }; | 107 { -4, 30, 137, 582, 582, 137, 30, -4 }; |
107 static int F_tbl24[] = | 108 static int F_tbl24[] = |
108 { 0, 1, 2, 7, 7, 2, 1, 0 }; | 109 { 0, 1, 2, 7, 7, 2, 1, 0 }; |
109 | 110 |
110 static int quant_tbl32[] = /* 32kbit/s 4bits per sample */ | 111 static int quant_tbl32[] = /**< 32kbit/s 4bits per sample */ |
111 { -125, 79, 177, 245, 299, 348, 399, INT_MAX }; | 112 { -125, 79, 177, 245, 299, 348, 399, INT_MAX }; |
112 static int iquant_tbl32[] = | 113 static int iquant_tbl32[] = |
113 { INT_MIN, 4, 135, 213, 273, 323, 373, 425, | 114 { INT_MIN, 4, 135, 213, 273, 323, 373, 425, |
114 425, 373, 323, 273, 213, 135, 4, INT_MIN }; | 115 425, 373, 323, 273, 213, 135, 4, INT_MIN }; |
115 static int W_tbl32[] = | 116 static int W_tbl32[] = |
116 { -12, 18, 41, 64, 112, 198, 355, 1122, | 117 { -12, 18, 41, 64, 112, 198, 355, 1122, |
117 1122, 355, 198, 112, 64, 41, 18, -12}; | 118 1122, 355, 198, 112, 64, 41, 18, -12}; |
118 static int F_tbl32[] = | 119 static int F_tbl32[] = |
119 { 0, 0, 0, 1, 1, 1, 3, 7, 7, 3, 1, 1, 1, 0, 0, 0 }; | 120 { 0, 0, 0, 1, 1, 1, 3, 7, 7, 3, 1, 1, 1, 0, 0, 0 }; |
120 | 121 |
121 static int quant_tbl40[] = /* 40kbit/s 5bits per sample */ | 122 static int quant_tbl40[] = /**< 40kbit/s 5bits per sample */ |
122 { -122, -16, 67, 138, 197, 249, 297, 338, | 123 { -122, -16, 67, 138, 197, 249, 297, 338, |
123 377, 412, 444, 474, 501, 527, 552, INT_MAX }; | 124 377, 412, 444, 474, 501, 527, 552, INT_MAX }; |
124 static int iquant_tbl40[] = | 125 static int iquant_tbl40[] = |
125 { INT_MIN, -66, 28, 104, 169, 224, 274, 318, | 126 { INT_MIN, -66, 28, 104, 169, 224, 274, 318, |
126 358, 395, 429, 459, 488, 514, 539, 566, | 127 358, 395, 429, 459, 488, 514, 539, 566, |
140 { 3, quant_tbl24, iquant_tbl24, W_tbl24, F_tbl24 }, | 141 { 3, quant_tbl24, iquant_tbl24, W_tbl24, F_tbl24 }, |
141 { 4, quant_tbl32, iquant_tbl32, W_tbl32, F_tbl32 }, | 142 { 4, quant_tbl32, iquant_tbl32, W_tbl32, F_tbl32 }, |
142 { 5, quant_tbl40, iquant_tbl40, W_tbl40, F_tbl40 }}; | 143 { 5, quant_tbl40, iquant_tbl40, W_tbl40, F_tbl40 }}; |
143 | 144 |
144 | 145 |
145 /* | 146 /** |
146 * Para 4.2.2 page 18: Adaptive quantizer. | 147 * Para 4.2.2 page 18: Adaptive quantizer. |
147 */ | 148 */ |
148 static inline uint8_t quant(G726Context* c, int d) | 149 static inline uint8_t quant(G726Context* c, int d) |
149 { | 150 { |
150 int sign, exp, i, dln; | 151 int sign, exp, i, dln; |
166 i = 0xff; | 167 i = 0xff; |
167 | 168 |
168 return i; | 169 return i; |
169 } | 170 } |
170 | 171 |
171 /* | 172 /** |
172 * Para 4.2.3 page 22: Inverse adaptive quantizer. | 173 * Para 4.2.3 page 22: Inverse adaptive quantizer. |
173 */ | 174 */ |
174 static inline int16_t inverse_quant(G726Context* c, int i) | 175 static inline int16_t inverse_quant(G726Context* c, int i) |
175 { | 176 { |
176 int dql, dex, dqt; | 177 int dql, dex, dqt; |