Module Gavl.Video

module Video: sig .. end

exception Invalid_frame
exception Invalid_conversion
exception Not_implemented
Raised when a feature is not yet implemented, in particular pixel format with data other than unsigned 8 bit integers.
type interlace_mode = 
| No_interlace (*
Progressive
*)
| Top_first (*
Top field first
*)
| Bottom_first (*
Bottom field first
*)
| Mixed (*
Use interlace_mode of the frames
*)
Interlace mode type
type pixel_format = 
| Gray_8 (*
8 bit gray, scaled 0x00..0xff
*)
| Gray_16 (*
16 bit gray, scaled 0x0000..0xffff
*)
| Gray_float (*
floating point gray, scaled 0.0..1.0
*)
| Graya_16 (*
8 bit gray + alpha, scaled 0x00..0xff
*)
| Graya_32 (*
16 bit gray + alpha, scaled 0x0000..0xffff
*)
| Graya_float (*
floating point gray + alpha, scaled 0.0..1.0
*)
| Rgb_15 (*
15 bit RGB. Each pixel is a uint16_t in native byte order. Color masks are: for red: 0x7C00, for green: 0x03e0, for blue: 0x001f
*)
| Bgr_15 (*
15 bit BGR. Each pixel is a uint16_t in native byte order. Color masks are: for red: 0x001f, for green: 0x03e0, for blue: 0x7C00
*)
| Rgb_16 (*
16 bit RGB. Each pixel is a uint16_t in native byte order. Color masks are: for red: 0xf800, for green: 0x07e0, for blue: 0x001f
*)
| Bgr_16 (*
16 bit BGR. Each pixel is a uint16_t in native byte order. Color masks are: for red: 0x001f, for green: 0x07e0, for blue: 0xf800
*)
| Rgb_24 (*
24 bit RGB. Each color is an uint8_t. Color order is RGBRGB
*)
| Bgr_24 (*
24 bit BGR. Each color is an uint8_t. Color order is BGRBGR
*)
| Rgb_32 (*
32 bit RGB. Each color is an uint8_t. Color order is RGBXRGBX, where X is unused
*)
| Bgr_32 (*
32 bit BGR. Each color is an uint8_t. Color order is BGRXBGRX, where X is unused
*)
| Rgba_32 (*
32 bit RGBA. Each color is an uint8_t. Color order is RGBARGBA
*)
| Rgb_48 (*
48 bit RGB. Each color is an uint16_t in native byte order. Color order is RGBRGB
*)
| Rgba_64 (*
64 bit RGBA. Each color is an uint16_t in native byte order. Color order is RGBARGBA
*)
| Rgb_float (*
float RGB. Each color is a float (0.0 .. 1.0) in native byte order. Color order is RGBRGB
*)
| Rgba_float (*
float RGBA. Each color is a float (0.0 .. 1.0) in native byte order. Color order is RGBARGBA
*)
| Yuy2 (*
Packed YCbCr 4:2:2. Each component is an uint8_t. Component order is Y1 U1 Y2 V1
*)
| Yuvy (*
Packed YCbCr 4:2:2. Each component is an uint8_t. Component order is U1 Y1 V1 Y2
*)
| Yuva_32 (*
Packed YCbCrA 4:4:4:4. Each component is an uint8_t. Component order is YUVA. Luma and chroma are video scaled, alpha is 0..255.
*)
| Yuva_64 (*
Packed YCbCrA 4:4:4:4. Each component is an uint16_t. Component order is YUVA. Luma and chroma are video scaled, alpha is 0..65535.
*)
| Yuv_float (*
Packed YCbCr 4:4:4. Each component is a float. Luma is scaled 0.0..1.0, chroma is -0.5..0.5
*)
| Yuva_float (*
Packed YCbCrA 4:4:4:4. Each component is a float. Luma is scaled 0.0..1.0, chroma is -0.5..0.5
*)
| Yuv_420_p (*
Packed YCbCrA 4:4:4:4. Each component is an uint16_t. Component order is YUVA. Luma and chroma are video scaled, alpha is 0..65535.
*)
| Yuv_422_p (*
Planar YCbCr 4:2:2. Each component is an uint8_t
*)
| Yuv_444_p (*
Planar YCbCr 4:4:4. Each component is an uint8_t
*)
| Yuv_411_p (*
Planar YCbCr 4:1:1. Each component is an uint8_t
*)
| Yuv_410_p (*
Planar YCbCr 4:1:0. Each component is an uint8_t
*)
| Yuvj_420_p (*
Planar YCbCr 4:2:0. Each component is an uint8_t, luma and chroma values are full range (0x00 .. 0xff)
*)
| Yuvj_422_p (*
Planar YCbCr 4:2:2. Each component is an uint8_t, luma and chroma values are full range (0x00 .. 0xff)
*)
| Yuvj_444_p (*
Planar YCbCr 4:4:4. Each component is an uint8_t, luma and chroma values are full range (0x00 .. 0xff)
*)
| Yuv_444_p_16 (*
16 bit Planar YCbCr 4:4:4. Each component is an uint16_t in native byte order.
*)
| Yuv_422_p_16 (*
16 bit Planar YCbCr 4:2:2. Each component is an uint16_t in native byte order.
*)
Pixel formats. Only formats using 8 bit unsigned integers are supported for now.
type framerate_mode = 
| Constant (*
Constant framerate
*)
| Variable (*
Variable framerate
*)
| Still (*
Still image
*)
Framerate mode
type chroma_placement = 
| Default (*
MPEG-1/JPEG
*)
| Mpeg2 (*
MPEG-2
*)
| Dvpal (*
DV PAL
*)
Chroma placement.
type format = {
   frame_width : int;
   frame_height : int;
   image_width : int;
   image_height : int;
   pixel_width : int;
   pixel_height : int;
   pixelformat : pixel_format;
   frame_duration : int;
   timescale : int;
   framerate_mode : framerate_mode;
   chroma_placement : chroma_placement;
   interlace_mode : interlace_mode;
}
Video format.
type plane = (int, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t 
Plane data, represented as a big array of unsigned 8 bits ints.
type frame = {
   planes : (plane * int) array;
   timestamp : Int64.t;
   duration : Int64.t;
   frame_interlace_mode : interlace_mode;
}
Frame type.
val new_frame : format -> frame
Create a new frame.
val clear_frame : format -> frame -> unit
Clear a frame.
type t 
Opaque type for a converter.
val create_converter : format -> format -> t
in_format out_format creates a converter converting from in_format to out_format.

Raises Not_implemented if input or output format do not use unsigned 8 bit integers.

val init : t -> format -> format -> unit
init conv in_format out_format: initializes a converter with new input and output formats.

Raises Not_implemented if input or output format do not use unsigned 8 bit integers.

val get_formats : t -> format * format
get_formats conv returns a pair (in_format,out_format).
val get_quality : t -> int
Get quality setting.
val set_quality : t -> int -> unit
Set quality setting.
type int_rect = int * int * int * int 
Type for integer rectangles: x/y offset and width/height.
type float_rect = float * float * float * float 
Type for float rectangles: x/y offset and width/height.
val get_rect : t -> float_rect * int_rect
get_rect conv returns a pair (in_rect,out_rect).
val set_rect : t -> float_rect -> int_rect -> unit
set_rect conv in_rec out_rec sets input and output rectangles.
type conversion_flags = [ `Convolve_chroma
| `Convolve_normalize
| `Force_deinterlace
| `Resample_chroma ]
Type for conversion flags.
val set_flags : t -> conversion_flags list -> unit
Set conversion flags.
val get_flags : t -> conversion_flags list
Get conversion flags.
type scale_mode = 
| Auto
| Nearest
| Bilinear
| Quadratic
| Cubic_bspline
| Cubic_mitchell
| Cubic_catmull
| Scale_sinc_lanczos
Type for scale mode.
val set_scale_mode : t -> scale_mode -> unit
Set scale mode.
val get_scale_mode : t -> scale_mode
Get scale mode.
val reinit : t -> unit
Reinitialize a converter. Should be called when a setting has changed.
val convert : t -> frame -> frame -> unit
Perform frame conversion.

Raises Invalid_frame if input or output frame doesn't match corresponding format.

Raises Not_implemented if input or output format do not use unsigned 8 bit integers.