| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 The Android Open Source Project | 2 * Copyright 2010 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "SkJpegUtility.h" | 9 #include "SkJpegUtility.h" |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 bytesToSkip -= bytes; | 83 bytesToSkip -= bytes; |
| 84 } | 84 } |
| 85 src->next_input_byte = (const JOCTET*)src->fBuffer; | 85 src->next_input_byte = (const JOCTET*)src->fBuffer; |
| 86 src->bytes_in_buffer = 0; | 86 src->bytes_in_buffer = 0; |
| 87 } else { | 87 } else { |
| 88 src->next_input_byte += num_bytes; | 88 src->next_input_byte += num_bytes; |
| 89 src->bytes_in_buffer -= num_bytes; | 89 src->bytes_in_buffer -= num_bytes; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 static boolean sk_resync_to_restart(j_decompress_ptr cinfo, int desired) { | |
| 94 skjpeg_source_mgr* src = (skjpeg_source_mgr*)cinfo->src; | |
| 95 | |
| 96 // what is the desired param for??? | |
| 97 | |
| 98 if (!src->fStream->rewind()) { | |
| 99 SkDebugf("xxxxxxxxxxxxxx failure to rewind\n"); | |
| 100 cinfo->err->error_exit((j_common_ptr)cinfo); | |
| 101 return FALSE; | |
| 102 } | |
| 103 src->next_input_byte = (const JOCTET*)src->fBuffer; | |
| 104 src->bytes_in_buffer = 0; | |
| 105 return TRUE; | |
| 106 } | |
| 107 | |
| 108 static void sk_term_source(j_decompress_ptr /*cinfo*/) {} | 93 static void sk_term_source(j_decompress_ptr /*cinfo*/) {} |
| 109 | 94 |
| 110 | 95 |
| 111 /////////////////////////////////////////////////////////////////////////////// | 96 /////////////////////////////////////////////////////////////////////////////// |
| 112 | 97 |
| 113 skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder) | 98 skjpeg_source_mgr::skjpeg_source_mgr(SkStream* stream, SkImageDecoder* decoder) |
| 114 : fStream(SkRef(stream)) | 99 : fStream(SkRef(stream)) |
| 115 , fDecoder(decoder) { | 100 , fDecoder(decoder) { |
| 116 | 101 |
| 117 init_source = sk_init_source; | 102 init_source = sk_init_source; |
| 118 fill_input_buffer = sk_fill_input_buffer; | 103 fill_input_buffer = sk_fill_input_buffer; |
| 119 skip_input_data = sk_skip_input_data; | 104 skip_input_data = sk_skip_input_data; |
| 120 resync_to_restart = sk_resync_to_restart; | 105 resync_to_restart = jpeg_resync_to_restart; |
| 121 term_source = sk_term_source; | 106 term_source = sk_term_source; |
| 122 #ifdef SK_BUILD_FOR_ANDROID | 107 #ifdef SK_BUILD_FOR_ANDROID |
| 123 seek_input_data = sk_seek_input_data; | 108 seek_input_data = sk_seek_input_data; |
| 124 #endif | 109 #endif |
| 125 // SkDebugf("**************** use memorybase %p %d\n", fMemoryBase, fMemoryBa
seSize); | 110 // SkDebugf("**************** use memorybase %p %d\n", fMemoryBase, fMemoryBa
seSize); |
| 126 } | 111 } |
| 127 | 112 |
| 128 skjpeg_source_mgr::~skjpeg_source_mgr() { | 113 skjpeg_source_mgr::~skjpeg_source_mgr() { |
| 129 SkSafeUnref(fStream); | 114 SkSafeUnref(fStream); |
| 130 } | 115 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 void skjpeg_error_exit(j_common_ptr cinfo) { | 161 void skjpeg_error_exit(j_common_ptr cinfo) { |
| 177 skjpeg_error_mgr* error = (skjpeg_error_mgr*)cinfo->err; | 162 skjpeg_error_mgr* error = (skjpeg_error_mgr*)cinfo->err; |
| 178 | 163 |
| 179 (*error->output_message) (cinfo); | 164 (*error->output_message) (cinfo); |
| 180 | 165 |
| 181 /* Let the memory manager delete any temp files before we die */ | 166 /* Let the memory manager delete any temp files before we die */ |
| 182 jpeg_destroy(cinfo); | 167 jpeg_destroy(cinfo); |
| 183 | 168 |
| 184 longjmp(error->fJmpBuf, -1); | 169 longjmp(error->fJmpBuf, -1); |
| 185 } | 170 } |
| OLD | NEW |