avif: indicate when all frames have been read

This commit is contained in:
Daniel Novomeský 2022-10-15 20:03:56 +02:00
parent 1190e53e9b
commit bfb12093ad
2 changed files with 11 additions and 3 deletions

View File

@ -43,7 +43,7 @@ bool QAVIFHandler::canRead() const
if (m_parseState != ParseAvifError) {
setFormat("avif");
if (m_parseState == ParseAvifSuccess && m_decoder->imageIndex >= m_decoder->imageCount - 1) {
if (m_parseState == ParseAvifFinished) {
return false;
}
@ -74,7 +74,7 @@ bool QAVIFHandler::canRead(QIODevice *device)
bool QAVIFHandler::ensureParsed() const
{
if (m_parseState == ParseAvifSuccess || m_parseState == ParseAvifMetadata) {
if (m_parseState == ParseAvifSuccess || m_parseState == ParseAvifMetadata || m_parseState == ParseAvifFinished) {
return true;
}
if (m_parseState == ParseAvifError) {
@ -88,7 +88,7 @@ bool QAVIFHandler::ensureParsed() const
bool QAVIFHandler::ensureOpened() const
{
if (m_parseState == ParseAvifSuccess) {
if (m_parseState == ParseAvifSuccess || m_parseState == ParseAvifFinished) {
return true;
}
if (m_parseState == ParseAvifError) {
@ -459,6 +459,13 @@ bool QAVIFHandler::read(QImage *image)
*image = m_current_image;
if (imageCount() >= 2) {
m_must_jump_to_next_image = true;
if (m_decoder->imageIndex >= m_decoder->imageCount - 1) {
// all frames in animation have been read
m_parseState = ParseAvifFinished;
}
} else {
// the static image has been read
m_parseState = ParseAvifFinished;
}
return true;
}

View File

@ -55,6 +55,7 @@ private:
ParseAvifNotParsed = 0,
ParseAvifSuccess = 1,
ParseAvifMetadata = 2,
ParseAvifFinished = 3,
};
ParseAvifState m_parseState;