Bug 1352282. Always fill in the number of loops when decoding an APNG file. r=aosmond

If we were doing a first frame only decode we wouldn't fill in this value. The spec says this chunk must come before any image data so it should always be available at the end of any full decode (whether it be truly full or first frame only).
This commit is contained in:
Timothy Nikkel 2017-04-05 11:28:40 -05:00
Родитель f84f44fbfa
Коммит 0e7000fdce
2 изменённых файлов: 28 добавлений и 12 удалений

Просмотреть файл

@ -943,6 +943,33 @@ nsPNGDecoder::DoYield(png_structp aPNGStruct)
Transition::ContinueUnbufferedAfterYield(State::PNG_DATA, consumedBytes);
}
nsresult
nsPNGDecoder::FinishInternal()
{
// We shouldn't be called in error cases.
MOZ_ASSERT(!HasError(), "Can't call FinishInternal on error!");
if (IsMetadataDecode()) {
return NS_OK;
}
int32_t loop_count = 0;
#ifdef PNG_APNG_SUPPORTED
if (png_get_valid(mPNG, mInfo, PNG_INFO_acTL)) {
int32_t num_plays = png_get_num_plays(mPNG, mInfo);
loop_count = num_plays - 1;
}
#endif
if (InFrame()) {
EndImageFrame();
}
PostDecodeDone(loop_count);
return NS_OK;
}
#ifdef PNG_APNG_SUPPORTED
// got the header of a new frame that's coming
void
@ -959,7 +986,6 @@ nsPNGDecoder::frame_info_callback(png_structp png_ptr, png_uint_32 frame_num)
if (!previousFrameWasHidden && decoder->IsFirstFrameDecode()) {
// We're about to get a second non-hidden frame, but we only want the first.
// Stop decoding now. (And avoid allocating the unnecessary buffers below.)
decoder->PostDecodeDone();
return decoder->DoTerminate(png_ptr, TerminalState::SUCCESS);
}
@ -1025,17 +1051,6 @@ nsPNGDecoder::end_callback(png_structp png_ptr, png_infop info_ptr)
// We shouldn't get here if we've hit an error
MOZ_ASSERT(!decoder->HasError(), "Finishing up PNG but hit error!");
int32_t loop_count = 0;
#ifdef PNG_APNG_SUPPORTED
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_acTL)) {
int32_t num_plays = png_get_num_plays(png_ptr, info_ptr);
loop_count = num_plays - 1;
}
#endif
// Send final notifications.
decoder->EndImageFrame();
decoder->PostDecodeDone(loop_count);
return decoder->DoTerminate(png_ptr, TerminalState::SUCCESS);
}

Просмотреть файл

@ -27,6 +27,7 @@ public:
protected:
nsresult InitInternal() override;
nsresult FinishInternal() override;
LexerResult DoDecode(SourceBufferIterator& aIterator,
IResumable* aOnResume) override;