[xiph-commits] r3243 - oogg/trunk

shans at svn.annodex.net shans at svn.annodex.net
Thu Sep 27 18:54:04 PDT 2007


Author: shans
Date: 2007-09-27 18:54:04 -0700 (Thu, 27 Sep 2007)
New Revision: 3243

Modified:
   oogg/trunk/oogg_copy_file.ml
   oogg/trunk/packet.ml
   oogg/trunk/page.ml
   oogg/trunk/page.mli
Log:
Added checksum generation to packet-to-page function.  Modified copy file to go to packet level and back.  Almost works except for some junk at the end of the copied file.



Modified: oogg/trunk/oogg_copy_file.ml
===================================================================
--- oogg/trunk/oogg_copy_file.ml	2007-09-27 05:27:21 UTC (rev 3242)
+++ oogg/trunk/oogg_copy_file.ml	2007-09-28 01:54:04 UTC (rev 3243)
@@ -1,6 +1,8 @@
 let f = File.file_open Sys.argv.(1);;
 let g = File.file_open ~writable:true Sys.argv.(2);;
 let istream = File.to_stream f 0;;
-let pstream = Page.to_rawPageStream istream;;
+let pstream = Page.to_pageStream istream;;
+let packetstream = Packet.to_packetStream pstream;;
+let newpstream = Packet.packetStream_to_pageStream packetstream;;
 let ostream = File.to_output_stream g 0;;
-Page.write_rawPageStream ostream pstream;;
+Page.write_pageStream ostream newpstream;;

Modified: oogg/trunk/packet.ml
===================================================================
--- oogg/trunk/packet.ml	2007-09-27 05:27:21 UTC (rev 3242)
+++ oogg/trunk/packet.ml	2007-09-28 01:54:04 UTC (rev 3243)
@@ -32,11 +32,16 @@
             pcont.cont_packet <- false;
               [< 'new_packet page h n oc false true >]
           )
+      | [h] ->
+          (
+            pcont.cont_packet <- true;
+              [< 'new_packet page h n oc true true >]
+          )
       | h::[r] when not page.raw.last_packet_complete ->
           (
             pcont.cont_packet <- true;
               [< 'new_packet page h n oc false             true ;
-                 'new_packet page r n oc pcont.cont_packet false >]
+                 'new_packet page r n false pcont.cont_packet false >]
           )
       | h::t  -> [< 'new_packet page h n oc false false; _ptp t (n+1) >]
       | []    -> [< >] in
@@ -81,18 +86,20 @@
             eos = packet.p_eos;
             last_packet_complete  = not packet.p_continues;
             granulepos            = if packet.p_continues
-                                    then None
+                                    then page.raw.granulepos
                                     else packet.p_granulepos;
             packet_sizes          = page.raw.packet_sizes @ 
                                     [String.length packet.p_data];
             raw_data              = page.raw.raw_data @ [packet.p_data]
           };
      time = if packet.p_continues
-            then None
+            then page.time
             else packet.p_time
   };;
 
-let flush_page page = [< 'page >];;
+let flush_page page = 
+    let checksum = Page.generate_crc page.raw in
+    [< '{ page with raw = {page.raw with checksum = checksum} } >];;
 
 let packet_to_page context packet = 
   let _flush _ =

Modified: oogg/trunk/page.ml
===================================================================
--- oogg/trunk/page.ml	2007-09-27 05:27:21 UTC (rev 3242)
+++ oogg/trunk/page.ml	2007-09-28 01:54:04 UTC (rev 3243)
@@ -243,6 +243,8 @@
       end
     | [< >] -> ();;
 
+let generate_crc page = Crc.crc (oogg_page_to_string page);;
+
 let rawPageStream_to_pageStream rpstream = 
   let context = { ct_info = [] } in
   let rec _rps_to_ps rpstream = match rpstream with parser

Modified: oogg/trunk/page.mli
===================================================================
--- oogg/trunk/page.mli	2007-09-27 05:27:21 UTC (rev 3242)
+++ oogg/trunk/page.mli	2007-09-28 01:54:04 UTC (rev 3243)
@@ -12,6 +12,8 @@
 
 val check_crc : Types.rawPageStream -> unit;;
 
+val generate_crc : Types.rawPage -> Types.oogg32;;
+
 val identify_bos : Types.rawPage -> Types.mediaType;;
 
 val to_streams_raw : Types.rawPageStream -> 



More information about the commits mailing list