[xiph-commits] r3196 - oogg/trunk
shans at svn.annodex.net
shans at svn.annodex.net
Thu Aug 16 18:42:06 PDT 2007
Author: shans
Date: 2007-08-16 18:42:06 -0700 (Thu, 16 Aug 2007)
New Revision: 3196
Modified:
oogg/trunk/mediaStream.ml
oogg/trunk/mediaStream.mli
oogg/trunk/oogg_info.ml
oogg/trunk/page.ml
oogg/trunk/page.mli
Log:
Added sorting to page and rawPage streams
Removed most of the mediaStream stuff (sorted pages work better)
Modified oogg_info to use sorted page streams
Modified: oogg/trunk/mediaStream.ml
===================================================================
--- oogg/trunk/mediaStream.ml 2007-08-16 10:20:18 UTC (rev 3195)
+++ oogg/trunk/mediaStream.ml 2007-08-17 01:42:06 UTC (rev 3196)
@@ -1,100 +1,5 @@
open Types
-exception PagesAfterEOS;;
-exception UnknownSerialNo;;
-
-(* internal type *)
-type _ooggMediaStream =
- { _stream_serialno : serialNo ;
- mutable _stream_cache : (rawPage list) option ;
- _stream_type : mediaType ;
- _stream_time : (granulePos -> float) option
- };;
-
-let rec oogg_find_stream serialno streams = match streams with
- | h::t when h._stream_serialno = serialno -> h
- | h::t -> oogg_find_stream serialno t
- | [] -> raise UnknownSerialNo
-
-(* get the beginning-of-stream pages destructively, but don't remove
- * any other data
- *)
-let rec get_bos_pages instream = match (Stream.peek instream) with
- | None -> []
- | Some page when page.bos == false -> []
- | Some page ->
- begin
- Stream.junk instream;
- let identity = Page.identify_bos page in
- { _stream_serialno = page.serialno;
- _stream_cache = (Some [page]);
- _stream_type = identity;
- _stream_time = None
- }::(get_bos_pages instream)
- end;;
-
-let rec get_next_page instream streamslist streamno =
- let ms = List.nth streamslist streamno in
- match ms._stream_cache with
- | None -> None
- | Some (h::t) ->
- begin
- if h.eos then
- ms._stream_cache <- None
- else
- ms._stream_cache <- Some t;
- Some h
- end
- | Some [] ->
- begin
- let page = Stream.next instream in
- if page.serialno = ms._stream_serialno then
- begin
- if page.eos then ms._stream_cache <- None;
- Some page
- end
- else
- begin
- let slist = oogg_find_stream page.serialno streamslist in
- begin
- match slist._stream_cache with
- | Some foo -> slist._stream_cache <- Some (foo @ [page])
- | None -> raise PagesAfterEOS
- end;
- get_next_page instream streamslist streamno
- end
- end;;
-
-let streamgen instream streamslist streamno count =
- get_next_page instream streamslist streamno
-
-(*
- * we need to convert from a single lazy stream to a list of lazy streams.
- * When pulling data from any of the streams, we will also be finding data that
- * belongs in other streams. Hence, we have an internal data structure that
- * caches frames, a get_next_page function which returns the next frame for
- * an output stream and caches frames on the other streams, and a
- * streamgen generator function with which we create the output streams. To
- * start the whole thing off we grab the stream's bos pages.
- *)
-let to_mediaStreams instream =
- let streamslist = get_bos_pages instream in
- let rec _gen_streams sl c = match sl with
- | [] -> []
- | h::t ->
- begin
- let s = h._stream_serialno in
- let ty = h._stream_type in
- let new_stream = Stream.from (streamgen instream streamslist c) in
- {
- stream_serialno=s ;
- stream_pages = new_stream ;
- stream_type = ty ;
- stream_time = fun x -> None ;
- }::(_gen_streams t (c+1))
- end in
- _gen_streams streamslist 0
-
let rec filter instream snos =
if snos = [] then [< >] else
match instream with parser
@@ -110,5 +15,3 @@
end
else [< filter rest snos >]
| [< >] -> [< >]
-
-let streamTime mediaStream gp = mediaStream.stream_time gp;;
Modified: oogg/trunk/mediaStream.mli
===================================================================
--- oogg/trunk/mediaStream.mli 2007-08-16 10:20:18 UTC (rev 3195)
+++ oogg/trunk/mediaStream.mli 2007-08-17 01:42:06 UTC (rev 3196)
@@ -1,5 +1,5 @@
-val to_mediaStreams : Types.rawPageStream -> Types.mediaStream list;;
+(*val to_mediaStreams : Types.rawPageStream -> Types.mediaStream list;;*)
val filter : Types.rawPageStream -> Types.serialNo list -> Types.rawPageStream;;
-val streamTime : Types.mediaStream -> Types.granulePos -> float option;;
+(*val streamTime : Types.mediaStream -> Types.granulePos -> float option;;*)
Modified: oogg/trunk/oogg_info.ml
===================================================================
--- oogg/trunk/oogg_info.ml 2007-08-16 10:20:18 UTC (rev 3195)
+++ oogg/trunk/oogg_info.ml 2007-08-17 01:42:06 UTC (rev 3196)
@@ -2,16 +2,19 @@
let f = File.file_open Sys.argv.(1);;
let s = File.to_stream f 0;;
-let pages = Page.to_rawPageStream s;;
+let pages = Page.to_pageStream s;;
+let sorted_pages = Page.sort pages;;
-let streams = MediaStream.to_mediaStreams pages;;
-
-let rec print_streams l = match l with
- | h::t -> begin
- print_oogg32 h.stream_serialno; print_string ": ";
- print_mediaType h.stream_type; print_newline ();
- print_streams t
- end
+let rec print_sorted_pages l = match l with
+ | (s,ps)::t ->
+ (
+ print_oogg32 s; print_string ": ";
+ let p = Stream.peek ps in
+ (match p with
+ | Some p -> print_mediaType p.identity; print_newline ()
+ | None -> print_newline ());
+ print_sorted_pages t
+ )
| [] -> ();;
-print_streams streams;;
+print_sorted_pages sorted_pages;;
Modified: oogg/trunk/page.ml
===================================================================
--- oogg/trunk/page.ml 2007-08-16 10:20:18 UTC (rev 3195)
+++ oogg/trunk/page.ml 2007-08-17 01:42:06 UTC (rev 3196)
@@ -258,3 +258,31 @@
let write_pageStream stream pstream =
write_rawPageStream stream (pageStream_to_rawPageStream pstream);;
+
+module RawPageInput =
+ struct
+ type k = serialNo
+ type s = rawPage
+ let eq = (=)
+ let get_key p = p.serialno
+ let is_first p = p.bos
+ let is_last p = p.eos
+ let printKey s = print_oogg32 s
+ end;;
+
+module RawPageSort = StreamSort.StreamSort (RawPageInput);;
+let sort_raw = RawPageSort.sort;;
+
+module PageInput =
+ struct
+ type k = serialNo
+ type s = page
+ let eq = (=)
+ let get_key p = p.raw.serialno
+ let is_first p = p.raw.bos
+ let is_last p = p.raw.eos
+ let printKey s = print_oogg32 s
+ end;;
+
+module PageSort = StreamSort.StreamSort (PageInput);;
+let sort = PageSort.sort;;
Modified: oogg/trunk/page.mli
===================================================================
--- oogg/trunk/page.mli 2007-08-16 10:20:18 UTC (rev 3195)
+++ oogg/trunk/page.mli 2007-08-17 01:42:06 UTC (rev 3196)
@@ -13,3 +13,8 @@
val check_crc : Types.rawPageStream -> unit;;
val identify_bos : Types.rawPage -> Types.mediaType;;
+
+val sort_raw : Types.rawPageStream ->
+ (Types.serialNo * Types.rawPageStream) list;;
+
+val sort : Types.pageStream -> (Types.serialNo * Types.pageStream) list;;
More information about the commits
mailing list