mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
jxl: indicate when all frames have been read
and return correct loop count
This commit is contained in:
parent
afa7399b36
commit
d734f28727
@ -48,6 +48,11 @@ bool QJpegXLHandler::canRead() const
|
|||||||
|
|
||||||
if (m_parseState != ParseJpegXLError) {
|
if (m_parseState != ParseJpegXLError) {
|
||||||
setFormat("jxl");
|
setFormat("jxl");
|
||||||
|
|
||||||
|
if (m_parseState == ParseJpegXLFinished) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -72,7 +77,7 @@ bool QJpegXLHandler::canRead(QIODevice *device)
|
|||||||
|
|
||||||
bool QJpegXLHandler::ensureParsed() const
|
bool QJpegXLHandler::ensureParsed() const
|
||||||
{
|
{
|
||||||
if (m_parseState == ParseJpegXLSuccess || m_parseState == ParseJpegXLBasicInfoParsed) {
|
if (m_parseState == ParseJpegXLSuccess || m_parseState == ParseJpegXLBasicInfoParsed || m_parseState == ParseJpegXLFinished) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (m_parseState == ParseJpegXLError) {
|
if (m_parseState == ParseJpegXLError) {
|
||||||
@ -90,7 +95,7 @@ bool QJpegXLHandler::ensureALLCounted() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_parseState == ParseJpegXLSuccess) {
|
if (m_parseState == ParseJpegXLSuccess || m_parseState == ParseJpegXLFinished) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +406,15 @@ bool QJpegXLHandler::decode_one_frame()
|
|||||||
if (!rewind()) {
|
if (!rewind()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// all frames in animation have been read
|
||||||
|
m_parseState = ParseJpegXLFinished;
|
||||||
|
} else {
|
||||||
|
m_parseState = ParseJpegXLSuccess;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// the static image has been read
|
||||||
|
m_parseState = ParseJpegXLFinished;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -860,6 +873,7 @@ bool QJpegXLHandler::jumpToNextImage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_parseState = ParseJpegXLSuccess;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -874,12 +888,14 @@ bool QJpegXLHandler::jumpToImage(int imageNumber)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (imageNumber == m_currentimage_index) {
|
if (imageNumber == m_currentimage_index) {
|
||||||
|
m_parseState = ParseJpegXLSuccess;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imageNumber > m_currentimage_index) {
|
if (imageNumber > m_currentimage_index) {
|
||||||
JxlDecoderSkipFrames(m_decoder, imageNumber - m_currentimage_index);
|
JxlDecoderSkipFrames(m_decoder, imageNumber - m_currentimage_index);
|
||||||
m_currentimage_index = imageNumber;
|
m_currentimage_index = imageNumber;
|
||||||
|
m_parseState = ParseJpegXLSuccess;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,6 +907,7 @@ bool QJpegXLHandler::jumpToImage(int imageNumber)
|
|||||||
JxlDecoderSkipFrames(m_decoder, imageNumber);
|
JxlDecoderSkipFrames(m_decoder, imageNumber);
|
||||||
}
|
}
|
||||||
m_currentimage_index = imageNumber;
|
m_currentimage_index = imageNumber;
|
||||||
|
m_parseState = ParseJpegXLSuccess;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -914,7 +931,7 @@ int QJpegXLHandler::loopCount() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_basicinfo.have_animation) {
|
if (m_basicinfo.have_animation) {
|
||||||
return 1;
|
return (m_basicinfo.animation.num_loops > 0) ? m_basicinfo.animation.num_loops - 1 : -1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ private:
|
|||||||
ParseJpegXLNotParsed = 0,
|
ParseJpegXLNotParsed = 0,
|
||||||
ParseJpegXLSuccess = 1,
|
ParseJpegXLSuccess = 1,
|
||||||
ParseJpegXLBasicInfoParsed = 2,
|
ParseJpegXLBasicInfoParsed = 2,
|
||||||
|
ParseJpegXLFinished = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseJpegXLState m_parseState;
|
ParseJpegXLState m_parseState;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user