blob: 33f4fbda8bc6761c51f2847b0c5b3845b3a7c651 [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
Matt Sarett4ef01482017-03-22 12:53:27 -040012#include "SkJpegPriv.h"
msarette16b04a2015-04-15 07:32:19 -070013#include "SkStream.h"
14
15#include <setjmp.h>
16// stdio is needed for jpeglib
17#include <stdio.h>
18
19extern "C" {
msarette16b04a2015-04-15 07:32:19 -070020 #include "jpeglib.h"
21 #include "jerror.h"
22}
23
msarette16b04a2015-04-15 07:32:19 -070024/*
msarette16b04a2015-04-15 07:32:19 -070025 * 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