{-# LANGUAGE
BangPatterns
+ , FlexibleContexts
+ , ScopedTypeVariables
, UnboxedTuples
, UnicodeSyntax
#-}
import Data.Bits
import Data.Bitstream.Generic (Bitstream)
import qualified Data.Bitstream.Generic as B
+import Data.Int
+import qualified Data.Vector.Generic as GV
import Data.Word
import Prelude.Unicode
}
deriving (Eq, Show)
--- This is an optimized version of 'getWord' that is used for lossless
--- only (error_limit ≡ 0). Also, rather than obtaining a single
--- sample, it can be used to obtain an entire buffer of either mono or
--- stereo samples.
---getWordsLossless ∷
+-- | This is an optimized version of 'getWord' that is used for
+-- lossless only ('edErrorLimit' ≡ 0). Also, rather than obtaining a
+-- single sample, it can be used to obtain an entire buffer of either
+-- mono or stereo samples.
+getWordsLossless ∷ ∀bs n v. (Bitstream bs, Integral n, GV.Vector v Int32)
+ ⇒ Bool -- ^ Is the stream monaural?
+ → WordsData
+ → bs -- ^ WV bitstream.
+ → n -- ^ Number of samples to get.
+ → (# WordsData, bs, v Int32 #)
+{-# INLINEABLE getWordsLossless #-}
+getWordsLossless isMono w bs nSamples0
+ = error "FIXME"
+ where
+ nSamples ∷ n
+ nSamples = if isMono
+ then nSamples0
+ else nSamples0 ⋅ 2
--- Read a single unsigned value from the specified bitstream with a
+-- | Read a single unsigned value from the specified bitstream with a
-- value from 0 to maxCode. If there are exactly a power of two number
-- of possible codes then this will read a fixed number of bits;
-- otherwise it reads the minimum number of bits and then determines