OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 // Because the DNG SDK can not guarantee to render to requested size, we all ow a small | 398 // Because the DNG SDK can not guarantee to render to requested size, we all ow a small |
399 // difference. Only the overlapping region will be converted. | 399 // difference. Only the overlapping region will be converted. |
400 const float maxDiffRatio = 1.03f; | 400 const float maxDiffRatio = 1.03f; |
401 const dng_point& imageSize = image->Size(); | 401 const dng_point& imageSize = image->Size(); |
402 if (imageSize.h / width > maxDiffRatio || imageSize.h < width || | 402 if (imageSize.h / width > maxDiffRatio || imageSize.h < width || |
403 imageSize.v / height > maxDiffRatio || imageSize.v < height) { | 403 imageSize.v / height > maxDiffRatio || imageSize.v < height) { |
404 return SkCodec::kInvalidScale; | 404 return SkCodec::kInvalidScale; |
405 } | 405 } |
406 | 406 |
407 void* dstRow = dst; | 407 void* dstRow = dst; |
408 uint8_t srcRow[width * 3]; | 408 SkAutoTMalloc<uint8_t> srcRow(width * 3); |
409 | 409 |
410 dng_pixel_buffer buffer; | 410 dng_pixel_buffer buffer; |
411 buffer.fData = &srcRow[0]; | 411 buffer.fData = &srcRow[0]; |
412 buffer.fPlane = 0; | 412 buffer.fPlane = 0; |
413 buffer.fPlanes = 3; | 413 buffer.fPlanes = 3; |
414 buffer.fColStep = buffer.fPlanes; | 414 buffer.fColStep = buffer.fPlanes; |
415 buffer.fPlaneStep = 1; | 415 buffer.fPlaneStep = 1; |
416 buffer.fPixelType = ttByte; | 416 buffer.fPixelType = ttByte; |
417 buffer.fPixelSize = sizeof(uint8_t); | 417 buffer.fPixelSize = sizeof(uint8_t); |
418 buffer.fRowStep = sizeof(srcRow); | 418 buffer.fRowStep = sizeof(srcRow); |
dogben
2016/01/29 19:36:08
Does this really work?
mtklein
2016/01/29 19:47:48
Nope, it's quite wrong. If the old VLA code was c
scroggo
2016/01/29 20:44:29
Agreed. Is someone already fixing this?
scroggo
2016/01/29 21:01:30
I've posted a fix at crrev.com/1643373002.
How di
| |
419 | 419 |
420 for (int i = 0; i < height; ++i) { | 420 for (int i = 0; i < height; ++i) { |
421 buffer.fArea = dng_rect(i, 0, i + 1, width); | 421 buffer.fArea = dng_rect(i, 0, i + 1, width); |
422 | 422 |
423 try { | 423 try { |
424 image->Get(buffer, dng_image::edge_zero); | 424 image->Get(buffer, dng_image::edge_zero); |
425 } catch (...) { | 425 } catch (...) { |
426 *rowsDecoded = i; | 426 *rowsDecoded = i; |
427 return kIncompleteInput; | 427 return kIncompleteInput; |
428 } | 428 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEd ge / shortEdge)); | 466 SkISize sizeFloor = this->onGetScaledDimensions(1.f / std::floor(fullShortEd ge / shortEdge)); |
467 SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge / shortEdge)); | 467 SkISize sizeCeil = this->onGetScaledDimensions(1.f / std::ceil(fullShortEdge / shortEdge)); |
468 return sizeFloor == dim || sizeCeil == dim; | 468 return sizeFloor == dim || sizeCeil == dim; |
469 } | 469 } |
470 | 470 |
471 SkRawCodec::~SkRawCodec() {} | 471 SkRawCodec::~SkRawCodec() {} |
472 | 472 |
473 SkRawCodec::SkRawCodec(SkDngImage* dngImage) | 473 SkRawCodec::SkRawCodec(SkDngImage* dngImage) |
474 : INHERITED(dngImage->getImageInfo(), nullptr) | 474 : INHERITED(dngImage->getImageInfo(), nullptr) |
475 , fDngImage(dngImage) {} | 475 , fDngImage(dngImage) {} |
OLD | NEW |