Commit a3d98a6f authored by Wan-Teh Chang's avatar Wan-Teh Chang Committed by Commit Bot

Parse image metadata when all data is received

Change AVIFImageDecoder::OnSetData() to parse the image metadata
automatically when all data is received. This meets the expectations of
ImageFrameGenerator::GetYUVAInfo() and
ImageFrameGenerator::DecodeToYUV().

In the ReadYUV() function in avif_image_decoder_test.cc, change the
IsSizeAvailable() call (which calls DecodeSize()) to
IsDecodedSizeAvailable() (which has no side effects) and call a few more
getter methods related to DecodeToYUV() to emulate the code in
ImageFrameGenerator::GetYUVAInfo() and
ImageFrameGenerator::DecodeToYUV().

Bug: 1149144
Bug: 1136922
Change-Id: I3790de99fd0e9745c4b3ab9555aa027f25a6d374
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2539329Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Cr-Commit-Position: refs/heads/master@{#827852}
parent e76ebba5
...@@ -280,6 +280,12 @@ void AVIFImageDecoder::OnSetData(SegmentReader* data) { ...@@ -280,6 +280,12 @@ void AVIFImageDecoder::OnSetData(SegmentReader* data) {
avif_io_data_.reader = data_.get(); avif_io_data_.reader = data_.get();
avif_io_data_.all_data_received = all_data_received; avif_io_data_.all_data_received = all_data_received;
avif_io_.sizeHint = all_data_received ? data_->size() : kMaxAvifFileSize; avif_io_.sizeHint = all_data_received ? data_->size() : kMaxAvifFileSize;
// ImageFrameGenerator::GetYUVAInfo() and ImageFrameGenerator::DecodeToYUV()
// assume that allow_decode_to_yuv_ and other image metadata are available
// after calling ImageDecoder::Create() with data_complete=true.
if (all_data_received)
ParseMetadata();
} }
cc::YUVSubsampling AVIFImageDecoder::GetYUVSubsampling() const { cc::YUVSubsampling AVIFImageDecoder::GetYUVSubsampling() const {
......
...@@ -514,8 +514,12 @@ void ReadYUV(const char* file_name, ...@@ -514,8 +514,12 @@ void ReadYUV(const char* file_name,
auto decoder = CreateAVIFDecoder(); auto decoder = CreateAVIFDecoder();
decoder->SetData(data.get(), true); decoder->SetData(data.get(), true);
ASSERT_TRUE(decoder->IsSizeAvailable()); ASSERT_TRUE(decoder->IsDecodedSizeAvailable());
ASSERT_TRUE(decoder->CanDecodeToYUV()); ASSERT_TRUE(decoder->CanDecodeToYUV());
EXPECT_NE(decoder->GetYUVSubsampling(), cc::YUVSubsampling::kUnknown);
EXPECT_NE(decoder->GetYUVColorSpace(),
SkYUVColorSpace::kIdentity_SkYUVColorSpace);
EXPECT_EQ(decoder->GetYUVBitDepth(), bit_depth);
IntSize size = decoder->DecodedSize(); IntSize size = decoder->DecodedSize();
IntSize y_size = decoder->DecodedYUVSize(cc::YUVIndex::kY); IntSize y_size = decoder->DecodedYUVSize(cc::YUVIndex::kY);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment