package ffmpeg-swresample
Source file swresample.ml
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 330open Avutil open Swresample_options module SF = Avutil.Sample_format module CL = Avutil.Channel_layout 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 type vector_kind = Str | P_Str | Fa | P_Fa | Ba | P_Ba | Frm module type AudioData = sig type t val vk : vector_kind val sf : SF.t end module Bytes = struct type t = bytes let vk = Str let sf = `None end module U8Bytes = struct type t = bytes let vk = Str let sf = `U8 end module S16Bytes = struct type t = bytes let vk = Str let sf = `S16 end module S32Bytes = struct type t = bytes let vk = Str let sf = `S32 end module FltBytes = struct type t = bytes let vk = Str let sf = `Flt end module DblBytes = struct type t = bytes let vk = Str let sf = `Dbl end module U8PlanarBytes = struct type t = bytes array let vk = P_Str let sf = `U8p end module S16PlanarBytes = struct type t = bytes array let vk = P_Str let sf = `S16p end module S32PlanarBytes = struct type t = bytes array let vk = P_Str let sf = `S32p end module FltPlanarBytes = struct type t = bytes array let vk = P_Str let sf = `Fltp end module DblPlanarBytes = struct type t = bytes array let vk = P_Str let sf = `Dblp end module FloatArray = struct type t = float array let vk = Fa let sf = `Dbl end module PlanarFloatArray = struct type t = float array array let vk = P_Fa let sf = `Dblp end module U8BigArray = struct type t = u8ba let vk = Ba let sf = `U8 end module S16BigArray = struct type t = s16ba let vk = Ba let sf = `S16 end module S32BigArray = struct type t = s32ba let vk = Ba let sf = `S32 end module FltBigArray = struct type t = f32ba let vk = Ba let sf = `Flt end module DblBigArray = struct type t = f64ba let vk = Ba let sf = `Dbl end module U8PlanarBigArray = struct type t = u8ba array let vk = P_Ba let sf = `U8p end module S16PlanarBigArray = struct type t = s16ba array let vk = P_Ba let sf = `S16p end module S32PlanarBigArray = struct type t = s32ba array let vk = P_Ba let sf = `S32p end module FltPlanarBigArray = struct type t = f32ba array let vk = P_Ba let sf = `Fltp end module DblPlanarBigArray = struct type t = f64ba array let vk = P_Ba let sf = `Dblp end module Frame = struct type t = audio frame let vk = Frm let sf = `None end module U8Frame = struct type t = audio frame let vk = Frm let sf = `U8 end module S16Frame = struct type t = audio frame let vk = Frm let sf = `S16 end module S32Frame = struct type t = audio frame let vk = Frm let sf = `S32 end module FltFrame = struct type t = audio frame let vk = Frm let sf = `Flt end module DblFrame = struct type t = audio frame let vk = Frm let sf = `Dbl end module U8PlanarFrame = struct type t = audio frame let vk = Frm let sf = `U8p end module S16PlanarFrame = struct type t = audio frame let vk = Frm let sf = `S16p end module S32PlanarFrame = struct type t = audio frame let vk = Frm let sf = `S32p end module FltPlanarFrame = struct type t = audio frame let vk = Frm let sf = `Fltp end module DblPlanarFrame = struct type t = audio frame let vk = Frm let sf = `Dblp end type options = [ dither_type | engine | filter_type ] type ('i, 'o) ctx module Make (I : AudioData) (O : AudioData) = struct type t = (I.t, O.t) ctx external create : vector_kind -> CL.t -> SF.t -> int -> vector_kind -> CL.t -> SF.t -> int -> options array -> t = "ocaml_swresample_create_byte" "ocaml_swresample_create" let create ?options in_channel_layout ?in_sample_format in_sample_rate out_channel_layout ?out_sample_format out_sample_rate = let opts = match options with Some os -> Array.of_list os | None -> [||] in let in_sample_format = match in_sample_format with | _ when I.sf <> `None -> I.sf | Some sf -> sf | _ -> raise (Error (`Failure "Swresample input sample format undefined")) in let out_sample_format = match out_sample_format with | _ when O.sf <> `None -> O.sf | Some sf -> sf | _ -> raise (Error (`Failure "Swresample output sample format undefined")) in create I.vk in_channel_layout in_sample_format in_sample_rate O.vk out_channel_layout out_sample_format out_sample_rate opts let from_codec ?options in_codec out_channel_layout ?out_sample_format out_sample_rate = create ?options (Avcodec.Audio.get_channel_layout in_codec) ~in_sample_format:(Avcodec.Audio.get_sample_format in_codec) (Avcodec.Audio.get_sample_rate in_codec) out_channel_layout ?out_sample_format out_sample_rate let to_codec ?options in_channel_layout ?in_sample_format in_sample_rate out_codec = create ?options in_channel_layout ?in_sample_format in_sample_rate (Avcodec.Audio.get_channel_layout out_codec) ~out_sample_format:(Avcodec.Audio.get_sample_format out_codec) (Avcodec.Audio.get_sample_rate out_codec) let from_codec_to_codec ?options in_codec out_codec = create ?options (Avcodec.Audio.get_channel_layout in_codec) ~in_sample_format:(Avcodec.Audio.get_sample_format in_codec) (Avcodec.Audio.get_sample_rate in_codec) (Avcodec.Audio.get_channel_layout out_codec) ~out_sample_format:(Avcodec.Audio.get_sample_format out_codec) (Avcodec.Audio.get_sample_rate out_codec) external convert : ?offset:int -> ?length:int -> t -> I.t -> O.t = "ocaml_swresample_convert" external flush : t -> O.t = "ocaml_swresample_flush" end