Chromium Code Reviews| Index: src/codec/SkRawCodec.cpp |
| diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp |
| index c7de3172863876cdbf1ec0e2d5a2d0111e6ddc3f..d4c756edaf7a0e425996a67254c4378a4bab01be 100644 |
| --- a/src/codec/SkRawCodec.cpp |
| +++ b/src/codec/SkRawCodec.cpp |
| @@ -303,13 +303,18 @@ private: |
| class SkDngImage { |
| public: |
| + /* |
| + * Initializes the object with the information from Piex in a first attempt. This way it can |
| + * save time and storage to obtain the DNG dimensions and CFA pattern. |
|
scroggo
2016/02/03 15:56:02
Should there be a comment somewhere describing wha
ebrauer
2016/02/04 15:17:08
Done.
|
| + */ |
| static SkDngImage* NewFromStream(SkRawStream* stream) { |
| SkAutoTDelete<SkDngImage> dngImage(new SkDngImage(stream)); |
| - if (!dngImage->readDng()) { |
| - return nullptr; |
| + if (!dngImage->initFromPiex()) { |
| + if (!dngImage->readDng()) { |
| + return nullptr; |
| + } |
| } |
| - SkASSERT(dngImage->fNegative); |
| return dngImage.release(); |
| } |
| @@ -381,6 +386,26 @@ public: |
| } |
| private: |
| + void init(const int width, const int height, const int cfaPatternSize) { |
| + fImageInfo = SkImageInfo::Make(width, height, kN32_SkColorType, kOpaque_SkAlphaType); |
| + |
| + // The DNG SDK scales only for at demosaicing, so only when a mosaic info is available also |
|
scroggo
2016/02/03 15:56:02
I don't follow this sentence. I think you mean som
ebrauer
2016/02/04 15:17:08
Done.
|
| + // scale is available. |
| + fIsScalable = cfaPatternSize != 0; |
| + fIsXtransImage = fIsScalable ? cfaPatternSize == 36 : false; |
|
msarett
2016/02/03 16:21:49
This seems like a possible behavior change to me?
ebrauer
2016/02/04 15:17:08
The pattern size is either 0, 2x2 or 6x6, but theo
|
| + } |
| + |
| + bool initFromPiex() { |
| + ::piex::PreviewImageData imageData; |
| + if (::piex::IsRaw(fStream.get()) |
|
scroggo
2016/02/03 15:56:02
These two methods have already been called by SkRa
ebrauer
2016/02/04 15:17:07
Yes, they are pretty cheap that is why we try to u
|
| + && ::piex::GetPreviewImageData(fStream.get(), &imageData) == ::piex::Error::kOk) { |
|
scroggo
2016/02/03 15:56:02
nit: Easier to follow along if you put the brace o
ebrauer
2016/02/04 15:17:08
Done.
|
| + init(static_cast<int>(imageData.full_width), static_cast<int>(imageData.full_height), |
|
scroggo
2016/02/03 15:56:02
this->init
ebrauer
2016/02/04 15:17:08
Done.
|
| + imageData.cfa_pattern_dim[0] * imageData.cfa_pattern_dim[1]); |
|
scroggo
2016/02/03 15:56:02
nit: This should either be indented 8 spaces, or t
ebrauer
2016/02/04 15:17:08
Done.
|
| + return true; |
| + } |
| + return false; |
| + } |
| + |
| bool readDng() { |
| // Due to the limit of DNG SDK, we need to reset host and info. |
| fHost.reset(new SkDngHost(&fAllocator)); |
| @@ -399,21 +424,15 @@ private: |
| fNegative->PostParse(*fHost, *fDngStream, *fInfo); |
| fNegative->SynchronizeMetadata(); |
| - fImageInfo = SkImageInfo::Make( |
| - static_cast<int>(fNegative->DefaultCropSizeH().As_real64()), |
| + dng_point cfaPattern(0, 0); |
|
scroggo
2016/02/03 15:56:02
Nit: it appears that a more accurate name for this
ebrauer
2016/02/04 15:17:08
Done.
|
| + if (fNegative->GetMosaicInfo() != nullptr) { |
| + cfaPattern = fNegative->GetMosaicInfo()->fCFAPatternSize; |
| + } |
| + init(static_cast<int>(fNegative->DefaultCropSizeH().As_real64()), |
|
scroggo
2016/02/03 15:56:02
this->init
ebrauer
2016/02/04 15:17:08
Done.
|
| static_cast<int>(fNegative->DefaultCropSizeV().As_real64()), |
| - kN32_SkColorType, kOpaque_SkAlphaType); |
| - |
| - // The DNG SDK scales only for at demosaicing, so only when a mosaic info |
| - // is available also scale is available. |
| - fIsScalable = fNegative->GetMosaicInfo() != nullptr; |
| - fIsXtransImage = fIsScalable |
| - ? (fNegative->GetMosaicInfo()->fCFAPatternSize.v == 6 |
| - && fNegative->GetMosaicInfo()->fCFAPatternSize.h == 6) |
| - : false; |
| + cfaPattern.v * cfaPattern.h); |
| return true; |
| } catch (...) { |
| - fNegative.reset(nullptr); |
|
scroggo
2016/02/03 15:56:02
Why is this no longer necessary?
ebrauer
2016/02/04 15:17:08
This is unrelated to the cl, but it is somehow mis
|
| return false; |
| } |
| } |