msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 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 | |
mtklein | 525e90a | 2015-06-18 09:58:57 -0700 | [diff] [blame] | 9 | #ifndef SkJpegUtility_codec_DEFINED |
| 10 | #define SkJpegUtility_codec_DEFINED |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 11 | |
Matt Sarett | 5df93de | 2017-03-22 21:52:47 +0000 | [diff] [blame] | 12 | #include "SkJpegPriv.h" |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 13 | #include "SkStream.h" |
| 14 | |
| 15 | #include <setjmp.h> |
| 16 | // stdio is needed for jpeglib |
| 17 | #include <stdio.h> |
| 18 | |
| 19 | extern "C" { |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 20 | #include "jpeglib.h" |
| 21 | #include "jerror.h" |
| 22 | } |
| 23 | |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 24 | /* |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 25 | * Error handling function |
| 26 | */ |
| 27 | void skjpeg_err_exit(j_common_ptr cinfo); |
| 28 | |
| 29 | /* |
| 30 | * Source handling struct for that allows libjpeg to use our stream object |
| 31 | */ |
Matt Sarett | 15f4d02 | 2017-06-06 17:58:33 +0000 | [diff] [blame] | 32 | struct skjpeg_source_mgr : jpeg_source_mgr { |
| 33 | skjpeg_source_mgr(SkStream* stream); |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 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 | |
msarett | e16b04a | 2015-04-15 07:32:19 -0700 | [diff] [blame] | 44 | #endif |