SkAnimatedImage: Update HEIF duration
Bug: 139815242 Test: Manual HEIF does not know the correct duration for a frame until it has been decoded. Update the frame time after decoding. Change-Id: I6c4d1f27ea927b27d4c435e6aca94d57126e1146 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/237876 Reviewed-by: Chong Zhang <chz@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
This commit is contained in:
parent
066ceb15b6
commit
0e68f44212
@ -190,7 +190,7 @@ int SkAnimatedImage::decodeNextFrame() {
|
||||
}
|
||||
|
||||
bool animationEnded = false;
|
||||
int frameToDecode = this->computeNextFrame(fDisplayFrame.fIndex, &animationEnded);
|
||||
const int frameToDecode = this->computeNextFrame(fDisplayFrame.fIndex, &animationEnded);
|
||||
|
||||
SkCodec::FrameInfo frameInfo;
|
||||
if (fCodec->codec()->getFrameInfo(frameToDecode, &frameInfo)) {
|
||||
@ -313,6 +313,17 @@ int SkAnimatedImage::decodeNextFrame() {
|
||||
|
||||
if (animationEnded) {
|
||||
return this->finish();
|
||||
} else if (fCodec->getEncodedFormat() == SkEncodedImageFormat::kHEIF) {
|
||||
// HEIF doesn't know the frame duration until after decoding. Update to
|
||||
// the correct value. Note that earlier returns in this method either
|
||||
// return kFinished, or fCurrentFrameDuration. If they return the
|
||||
// latter, it is a frame that was previously decoded, so it has the
|
||||
// updated value.
|
||||
if (fCodec->codec()->getFrameInfo(frameToDecode, &frameInfo)) {
|
||||
fCurrentFrameDuration = frameInfo.fDuration;
|
||||
} else {
|
||||
SkCodecPrintf("Failed to getFrameInfo on second attempt (HEIF)");
|
||||
}
|
||||
}
|
||||
return fCurrentFrameDuration;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user