[xiph-commits] r3185 - oogg/trunk

shans at svn.annodex.net shans at svn.annodex.net
Mon Aug 13 01:10:15 PDT 2007


Author: shans
Date: 2007-08-13 01:10:15 -0700 (Mon, 13 Aug 2007)
New Revision: 3185

Modified:
   oogg/trunk/granules.ml
   oogg/trunk/granules.mli
   oogg/trunk/mediaStream.ml
   oogg/trunk/mediaStream.mli
   oogg/trunk/page.ml
   oogg/trunk/page_util.ml
   oogg/trunk/types.ml
   oogg/trunk/types.mli
Log:
Turned time generated by gp into an option type



Modified: oogg/trunk/granules.ml
===================================================================
--- oogg/trunk/granules.ml	2007-08-13 08:01:47 UTC (rev 3184)
+++ oogg/trunk/granules.ml	2007-08-13 08:10:15 UTC (rev 3185)
@@ -28,15 +28,15 @@
   Int64.to_float num *. gp /. Int64.to_float denom;;
 
 let vorbis_time bos gp = match gp with
-  | None -> -1.
+  | None -> None 
   | Some gp -> (
     let bos_packet = List.hd bos.raw_data in
     let granule_rate = extract_le_int32 bos_packet 12 in
-    granulerate_time 1L granule_rate (oogg64_to_float gp)
+    Some (granulerate_time 1L granule_rate (oogg64_to_float gp))
     );;
 
 let theora_time bos gp = match gp with
-  | None -> -1.
+  | None -> None
   | Some gp -> (
     let bos_packet = List.hd bos.raw_data in
     let num = extract_be_int32 bos_packet 22 in
@@ -50,11 +50,11 @@
     let offset = Int64.logand igp 
         (Int64.sub (Int64.shift_left Int64.one shift) Int64.one) in
     let gpv = Int64.to_float (Int64.add keyframe offset) in
-    granulerate_time denom num gpv
+    Some (granulerate_time denom num gpv)
   );;
 
 let granulerate_function id bos = match id with
-  | Vorbis -> Some (vorbis_time bos)
-  | Theora -> Some (theora_time bos)
-  | _      -> None
+  | Vorbis -> vorbis_time bos
+  | Theora -> theora_time bos
+  | _      -> fun x -> None
 

Modified: oogg/trunk/granules.mli
===================================================================
--- oogg/trunk/granules.mli	2007-08-13 08:01:47 UTC (rev 3184)
+++ oogg/trunk/granules.mli	2007-08-13 08:10:15 UTC (rev 3185)
@@ -1,2 +1,2 @@
 val granulerate_function : Types.mediaType -> Types.rawPage -> 
-                    (Types.granulePos -> float) option;;
+                    (Types.granulePos -> float option);;

Modified: oogg/trunk/mediaStream.ml
===================================================================
--- oogg/trunk/mediaStream.ml	2007-08-13 08:01:47 UTC (rev 3184)
+++ oogg/trunk/mediaStream.ml	2007-08-13 08:10:15 UTC (rev 3185)
@@ -90,7 +90,7 @@
             stream_serialno=s ; 
             stream_pages = new_stream ; 
             stream_type = ty ;
-            stream_time = None
+            stream_time = fun x -> None ;
           }::(_gen_streams t (c+1))
         end in
   _gen_streams streamslist 0
@@ -111,8 +111,4 @@
                 else [< filter rest snos >]
     | [< >]              -> [< >]
 
-let streamTime mediaStream gp = 
-  match mediaStream.stream_time with 
-    | None -> -1.0
-    | Some f -> f gp;;
-
+let streamTime mediaStream gp = mediaStream.stream_time gp;;

Modified: oogg/trunk/mediaStream.mli
===================================================================
--- oogg/trunk/mediaStream.mli	2007-08-13 08:01:47 UTC (rev 3184)
+++ oogg/trunk/mediaStream.mli	2007-08-13 08:10:15 UTC (rev 3185)
@@ -2,4 +2,4 @@
 
 val filter : Types.rawPageStream -> Types.serialNo list -> Types.rawPageStream;;
 
-val streamTime : Types.mediaStream -> Types.granulePos -> float;;
+val streamTime : Types.mediaStream -> Types.granulePos -> float option;;

Modified: oogg/trunk/page.ml
===================================================================
--- oogg/trunk/page.ml	2007-08-13 08:01:47 UTC (rev 3184)
+++ oogg/trunk/page.ml	2007-08-13 08:10:15 UTC (rev 3185)
@@ -195,7 +195,7 @@
   IO.close_out the_string;;
 
 type contextRecord = { mutable ct_info : 
-      (serialNo * ((granulePos -> float) option * mediaType)) list };;
+      (serialNo * ((granulePos -> float option) * mediaType)) list };;
 
 let add_bos context rpage =
   let sn = rpage.serialno in
@@ -206,14 +206,12 @@
 
 let lookup_bos context rpage =
   let (f, id) = List.assoc rpage.serialno context.ct_info in
-  match f with 
-    | Some ff -> (id, ff rpage.granulepos)
-    | None    -> (id, -1.0);;
+  (id, f rpage.granulepos)
 
 let rawPage_to_page context rpage = 
   if rpage.bos then (
     let id = add_bos context rpage in
-    { raw = rpage; time = 0.0; identity = id }
+    { raw = rpage; time = Some 0.0; identity = id }
   ) else (
     let (id, time) = lookup_bos context rpage in
     { raw = rpage; time = time; identity = id }

Modified: oogg/trunk/page_util.ml
===================================================================
--- oogg/trunk/page_util.ml	2007-08-13 08:01:47 UTC (rev 3184)
+++ oogg/trunk/page_util.ml	2007-08-13 08:10:15 UTC (rev 3185)
@@ -36,7 +36,9 @@
 let print_page p =
   print_mediaType p.identity;
   print_string " ";
-  Printf.printf "%.3f\n" p.time;
+  (match p.time with
+    | None -> Printf.printf "None\n"
+    | Some t -> Printf.printf "%.3f\n" t);
   print_rawPage p.raw;;
 
 let rec print_pageStream ps = match ps with parser

Modified: oogg/trunk/types.ml
===================================================================
--- oogg/trunk/types.ml	2007-08-13 08:01:47 UTC (rev 3184)
+++ oogg/trunk/types.ml	2007-08-13 08:10:15 UTC (rev 3185)
@@ -32,7 +32,7 @@
 
 type page = 
   { raw : rawPage ;
-    time : float ; 
+    time : float option; 
     identity : mediaType
   };;
 
@@ -45,7 +45,7 @@
   { stream_serialno : serialNo ;
     stream_pages : rawPageStream ;
     stream_type : mediaType ;
-    stream_time : (granulePos -> float) option
+    stream_time : (granulePos -> float option) 
   };;
 
 let oogg32_to_int64 (a, b) =

Modified: oogg/trunk/types.mli
===================================================================
--- oogg/trunk/types.mli	2007-08-13 08:01:47 UTC (rev 3184)
+++ oogg/trunk/types.mli	2007-08-13 08:10:15 UTC (rev 3185)
@@ -45,7 +45,7 @@
 
 type page = 
   { raw : rawPage ;
-    time : float ; 
+    time : float option ; 
     identity : mediaType
   };;
 
@@ -59,7 +59,7 @@
   { stream_serialno : serialNo ;
     stream_pages : rawPageStream ;
     stream_type : mediaType ;
-    stream_time : (granulePos -> float) option
+    stream_time : (granulePos -> float option) 
   };;
 
 val print_mediaType : mediaType -> unit;;



More information about the commits mailing list