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

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

Issue 1094603002: Zero jpeg_decompress_struct before calling jpeg_calc_output_dimensions(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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 | « no previous file | no next file » | 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 "SkJpegCodec.h" 9 #include "SkJpegCodec.h"
10 #include "SkJpegDecoderMgr.h" 10 #include "SkJpegDecoderMgr.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } else if (desiredScale > 0.375f) { 181 } else if (desiredScale > 0.375f) {
182 scale = 2; 182 scale = 2;
183 } else if (desiredScale > 0.1875f) { 183 } else if (desiredScale > 0.1875f) {
184 scale = 4; 184 scale = 4;
185 } else { 185 } else {
186 scale = 8; 186 scale = 8;
187 } 187 }
188 188
189 // Set up a fake decompress struct in order to use libjpeg to calculate outp ut dimensions 189 // Set up a fake decompress struct in order to use libjpeg to calculate outp ut dimensions
190 jpeg_decompress_struct dinfo; 190 jpeg_decompress_struct dinfo;
191 sk_bzero(&dinfo, sizeof(dinfo));
191 dinfo.image_width = this->getInfo().width(); 192 dinfo.image_width = this->getInfo().width();
192 dinfo.image_height = this->getInfo().height(); 193 dinfo.image_height = this->getInfo().height();
193 dinfo.global_state = DSTATE_READY; 194 dinfo.global_state = DSTATE_READY;
194 dinfo.num_components = 0; 195 dinfo.num_components = 0;
195 dinfo.scale_num = 1; 196 dinfo.scale_num = 1;
196 dinfo.scale_denom = scale; 197 dinfo.scale_denom = scale;
197 jpeg_calc_output_dimensions(&dinfo); 198 jpeg_calc_output_dimensions(&dinfo);
198 199
199 // Return the calculated output dimensions for the given scale 200 // Return the calculated output dimensions for the given scale
200 return SkISize::Make(dinfo.output_width, dinfo.output_height); 201 return SkISize::Make(dinfo.output_width, dinfo.output_height);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 339
339 // Finish the decode and indicate that the input was incomplete. 340 // Finish the decode and indicate that the input was incomplete.
340 jpeg_finish_decompress(dinfo); 341 jpeg_finish_decompress(dinfo);
341 return fDecoderMgr->returnFailure("Incomplete image data", kIncomple teInput); 342 return fDecoderMgr->returnFailure("Incomplete image data", kIncomple teInput);
342 } 343 }
343 } 344 }
344 jpeg_finish_decompress(dinfo); 345 jpeg_finish_decompress(dinfo);
345 346
346 return kSuccess; 347 return kSuccess;
347 } 348 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698