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 <cstdint> 13 14 extern "C" { 15 // We need to include stdio.h before jpeg because jpeg does not include it, but uses FILE 16 // See https://github.com/libjpeg-turbo/libjpeg-turbo/issues/17 17 #include <stdio.h> // IWYU pragma: keep 18 #include "jpeglib.h" // NO_G3_REWRITE 19 } 20 21 class SkStream; 22 23 /* 24 * Error handling function 25 */ 26 void skjpeg_err_exit(j_common_ptr cinfo); 27 28 /* 29 * Source handling struct for that allows libjpeg to use our stream object 30 */ 31 struct skjpeg_source_mgr : jpeg_source_mgr { 32 skjpeg_source_mgr(SkStream* stream); 33 34 SkStream* fStream; // unowned 35 enum { 36 // TODO (msarett): Experiment with different buffer sizes. 37 // This size was chosen because it matches SkImageDecoder. 38 kBufferSize = 1024 39 }; 40 uint8_t fBuffer[kBufferSize]; 41 }; 42 43 #endif 44