fi.helsinki.cs.ohtu.mpeg2
Class ClockOps

java.lang.Object
  extended by fi.helsinki.cs.ohtu.mpeg2.ClockOps

 class ClockOps
extends java.lang.Object

Implements assorted methods to handle the 33-bit 90kHz MPEG system clock values.


Field Summary
static int TICK_RATE
          The number of system clock ticks per second
 
Constructor Summary
private ClockOps()
           
 
Method Summary
static long add(long t, double s)
          Adds system clock ticks and seconds.
static long add(long a, long b)
          Adds two system clock values.
static boolean isLessThan(long a, long b)
          Compares whether the first system clock value is less than (or precedes) the second value.
static long normalize(long t)
          Normalizes (that is, gets mod 2^33 - 1) of a system clock value.
static double toSeconds(long t)
          Converts system clock ticks to seconds.
static long toTicks(double s)
          Converts seconds to system clock ticks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TICK_RATE

public static final int TICK_RATE
The number of system clock ticks per second

See Also:
Constant Field Values
Constructor Detail

ClockOps

private ClockOps()
Method Detail

toTicks

public static long toTicks(double s)
Converts seconds to system clock ticks.

Parameters:
s - the seconds to convert
Returns:
the system clock ticks

toSeconds

public static double toSeconds(long t)
Converts system clock ticks to seconds.

Parameters:
t - the system clock ticks
Returns:
the seconds

add

public static long add(long a,
                       long b)
Adds two system clock values.

Parameters:
a - the first system clock value
b - the second system clock value
Returns:
the sum of the system clock values

add

public static long add(long t,
                       double s)
Adds system clock ticks and seconds.

Parameters:
t - the system clock ticks
s - the seconds to add
Returns:
the sum of the ticks and seconds, in ticks

normalize

public static long normalize(long t)
Normalizes (that is, gets mod 2^33 - 1) of a system clock value.

Parameters:
t - the system clock value
Returns:
the normalized system clock value

isLessThan

public static boolean isLessThan(long a,
                                 long b)
Compares whether the first system clock value is less than (or precedes) the second value. As the values can overflow and wrap around, the comparison is slightly tricky. The values are assumed to be less than 2^32 ticks apart. If a - b is at least 2^32, one of the values (not both!) is assumed to have wrapped around.

Parameters:
a - the first system clock value
b - the second system clock value
Returns:
true if a is less than (or precedes) b