mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-31 10:25:46 +01:00 
			
		
		
		
	demux: keep a frame tail pointer; used in AddFrame
this speeds up the parse of a file with a large number of frames. Change-Id: Ibc61324eb50a04438f811a6f7787d378d763c104
This commit is contained in:
		| @@ -69,6 +69,7 @@ struct WebPDemuxer { | |||||||
|   uint32_t bgcolor_; |   uint32_t bgcolor_; | ||||||
|   int num_frames_; |   int num_frames_; | ||||||
|   Frame* frames_; |   Frame* frames_; | ||||||
|  |   Frame** frames_tail_; | ||||||
|   Chunk* chunks_;  // non-image chunks |   Chunk* chunks_;  // non-image chunks | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -183,15 +184,12 @@ static void AddChunk(WebPDemuxer* const dmux, Chunk* const chunk) { | |||||||
| // Add a frame to the end of the list, ensuring the last frame is complete. | // Add a frame to the end of the list, ensuring the last frame is complete. | ||||||
| // Returns true on success, false otherwise. | // Returns true on success, false otherwise. | ||||||
| static int AddFrame(WebPDemuxer* const dmux, Frame* const frame) { | static int AddFrame(WebPDemuxer* const dmux, Frame* const frame) { | ||||||
|   const Frame* last_frame = NULL; |   const Frame* const last_frame = *dmux->frames_tail_; | ||||||
|   Frame** f = &dmux->frames_; |  | ||||||
|   while (*f != NULL) { |  | ||||||
|     last_frame = *f; |  | ||||||
|     f = &(*f)->next_; |  | ||||||
|   } |  | ||||||
|   if (last_frame != NULL && !last_frame->complete_) return 0; |   if (last_frame != NULL && !last_frame->complete_) return 0; | ||||||
|   *f = frame; |  | ||||||
|  |   *dmux->frames_tail_ = frame; | ||||||
|   frame->next_ = NULL; |   frame->next_ = NULL; | ||||||
|  |   dmux->frames_tail_ = &frame->next_; | ||||||
|   return 1; |   return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -660,6 +658,7 @@ static void InitDemux(WebPDemuxer* const dmux, const MemBuffer* const mem) { | |||||||
|   dmux->bgcolor_ = 0xFFFFFFFF;  // White background by default. |   dmux->bgcolor_ = 0xFFFFFFFF;  // White background by default. | ||||||
|   dmux->canvas_width_ = -1; |   dmux->canvas_width_ = -1; | ||||||
|   dmux->canvas_height_ = -1; |   dmux->canvas_height_ = -1; | ||||||
|  |   dmux->frames_tail_ = &dmux->frames_; | ||||||
|   dmux->mem_ = *mem; |   dmux->mem_ = *mem; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user