1/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8
9#ifndef SkJpegUtility_codec_DEFINED
10#define SkJpegUtility_codec_DEFINED
11
12#include "include/core/SkStream.h"
13#include "src/codec/SkJpegPriv.h"
14
15#include <setjmp.h>
16// stdio is needed for jpeglib
17#include <stdio.h>
18
19extern "C" {
20 #include "jpeglib.h"
21 #include "jerror.h"
22}
23
24/*
25 * Error handling function
26 */
27void skjpeg_err_exit(j_common_ptr cinfo);
28
29/*
30 * Source handling struct for that allows libjpeg to use our stream object
31 */
32struct skjpeg_source_mgr : jpeg_source_mgr {
33 skjpeg_source_mgr(SkStream* stream);
34
35 SkStream* fStream; // unowned
36 enum {
37 // TODO (msarett): Experiment with different buffer sizes.
38 // This size was chosen because it matches SkImageDecoder.
39 kBufferSize = 1024
40 };
41 uint8_t fBuffer[kBufferSize];
42};
43
44#endif
45