[xiph-commits] r3187 - oogg/trunk
shans at svn.annodex.net
shans at svn.annodex.net
Mon Aug 13 05:34:31 PDT 2007
Author: shans
Date: 2007-08-13 05:34:31 -0700 (Mon, 13 Aug 2007)
New Revision: 3187
Modified:
oogg/trunk/granules.ml
oogg/trunk/granules.mli
oogg/trunk/oogg_dump_packets.ml
oogg/trunk/packet.ml
oogg/trunk/packet.mli
oogg/trunk/types.ml
oogg/trunk/types.mli
Log:
Framework for calculating lost timing / granulepos information on packet streams. Actual calculator functions (in granules.ml) don't do the right thing yet.
Modified: oogg/trunk/granules.ml
===================================================================
--- oogg/trunk/granules.ml 2007-08-13 10:48:49 UTC (rev 3186)
+++ oogg/trunk/granules.ml 2007-08-13 12:34:31 UTC (rev 3187)
@@ -58,3 +58,5 @@
| Theora -> theora_time bos
| _ -> fun x -> None
+let calculate_next_gp id (Some (a,b,c,d)) = Some (a,b,c,d+1)
+let calculate_last_gp id (Some (a,b,c,d)) = Some (a,b,c,d-1)
Modified: oogg/trunk/granules.mli
===================================================================
--- oogg/trunk/granules.mli 2007-08-13 10:48:49 UTC (rev 3186)
+++ oogg/trunk/granules.mli 2007-08-13 12:34:31 UTC (rev 3187)
@@ -1,2 +1,7 @@
val granulerate_function : Types.mediaType -> Types.rawPage ->
(Types.granulePos -> float option);;
+
+val calculate_next_gp : Types.mediaType -> Types.granulePos ->
+ Types.granulePos;;
+val calculate_last_gp : Types.mediaType -> Types.granulePos ->
+ Types.granulePos;;
Modified: oogg/trunk/oogg_dump_packets.ml
===================================================================
--- oogg/trunk/oogg_dump_packets.ml 2007-08-13 10:48:49 UTC (rev 3186)
+++ oogg/trunk/oogg_dump_packets.ml 2007-08-13 12:34:31 UTC (rev 3187)
@@ -2,4 +2,5 @@
let s = File.to_stream f 0;;
let ps = Page.to_pageStream s;;
let pps = Packet.to_packetStream ps;;
-Packet_util.print_packetStream pps;;
+let ppps = Packet.reconstruct_timing pps;;
+Packet_util.print_packetStream ppps;;
Modified: oogg/trunk/packet.ml
===================================================================
--- oogg/trunk/packet.ml 2007-08-13 10:48:49 UTC (rev 3186)
+++ oogg/trunk/packet.ml 2007-08-13 12:34:31 UTC (rev 3187)
@@ -21,3 +21,51 @@
| [< 'page ; rest >] -> [< page_to_packets page ; to_packetStream rest >]
| [< >] -> [< >];;
+type reconstruct_context = {
+ rc_tf : granulePos -> float option;
+ mutable rc_cache : packet list;
+ rc_lgp : granulePos option;
+} ;;
+
+let packet_from_last_gp crec pack gp =
+ let new_gp = Granules.calculate_next_gp pack.p_page.identity gp in
+ [< '{ pack with p_granulepos = new_gp; p_time = crec.rc_tf new_gp } >]
+
+let new_gp_and_flush crec pack =
+ let rec _ngaf l gp = match l with
+ | h::t -> (
+ let last_gp = Granules.calculate_last_gp pack.p_page.identity gp in
+ [< _ngaf t last_gp;
+ '{ h with p_granulepos = last_gp; p_time = crec.rc_tf last_gp } >])
+ | [] -> [< >] in
+ [< _ngaf crec.rc_cache pack.p_granulepos; 'pack >]
+
+let reconstruct_packet context pack =
+ let sn = pack.p_page.raw.serialno in
+ let id = pack.p_page.identity in
+ let rpage = pack.p_page.raw in
+ let gp = pack.p_granulepos in
+ let crec =
+ (
+ if pack.p_page.raw.bos
+ then (
+ context :=
+ (sn, {rc_tf=Granules.granulerate_function id rpage;
+ rc_cache=[];
+ rc_lgp=None})::
+ (!context);
+ snd (List.hd !context))
+ else List.assoc sn !context
+ ) in
+ match gp with
+ | None -> (match crec.rc_lgp with
+ | None -> (crec.rc_cache <- pack::crec.rc_cache; [< >])
+ | Some gp -> packet_from_last_gp crec pack gp)
+ | Some gp -> [< new_gp_and_flush crec pack >];;
+
+let reconstruct_timing pstream =
+ let context = ref [] in
+ let rec _rt s = match s with parser
+ | [< 'pack ; rest >] -> [<reconstruct_packet context pack; _rt rest>]
+ | [< >] -> [< >] in
+ _rt pstream;;
Modified: oogg/trunk/packet.mli
===================================================================
--- oogg/trunk/packet.mli 2007-08-13 10:48:49 UTC (rev 3186)
+++ oogg/trunk/packet.mli 2007-08-13 12:34:31 UTC (rev 3187)
@@ -1 +1,3 @@
val to_packetStream : Types.pageStream -> Types.packetStream;;
+
+val reconstruct_timing : Types.packetStream -> Types.packetStream;;
Modified: oogg/trunk/types.ml
===================================================================
--- oogg/trunk/types.ml 2007-08-13 10:48:49 UTC (rev 3186)
+++ oogg/trunk/types.ml 2007-08-13 12:34:31 UTC (rev 3187)
@@ -103,8 +103,8 @@
type packet =
{ p_data : string ;
- p_granulepos : granulePos ;
- p_time : float option ;
+ mutable p_granulepos : granulePos ;
+ mutable p_time : float option ;
p_page : page
};;
Modified: oogg/trunk/types.mli
===================================================================
--- oogg/trunk/types.mli 2007-08-13 10:48:49 UTC (rev 3186)
+++ oogg/trunk/types.mli 2007-08-13 12:34:31 UTC (rev 3187)
@@ -66,8 +66,8 @@
type packet =
{ p_data : string ;
- p_granulepos : granulePos ;
- p_time : float option ;
+ mutable p_granulepos : granulePos ;
+ mutable p_time : float option ;
p_page : page
};;
More information about the commits
mailing list