Lines Matching +full:byte +full:- +full:len
1 /* libSoX lpc-10 format.
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 Write the bits in bits[0] through bits[len-1] to file f, in "packed"
36 bits is expected to be an array of len integer values, where each
39 several 8 bit characters. If len is not a multiple of 8, then the
40 last character is padded with 0 bits -- the padding is in the least
41 significant bits of the last byte. The 8 bit characters are "filled"
44 static void write_bits(sox_format_t * ft, INT32 *bits, int len) in write_bits() argument
49 uint8_t data; /* The contents of the next byte to place in the in write_bits()
54 * bit of the byte, so initialize mask to 0x80. The next byte of in write_bits()
61 for (i = 0; i < len; i++) { in write_bits()
67 * If the byte data is full, determined by mask becoming 0, in write_bits()
68 * then write the byte to the output file, and reinitialize in write_bits()
69 * data and mask for the next output byte. Also add the byte in write_bits()
70 * if (i == len-1), because if len is not a multiple of 8, in write_bits()
73 if ((mask == 0) || (i == len-1)) { in write_bits()
82 Read bits from file f into bits[0] through bits[len-1], in "packed"
85 Read ceiling(len/8) characters from file f, if that many are
89 fill bits[8] through bits[15], and so on. If ceiling(len/8)
90 characters are available to read, and len is not a multiple of 8,
96 the range 0 to len, inclusive. If it is less than len, it will
99 static int read_bits(sox_format_t * ft, INT32 *bits, int len) in read_bits() argument
105 for (i = 0; i < len; i++) { in read_bits()
118 return (len); in read_bits()
123 priv_t * lpc = (priv_t *)ft->priv; in startread()
125 if ((lpc->decst = create_lpc10_decoder_state()) == NULL) { in startread()
129 lpc->samples = LPC10_SAMPLES_PER_FRAME; in startread()
135 priv_t * lpc = (priv_t *)ft->priv; in startwrite()
137 if ((lpc->encst = create_lpc10_encoder_state()) == NULL) { in startwrite()
141 lpc->samples = 0; in startwrite()
146 static size_t read_samples(sox_format_t * ft, sox_sample_t *buf, size_t len) in read_samples() argument
148 priv_t * lpc = (priv_t *)ft->priv; in read_samples()
151 while (nread < len) { in read_samples()
154 if (lpc->samples == LPC10_SAMPLES_PER_FRAME) { in read_samples()
160 lpc10_decode(bits, lpc->speech, lpc->decst); in read_samples()
161 lpc->samples = 0; in read_samples()
164 while (nread < len && lpc->samples < LPC10_SAMPLES_PER_FRAME) in read_samples()
165 buf[nread++] = SOX_FLOAT_32BIT_TO_SAMPLE(lpc->speech[lpc->samples++], ft->clips); in read_samples()
171 static size_t write_samples(sox_format_t * ft, const sox_sample_t *buf, size_t len) in write_samples() argument
173 priv_t * lpc = (priv_t *)ft->priv; in write_samples()
176 while (len > 0) { in write_samples()
177 while (len > 0 && lpc->samples < LPC10_SAMPLES_PER_FRAME) { in write_samples()
179 lpc->speech[lpc->samples++] = SOX_SAMPLE_TO_FLOAT_32BIT(buf[nwritten++], ft->clips); in write_samples()
180 len--; in write_samples()
183 if (lpc->samples == LPC10_SAMPLES_PER_FRAME) { in write_samples()
186 lpc10_encode(lpc->speech, bits, lpc->encst); in write_samples()
188 lpc->samples = 0; in write_samples()
197 priv_t * lpc = (priv_t *)ft->priv; in stopread()
199 free(lpc->decst); in stopread()
206 priv_t * lpc = (priv_t *)ft->priv; in stopwrite()
208 free(lpc->encst); in stopwrite()