Lines Matching +full:0 +full:- +full:7
20 /* ulaw[unsigned char] -> signed 16-bit */
22 /* alaw[unsigned char] -> signed 16-bit */
28 /* signed 16-bit -> law */
32 /* alaw -> ulaw */
34 /* ulaw -> alaw */
43 #define AMI_MASK 0x55
51 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF in linear2alaw()
55 if (pcm_val >= 0) { in linear2alaw()
56 /* Sign (7th) bit = 1 */ in linear2alaw()
57 mask = AMI_MASK | 0x80; in linear2alaw()
59 /* Sign bit = 0 */ in linear2alaw()
61 pcm_val = -pcm_val; in linear2alaw()
65 for (seg = 0; seg < 8; seg++) { in linear2alaw()
71 ((pcm_val >> ((seg) ? (seg + 3) : 4)) & 0x0F)) ^ mask; in linear2alaw()
81 i = ((alaw & 0x0F) << 4) + 8 /* rounding error */; in alaw2linear()
82 seg = (((int) alaw & 0x70) >> 4); in alaw2linear()
84 i = (i + 0x100) << (seg - 1); in alaw2linear()
85 return (short int) ((alaw & 0x80) ? i : -i); in alaw2linear()
91 static short etab[] = {0, 132, 396, 924, 1980, 4092, 8316, 16764}; in ulaw2linear()
93 mu = 255 - ulaw; in ulaw2linear()
94 e = (mu & 0x70) / 16; in ulaw2linear()
95 f = mu & 0x0f; in ulaw2linear()
98 if (mu & 0x80) in ulaw2linear()
99 y = -y; in ulaw2linear()
103 #define BIAS 0x84 /*!< define the add-in bias for 16 bit samples */
108 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, in linear2ulaw()
116 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, in linear2ulaw()
117 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, in linear2ulaw()
118 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, in linear2ulaw()
119 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, in linear2ulaw()
120 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, in linear2ulaw()
121 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, in linear2ulaw()
122 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, in linear2ulaw()
123 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}; in linear2ulaw()
127 /* Get the sample into sign-magnitude. */ in linear2ulaw()
128 sign = (sample >> 8) & 0x80; /* set aside the sign */ in linear2ulaw()
129 if (sign != 0) in linear2ulaw()
130 sample = -sample; /* get magnitude */ in linear2ulaw()
134 exponent = exp_lut[(sample >> 7) & 0xFF]; in linear2ulaw()
135 mantissa = (sample >> (exponent + 3)) & 0x0F; in linear2ulaw()
144 for (i = 0; i < 256; i++) in dsp_audio_generate_law_tables()
147 for (i = 0; i < 256; i++) in dsp_audio_generate_law_tables()
150 for (i = 0; i < 256; i++) { in dsp_audio_generate_law_tables()
164 /* generating ulaw-table */ in dsp_audio_generate_s2law_table()
165 for (i = -32768; i < 32768; i++) { in dsp_audio_generate_s2law_table()
166 dsp_audio_s16_to_law[i & 0xffff] = in dsp_audio_generate_s2law_table()
170 /* generating alaw-table */ in dsp_audio_generate_s2law_table()
171 for (i = -32768; i < 32768; i++) { in dsp_audio_generate_s2law_table()
172 dsp_audio_s16_to_law[i & 0xffff] = in dsp_audio_generate_s2law_table()
180 * the seven bit sample is the number of every second alaw-sample ordered by
181 * aplitude. 0x00 is negative, 0x7f is positive amplitude.
187 * generate table for conversion law from/to 7-bit alaw-like sample *
198 for (i = 0; i < 256; i++) { in dsp_audio_generate_seven()
199 j = 0; in dsp_audio_generate_seven()
200 for (k = 0; k < 256; k++) { in dsp_audio_generate_seven()
209 for (i = 0; i < 256; i++) { in dsp_audio_generate_seven()
210 /* spl is the source: the law-sample (converted to alaw) */ in dsp_audio_generate_seven()
214 /* find the 7-bit-sample */ in dsp_audio_generate_seven()
215 for (j = 0; j < 256; j++) { in dsp_audio_generate_seven()
219 /* write 7-bit audio value */ in dsp_audio_generate_seven()
222 for (i = 0; i < 128; i++) { in dsp_audio_generate_seven()
231 /* mix 2*law -> law */
244 i = 0; in dsp_audio_generate_mix_table()
246 j = 0; in dsp_audio_generate_mix_table()
252 if (sample < -32768) in dsp_audio_generate_mix_table()
253 sample = -32768; in dsp_audio_generate_mix_table()
255 dsp_audio_s16_to_law[sample & 0xffff]; in dsp_audio_generate_mix_table()
311 i = 0; in dsp_audio_generate_volume_changes()
314 (dsp_audio_law_to_s32[i] * denum[7] / num[7]) & 0xffff]; in dsp_audio_generate_volume_changes()
316 (dsp_audio_law_to_s32[i] * denum[6] / num[6]) & 0xffff]; in dsp_audio_generate_volume_changes()
318 (dsp_audio_law_to_s32[i] * denum[5] / num[5]) & 0xffff]; in dsp_audio_generate_volume_changes()
320 (dsp_audio_law_to_s32[i] * denum[4] / num[4]) & 0xffff]; in dsp_audio_generate_volume_changes()
322 (dsp_audio_law_to_s32[i] * denum[3] / num[3]) & 0xffff]; in dsp_audio_generate_volume_changes()
324 (dsp_audio_law_to_s32[i] * denum[2] / num[2]) & 0xffff]; in dsp_audio_generate_volume_changes()
326 (dsp_audio_law_to_s32[i] * denum[1] / num[1]) & 0xffff]; in dsp_audio_generate_volume_changes()
328 (dsp_audio_law_to_s32[i] * denum[0] / num[0]) & 0xffff]; in dsp_audio_generate_volume_changes()
329 sample = dsp_audio_law_to_s32[i] * num[0] / denum[0]; in dsp_audio_generate_volume_changes()
330 if (sample < -32768) in dsp_audio_generate_volume_changes()
331 sample = -32768; in dsp_audio_generate_volume_changes()
334 dsp_audio_increase1[i] = dsp_audio_s16_to_law[sample & 0xffff]; in dsp_audio_generate_volume_changes()
336 if (sample < -32768) in dsp_audio_generate_volume_changes()
337 sample = -32768; in dsp_audio_generate_volume_changes()
340 dsp_audio_increase2[i] = dsp_audio_s16_to_law[sample & 0xffff]; in dsp_audio_generate_volume_changes()
342 if (sample < -32768) in dsp_audio_generate_volume_changes()
343 sample = -32768; in dsp_audio_generate_volume_changes()
346 dsp_audio_increase3[i] = dsp_audio_s16_to_law[sample & 0xffff]; in dsp_audio_generate_volume_changes()
348 if (sample < -32768) in dsp_audio_generate_volume_changes()
349 sample = -32768; in dsp_audio_generate_volume_changes()
352 dsp_audio_increase4[i] = dsp_audio_s16_to_law[sample & 0xffff]; in dsp_audio_generate_volume_changes()
354 if (sample < -32768) in dsp_audio_generate_volume_changes()
355 sample = -32768; in dsp_audio_generate_volume_changes()
358 dsp_audio_increase5[i] = dsp_audio_s16_to_law[sample & 0xffff]; in dsp_audio_generate_volume_changes()
360 if (sample < -32768) in dsp_audio_generate_volume_changes()
361 sample = -32768; in dsp_audio_generate_volume_changes()
364 dsp_audio_increase6[i] = dsp_audio_s16_to_law[sample & 0xffff]; in dsp_audio_generate_volume_changes()
366 if (sample < -32768) in dsp_audio_generate_volume_changes()
367 sample = -32768; in dsp_audio_generate_volume_changes()
370 dsp_audio_increase7[i] = dsp_audio_s16_to_law[sample & 0xffff]; in dsp_audio_generate_volume_changes()
371 sample = dsp_audio_law_to_s32[i] * num[7] / denum[7]; in dsp_audio_generate_volume_changes()
372 if (sample < -32768) in dsp_audio_generate_volume_changes()
373 sample = -32768; in dsp_audio_generate_volume_changes()
376 dsp_audio_increase8[i] = dsp_audio_s16_to_law[sample & 0xffff]; in dsp_audio_generate_volume_changes()
388 * -8 to 8, which is a shift to the power of 2. 0 == no volume, 3 == volume*8
398 if (volume == 0) in dsp_change_volume()
402 if (volume < 0) { in dsp_change_volume()
404 if (shift < 0) in dsp_change_volume()
405 shift = 0; in dsp_change_volume()
407 shift = volume + 7; in dsp_change_volume()
412 i = 0; in dsp_change_volume()
413 ii = skb->len; in dsp_change_volume()
414 p = skb->data; in dsp_change_volume()