Swresample.MakeConverters that read values of type I.t and return values of type O.t.
val create :
?options:options list ->
Avutil.Channel_layout.t ->
?in_sample_format:Avutil.Sample_format.t ->
int ->
Avutil.Channel_layout.t ->
?out_sample_format:Avutil.Sample_format.t ->
int ->
tcreate ?options in_layout ?in_sample_format in_rate out_layout ?out_sample_format out_rate creates a converter. The positional arguments are, in order: the input channel layout, the input sample rate in Hz, the output channel layout and the output sample rate in Hz.
The sample format of each side comes from its data module. When the module fixes a format, as S16Bytes or FloatArray do, the optional argument is omitted, or equal to that format. When the module leaves the format open, as Bytes and Frame do, the optional argument is required. With Bytes the format is a packed (interleaved) one.
Both layouts are copied. Every other setting of the resampler keeps FFmpeg's default. The call releases the OCaml runtime lock while the resampler is initialised.
val from_codec :
?options:options list ->
Avutil.audio Avcodec.params ->
Avutil.Channel_layout.t ->
?out_sample_format:Avutil.Sample_format.t ->
int ->
tfrom_codec ?options params out_layout ?out_sample_format out_rate is create with the input channel layout, sample format and sample rate read from the codec parameters params. The format read is given as in_sample_format: creation fails when I fixes another format.
val to_codec :
?options:options list ->
Avutil.Channel_layout.t ->
?in_sample_format:Avutil.Sample_format.t ->
int ->
Avutil.audio Avcodec.params ->
tto_codec ?options in_layout ?in_sample_format in_rate params is create with the output channel layout, sample format and sample rate read from the codec parameters params. The format read is given as out_sample_format: creation fails when O fixes another format.
val from_codec_to_codec :
?options:options list ->
Avutil.audio Avcodec.params ->
Avutil.audio Avcodec.params ->
tfrom_codec_to_codec ?options in_params out_params is create with the channel layout, sample format and sample rate of the input read from in_params and those of the output read from out_params. Creation fails when a data module fixes a format other than the one read.
convert ?offset ?length converter input converts samples of input and returns the samples the resampler produces, as a new value.
The result holds exactly the samples produced. Their number is known only after the conversion: the resampler keeps samples buffered between calls, and flush returns the ones it still holds. It can be 0, and the result is then an empty value of the same shape: empty planes, or a frame of zero samples. A frame returned has the output channel layout, sample format and sample rate, and no timestamp.
input is checked against the input side of the converter. A planar value has one plane per channel, all of the same length. A frame has the channel count and the sample format of the converter; its sample rate and the arrangement of its channel layout are the caller's to match. A trailing partial sample group of an interleaved value is ignored.
Bytes and float arrays are copied in and out. A NaN read from a float array, and a NaN written to one, becomes 0. Bigarrays and frames are read in place while the OCaml runtime lock is released, without any NaN replacement: what another thread writes to them during the call is visible to the conversion.
The call excludes every other operation on the converter: a concurrent one raises Error (`Failure "Object in use!") at once. After a failure the converter stays usable.
flush converter returns the samples the resampler still holds: the tail a rate conversion keeps back until it knows that no input follows. After it, the samples returned by all the calls since creation are everything the input produces.
A second flush with no conversion in between returns an empty value. The converter stays usable: convert may be called again. The call releases the OCaml runtime lock and excludes other operations on the converter, as convert does.