[xiph-commits] r3202 - oogg/trunk
shans at svn.annodex.net
shans at svn.annodex.net
Sun Aug 26 16:27:03 PDT 2007
Author: shans
Date: 2007-08-26 16:27:02 -0700 (Sun, 26 Aug 2007)
New Revision: 3202
Added:
oogg/trunk/oogg_sort_stream.ml
Modified:
oogg/trunk/Makefile
oogg/trunk/oogg_info.ml
oogg/trunk/packet.ml
oogg/trunk/page.ml
oogg/trunk/page.mli
Log:
renamed "sort" function in page.ml to "to_streams".
Added sort function in page.ml that bubble-sorts a page stream to get
time values into correct order.
Implementation of stream sorting script (oogg_sort_stream.ml)
Modified: oogg/trunk/Makefile
===================================================================
--- oogg/trunk/Makefile 2007-08-25 09:36:12 UTC (rev 3201)
+++ oogg/trunk/Makefile 2007-08-26 23:27:02 UTC (rev 3202)
@@ -1,5 +1,5 @@
PROGRAMS = oogg_dump_pages oogg_copy_file oogg_rip oogg_check_checksums \
- oogg_info oogg_dump_packets
+ oogg_info oogg_dump_packets oogg_sort_stream
LIBINCS = -I +extlib
LIBS = unix.cmxa extLib.cmxa oogg.cmxa
PROF =
@@ -26,6 +26,10 @@
oogg_rip: oogg.cmxa oogg_rip.ml
ocamlopt $(PROF) -o oogg_rip $(LIBINCS) $(LIBS) oogg_rip.ml
+
+oogg_sort_stream: oogg.cmxa oogg_sort_stream.ml
+ ocamlopt $(PROF) -o oogg_sort_stream $(LIBINCS) $(LIBS) \
+ oogg_sort_stream.ml
oogg.cmxa: types.cmx crc.cmx file.cmx granules.cmx streamSort.cmx page.cmx \
page_util.cmx mediaStream.cmx packet.cmx packet_util.cmx
Modified: oogg/trunk/oogg_info.ml
===================================================================
--- oogg/trunk/oogg_info.ml 2007-08-25 09:36:12 UTC (rev 3201)
+++ oogg/trunk/oogg_info.ml 2007-08-26 23:27:02 UTC (rev 3202)
@@ -3,7 +3,7 @@
let f = File.file_open Sys.argv.(1);;
let s = File.to_stream f 0;;
let pages = Page.to_pageStream s;;
-let sorted_pages = Page.sort pages;;
+let sorted_pages = Page.to_streams pages;;
let rec print_sorted_pages l = match l with
| (s,ps)::t ->
Added: oogg/trunk/oogg_sort_stream.ml
===================================================================
--- oogg/trunk/oogg_sort_stream.ml (rev 0)
+++ oogg/trunk/oogg_sort_stream.ml 2007-08-26 23:27:02 UTC (rev 3202)
@@ -0,0 +1,7 @@
+let f = File.file_open Sys.argv.(1);;
+let g = File.file_open ~writable:true Sys.argv.(2);;
+let s = File.to_stream f 0;;
+let ps = Page.to_pageStream s;;
+let sps = Page.sort ps;;
+let ostream = File.to_output_stream g 0;;
+Page.write_pageStream ostream sps;;
Modified: oogg/trunk/packet.ml
===================================================================
--- oogg/trunk/packet.ml 2007-08-25 09:36:12 UTC (rev 3201)
+++ oogg/trunk/packet.ml 2007-08-26 23:27:02 UTC (rev 3202)
@@ -40,7 +40,7 @@
| [< 'page ; rest >] -> [< page_to_packets cont page ; _tps rest >]
| [< >] -> [< >] in
_tps pstream;;
-
+(*
let create_fresh_page packet =
let raw_page =
{
@@ -85,6 +85,7 @@
| [< 'packet >] -> [< packet_to_page context packet; _ptp () >]
| [< >] -> [< flush_page !context >] in
_ptp ();;
+*)
type reconstruct_context = {
rc_tf : granulePos -> float option;
Modified: oogg/trunk/page.ml
===================================================================
--- oogg/trunk/page.ml 2007-08-25 09:36:12 UTC (rev 3201)
+++ oogg/trunk/page.ml 2007-08-26 23:27:02 UTC (rev 3202)
@@ -271,7 +271,7 @@
end;;
module RawPageSort = StreamSort.StreamSort (RawPageInput);;
-let sort_raw = RawPageSort.sort;;
+let to_streams_raw = RawPageSort.sort;;
module PageInput =
struct
@@ -285,4 +285,50 @@
end;;
module PageSort = StreamSort.StreamSort (PageInput);;
-let sort = PageSort.sort;;
+let to_streams = PageSort.sort;;
+
+let _cmp a b =
+ if a = None then true
+ else if b = None then true
+ else a >= b;;
+
+let _p t = match t with
+ | None -> "None"
+ | Some t -> "Some " ^ string_of_float t
+
+let sort pageStream =
+ let sorted = ref false in
+ let lookaside = ref None in
+ let last = ref (Some 0.0) in
+ let rec _sort pageStream = match pageStream with parser
+ | [< 'page >] ->
+ (
+ if !last > page.time then sorted := false;
+ match !lookaside with
+ | None -> lookaside := Some page; [< _sort pageStream >]
+ | Some stored ->
+ (
+ if _cmp page.time stored.time
+ then
+ (
+ lookaside := Some page;
+ last := stored.time ;
+ [< 'stored ; _sort pageStream >]
+ )
+ else
+ (
+ last := page.time ;
+ [< 'page ; _sort pageStream >]
+ )
+ )
+ )
+ | [< >] ->
+ ( match !lookaside with
+ | None -> [< >]
+ | Some stored -> [< 'stored >] ) in
+ let ps = ref pageStream in
+ while not !sorted do (
+ sorted := true;
+ ps := _sort !ps;
+ ) done;
+ !ps;;
Modified: oogg/trunk/page.mli
===================================================================
--- oogg/trunk/page.mli 2007-08-25 09:36:12 UTC (rev 3201)
+++ oogg/trunk/page.mli 2007-08-26 23:27:02 UTC (rev 3202)
@@ -14,7 +14,9 @@
val identify_bos : Types.rawPage -> Types.mediaType;;
-val sort_raw : Types.rawPageStream ->
+val to_streams_raw : Types.rawPageStream ->
(Types.serialNo * Types.rawPageStream) list;;
-val sort : Types.pageStream -> (Types.serialNo * Types.pageStream) list;;
+val to_streams : Types.pageStream -> (Types.serialNo * Types.pageStream) list;;
+
+val sort : Types.pageStream -> Types.pageStream;;
More information about the commits
mailing list