Bumping manifests a=b2g-bump
[gecko.git] / image / decoders / nsJPEGDecoder.h
blob1f5b2e519aa654cb1afc466865d50c22500692b1
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'. */
14 #undef INT32
16 #include "Decoder.h"
18 #include "nsAutoPtr.h"
20 #include "nsIInputStream.h"
21 #include "nsIPipe.h"
22 #include "qcms.h"
24 extern "C" {
25 #include "jpeglib.h"
28 #include <setjmp.h>
30 namespace mozilla {
31 namespace image {
33 typedef struct {
34 struct jpeg_error_mgr pub; /* "public" fields for IJG library*/
35 jmp_buf setjmp_buffer; /* For handling catastropic errors */
36 } decoder_error_mgr;
38 typedef enum {
39 JPEG_HEADER, /* Reading JFIF headers */
40 JPEG_START_DECOMPRESS,
41 JPEG_DECOMPRESS_PROGRESSIVE, /* Output progressive pixels */
42 JPEG_DECOMPRESS_SEQUENTIAL, /* Output sequential pixels */
43 JPEG_DONE,
44 JPEG_SINK_NON_JPEG_TRAILER, /* Some image files have a */
45 /* non-JPEG trailer */
46 JPEG_ERROR
47 } jstate;
49 class RasterImage;
50 struct Orientation;
52 class nsJPEGDecoder : public Decoder
54 public:
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();
63 void NotifyDone();
65 protected:
66 Orientation ReadOrientationFromEXIF();
67 void OutputScanlines(bool* suspend);
69 public:
70 struct jpeg_decompress_struct mInfo;
71 struct jpeg_source_mgr mSourceMgr;
72 decoder_error_mgr mErr;
73 jstate mState;
75 uint32_t mBytesToSkip;
77 const JOCTET *mSegment; // The current segment we are decoding from
78 uint32_t mSegmentLen; // amount of data in mSegment
80 JOCTET *mBackBuffer;
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
85 JOCTET *mProfile;
86 uint32_t mProfileLength;
88 qcms_profile *mInProfile;
89 qcms_transform *mTransform;
91 bool mReading;
93 const Decoder::DecodeStyle mDecodeStyle;
95 uint32_t mCMSMode;
98 } // namespace image
99 } // namespace mozilla
101 #endif // nsJPEGDecoder_h__