[xiph-commits] r3186 - oogg/trunk

shans at svn.annodex.net shans at svn.annodex.net
Mon Aug 13 03:48:49 PDT 2007


Author: shans
Date: 2007-08-13 03:48:49 -0700 (Mon, 13 Aug 2007)
New Revision: 3186

Added:
   oogg/trunk/oogg_dump_packets.ml
   oogg/trunk/packet.ml
   oogg/trunk/packet.mli
   oogg/trunk/packet_util.ml
   oogg/trunk/packet_util.mli
Modified:
   oogg/trunk/Makefile
   oogg/trunk/types.ml
   oogg/trunk/types.mli
Log:
Packet stream generators, packet printing functions, test script



Modified: oogg/trunk/Makefile
===================================================================
--- oogg/trunk/Makefile	2007-08-13 08:10:15 UTC (rev 3185)
+++ oogg/trunk/Makefile	2007-08-13 10:48:49 UTC (rev 3186)
@@ -1,7 +1,8 @@
-PROGRAMS = oogg_dump_pages oogg_copy_file oogg_rip oogg_check_checksums oogg_info
+PROGRAMS = oogg_dump_pages oogg_copy_file oogg_rip oogg_check_checksums \
+	   oogg_info oogg_dump_packets
 LIBINCS = -I +extlib
 LIBS = unix.cmxa extLib.cmxa oogg.cmxa 
-PROF = -p 
+PROF = 
 
 all: $(PROGRAMS)
 
@@ -9,6 +10,10 @@
 	ocamlopt $(PROF) -o oogg_dump_pages $(LIBINCS) $(LIBS) \
 							oogg_dump_pages.ml
 
+oogg_dump_packets: oogg.cmxa oogg_dump_packets.ml
+	ocamlopt $(PROF) -o oogg_dump_packets $(LIBINCS) $(LIBS) \
+							oogg_dump_packets.ml
+
 oogg_info: oogg.cmxa oogg_info.ml
 	ocamlopt $(PROF) -o oogg_info $(LIBINCS) $(LIBS) oogg_info.ml
 
@@ -22,7 +27,8 @@
 oogg_rip: oogg.cmxa oogg_rip.ml
 	ocamlopt $(PROF) -o oogg_rip $(LIBINCS) $(LIBS) oogg_rip.ml
 	
-oogg.cmxa: types.cmx crc.cmx file.cmx granules.cmx page.cmx page_util.cmx mediaStream.cmx 
+oogg.cmxa: types.cmx crc.cmx file.cmx granules.cmx page.cmx page_util.cmx \
+           mediaStream.cmx packet.cmx packet_util.cmx
 	ocamlopt $(PROF) -a -o oogg.cmxa -i $^
 
 %.cmx: %.mli %.ml

Added: oogg/trunk/oogg_dump_packets.ml
===================================================================
--- oogg/trunk/oogg_dump_packets.ml	                        (rev 0)
+++ oogg/trunk/oogg_dump_packets.ml	2007-08-13 10:48:49 UTC (rev 3186)
@@ -0,0 +1,5 @@
+let f = File.file_open Sys.argv.(1);;
+let s = File.to_stream f 0;;
+let ps = Page.to_pageStream s;;
+let pps = Packet.to_packetStream ps;;
+Packet_util.print_packetStream pps;;

Added: oogg/trunk/packet.ml
===================================================================
--- oogg/trunk/packet.ml	                        (rev 0)
+++ oogg/trunk/packet.ml	2007-08-13 10:48:49 UTC (rev 3186)
@@ -0,0 +1,23 @@
+open Types
+
+let new_packet page data isLast =
+  {
+    p_data = data ;
+    p_granulepos = if isLast then page.raw.granulepos else None ;
+    p_time = if isLast then page.time else None ;
+    p_page = page
+  };;
+
+let page_to_packets page =
+  let rec _ptp raw_data = match raw_data with
+  | h::[l] when page.raw.continued -> 
+        [< 'new_packet page h true; 'new_packet page l false >]
+  | h::[] when not page.raw.continued -> [< 'new_packet page h true >]
+  | h::t  -> [< 'new_packet page h false; _ptp t >]
+  | []    -> [< >] in
+  _ptp page.raw.raw_data;;
+
+let rec to_packetStream pstream = match pstream with parser
+  | [< 'page ; rest >] -> [< page_to_packets page ; to_packetStream rest >]
+  | [< >] -> [< >];;
+

Added: oogg/trunk/packet.mli
===================================================================
--- oogg/trunk/packet.mli	                        (rev 0)
+++ oogg/trunk/packet.mli	2007-08-13 10:48:49 UTC (rev 3186)
@@ -0,0 +1 @@
+val to_packetStream : Types.pageStream -> Types.packetStream;;

Added: oogg/trunk/packet_util.ml
===================================================================
--- oogg/trunk/packet_util.ml	                        (rev 0)
+++ oogg/trunk/packet_util.ml	2007-08-13 10:48:49 UTC (rev 3186)
@@ -0,0 +1,13 @@
+open Types
+
+let print_packet p =
+  print_mediaType p.p_page.identity; 
+  Printf.printf " size %d gp " (String.length p.p_data);
+  print_granulepos p.p_granulepos;
+  Printf.printf " time ";
+  (match p.p_time with None -> Printf.printf "None" | Some f -> print_float f);
+  Printf.printf "\n";;
+
+let rec print_packetStream s = match s with parser
+  | [< 'p; rest >] -> (print_packet p; print_packetStream rest)
+  | [< >] -> ();;

Added: oogg/trunk/packet_util.mli
===================================================================
--- oogg/trunk/packet_util.mli	                        (rev 0)
+++ oogg/trunk/packet_util.mli	2007-08-13 10:48:49 UTC (rev 3186)
@@ -0,0 +1,2 @@
+val print_packet : Types.packet -> unit;;
+val print_packetStream : Types.packetStream -> unit;;

Modified: oogg/trunk/types.ml
===================================================================
--- oogg/trunk/types.ml	2007-08-13 08:10:15 UTC (rev 3185)
+++ oogg/trunk/types.ml	2007-08-13 10:48:49 UTC (rev 3186)
@@ -101,4 +101,11 @@
   | Theora   -> "Theora"
   | Unknown  -> "Unknown!");;
 
+type packet = 
+  { p_data : string ;
+    p_granulepos : granulePos ;
+    p_time : float option ;
+    p_page : page
+  };;
 
+type packetStream = packet Stream.t;;

Modified: oogg/trunk/types.mli
===================================================================
--- oogg/trunk/types.mli	2007-08-13 08:10:15 UTC (rev 3185)
+++ oogg/trunk/types.mli	2007-08-13 10:48:49 UTC (rev 3186)
@@ -64,3 +64,11 @@
 
 val print_mediaType : mediaType -> unit;;
 
+type packet = 
+  { p_data : string ;
+    p_granulepos : granulePos ;
+    p_time : float option ;
+    p_page : page
+  };;
+
+type packetStream = packet Stream.t;;



More information about the commits mailing list