blob: 4b3f1ab23b19f4a4944a552147f96797e0f3e02f [file] [log] [blame]
msarette16b04a2015-04-15 07:32:19 -07001/*
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
mtklein525e90a2015-06-18 09:58:57 -07009#ifndef SkJpegUtility_codec_DEFINED
10#define SkJpegUtility_codec_DEFINED
msarette16b04a2015-04-15 07:32:19 -070011
12#include "SkStream.h"
13
14#include <setjmp.h>
15// stdio is needed for jpeglib
16#include <stdio.h>
17
18extern "C" {
msarette9e3ee32015-07-01 12:36:18 -070019 #include "jpeglibmangler.h"
msarette16b04a2015-04-15 07:32:19 -070020 #include "jpeglib.h"
21 #include "jerror.h"
22}
23
24/*
25 * Error handling struct
26 */
27struct skjpeg_error_mgr : jpeg_error_mgr {
28 jmp_buf fJmpBuf;
29};
30
31/*
32 * Error handling function
33 */
34void skjpeg_err_exit(j_common_ptr cinfo);
35
36/*
37 * Source handling struct for that allows libjpeg to use our stream object
38 */
39struct skjpeg_source_mgr : jpeg_source_mgr {
40 skjpeg_source_mgr(SkStream* stream);
41
42 SkStream* fStream; // unowned
43 enum {
44 // TODO (msarett): Experiment with different buffer sizes.
45 // This size was chosen because it matches SkImageDecoder.
46 kBufferSize = 1024
47 };
48 uint8_t fBuffer[kBufferSize];
49};
50
51#endif