Created
January 7, 2017 13:40
-
-
Save toshi0383/1531f5cec6de9f06e1bfa685fbc2b45b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-| | |
- MP4 Header (UInt8 Array) Parsing | |
-} | |
import Data.Char (chr) | |
toInt32 :: [Int] -> Int | |
toInt32 (a:b:c:d:[]) = (a*256*256*256) + (b*256*256) + (c*256) + d | |
toInt32 x = error "Unexpected parameter" | |
toString32 :: [Int] -> String | |
toString32 (a:b:c:d:[]) = map chr [a,b,c,d] | |
toString32 x = error "Unexpected parameter" | |
main = do | |
print $ "size:" ++ (show $ toInt32 sizeBytes) ++ ", type:" ++ map chr typeBytes | |
where | |
bufferBytes = [0,6,135,152,102,114,101,101] | |
sizeBytes = take 4 bufferBytes | |
typeBytes = (take 4 . drop 4) bufferBytes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment