1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsJPEGDecoder_h__
8 #define nsJPEGDecoder_h__
10 #include "RasterImage.h"
11 /* On Windows systems, RasterImage.h brings in 'windows.h', which defines INT32.
12 * But the jpeg decoder has its own definition of INT32. To avoid build issues,
13 * we need to undefine the version from 'windows.h'. */
18 #include "nsAutoPtr.h"
20 #include "nsIInputStream.h"
34 struct jpeg_error_mgr pub
; /* "public" fields for IJG library*/
35 jmp_buf setjmp_buffer
; /* For handling catastropic errors */
39 JPEG_HEADER
, /* Reading JFIF headers */
40 JPEG_START_DECOMPRESS
,
41 JPEG_DECOMPRESS_PROGRESSIVE
, /* Output progressive pixels */
42 JPEG_DECOMPRESS_SEQUENTIAL
, /* Output sequential pixels */
44 JPEG_SINK_NON_JPEG_TRAILER
, /* Some image files have a */
45 /* non-JPEG trailer */
52 class nsJPEGDecoder
: public Decoder
55 nsJPEGDecoder(RasterImage
&aImage
, Decoder::DecodeStyle aDecodeStyle
);
56 virtual ~nsJPEGDecoder();
58 virtual void InitInternal();
59 virtual void WriteInternal(const char* aBuffer
, uint32_t aCount
, DecodeStrategy aStrategy
);
60 virtual void FinishInternal();
62 virtual Telemetry::ID
SpeedHistogram();
66 Orientation
ReadOrientationFromEXIF();
67 void OutputScanlines(bool* suspend
);
70 struct jpeg_decompress_struct mInfo
;
71 struct jpeg_source_mgr mSourceMgr
;
72 decoder_error_mgr mErr
;
75 uint32_t mBytesToSkip
;
77 const JOCTET
*mSegment
; // The current segment we are decoding from
78 uint32_t mSegmentLen
; // amount of data in mSegment
81 uint32_t mBackBufferLen
; // Offset of end of active backtrack data
82 uint32_t mBackBufferSize
; // size in bytes what mBackBuffer was created with
83 uint32_t mBackBufferUnreadLen
; // amount of data currently in mBackBuffer
86 uint32_t mProfileLength
;
88 qcms_profile
*mInProfile
;
89 qcms_transform
*mTransform
;
93 const Decoder::DecodeStyle mDecodeStyle
;
99 } // namespace mozilla
101 #endif // nsJPEGDecoder_h__