[xiph-commits] r3252 - oogg/trunk
shans at svn.annodex.net
shans at svn.annodex.net
Sun Oct 7 23:34:25 PDT 2007
Author: shans
Date: 2007-10-07 23:34:24 -0700 (Sun, 07 Oct 2007)
New Revision: 3252
Modified:
oogg/trunk/Makefile
oogg/trunk/granules.ml
oogg/trunk/packet.ml
oogg/trunk/packet_util.ml
oogg/trunk/page.ml
oogg/trunk/types.ml
oogg/trunk/types.mli
Log:
Limited skeleton parsing
Modified: oogg/trunk/Makefile
===================================================================
--- oogg/trunk/Makefile 2007-10-06 06:16:39 UTC (rev 3251)
+++ oogg/trunk/Makefile 2007-10-08 06:34:24 UTC (rev 3252)
@@ -1,5 +1,5 @@
PROGRAMS = oogg_dump_pages oogg_copy_file oogg_rip oogg_check_checksums \
- oogg_info oogg_dump_packets oogg_sort_stream \
+ oogg_info oogg_dump_packets oogg_sort_stream oogg_remove_excess \
oogg_dump_complete_packets
LIBINCS = -I +extlib
LIBS = unix.cmxa extLib.cmxa oogg.cmxa
@@ -36,6 +36,10 @@
ocamlopt $(PROF) -o oogg_sort_stream $(LIBINCS) $(LIBS) \
oogg_sort_stream.ml
+oogg_remove_excess: oogg.cmxa oogg_remove_excess.ml
+ ocamlopt $(PROF) -o oogg_remove_excess $(LIBINCS) $(LIBS) \
+ -pp 'camlp4o' oogg_remove_excess.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
ocamlopt $(PROF) -a -o oogg.cmxa -i $^
Modified: oogg/trunk/granules.ml
===================================================================
--- oogg/trunk/granules.ml 2007-10-06 06:16:39 UTC (rev 3251)
+++ oogg/trunk/granules.ml 2007-10-08 06:34:24 UTC (rev 3252)
@@ -1,5 +1,6 @@
open Types
+(*
let extract_be_int32 str pos =
let substr = IO.input_string (String.sub str pos 4) in
let a = IO.read_byte substr in
@@ -23,6 +24,7 @@
let extract_int8 str pos =
let substr = IO.input_string (String.sub str pos 1) in
IO.read_byte substr;;
+*)
let granulerate_time num denom gp =
Int64.to_float num *. gp /. Int64.to_float denom;;
Modified: oogg/trunk/packet.ml
===================================================================
--- oogg/trunk/packet.ml 2007-10-06 06:16:39 UTC (rev 3251)
+++ oogg/trunk/packet.ml 2007-10-08 06:34:24 UTC (rev 3252)
@@ -12,7 +12,7 @@
p_page_seq = page.raw.sequenceno ;
p_identity = page.identity ;
p_bos = page.raw.bos ;
- p_eos = page.raw.eos
+ p_eos = if isLast then page.raw.eos else false
};;
type ptp_context = {mutable cont_packet : bool};;
Modified: oogg/trunk/packet_util.ml
===================================================================
--- oogg/trunk/packet_util.ml 2007-10-06 06:16:39 UTC (rev 3251)
+++ oogg/trunk/packet_util.ml 2007-10-08 06:34:24 UTC (rev 3252)
@@ -10,7 +10,26 @@
(match p.p_time with None -> Printf.printf "None" | Some f -> print_float f);
Printf.printf " pageno " ;
print_oogg32 p.p_page_seq ;
- Printf.printf " packetno %d\n" p.p_pageno ;;
+ Printf.printf " packetno %d\n" p.p_pageno;
+ (* display skeleton information *)
+ if p.p_identity = Skeleton then (
+ if p.p_bos then (
+ let pt_num = oogg64_to_float (extract_le_oogg64 p.p_data 12) in
+ let pt_den = oogg64_to_float (extract_le_oogg64 p.p_data 20) in
+ let pt = pt_num /. pt_den in
+ let bt_num = oogg64_to_float (extract_le_oogg64 p.p_data 28) in
+ let bt_den = oogg64_to_float (extract_le_oogg64 p.p_data 36) in
+ let bt = bt_num /. bt_den in
+ Printf.printf "\tPresentation time: %f Base time: %f\n" pt bt
+ ) else if p.p_eos then (
+
+ ) else (
+ Printf.printf "\tSerial number: %Ld" (extract_be_int32 p.p_data 12);
+ Printf.printf " startgranule: ";
+ print_oogg64 (extract_le_oogg64 p.p_data 36);
+ Printf.printf "\n"
+ )
+ );;
let rec print_packetStream s = match s with parser
| [< 'p; rest >] -> (print_packet p; print_packetStream rest)
Modified: oogg/trunk/page.ml
===================================================================
--- oogg/trunk/page.ml 2007-10-06 06:16:39 UTC (rev 3251)
+++ oogg/trunk/page.ml 2007-10-08 06:34:24 UTC (rev 3252)
@@ -116,7 +116,8 @@
write_packet_data stream data;;
let wrap_value = Int64.sub (Int64.shift_left Int64.one 32) Int64.one;;
-
+
+(*
let read_ui32 stream =
let b = IO.read_ui16 stream in
let a = IO.read_ui16 stream in
@@ -152,6 +153,8 @@
| None -> write_oogg64 stream (0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF)
| Some gp -> write_oogg64 stream gp;;
+*)
+
let page_to_raw stream page =
IO.nwrite stream "OggS"; IO.write_byte stream 0;
IO.write_byte stream (make_header page);
Modified: oogg/trunk/types.ml
===================================================================
--- oogg/trunk/types.ml 2007-10-06 06:16:39 UTC (rev 3251)
+++ oogg/trunk/types.ml 2007-10-08 06:34:24 UTC (rev 3252)
@@ -116,3 +116,66 @@
};;
type packetStream = packet Stream.t;;
+
+let read_ui32 stream =
+ let b = IO.read_ui16 stream in
+ let a = IO.read_ui16 stream in
+ Int64.add (Int64.shift_left (Int64.of_int a) 16) (Int64.of_int b);;
+
+let mask = Int64.of_int 0xFFFF
+
+let write_ui32 stream value =
+ let a = Int64.to_int (Int64.shift_right value 16) in
+ let b = Int64.to_int (Int64.logand value mask) in
+ IO.write_ui16 stream b;
+ IO.write_ui16 stream a;;
+
+let read_oogg64 stream =
+ (IO.read_ui16 stream, IO.read_ui16 stream, IO.read_ui16 stream,
+ IO.read_ui16 stream);;
+
+let write_oogg64 stream (a, b, c, d) =
+ IO.write_ui16 stream d; IO.write_ui16 stream c;
+ IO.write_ui16 stream b; IO.write_ui16 stream a;;
+
+let read_oogg32 stream =
+ (IO.read_ui16 stream, IO.read_ui16 stream);;
+
+let write_oogg32 stream (a, b) =
+ IO.write_ui16 stream b; IO.write_ui16 stream a;;
+
+let read_granulepos stream =
+ let gp = read_oogg64 stream in
+ if gp = (0xFFFF,0xFFFF,0xFFFF,0xFFFF) then None else Some gp;;
+
+let write_granulepos stream gp = match gp with
+ | None -> write_oogg64 stream (0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF)
+ | Some gp -> write_oogg64 stream gp;;
+
+let extract_be_int32 str pos =
+ let substr = IO.input_string (String.sub str pos 4) in
+ let a = IO.read_byte substr in
+ let b = IO.read_byte substr in
+ let c = IO.read_byte substr in
+ let d = IO.read_byte substr in
+ let e = (a lsl 8) + b in
+ let f = (c lsl 8) + d in
+ Int64.add (Int64.shift_left (Int64.of_int e) 16) (Int64.of_int f);;
+
+let extract_le_int32 str pos =
+ let substr = IO.input_string (String.sub str pos 4) in
+ let d = IO.read_byte substr in
+ let c = IO.read_byte substr in
+ let b = IO.read_byte substr in
+ let a = IO.read_byte substr in
+ let e = (a lsl 8) + b in
+ let f = (c lsl 8) + d in
+ Int64.add (Int64.shift_left (Int64.of_int e) 16) (Int64.of_int f);;
+
+let extract_int8 str pos =
+ let substr = IO.input_string (String.sub str pos 1) in
+ IO.read_byte substr;;
+
+let extract_le_oogg64 str pos =
+ let substr = IO.input_string (String.sub str pos 8) in read_oogg64 substr;;
+
Modified: oogg/trunk/types.mli
===================================================================
--- oogg/trunk/types.mli 2007-10-06 06:16:39 UTC (rev 3251)
+++ oogg/trunk/types.mli 2007-10-08 06:34:24 UTC (rev 3252)
@@ -79,3 +79,19 @@
};;
type packetStream = packet Stream.t;;
+
+val read_ui32 : IO.input -> int64;;
+val write_ui32 : 'a IO.output -> int64 -> unit;;
+
+val read_oogg64 : IO.input -> oogg64;;
+val write_oogg64 : 'a IO.output -> oogg64 -> unit;;
+val read_oogg32 : IO.input -> oogg32;;
+val write_oogg32 : 'a IO.output -> oogg32 -> unit;;
+
+val read_granulepos : IO.input -> granulePos;;
+val write_granulepos : 'a IO.output -> granulePos -> unit;;
+
+val extract_be_int32 : string -> int -> int64;;
+val extract_le_int32 : string -> int -> int64;;
+val extract_le_oogg64 : string -> int -> oogg64;;
+val extract_int8 : string -> int -> int;;
More information about the commits
mailing list