-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvideo.mli
242 lines (187 loc) · 6.78 KB
/
video.mli
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
(*
* Copyright 2011 The Savonet Team
*
* This file is part of ocaml-mm.
*
* ocaml-mm is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ocaml-mm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ocaml-mm; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* As a special exception to the GNU Library General Public License, you may
* link, statically or dynamically, a "work that uses the Library" with a publicly
* distributed version of the Library to produce an executable file containing
* portions of the Library, and distribute that executable file under terms of
* your choice, without any of the additional requirements listed in clause 6
* of the GNU Library General Public License.
* By "a publicly distributed version of the Library", we mean either the unmodified
* Library as distributed by The Savonet Team, or a modified version of the Library that is
* distributed under the conditions defined in clause 3 of the GNU Library General
* Public License. This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU Library General Public License.
*
*)
(** Operations on video data. *)
open Mm_audio
open Mm_image
module YUV420 = Image.YUV420
(** Images of videos. *)
module Image : sig
type t = Image.YUV420.t
val create : int -> int -> t
val of_RGB24_string : string -> int -> t
(** Convert to format useable by [Graphics.make_image]. *)
val to_int_image : t -> int array array
val copy : t -> t
val width : t -> int
val height : t -> int
val dimensions : t -> int * int
(** Size in bytes. *)
val size : t -> int
val blank : t -> unit
val has_alpha : t -> bool
val fill_alpha : t -> int -> unit
val scale : t -> t -> unit
val randomize : t -> unit
(** [blit_all src dst] blits an entire image. *)
val blit : t -> t -> unit
val get_pixel_rgba : t -> int -> int -> int * int * int * int
val set_pixel_rgba : t -> int -> int -> int * int * int * int -> unit
(** Add the fist image to the second. *)
val add : t -> ?x:int -> ?y:int -> t -> unit
module Effect : sig
val greyscale : t -> unit
val sepia : t -> unit
val invert : t -> unit
val lomo : t -> unit
module Alpha : sig
val scale : t -> float -> unit
val disk : t -> int -> int -> int -> unit
end
end
end
(** A video buffer. *)
type t = Image.t array
type buffer = t
(** Create a buffer with a given number of frames of given size. *)
val make : int -> int -> int -> t
(** Video with a single image. *)
val single : Image.t -> t
val blit : t -> int -> t -> int -> int -> unit
(** Create a fresh copy of a buffer. *)
val copy : t -> t
(** Length in images. *)
val length : t -> int
(** Size in bytes. *)
val size : t -> int
(** Obtaine the i-th image of a video. *)
val get : t -> int -> Image.t
val set : t -> int -> Image.t -> unit
val iter : (Image.t -> unit) -> t -> int -> int -> unit
val blank : t -> int -> int -> unit
val randomize : t -> int -> int -> unit
(** Videos with canvas images. *)
module MakeCanvas (_ : Mm_image.Image.CanvasImage) : sig
module Image : module type of Mm_image.Image.Canvas (Image)
(** An image. *)
type image = Image.t
(** A video. *)
type t = image array
(** Create a video with given length and dimensions. *)
val make : int -> int * int -> t
(** Make a copy of the video (images themselves are not copied since they are
supposed to be immutable). *)
val copy : t -> t
(** Create a video with one canvas image. *)
val single : Image.t -> t
(** Create a video with one image. *)
val single_image : Mm_image.Image.YUV420.t -> t
(** Length of the video (in images). *)
val length : t -> int
(** Estimated size of the video (in bytes). *)
val size : t -> int
(** Get the nth image of the video. *)
val get : t -> int -> image
(** Set the nth image of the video. *)
val set : t -> int -> image -> unit
(** Apply a function on the nth image of the video. *)
val map_image : (image -> image) -> t -> int -> unit
(** Render the nth image of the video. *)
val render : ?transparent:bool -> t -> int -> Mm_image.Image.YUV420.t
(** Change the contents of the nth image of the video (like [set] but takes an
image instead of a canvas as argument). *)
val put : t -> int -> Mm_image.Image.YUV420.t -> unit
(** Blank the video starting at offset with given length. *)
val blank : t -> int -> int -> unit
(** Copy the images of one video to the other. *)
val blit : t -> int -> t -> int -> int -> unit
(** Map a function to the images of a video (starting at given offset, for
given length). *)
val map : (image -> image) -> t -> int -> int -> unit
(** Iterate a function on the rendering of the images of the video. *)
val iter : (Mm_image.Image.YUV420.t -> unit) -> t -> int -> int -> unit
end
module Canvas : module type of MakeCanvas (Image)
(* module Ringbuffer_ext : Ringbuffer.R with type elt = frame *)
(* module Ringbuffer : Ringbuffer.R with type elt = frame *)
(** Operations on frame rates. *)
module FPS : sig
type t = float
(** Convert a frame rate to a fraction. *)
val to_frac : t -> int * int
end
(** Operation on files in AVI format. *)
module AVI : sig
(** Writing AVI files. *)
module Writer : sig
(** Generate a header for the AVI file. *)
val header :
?format:[> `YUV420 ] ->
width:int ->
height:int ->
framerate:int ->
?channels:int ->
?samplerate:int ->
?vendor:string ->
unit ->
string
(** Operations on chunks, which are blocks of (audio / video) data. *)
module Chunk : sig
val audio_s16le : Audio.t -> string
val video_yuv420 : YUV420.t -> string
end
end
end
module IO : sig
exception Invalid_file
module Reader : sig
class type t =
object
method width : int
method height : int
(** Number of frames per second. *)
method frame_rate : FPS.t
(* method set_target_size : int -> int -> unit *)
(** Read a given number of frames. *)
method read : buffer -> int -> int -> int
method close : unit
end
end
module Writer : sig
class type t =
object
method write : buffer -> int -> int -> unit
method close : unit
end
class to_avi_file : string -> FPS.t -> int -> int -> t
end
end