Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A good explanation of the JPEG format, including diagrams, is given at: https://github.com/corkami/formats/blob/master/image/jpeg.md
The full spec (excluding EXIF): https://www.w3.org/Graphics/JPEG/itu-t81.pdf
Synopsis
- type MutableMacroBlock s a = STVector s a
- createEmptyMutableMacroBlock :: (Storable a, Num a) => ST s (MutableMacroBlock s a)
- printMacroBlock :: (Storable a, PrintfArg a) => MutableMacroBlock s a -> ST s String
- printPureMacroBlock :: (Storable a, PrintfArg a) => MacroBlock a -> String
- type DcCoefficient = Int16
- data JpgImage = JpgImage {}
- data JpgComponent = JpgComponent {}
- data JpgFrameHeader = JpgFrameHeader {}
- data JpgFrame
- = JpgAppFrame !Word8 ByteString
- | JpgAdobeAPP14 !JpgAdobeApp14
- | JpgJFIF !JpgJFIFApp0
- | JpgExif ![ImageFileDirectory]
- | JpgExtension !Word8 ByteString
- | JpgQuantTable ![JpgQuantTableSpec]
- | JpgHuffmanTable ![(JpgHuffmanTableSpec, HuffmanPackedTree)]
- | JpgScanBlob !JpgScanHeader !ByteString
- | JpgScans !JpgFrameKind !JpgFrameHeader
- | JpgIntervalRestart !Word16
- data JpgFrameKind
- = JpgBaselineDCTHuffman
- | JpgExtendedSequentialDCTHuffman
- | JpgProgressiveDCTHuffman
- | JpgLosslessHuffman
- | JpgDifferentialSequentialDCTHuffman
- | JpgDifferentialProgressiveDCTHuffman
- | JpgDifferentialLosslessHuffman
- | JpgExtendedSequentialArithmetic
- | JpgProgressiveDCTArithmetic
- | JpgLosslessArithmetic
- | JpgDifferentialSequentialDCTArithmetic
- | JpgDifferentialProgressiveDCTArithmetic
- | JpgDifferentialLosslessArithmetic
- | JpgQuantizationTable
- | JpgHuffmanTableMarker
- | JpgStartOfScan
- | JpgEndOfImage
- | JpgAppSegment Word8
- | JpgExtensionSegment Word8
- | JpgRestartInterval
- | JpgRestartIntervalEnd Word8
- data JpgScanHeader = JpgScanHeader {}
- data JpgQuantTableSpec = JpgQuantTableSpec {}
- data JpgHuffmanTableSpec = JpgHuffmanTableSpec {
- huffmanTableClass :: !DctComponent
- huffmanTableDest :: !Word8
- huffSizes :: !(Vector Word8)
- huffCodes :: !(Vector (Vector Word8))
- data JpgImageKind
- data JpgScanSpecification = JpgScanSpecification {}
- data JpgColorSpace
- data AdobeTransform
- data JpgAdobeApp14 = JpgAdobeApp14 {}
- data JpgJFIFApp0 = JpgJFIFApp0 {}
- data JFifUnit
- newtype TableList a = TableList [a]
- newtype RestartInterval = RestartInterval Word16
- getJpgImage :: Get JpgImage
- calculateSize :: SizeCalculable a => a -> Int
- dctBlockSize :: Num a => a
- parseECS :: Get ByteString
- parseECS_simple :: Get ByteString
- skipUntilFrames :: Get ()
- skipFrameMarker :: Get ()
- parseFrameOfKind :: JpgFrameKind -> Get (Maybe JpgFrame)
- parseFrames :: Get [JpgFrame]
- parseFrameKinds :: Get [(JpgFrameKind, Int64, Int64)]
- parseToFirstFrameHeader :: Get (Maybe JpgFrameHeader)
Documentation
type MutableMacroBlock s a = STVector s a Source #
Macroblock that can be transformed.
createEmptyMutableMacroBlock :: (Storable a, Num a) => ST s (MutableMacroBlock s a) Source #
Create a new macroblock with the good array size
printMacroBlock :: (Storable a, PrintfArg a) => MutableMacroBlock s a -> ST s String Source #
printPureMacroBlock :: (Storable a, PrintfArg a) => MacroBlock a -> String Source #
type DcCoefficient = Int16 Source #
Type only used to make clear what kind of integer we are carrying Might be transformed into newtype in the future
data JpgComponent Source #
JpgComponent | |
|
Instances
data JpgFrameHeader Source #
JpgFrameHeader | |
|
Instances
JpgAppFrame !Word8 ByteString | |
JpgAdobeAPP14 !JpgAdobeApp14 | |
JpgJFIF !JpgJFIFApp0 | |
JpgExif ![ImageFileDirectory] | |
JpgExtension !Word8 ByteString | |
JpgQuantTable ![JpgQuantTableSpec] | |
JpgHuffmanTable ![(JpgHuffmanTableSpec, HuffmanPackedTree)] | |
JpgScanBlob !JpgScanHeader !ByteString | The |
JpgScans !JpgFrameKind !JpgFrameHeader | |
JpgIntervalRestart !Word16 |
Instances
data JpgFrameKind Source #
Instances
data JpgScanHeader Source #
JpgScanHeader | |
|
Instances
data JpgQuantTableSpec Source #
JpgQuantTableSpec | |
|
Instances
data JpgHuffmanTableSpec Source #
JpgHuffmanTableSpec | |
|
Instances
data JpgScanSpecification Source #
JpgScanSpecification | |
|
Instances
data JpgColorSpace Source #
JpgColorSpaceYCbCr | |
JpgColorSpaceYCC | |
JpgColorSpaceY | |
JpgColorSpaceYA | |
JpgColorSpaceYCCA | |
JpgColorSpaceYCCK | |
JpgColorSpaceCMYK | |
JpgColorSpaceRGB | |
JpgColorSpaceRGBA |
Instances
data AdobeTransform Source #
AdobeUnknown | Value 0 |
AdobeYCbCr | value 1 |
AdobeYCck | value 2 |
Instances
data JpgAdobeApp14 Source #
JpgAdobeApp14 | |
|
Instances
data JpgJFIFApp0 Source #
Instances
Size: 1
Instances
Generic JFifUnit Source # | |
Show JFifUnit Source # | |
Binary JFifUnit Source # | |
NFData JFifUnit Source # | |
Defined in Codec.Picture.Jpg.Internal.Types | |
Eq JFifUnit Source # | |
type Rep JFifUnit Source # | |
Defined in Codec.Picture.Jpg.Internal.Types type Rep JFifUnit = D1 ('MetaData "JFifUnit" "Codec.Picture.Jpg.Internal.Types" "JuicyPixels-3.3.9-8TrKyMTj3IQ4xY3eA8GFM4" 'False) (C1 ('MetaCons "JFifUnitUnknown" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "JFifPixelsPerInch" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "JFifPixelsPerCentimeter" 'PrefixI 'False) (U1 :: Type -> Type))) |
Type introduced only to avoid some typeclass overlapping problem
TableList [a] |
newtype RestartInterval Source #
Instances
Binary RestartInterval Source # | |
Defined in Codec.Picture.Jpg.Internal.Types |
getJpgImage :: Get JpgImage Source #
Like get
from `instance Binary JpgImage`, but without the legacy
semi-lazy implementation.
calculateSize :: SizeCalculable a => a -> Int Source #
dctBlockSize :: Num a => a Source #
parseECS :: Get ByteString Source #
Parses a Scan's ECS (Entropy-Coded Segment, the largest part of compressed image data)
from the Get
stream.
When this function is called, the parser's offset should be immediately behind the SOS tag.
As described on e.g. https://www.ccoderun.ca/programming/2017-01-31_jpeg/,
To find the next segment after the SOS, you must keep reading until you find a 0xFF bytes which is not immediately followed by 0x00 (see "byte stuffing") [or a reset marker's byte: 0xD0 through 0xD7]. Normally, this will be the EOI segment that comes at the end of the file.
where the 0xFF is the next segment's marker. See https://github.com/corkami/formats/blob/master/image/jpeg.md#entropy-coded-segment for more details.
This function returns the ECS, not including the next segment's marker on its trailing end.
parseECS_simple :: Get ByteString Source #
Simpler implementation of parseECS
to allow an easier understanding
of the logic, and to provide a comparison for correctness.
skipUntilFrames :: Get () Source #
skipFrameMarker :: Get () Source #
parseFrameOfKind :: JpgFrameKind -> Get (Maybe JpgFrame) Source #
Parses a single frame.
Returns Nothing
when we encounter a frame we want to skip.
parseFrameKinds :: Get [(JpgFrameKind, Int64, Int64)] Source #
Parse a list of JpgFrameKind
s with their corresponding offsets and lengths
(not counting the segment and frame markers into the lengths).
Useful for debugging.
parseToFirstFrameHeader :: Get (Maybe JpgFrameHeader) Source #
Parses forward, returning the first scan header encountered.
Should be used after skipUntilFrames
.
Fails parsing when an SOS segment marker (JpgStartOfScan
, resulting
in JpgScanBlob
) is encountered before an SOF segment marker (that
results in JpgScans
carrying the JpgFrameHeader
).