1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
|
(** This module perform audio resampling, rematrixing and sample format
conversion operations. *)
open Avutil
open Swresample_options
(**/**)
type vector_kind = Str | P_Str | Fa | P_Fa | Ba | P_Ba | Frm
(**/**)
(** Audio data modules for Swresample module input and output parameterization.
*)
module type AudioData = sig
type t
val vk : vector_kind
val sf : Avutil.Sample_format.t
end
type options = [ dither_type | engine | filter_type ]
type ('i, 'o) ctx
(** Functor building an implementation of the swresample structure with
parameterized input an output audio data types *)
module Make (I : AudioData) (O : AudioData) : sig
type t = (I.t, O.t) ctx
(** [Swresample.create in_cl ~in_sample_format:in_sf in_sr out_cl
~out_sample_format:out_sf out_sr] create a Swresample.t with [in_cl]
channel layout, [in_sf] sample format and [in_sr] sample rate as input
format and [out_cl] channel layout, [out_sf] sample format and [out_sr]
sample rate as output format. If a sample format parameter is not
provided, the sample format defined by the associated AudioData module is
used.
Raise Error "Swresample input/output sample format undefined" if a sample
format parameter is not provided and the associated AudioData module does
not define a sample format as is the case for Bytes and Frame. *)
val create :
?options:options list ->
Channel_layout.t ->
?in_sample_format:Sample_format.t ->
int ->
Channel_layout.t ->
?out_sample_format:Sample_format.t ->
int ->
t
(** [Swresample.from_codec in_ac out_cl ~out_sample_format:out_sf out_sr] do
the same as {!Swresample.create} with the [in_ac] audio codec properties
as input format. *)
val from_codec :
?options:options list ->
audio Avcodec.params ->
Channel_layout.t ->
?out_sample_format:Sample_format.t ->
int ->
t
(** [Swresample.to_codec in_cl ~in_sample_format:in_sf in_sr out_ac] do the
same as {!Swresample.create} with the [out_ac] audio codec properties as
output format. *)
val to_codec :
?options:options list ->
Channel_layout.t ->
?in_sample_format:Sample_format.t ->
int ->
audio Avcodec.params ->
t
(** [Swresample.from_codec_to_codec in_ac out_ac] do the same as
{!Swresample.create} with the [in_ac] audio codec properties as input
format and the [out_ac] audio codec properties as output format. *)
val from_codec_to_codec :
?options:options list -> audio Avcodec.params -> audio Avcodec.params -> t
(** [Swresample.convert rsp iad] resample and convert the [iad] input audio
data to the output audio data according to the [rsp] resampler context
format.
Raise Error if the conversion failed. *)
val convert : ?offset:int -> ?length:int -> t -> I.t -> O.t
(** [Swresample.convert rpsp] flushes the last remaining data. *)
val flush : t -> O.t
end
(** Byte string with undefined sample format for interleaved channels. The
sample format must be passed to the create function. *)
module Bytes : sig
type t = bytes
val vk : vector_kind
val sf : Sample_format.t
end
(** Unsigned 8 bit sample format byte string for interleaved channels. *)
module U8Bytes : sig
type t = bytes
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 16 bit sample format byte string for interleaved channels. *)
module S16Bytes : sig
type t = bytes
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 32 bit sample format byte string for interleaved channels. *)
module S32Bytes : sig
type t = bytes
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 32 bit sample format byte string for interleaved channels. *)
module FltBytes : sig
type t = bytes
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 64 bit sample format byte string for interleaved channels. *)
module DblBytes : sig
type t = bytes
val vk : vector_kind
val sf : Sample_format.t
end
(** Unsigned 8 bit sample format byte string for planar channels. *)
module U8PlanarBytes : sig
type t = bytes array
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 16 bit sample format byte string for planar channels. *)
module S16PlanarBytes : sig
type t = bytes array
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 32 bit sample format byte string for planar channels. *)
module S32PlanarBytes : sig
type t = bytes array
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 32 bit sample format byte string for planar channels. *)
module FltPlanarBytes : sig
type t = bytes array
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 64 bit sample format byte string for planar channels. *)
module DblPlanarBytes : sig
type t = bytes array
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 64 bit sample format array for interleaved channels. *)
module FloatArray : sig
type t = float array
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 64 bit sample format array for planar channels. *)
module PlanarFloatArray : sig
type t = float array array
val vk : vector_kind
val sf : Sample_format.t
end
type u8ba =
(int, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
type s16ba =
(int, Bigarray.int16_signed_elt, Bigarray.c_layout) Bigarray.Array1.t
type s32ba = (int32, Bigarray.int32_elt, Bigarray.c_layout) Bigarray.Array1.t
type f32ba = (float, Bigarray.float32_elt, Bigarray.c_layout) Bigarray.Array1.t
type f64ba = (float, Bigarray.float64_elt, Bigarray.c_layout) Bigarray.Array1.t
(** Unsigned 8 bit sample format bigarray for interleaved channels. *)
module U8BigArray : sig
type t = u8ba
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 16 bit sample format bigarray for interleaved channels. *)
module S16BigArray : sig
type t = s16ba
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 32 bit sample format bigarray for interleaved channels. *)
module S32BigArray : sig
type t = s32ba
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 32 bit sample format bigarray for interleaved channels. *)
module FltBigArray : sig
type t = f32ba
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 64 bit sample format bigarray for interleaved channels. *)
module DblBigArray : sig
type t = f64ba
val vk : vector_kind
val sf : Sample_format.t
end
(** Unsigned 8 bit sample format bigarray for planar channels. *)
module U8PlanarBigArray : sig
type t = u8ba array
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 16 bit sample format bigarray for planar channels. *)
module S16PlanarBigArray : sig
type t = s16ba array
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 32 bit sample format bigarray for planar channels. *)
module S32PlanarBigArray : sig
type t = s32ba array
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 32 bit sample format bigarray for planar channels. *)
module FltPlanarBigArray : sig
type t = f32ba array
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 64 bit sample format bigarray for planar channels. *)
module DblPlanarBigArray : sig
type t = f64ba array
val vk : vector_kind
val sf : Sample_format.t
end
(** Audio frame with undefined sample format. The sample format must be passed
to the create function. *)
module Frame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
(** Unsigned 8 bit sample format audio frame for interleaved channels. *)
module U8Frame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 16 bit sample format audio frame for interleaved channels. *)
module S16Frame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 32 bit sample format audio frame for interleaved channels. *)
module S32Frame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 32 bit sample format audio frame for interleaved channels. *)
module FltFrame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 64 bit sample format audio frame for interleaved channels. *)
module DblFrame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
(** Unsigned 8 bit sample format audio frame for planar channels. *)
module U8PlanarFrame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 16 bit sample format audio frame for planar channels. *)
module S16PlanarFrame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
(** Signed 32 bit sample format audio frame for planar channels. *)
module S32PlanarFrame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 32 bit sample format audio frame for planar channels. *)
module FltPlanarFrame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
(** Float 64 bit sample format audio frame for planar channels. *)
module DblPlanarFrame : sig
type t = audio frame
val vk : vector_kind
val sf : Sample_format.t
end
|