Lines Matching refs:ft
67 sox_format_t* ft = (sox_format_t*)ft_data; in callback_read() local
68 size_t ret = lsx_readbuf(ft, ptr, size * nmemb); in callback_read()
74 sox_format_t* ft = (sox_format_t*)ft_data; in callback_seek() local
75 int ret = ft->seekable ? lsx_seeki(ft, (off_t)off, whence) : -1; in callback_seek()
90 sox_format_t* ft = (sox_format_t*)ft_data; in callback_tell() local
91 return lsx_tell(ft); in callback_tell()
104 static int startread(sox_format_t * ft) in startread() argument
106 priv_t * vb = (priv_t *) ft->priv; in startread()
122 if (ov_open_callbacks(ft, vb->vf, NULL, (size_t) 0, callbacks) < 0) { in startread()
123 lsx_fail_errno(ft, SOX_EHDR, "Input not an Ogg Vorbis audio stream"); in startread()
132 ft->signal.rate = vi->rate; in startread()
133 ft->encoding.encoding = SOX_ENCODING_VORBIS; in startread()
134 ft->signal.channels = vi->channels; in startread()
140 if (ft->seekable) in startread()
141 ft->signal.length = ov_pcm_total(vb->vf, -1) * ft->signal.channels; in startread()
145 sox_append_comment(&ft->oob.comments, vc->user_comments[i]); in startread()
194 static size_t read_samples(sox_format_t * ft, sox_sample_t * buf, size_t len) in read_samples() argument
196 priv_t * vb = (priv_t *) ft->priv; in read_samples()
226 static int stopread(sox_format_t * ft) in stopread() argument
228 priv_t * vb = (priv_t *) ft->priv; in stopread()
238 static int oe_write_page(ogg_page * page, sox_format_t * ft) in oe_write_page() argument
242 written = lsx_writebuf(ft, page->header, (size_t) page->header_len); in oe_write_page()
243 written += lsx_writebuf(ft, page->body, (size_t) page->body_len); in oe_write_page()
250 static int write_vorbis_header(sox_format_t * ft, vorbis_enc_t * ve) in write_vorbis_header() argument
259 vc.comments = sox_num_comments(ft->oob.comments); in write_vorbis_header()
265 char * text = lsx_calloc(strlen(prepend) + strlen(ft->oob.comments[i]) + 1, sizeof(*text)); in write_vorbis_header()
267 if (!strchr(ft->oob.comments[i], '=')) in write_vorbis_header()
269 vc.user_comments[i] = strcat(text, ft->oob.comments[i]); in write_vorbis_header()
284 if (!oe_write_page(&ve->og, ft)) in write_vorbis_header()
294 static int startwrite(sox_format_t * ft) in startwrite() argument
296 priv_t * vb = (priv_t *) ft->priv; in startwrite()
301 ft->encoding.encoding = SOX_ENCODING_VORBIS; in startwrite()
309 rate = ft->signal.rate; in startwrite()
311 lsx_fail_errno(ft, SOX_EHDR, in startwrite()
315 if (ft->encoding.compression != HUGE_VAL) { in startwrite()
316 if (ft->encoding.compression < -1 || ft->encoding.compression > 10) { in startwrite()
317 lsx_fail_errno(ft, SOX_EINVAL, in startwrite()
321 quality = ft->encoding.compression; in startwrite()
324 if (vorbis_encode_init_vbr(&ve->vi, ft->signal.channels, ft->signal.rate + .5, quality / 10)) in startwrite()
326 lsx_fail_errno(ft, SOX_EFMT, "libVorbis cannot encode this sample-rate or # of channels"); in startwrite()
335 if (write_vorbis_header(ft, ve) == HEADER_ERROR) { in startwrite()
336 lsx_fail_errno(ft, SOX_EHDR, in startwrite()
344 static size_t write_samples(sox_format_t * ft, const sox_sample_t * buf, in write_samples() argument
347 priv_t * vb = (priv_t *) ft->priv; in write_samples()
349 size_t samples = len / ft->signal.channels; in write_samples()
357 for (j = 0; j < ft->signal.channels; j++) in write_samples()
358 buffer[j][i] = buf[i * ft->signal.channels + j] in write_samples()
382 ret = oe_write_page(&ve->og, ft); in write_samples()
395 static int stopwrite(sox_format_t * ft) in stopwrite() argument
397 priv_t * vb = (priv_t *) ft->priv; in stopwrite()
401 write_samples(ft, NULL, (size_t) 0); in stopwrite()
411 static int seek(sox_format_t * ft, uint64_t offset) in seek() argument
413 priv_t * vb = (priv_t *) ft->priv; in seek()
415 return ov_pcm_seek(vb->vf, (ogg_int64_t)(offset / ft->signal.channels))? SOX_EOF:SOX_SUCCESS; in seek()