OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
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 #include "SkCodec.h" | 8 #include "SkCodec.h" |
9 #include "SkJpegCodec.h" | 9 #include "SkJpegCodec.h" |
10 #include "SkJpegDecoderMgr.h" | 10 #include "SkJpegDecoderMgr.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 SkJpegCodec::SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream, | 77 SkJpegCodec::SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream, |
78 JpegDecoderMgr* decoderMgr) | 78 JpegDecoderMgr* decoderMgr) |
79 : INHERITED(srcInfo, stream) | 79 : INHERITED(srcInfo, stream) |
80 , fDecoderMgr(decoderMgr) | 80 , fDecoderMgr(decoderMgr) |
81 , fReadyState(decoderMgr->dinfo()->global_state) | 81 , fReadyState(decoderMgr->dinfo()->global_state) |
82 {} | 82 {} |
83 | 83 |
84 /* | 84 /* |
85 * Return the row bytes of a particular image type and width | 85 * Return the row bytes of a particular image type and width |
86 */ | 86 */ |
87 static int get_row_bytes(const j_decompress_ptr dinfo) { | 87 static size_t get_row_bytes(const j_decompress_ptr dinfo) { |
88 int colorBytes = (dinfo->out_color_space == JCS_RGB565) ? 2 : dinfo->out_col
or_components; | 88 size_t colorBytes = (dinfo->out_color_space == JCS_RGB565) ? 2 : dinfo->out_
color_components; |
89 return dinfo->output_width * colorBytes; | 89 return dinfo->output_width * colorBytes; |
90 | 90 |
91 } | 91 } |
92 | 92 |
93 /* | 93 /* |
94 * Calculate output dimensions based on the provided factors. | 94 * Calculate output dimensions based on the provided factors. |
95 * | 95 * |
96 * Not to be used on the actual jpeg_decompress_struct used for decoding, since
it will | 96 * Not to be used on the actual jpeg_decompress_struct used for decoding, since
it will |
97 * incorrectly modify num_components. | 97 * incorrectly modify num_components. |
98 */ | 98 */ |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 | 641 |
642 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); | 642 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); |
643 if (linesRead < remainingRows) { | 643 if (linesRead < remainingRows) { |
644 // FIXME: Handle incomplete YUV decodes without signalling an error. | 644 // FIXME: Handle incomplete YUV decodes without signalling an error. |
645 return kInvalidInput; | 645 return kInvalidInput; |
646 } | 646 } |
647 } | 647 } |
648 | 648 |
649 return kSuccess; | 649 return kSuccess; |
650 } | 650 } |
OLD | NEW |