isobmff-0.14.0.0: A parser and generator for the ISO-14496-12/14 base media file format

Safe HaskellNone
LanguageHaskell2010

Data.Type.BitRecords.BitBuffer64

Synopsis

Documentation

type BitBuffer64MaxLength = 64 Source #

The maximum number of bits a BitBuffer can hold.

bitBuffer64MaxLength :: Int Source #

The maximum number of bits a BitBuffer can hold.

bitBuffer64MaxLengthBytes :: Word64 Source #

The maximum number of bytes a BitBuffer can hold.

data BitBuffer64 Source #

A buffer for 64 bits, such that the bits are written MSB to LSB.

type TwoFields = "f0" @: Field m .+. "f1" @: Field n

Writes: MSB LSB Bit: |k .. k-(m+1)|k-m .. k-(m+n+1)|k-(m+n) .. 0| Value: |------f0------|--------f1--------|XXXXXXXXXXXXXX|

Where k is the current bit offset. The input values are expected to be in the order of the fields, i.e.:

toFunction $ bitBuffer64Builder (Proxy :: Proxy TwoFields) 1 2

Will result in: MSB LSB Bit: |k .. k-(m+1)|k-m .. k-(m+n+1)| k-(m+n) .. 0| Value: |0 .. 1|0 .. 10| X .. X|

The string of bits with a given length (but always <= bitBuffer64MaxLength. The number of bits must be smaller that bitBuffer64MaxLength.

bitBuffer64 :: Int -> Word64 -> BitBuffer64 Source #

Create a BitBuffer64 containing len bits from LSB to MSB, properly masked, such that only len least significant bits are kept..

bitBuffer64ProxyLength :: KnownChunkSize n => Proxy n -> Word64 -> BitBuffer64 Source #

Create a BitBuffer64 with a length given by a Proxy to a type level Nat.

bufferBits Source #

Arguments

:: BitBuffer64

The value to write (in the lower length bits).

-> BitBuffer64

The input to write to (starting from length)

-> (BitBuffer64, BitBuffer64)

The remaining bits that did not fit in the buffer and the output buffer.

Copy bits starting at a specific offset from one a the the other. Set bits starting from the most significant bit to the least. For example writeBits m 1 <> writeBits n 2 would result in:

        MSB                                             LSB
   Bit: |k  ..  k-(m+1)|k-m  ..  k-(m+n+1)| k-(m+n)  ..  0|
 Value: |0     ..     1|0        ..     10|  ...          |
         ->             ->                 ->     (direction of writing)

type family KnownChunkSize (s :: Nat) :: Constraint where ... Source #

Equations

KnownChunkSize size = (KnownNat size, size <= BitBuffer64MaxLength)