libkate: Granule encoding

# Granule encoding

Ogg leaves the encoding of granules up to a particular codec, only mandating that granules be non decreasing with time.

The Kate bitstream format uses a linear mapping between time and granule, described here.

A Kate granule position is composed of two different parts:

- a base granule, in the high bits
- a granule offset, in the low bits

    +----------------+----------------+
    | base           | offset         |
    +----------------+----------------+

The number of bits these parts occupy is variable, and each stream may choose how many bits to dedicate to each. The kate_info structure for a stream holds that information in the granule_shift field, so each part may be reconstructed from a granulepos.

The kate_info structure for a stream also holds a rational fraction representing the time span of granule units.

The granule rate is defined by the two fields:

    kate_info::gps_numerator
    kate_info::gps_denominator

The number of bits reserved for the offset is defined by the field:

    kate_info::granule_shift