Lines Matching refs:ft

60   sox_format_t* ft = (sox_format_t*)ft_data;  in decoder_read_callback()  local
62 *bytes = lsx_readbuf(ft, buffer, *bytes); in decoder_read_callback()
63 if(lsx_error(ft)) in decoder_read_callback()
76 sox_format_t* ft = (sox_format_t*)ft_data; in decoder_seek_callback() local
77 if(lsx_seeki(ft, (off_t)absolute_byte_offset, SEEK_SET) < 0) in decoder_seek_callback()
85 sox_format_t* ft = (sox_format_t*)ft_data; in decoder_tell_callback() local
87 if((pos = lsx_tell(ft)) < 0) in decoder_tell_callback()
97 sox_format_t* ft = (sox_format_t*)ft_data; in decoder_length_callback() local
98 *stream_length = lsx_filelength(ft); in decoder_length_callback()
104 sox_format_t* ft = (sox_format_t*)ft_data; in decoder_eof_callback() local
105 return lsx_eof(ft) ? 1 : 0; in decoder_eof_callback()
110 sox_format_t * ft = (sox_format_t *) client_data; in decoder_metadata_callback() local
111 priv_t * p = (priv_t *)ft->priv; in decoder_metadata_callback()
128 if (ft->oob.comments != NULL) { in decoder_metadata_callback()
135 sox_append_comment(&ft->oob.comments, (char const *) vc->comments[i].entry); in decoder_metadata_callback()
143 sox_format_t * ft = (sox_format_t *) client_data; in decoder_error_callback() local
147 lsx_fail_errno(ft, SOX_EINVAL, "%s", FLAC__StreamDecoderErrorStatusString[status]); in decoder_error_callback()
154 sox_format_t * ft = (sox_format_t *) client_data; in decoder_write_callback() local
155 priv_t * p = (priv_t *)ft->priv; in decoder_write_callback()
165 lsx_fail_errno(ft, SOX_EINVAL, "FLAC ERROR: parameters differ between frame and header"); in decoder_write_callback()
214 static int start_read(sox_format_t * const ft) in start_read() argument
216 priv_t * p = (priv_t *)ft->priv; in start_read()
220 lsx_fail_errno(ft, SOX_ENOMEM, "FLAC ERROR creating the decoder instance"); in start_read()
229 ft->seekable ? decoder_seek_callback : NULL, in start_read()
230 ft->seekable ? decoder_tell_callback : NULL, in start_read()
231 ft->seekable ? decoder_length_callback : NULL, in start_read()
232 ft->seekable ? decoder_eof_callback : NULL, in start_read()
236 ft) != FLAC__STREAM_DECODER_INIT_STATUS_OK){ in start_read()
237 lsx_fail_errno(ft, SOX_EHDR, "FLAC ERROR initialising decoder"); in start_read()
242 lsx_fail_errno(ft, SOX_EHDR, "FLAC ERROR whilst decoding metadata"); in start_read()
247 lsx_fail_errno(ft, SOX_EHDR, "FLAC ERROR during metadata decoding"); in start_read()
251 ft->encoding.encoding = SOX_ENCODING_FLAC; in start_read()
252 ft->signal.rate = p->sample_rate; in start_read()
253 ft->encoding.bits_per_sample = p->bits_per_sample; in start_read()
254 ft->signal.channels = p->channels; in start_read()
255 ft->signal.length = p->total_samples * p->channels; in start_read()
260 static size_t read_samples(sox_format_t * const ft, sox_sample_t * sampleBuffer, size_t const reque… in read_samples() argument
262 priv_t * p = (priv_t *)ft->priv; in read_samples()
277 …if (!FLAC__stream_decoder_seek_absolute(p->decoder, (FLAC__uint64)(p->seek_offset / ft->signal.cha… in read_samples()
327 static int stop_read(sox_format_t * const ft) in stop_read() argument
329 priv_t * p = (priv_t *)ft->priv; in stop_read()
344 sox_format_t * const ft = (sox_format_t *) client_data; in flac_stream_encoder_write_callback() local
347 …return lsx_writebuf(ft, buffer, bytes) == bytes ? FLAC__STREAM_ENCODER_WRITE_STATUS_OK : FLAC__STR… in flac_stream_encoder_write_callback()
361 sox_format_t * const ft = (sox_format_t *) client_data; in flac_stream_encoder_seek_callback() local
363 if (!ft->seekable) in flac_stream_encoder_seek_callback()
365 else if (lsx_seeki(ft, (off_t)absolute_byte_offset, SEEK_SET) != SOX_SUCCESS) in flac_stream_encoder_seek_callback()
375 sox_format_t * const ft = (sox_format_t *) client_data; in flac_stream_encoder_tell_callback() local
378 if (!ft->seekable) in flac_stream_encoder_tell_callback()
380 else if ((pos = lsx_tell(ft)) < 0) in flac_stream_encoder_tell_callback()
390 static int start_write(sox_format_t * const ft) in start_write() argument
392 priv_t * p = (priv_t *)ft->priv; in start_write()
396 if (ft->encoding.compression != HUGE_VAL) { in start_write()
397 compression_level = ft->encoding.compression; in start_write()
398 if (compression_level != ft->encoding.compression || in start_write()
400 lsx_fail_errno(ft, SOX_EINVAL, in start_write()
409 lsx_fail_errno(ft, SOX_ENOMEM, "FLAC ERROR creating the encoder instance"); in start_write()
413 p->bits_per_sample = ft->encoding.bits_per_sample; in start_write()
414 ft->signal.precision = ft->encoding.bits_per_sample; in start_write()
418 FLAC__stream_encoder_set_channels(p->encoder, ft->signal.channels); in start_write()
420 FLAC__stream_encoder_set_sample_rate(p->encoder, (unsigned)(ft->signal.rate + .5)); in start_write()
428 streamable = (streamable_rates[i] == ft->signal.rate); in start_write()
467 if (ft->signal.channels == 2) { in start_write()
475 if (ft->signal.length != 0) { in start_write()
476 …am_encoder_set_total_samples_estimate(p->encoder, (FLAC__uint64)(ft->signal.length / ft->signal.ch… in start_write()
480 lsx_fail_errno(ft, SOX_ENOMEM, "FLAC ERROR creating the encoder seek table template"); in start_write()
484 …(p->metadata[p->num_metadata], (unsigned)(10 * ft->signal.rate + .5), (FLAC__uint64)(ft->signal.le… in start_write()
485 lsx_fail_errno(ft, SOX_ENOMEM, "FLAC ERROR creating the encoder seek table points"); in start_write()
493 if (ft->oob.comments) { /* Make the comment structure */ in start_write()
498 for (i = 0; ft->oob.comments[i]; ++i) { in start_write()
500 char * text = lsx_calloc(strlen(prepend) + strlen(ft->oob.comments[i]) + 1, sizeof(*text)); in start_write()
502 if (!strchr(ft->oob.comments[i], '=')) in start_write()
504 entry.entry = (FLAC__byte *) strcat(text, ft->oob.comments[i]); in start_write()
516 …coder_seek_callback, flac_stream_encoder_tell_callback, flac_stream_encoder_metadata_callback, ft); in start_write()
519 lsx_fail_errno(ft, SOX_EINVAL, "%s", FLAC__StreamEncoderInitStatusString[status]); in start_write()
527 static size_t write_samples(sox_format_t * const ft, sox_sample_t const * const sampleBuffer, size_… in write_samples() argument
529 priv_t * p = (priv_t *)ft->priv; in write_samples()
541 long pcm = SOX_SAMPLE_TO_SIGNED_32BIT(sampleBuffer[i], ft->clips); in write_samples()
545 SOX_SAMPLE_TO_SIGNED_8BIT(sampleBuffer[i], ft->clips); in write_samples()
548 SOX_SAMPLE_TO_SIGNED_16BIT(sampleBuffer[i], ft->clips); in write_samples()
551 SOX_SAMPLE_TO_SIGNED_24BIT(sampleBuffer[i],ft->clips) << 8; in write_samples()
555 SOX_SAMPLE_TO_SIGNED_32BIT(sampleBuffer[i],ft->clips); in write_samples()
559 …FLAC__stream_encoder_process_interleaved(p->encoder, p->decoded_samples, (unsigned) len / ft->sign… in write_samples()
565 static int stop_write(sox_format_t * const ft) in stop_write() argument
567 priv_t * p = (priv_t *)ft->priv; in stop_write()
577 lsx_fail_errno(ft, SOX_EINVAL, "FLAC ERROR: failed to encode to end of stream"); in stop_write()
585 static int seek(sox_format_t * ft, uint64_t offset) in seek() argument
587 priv_t * p = (priv_t *)ft->priv; in seek()
590 return ft->mode == 'r' ? SOX_SUCCESS : SOX_EOF; in seek()