| 44 | | let shift = |
|---|
| 45 | | ((extract_int8 bos_packet 40 land 0x03) lsl 3) |
|---|
| 46 | | lor |
|---|
| 47 | | ((extract_int8 bos_packet 41 land 0xe0) lsr 5) in |
|---|
| 48 | | let igp = oogg64_to_int64 gp in |
|---|
| 49 | | let keyframe = Int64.shift_right igp shift in |
|---|
| 50 | | let offset = Int64.logand igp |
|---|
| 51 | | (Int64.sub (Int64.shift_left Int64.one shift) Int64.one) in |
|---|
| | 57 | let shift = theora_shift bos in |
|---|
| | 58 | let (keyframe, offset) = theora_gp_to_frames shift gp in |
|---|
| 87 | | let theora_last_gp _ _ _ _ = None;; |
|---|
| | 94 | let theora_frames_to_gp shift keyframe frame = |
|---|
| | 95 | int64_to_oogg64 (Int64.add (Int64.shift_left keyframe shift) frame);; |
|---|
| | 96 | |
|---|
| | 97 | (* assume that we only do negative generation at the beginning, and |
|---|
| | 98 | that we never go over more than 1 keyframe. At worst we just miss |
|---|
| | 99 | out on a keyframe at the beginning |
|---|
| | 100 | *) |
|---|
| | 101 | let theora_last_gp bos prevpack thispack thisgp = |
|---|
| | 102 | match thisgp with |
|---|
| | 103 | | None -> None |
|---|
| | 104 | | Some gp -> ( |
|---|
| | 105 | let shift = theora_shift bos in |
|---|
| | 106 | let (keyframe, offset) = theora_gp_to_frames shift gp in |
|---|
| | 107 | if offset = 0L |
|---|
| | 108 | then Some (theora_frames_to_gp shift 0L (Int64.sub keyframe 1L)) |
|---|
| | 109 | else Some (theora_frames_to_gp shift keyframe (Int64.sub offset 1L)));; |
|---|
| 104 | | let theora_next_gp _ _ _ _ = None;; |
|---|
| | 126 | let theora_next_gp bos prevpack thispack lastgp = |
|---|
| | 127 | match lastgp with |
|---|
| | 128 | | None -> None |
|---|
| | 129 | | Some gp -> ( |
|---|
| | 130 | let shift = theora_shift bos in |
|---|
| | 131 | let (keyframe, offset) = theora_gp_to_frames shift gp in |
|---|
| | 132 | let fb = extract_int8 thispack 0 in |
|---|
| | 133 | if (fb land 0x80) = 0x80 (* header packet *) |
|---|
| | 134 | then Some (0,0,0,0) |
|---|
| | 135 | else ( |
|---|
| | 136 | if (fb land 0x40) = 0x40 (* inter packet *) |
|---|
| | 137 | then Some (theora_frames_to_gp shift keyframe (Int64.add offset 1L)) |
|---|
| | 138 | else Some (theora_frames_to_gp shift |
|---|
| | 139 | (Int64.add (Int64.add keyframe offset) 1L) 0L) |
|---|
| | 140 | ));; |
|---|