Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: src/codec/SkJpegCodec.cpp

Issue 1820073002: Add SkEncodedInfo to report properties of encoded image data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Order of param eval bug Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/codec/SkJpegCodec.h ('k') | src/codec/SkJpegDecoderMgr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkMSAN.h" 9 #include "SkMSAN.h"
10 #include "SkJpegCodec.h" 10 #include "SkJpegCodec.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 jpeg_save_markers(decoderMgr->dinfo(), kExifMarker, 0xFFFF); 204 jpeg_save_markers(decoderMgr->dinfo(), kExifMarker, 0xFFFF);
205 jpeg_save_markers(decoderMgr->dinfo(), kICCMarker, 0xFFFF); 205 jpeg_save_markers(decoderMgr->dinfo(), kICCMarker, 0xFFFF);
206 } 206 }
207 207
208 // Read the jpeg header 208 // Read the jpeg header
209 if (JPEG_HEADER_OK != jpeg_read_header(decoderMgr->dinfo(), true)) { 209 if (JPEG_HEADER_OK != jpeg_read_header(decoderMgr->dinfo(), true)) {
210 return decoderMgr->returnFalse("read_header"); 210 return decoderMgr->returnFalse("read_header");
211 } 211 }
212 212
213 if (codecOut) { 213 if (codecOut) {
214 // Recommend the color type to decode to 214 // Get the encoded color type
215 const SkColorType colorType = decoderMgr->getColorType(); 215 SkEncodedInfo::Color color = decoderMgr->getEncodedColor();
216 if (SkEncodedInfo::kUnknown_Color == color) {
217 return false;
218 }
216 219
217 // Create image info object and the codec 220 // Create image info object and the codec
218 const SkImageInfo& imageInfo = SkImageInfo::Make(decoderMgr->dinfo()->im age_width, 221 SkEncodedInfo info = SkEncodedInfo::Make(color, SkEncodedInfo::kOpaque_A lpha, 8);
219 decoderMgr->dinfo()->image_height, colorType, kOpaque_SkAlphaTyp e);
220 222
221 Origin orientation = get_exif_orientation(decoderMgr->dinfo()); 223 Origin orientation = get_exif_orientation(decoderMgr->dinfo());
222 sk_sp<SkColorSpace> colorSpace = get_icc_profile(decoderMgr->dinfo()); 224 sk_sp<SkColorSpace> colorSpace = get_icc_profile(decoderMgr->dinfo());
223 225
224 *codecOut = new SkJpegCodec(imageInfo, stream, decoderMgr.release(), col orSpace, 226 const int width = decoderMgr->dinfo()->image_width;
227 const int height = decoderMgr->dinfo()->image_height;
228 *codecOut = new SkJpegCodec(width, height, info, stream, decoderMgr.rele ase(), colorSpace,
225 orientation); 229 orientation);
226 } else { 230 } else {
227 SkASSERT(nullptr != decoderMgrOut); 231 SkASSERT(nullptr != decoderMgrOut);
228 *decoderMgrOut = decoderMgr.release(); 232 *decoderMgrOut = decoderMgr.release();
229 } 233 }
230 return true; 234 return true;
231 } 235 }
232 236
233 SkCodec* SkJpegCodec::NewFromStream(SkStream* stream) { 237 SkCodec* SkJpegCodec::NewFromStream(SkStream* stream) {
234 SkAutoTDelete<SkStream> streamDeleter(stream); 238 SkAutoTDelete<SkStream> streamDeleter(stream);
235 SkCodec* codec = nullptr; 239 SkCodec* codec = nullptr;
236 if (ReadHeader(stream, &codec, nullptr)) { 240 if (ReadHeader(stream, &codec, nullptr)) {
237 // Codec has taken ownership of the stream, we do not need to delete it 241 // Codec has taken ownership of the stream, we do not need to delete it
238 SkASSERT(codec); 242 SkASSERT(codec);
239 streamDeleter.release(); 243 streamDeleter.release();
240 return codec; 244 return codec;
241 } 245 }
242 return nullptr; 246 return nullptr;
243 } 247 }
244 248
245 SkJpegCodec::SkJpegCodec(const SkImageInfo& srcInfo, SkStream* stream, 249 SkJpegCodec::SkJpegCodec(int width, int height, const SkEncodedInfo& info, SkStr eam* stream,
246 JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin origi n) 250 JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin origi n)
247 : INHERITED(srcInfo, stream, colorSpace, origin) 251 : INHERITED(width, height, info, stream, colorSpace, origin)
248 , fDecoderMgr(decoderMgr) 252 , fDecoderMgr(decoderMgr)
249 , fReadyState(decoderMgr->dinfo()->global_state) 253 , fReadyState(decoderMgr->dinfo()->global_state)
250 , fSwizzlerSubset(SkIRect::MakeEmpty()) 254 , fSwizzlerSubset(SkIRect::MakeEmpty())
251 {} 255 {}
252 256
253 /* 257 /*
254 * Return the row bytes of a particular image type and width 258 * Return the row bytes of a particular image type and width
255 */ 259 */
256 static size_t get_row_bytes(const j_decompress_ptr dinfo) { 260 static size_t get_row_bytes(const j_decompress_ptr dinfo) {
257 #ifdef TURBO_HAS_565 261 #ifdef TURBO_HAS_565
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 893
890 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock); 894 JDIMENSION linesRead = jpeg_read_raw_data(dinfo, yuv, numRowsPerBlock);
891 if (linesRead < remainingRows) { 895 if (linesRead < remainingRows) {
892 // FIXME: Handle incomplete YUV decodes without signalling an error. 896 // FIXME: Handle incomplete YUV decodes without signalling an error.
893 return kInvalidInput; 897 return kInvalidInput;
894 } 898 }
895 } 899 }
896 900
897 return kSuccess; 901 return kSuccess;
898 } 902 }
OLDNEW
« no previous file with comments | « src/codec/SkJpegCodec.h ('k') | src/codec/SkJpegDecoderMgr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698