mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
demux: add a tail pointer for chunks
a large number of non-frame chunks could slow the parse Change-Id: I181bc73626e92263c3c5b2a6dc2bf6e6a0481d52
This commit is contained in:
parent
87cffcc3c9
commit
d2e3f4e6b5
@ -75,6 +75,7 @@ struct WebPDemuxer {
|
||||
Frame* frames_;
|
||||
Frame** frames_tail_;
|
||||
Chunk* chunks_; // non-image chunks
|
||||
Chunk** chunks_tail_;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@ -179,10 +180,9 @@ static WEBP_INLINE uint32_t ReadLE32(MemBuffer* const mem) {
|
||||
// Secondary chunk parsing
|
||||
|
||||
static void AddChunk(WebPDemuxer* const dmux, Chunk* const chunk) {
|
||||
Chunk** c = &dmux->chunks_;
|
||||
while (*c != NULL) c = &(*c)->next_;
|
||||
*c = chunk;
|
||||
*dmux->chunks_tail_ = chunk;
|
||||
chunk->next_ = NULL;
|
||||
dmux->chunks_tail_ = &chunk->next_;
|
||||
}
|
||||
|
||||
// Add a frame to the end of the list, ensuring the last frame is complete.
|
||||
@ -697,6 +697,7 @@ static void InitDemux(WebPDemuxer* const dmux, const MemBuffer* const mem) {
|
||||
dmux->canvas_width_ = -1;
|
||||
dmux->canvas_height_ = -1;
|
||||
dmux->frames_tail_ = &dmux->frames_;
|
||||
dmux->chunks_tail_ = &dmux->chunks_;
|
||||
dmux->mem_ = *mem;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user