{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeFamilies #-}
module Codec.Picture.Jpg.Internal.FastDct( referenceDct, fastDctLibJpeg ) where
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative( (<$>) )
#endif
import Data.Int( Int16, Int32 )
import Data.Bits( unsafeShiftR, unsafeShiftL )
import Control.Monad.ST( ST )
import qualified Data.Vector.Storable.Mutable as M
import Codec.Picture.Jpg.Internal.Types
import Control.Monad( forM, forM_ )
referenceDct :: MutableMacroBlock s Int32
-> MutableMacroBlock s Int16
-> ST s (MutableMacroBlock s Int32)
referenceDct :: MutableMacroBlock s Int32
-> MutableMacroBlock s Int16 -> ST s (MutableMacroBlock s Int32)
referenceDct MutableMacroBlock s Int32
workData MutableMacroBlock s Int16
block = do
[(Int, Int)] -> ((Int, Int) -> ST s ()) -> ST s ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(Int
u, Int
v) | Int
u <- [Int
0 :: Int .. Int
forall a. Num a => a
dctBlockSize Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1], Int
v <- [Int
0..Int
forall a. Num a => a
dctBlockSize Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1]] (((Int, Int) -> ST s ()) -> ST s ())
-> ((Int, Int) -> ST s ()) -> ST s ()
forall a b. (a -> b) -> a -> b
$ \(Int
u,Int
v) -> do
Float
val <- (Int, Int) -> ST s Float
at (Int
u,Int
v)
(MutableMacroBlock s Int32
MVector (PrimState (ST s)) Int32
workData MVector (PrimState (ST s)) Int32 -> Int -> Int32 -> ST s ()
forall (m :: * -> *) a.
(PrimMonad m, Storable a) =>
MVector (PrimState m) a -> Int -> a -> m ()
`M.unsafeWrite` (Int
v Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
forall a. Num a => a
dctBlockSize Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
u)) (Int32 -> ST s ()) -> (Float -> Int32) -> Float -> ST s ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Float -> Int32
forall a b. (RealFrac a, Integral b) => a -> b
truncate (Float -> ST s ()) -> Float -> ST s ()
forall a b. (a -> b) -> a -> b
$ (Float
1 Float -> Float -> Float
forall a. Fractional a => a -> a -> a
/ Float
4) Float -> Float -> Float
forall a. Num a => a -> a -> a
* Int -> Float
forall a p. (Eq a, Num a, Floating p) => a -> p
c Int
u Float -> Float -> Float
forall a. Num a => a -> a -> a
* Int -> Float
forall a p. (Eq a, Num a, Floating p) => a -> p
c Int
v Float -> Float -> Float
forall a. Num a => a -> a -> a
* Float
val
MutableMacroBlock s Int32 -> ST s (MutableMacroBlock s Int32)
forall (m :: * -> *) a. Monad m => a -> m a
return MutableMacroBlock s Int32
workData
where
at :: (Int, Int) -> ST s Float
at (Int
u,Int
v) = do
[Float]
toSum <-
[(Int, Int)] -> ((Int, Int) -> ST s Float) -> ST s [Float]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [(Int
x,Int
y) | Int
x <- [Int
0..Int
forall a. Num a => a
dctBlockSize Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1], Int
y <- [Int
0..Int
forall a. Num a => a
dctBlockSize Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1 :: Int]] (((Int, Int) -> ST s Float) -> ST s [Float])
-> ((Int, Int) -> ST s Float) -> ST s [Float]
forall a b. (a -> b) -> a -> b
$ \(Int
x,Int
y) -> do
Float
sample <- Int16 -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int16 -> Float) -> ST s Int16 -> ST s Float
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (MutableMacroBlock s Int16
MVector (PrimState (ST s)) Int16
block MVector (PrimState (ST s)) Int16 -> Int -> ST s Int16
forall (m :: * -> *) a.
(PrimMonad m, Storable a) =>
MVector (PrimState m) a -> Int -> m a
`M.unsafeRead` (Int
y Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
forall a. Num a => a
dctBlockSize Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
x))
Float -> ST s Float
forall (m :: * -> *) a. Monad m => a -> m a
return (Float -> ST s Float) -> Float -> ST s Float
forall a b. (a -> b) -> a -> b
$ Float
sample Float -> Float -> Float
forall a. Num a => a -> a -> a
* Float -> Float
forall a. Floating a => a -> a
cos ((Float
2 Float -> Float -> Float
forall a. Num a => a -> a -> a
* Int -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
x Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
1) Float -> Float -> Float
forall a. Num a => a -> a -> a
* Int -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
u Float -> Float -> Float
forall a. Num a => a -> a -> a
* (Float
forall a. Floating a => a
pi :: Float)Float -> Float -> Float
forall a. Fractional a => a -> a -> a
/ Float
16)
Float -> Float -> Float
forall a. Num a => a -> a -> a
* Float -> Float
forall a. Floating a => a -> a
cos ((Float
2 Float -> Float -> Float
forall a. Num a => a -> a -> a
* Int -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
y Float -> Float -> Float
forall a. Num a => a -> a -> a
+ Float
1) Float -> Float -> Float
forall a. Num a => a -> a -> a
* Int -> Float
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
v Float -> Float -> Float
forall a. Num a => a -> a -> a
* Float
forall a. Floating a => a
pi Float -> Float -> Float
forall a. Fractional a => a -> a -> a
/ Float
16)
Float -> ST s Float
forall (m :: * -> *) a. Monad m => a -> m a
return (Float -> ST s Float) -> Float -> ST s Float
forall a b. (a -> b) -> a -> b
$ [Float] -> Float
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [Float]
toSum
c :: a -> p
c a
0 = p
1 p -> p -> p
forall a. Fractional a => a -> a -> a
/ p -> p
forall a. Floating a => a -> a
sqrt p
2
c a
_ = p
1
pASS1_BITS, cONST_BITS :: Int
cONST_BITS :: Int
cONST_BITS = Int
13
pASS1_BITS :: Int
pASS1_BITS = Int
2
fIX_0_298631336, fIX_0_390180644, fIX_0_541196100,
fIX_0_765366865, fIX_0_899976223, fIX_1_175875602,
fIX_1_501321110, fIX_1_847759065, fIX_1_961570560,
fIX_2_053119869, fIX_2_562915447, fIX_3_072711026 :: Int32
fIX_0_298631336 :: Int32
fIX_0_298631336 = Int32
2446
fIX_0_390180644 :: Int32
fIX_0_390180644 = Int32
3196
fIX_0_541196100 :: Int32
fIX_0_541196100 = Int32
4433
fIX_0_765366865 :: Int32
fIX_0_765366865 = Int32
6270
fIX_0_899976223 :: Int32
fIX_0_899976223 = Int32
7373
fIX_1_175875602 :: Int32
fIX_1_175875602 = Int32
9633
fIX_1_501321110 :: Int32
fIX_1_501321110 = Int32
12299
fIX_1_847759065 :: Int32
fIX_1_847759065 = Int32
15137
fIX_1_961570560 :: Int32
fIX_1_961570560 = Int32
16069
fIX_2_053119869 :: Int32
fIX_2_053119869 = Int32
16819
fIX_2_562915447 :: Int32
fIX_2_562915447 = Int32
20995
fIX_3_072711026 :: Int32
fIX_3_072711026 = Int32
25172
cENTERJSAMPLE :: Int32
cENTERJSAMPLE :: Int32
cENTERJSAMPLE = Int32
128
fastDctLibJpeg :: MutableMacroBlock s Int32
-> MutableMacroBlock s Int16
-> ST s (MutableMacroBlock s Int32)
fastDctLibJpeg :: MutableMacroBlock s Int32
-> MutableMacroBlock s Int16 -> ST s (MutableMacroBlock s Int32)
fastDctLibJpeg MutableMacroBlock s Int32
workData MutableMacroBlock s Int16
sample_block = do
MutableMacroBlock s Int32 -> Int -> ST s ()
firstPass MutableMacroBlock s Int32
workData Int
0
MutableMacroBlock s Int32 -> Int -> ST s ()
forall s. STVector s Int32 -> Int -> ST s ()
secondPass MutableMacroBlock s Int32
workData Int
7
MutableMacroBlock s Int32 -> ST s (MutableMacroBlock s Int32)
forall (m :: * -> *) a. Monad m => a -> m a
return MutableMacroBlock s Int32
workData
where
firstPass :: MutableMacroBlock s Int32 -> Int -> ST s ()
firstPass MutableMacroBlock s Int32
_ Int
i | Int
i Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
forall a. Num a => a
dctBlockSize = () -> ST s ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
firstPass MutableMacroBlock s Int32
dataBlock Int
i = do
let baseIdx :: Int
baseIdx = Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
forall a. Num a => a
dctBlockSize
readAt :: Int -> ST s Int32
readAt Int
idx = Int16 -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int16 -> Int32) -> ST s Int16 -> ST s Int32
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MutableMacroBlock s Int16
MVector (PrimState (ST s)) Int16
sample_block MVector (PrimState (ST s)) Int16 -> Int -> ST s Int16
forall (m :: * -> *) a.
(PrimMonad m, Storable a) =>
MVector (PrimState m) a -> Int -> m a
`M.unsafeRead` (Int
baseIdx Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
idx)
mult :: Int32 -> Int32 -> Int32
mult = Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
(*)
writeAt :: Int -> Int32 -> ST s ()
writeAt Int
idx = MutableMacroBlock s Int32
MVector (PrimState (ST s)) Int32
dataBlock MVector (PrimState (ST s)) Int32 -> Int -> Int32 -> ST s ()
forall (m :: * -> *) a.
(PrimMonad m, Storable a) =>
MVector (PrimState m) a -> Int -> a -> m ()
`M.unsafeWrite` (Int
baseIdx Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
idx)
writeAtPos :: Int -> Int32 -> ST s ()
writeAtPos Int
idx Int32
n = (MutableMacroBlock s Int32
MVector (PrimState (ST s)) Int32
dataBlock MVector (PrimState (ST s)) Int32 -> Int -> Int32 -> ST s ()
forall (m :: * -> *) a.
(PrimMonad m, Storable a) =>
MVector (PrimState m) a -> Int -> a -> m ()
`M.unsafeWrite` (Int
baseIdx Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
idx))
(Int32
n Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftR` (Int
cONST_BITS Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
pASS1_BITS))
Int32
blk0 <- Int -> ST s Int32
readAt Int
0
Int32
blk1 <- Int -> ST s Int32
readAt Int
1
Int32
blk2 <- Int -> ST s Int32
readAt Int
2
Int32
blk3 <- Int -> ST s Int32
readAt Int
3
Int32
blk4 <- Int -> ST s Int32
readAt Int
4
Int32
blk5 <- Int -> ST s Int32
readAt Int
5
Int32
blk6 <- Int -> ST s Int32
readAt Int
6
Int32
blk7 <- Int -> ST s Int32
readAt Int
7
let tmp0 :: Int32
tmp0 = Int32
blk0 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
blk7
tmp1 :: Int32
tmp1 = Int32
blk1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
blk6
tmp2 :: Int32
tmp2 = Int32
blk2 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
blk5
tmp3 :: Int32
tmp3 = Int32
blk3 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
blk4
tmp10 :: Int32
tmp10 = Int32
tmp0 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp3
tmp12 :: Int32
tmp12 = Int32
tmp0 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
tmp3
tmp11 :: Int32
tmp11 = Int32
tmp1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp2
tmp13 :: Int32
tmp13 = Int32
tmp1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
tmp2
tmp0' :: Int32
tmp0' = Int32
blk0 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
blk7
tmp1' :: Int32
tmp1' = Int32
blk1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
blk6
tmp2' :: Int32
tmp2' = Int32
blk2 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
blk5
tmp3' :: Int32
tmp3' = Int32
blk3 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
blk4
Int -> Int32 -> ST s ()
writeAt Int
0 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ (Int32
tmp10 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp11 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
forall a. Num a => a
dctBlockSize Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
cENTERJSAMPLE) Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
pASS1_BITS
Int -> Int32 -> ST s ()
writeAt Int
4 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ (Int32
tmp10 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
tmp11) Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftL` Int
pASS1_BITS
let z1 :: Int32
z1 = Int32 -> Int32 -> Int32
mult (Int32
tmp12 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp13) Int32
fIX_0_541196100
Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ (Int32
1 Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftL` (Int
cONST_BITS Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
pASS1_BITS Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1))
Int -> Int32 -> ST s ()
writeAtPos Int
2 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
z1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32 -> Int32 -> Int32
mult Int32
tmp12 Int32
fIX_0_765366865
Int -> Int32 -> ST s ()
writeAtPos Int
6 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
z1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32 -> Int32 -> Int32
mult Int32
tmp13 Int32
fIX_1_847759065
let tmp10' :: Int32
tmp10' = Int32
tmp0' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp3'
tmp11' :: Int32
tmp11' = Int32
tmp1' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp2'
tmp12' :: Int32
tmp12' = Int32
tmp0' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp2'
tmp13' :: Int32
tmp13' = Int32
tmp1' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp3'
z1' :: Int32
z1' = Int32 -> Int32 -> Int32
mult (Int32
tmp12' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp13') Int32
fIX_1_175875602
Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ (Int32
1 Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftL` (Int
cONST_BITS Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
pASS1_BITSInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1))
tmp0'' :: Int32
tmp0'' = Int32 -> Int32 -> Int32
mult Int32
tmp0' Int32
fIX_1_501321110
tmp1'' :: Int32
tmp1'' = Int32 -> Int32 -> Int32
mult Int32
tmp1' Int32
fIX_3_072711026
tmp2'' :: Int32
tmp2'' = Int32 -> Int32 -> Int32
mult Int32
tmp2' Int32
fIX_2_053119869
tmp3'' :: Int32
tmp3'' = Int32 -> Int32 -> Int32
mult Int32
tmp3' Int32
fIX_0_298631336
tmp10'' :: Int32
tmp10'' = Int32 -> Int32 -> Int32
mult Int32
tmp10' (- Int32
fIX_0_899976223)
tmp11'' :: Int32
tmp11'' = Int32 -> Int32 -> Int32
mult Int32
tmp11' (- Int32
fIX_2_562915447)
tmp12'' :: Int32
tmp12'' = Int32 -> Int32 -> Int32
mult Int32
tmp12' (- Int32
fIX_0_390180644) Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
z1'
tmp13'' :: Int32
tmp13'' = Int32 -> Int32 -> Int32
mult Int32
tmp13' (- Int32
fIX_1_961570560) Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
z1'
Int -> Int32 -> ST s ()
writeAtPos Int
1 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
tmp0'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp10'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp12''
Int -> Int32 -> ST s ()
writeAtPos Int
3 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
tmp1'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp11'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp13''
Int -> Int32 -> ST s ()
writeAtPos Int
5 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
tmp2'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp11'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp12''
Int -> Int32 -> ST s ()
writeAtPos Int
7 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
tmp3'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp10'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp13''
MutableMacroBlock s Int32 -> Int -> ST s ()
firstPass MutableMacroBlock s Int32
dataBlock (Int -> ST s ()) -> Int -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1
secondPass :: M.STVector s Int32 -> Int -> ST s ()
secondPass :: STVector s Int32 -> Int -> ST s ()
secondPass STVector s Int32
_ (-1) = () -> ST s ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
secondPass STVector s Int32
block Int
i = do
let readAt :: Int -> ST s Int32
readAt Int
idx = STVector s Int32
MVector (PrimState (ST s)) Int32
block MVector (PrimState (ST s)) Int32 -> Int -> ST s Int32
forall (m :: * -> *) a.
(PrimMonad m, Storable a) =>
MVector (PrimState m) a -> Int -> m a
`M.unsafeRead` ((Int
7 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
i) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
idx Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
forall a. Num a => a
dctBlockSize)
mult :: Int32 -> Int32 -> Int32
mult = Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
(*)
writeAt :: Int -> Int32 -> ST s ()
writeAt Int
idx = STVector s Int32
MVector (PrimState (ST s)) Int32
block MVector (PrimState (ST s)) Int32 -> Int -> Int32 -> ST s ()
forall (m :: * -> *) a.
(PrimMonad m, Storable a) =>
MVector (PrimState m) a -> Int -> a -> m ()
`M.unsafeWrite` (Int
forall a. Num a => a
dctBlockSize Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
idx Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (Int
7 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
i))
writeAtPos :: Int -> Int32 -> ST s ()
writeAtPos Int
idx Int32
n = (STVector s Int32
MVector (PrimState (ST s)) Int32
block MVector (PrimState (ST s)) Int32 -> Int -> Int32 -> ST s ()
forall (m :: * -> *) a.
(PrimMonad m, Storable a) =>
MVector (PrimState m) a -> Int -> a -> m ()
`M.unsafeWrite` (Int
forall a. Num a => a
dctBlockSize Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
idx Int -> Int -> Int
forall a. Num a => a -> a -> a
+ (Int
7 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
i))) (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
n Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftR` (Int
cONST_BITS Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
pASS1_BITS Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3)
Int32
blk0 <- Int -> ST s Int32
readAt Int
0
Int32
blk1 <- Int -> ST s Int32
readAt Int
1
Int32
blk2 <- Int -> ST s Int32
readAt Int
2
Int32
blk3 <- Int -> ST s Int32
readAt Int
3
Int32
blk4 <- Int -> ST s Int32
readAt Int
4
Int32
blk5 <- Int -> ST s Int32
readAt Int
5
Int32
blk6 <- Int -> ST s Int32
readAt Int
6
Int32
blk7 <- Int -> ST s Int32
readAt Int
7
let tmp0 :: Int32
tmp0 = Int32
blk0 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
blk7
tmp1 :: Int32
tmp1 = Int32
blk1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
blk6
tmp2 :: Int32
tmp2 = Int32
blk2 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
blk5
tmp3 :: Int32
tmp3 = Int32
blk3 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
blk4
tmp10 :: Int32
tmp10 = Int32
tmp0 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp3 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ (Int32
1 Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftL` (Int
pASS1_BITSInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1))
tmp12 :: Int32
tmp12 = Int32
tmp0 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
tmp3
tmp11 :: Int32
tmp11 = Int32
tmp1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp2
tmp13 :: Int32
tmp13 = Int32
tmp1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
tmp2
tmp0' :: Int32
tmp0' = Int32
blk0 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
blk7
tmp1' :: Int32
tmp1' = Int32
blk1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
blk6
tmp2' :: Int32
tmp2' = Int32
blk2 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
blk5
tmp3' :: Int32
tmp3' = Int32
blk3 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
blk4
Int -> Int32 -> ST s ()
writeAt Int
0 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ (Int32
tmp10 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp11) Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftR` (Int
pASS1_BITS Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3)
Int -> Int32 -> ST s ()
writeAt Int
4 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ (Int32
tmp10 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32
tmp11) Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftR` (Int
pASS1_BITS Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
3)
let z1 :: Int32
z1 = Int32 -> Int32 -> Int32
mult (Int32
tmp12 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp13) Int32
fIX_0_541196100
Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ (Int32
1 Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftL` (Int
cONST_BITS Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
pASS1_BITS Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1))
Int -> Int32 -> ST s ()
writeAtPos Int
2 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
z1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32 -> Int32 -> Int32
mult Int32
tmp12 Int32
fIX_0_765366865
Int -> Int32 -> ST s ()
writeAtPos Int
6 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
z1 Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
- Int32 -> Int32 -> Int32
mult Int32
tmp13 Int32
fIX_1_847759065
let tmp10' :: Int32
tmp10' = Int32
tmp0' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp3'
tmp11' :: Int32
tmp11' = Int32
tmp1' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp2'
tmp12' :: Int32
tmp12' = Int32
tmp0' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp2'
tmp13' :: Int32
tmp13' = Int32
tmp1' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp3'
z1' :: Int32
z1' = Int32 -> Int32 -> Int32
mult (Int32
tmp12' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp13') Int32
fIX_1_175875602
Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
1 Int32 -> Int -> Int32
forall a. Bits a => a -> Int -> a
`unsafeShiftL` (Int
cONST_BITSInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
pASS1_BITSInt -> Int -> Int
forall a. Num a => a -> a -> a
-Int
1);
tmp0'' :: Int32
tmp0'' = Int32 -> Int32 -> Int32
mult Int32
tmp0' Int32
fIX_1_501321110
tmp1'' :: Int32
tmp1'' = Int32 -> Int32 -> Int32
mult Int32
tmp1' Int32
fIX_3_072711026
tmp2'' :: Int32
tmp2'' = Int32 -> Int32 -> Int32
mult Int32
tmp2' Int32
fIX_2_053119869
tmp3'' :: Int32
tmp3'' = Int32 -> Int32 -> Int32
mult Int32
tmp3' Int32
fIX_0_298631336
tmp10'' :: Int32
tmp10'' = Int32 -> Int32 -> Int32
mult Int32
tmp10' (- Int32
fIX_0_899976223)
tmp11'' :: Int32
tmp11'' = Int32 -> Int32 -> Int32
mult Int32
tmp11' (- Int32
fIX_2_562915447)
tmp12'' :: Int32
tmp12'' = Int32 -> Int32 -> Int32
mult Int32
tmp12' (- Int32
fIX_0_390180644)
Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
z1'
tmp13'' :: Int32
tmp13'' = Int32 -> Int32 -> Int32
mult Int32
tmp13' (- Int32
fIX_1_961570560)
Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
z1'
Int -> Int32 -> ST s ()
writeAtPos Int
1 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
tmp0'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp10'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp12''
Int -> Int32 -> ST s ()
writeAtPos Int
3 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
tmp1'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp11'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp13''
Int -> Int32 -> ST s ()
writeAtPos Int
5 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
tmp2'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp11'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp12''
Int -> Int32 -> ST s ()
writeAtPos Int
7 (Int32 -> ST s ()) -> Int32 -> ST s ()
forall a b. (a -> b) -> a -> b
$ Int32
tmp3'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp10'' Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
+ Int32
tmp13''
STVector s Int32 -> Int -> ST s ()
forall s. STVector s Int32 -> Int -> ST s ()
secondPass STVector s Int32
block (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)
{-# ANN module "HLint: ignore Use camelCase" #-}
{-# ANN module "HLint: ignore Reduce duplication" #-}