mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-31 18:35:41 +01:00 
			
		
		
		
	demux: remove GetFragment()
Change-Id: Ibea117b64ca91ccafde80411c10e0035dc3247f3
This commit is contained in:
		| @@ -47,7 +47,7 @@ typedef struct Frame { | |||||||
|   int duration_; |   int duration_; | ||||||
|   WebPMuxAnimDispose dispose_method_; |   WebPMuxAnimDispose dispose_method_; | ||||||
|   WebPMuxAnimBlend blend_method_; |   WebPMuxAnimBlend blend_method_; | ||||||
|   int frame_num_;  // the referent frame number for use in assembling fragments. |   int frame_num_; | ||||||
|   int complete_;   // img_components_ contains a full image. |   int complete_;   // img_components_ contains a full image. | ||||||
|   ChunkData img_components_[2];  // 0=VP8{,L} 1=ALPH |   ChunkData img_components_[2];  // 0=VP8{,L} 1=ALPH | ||||||
|   struct Frame* next_; |   struct Frame* next_; | ||||||
| @@ -737,8 +737,6 @@ uint32_t WebPDemuxGetI(const WebPDemuxer* dmux, WebPFormatFeature feature) { | |||||||
| // ----------------------------------------------------------------------------- | // ----------------------------------------------------------------------------- | ||||||
| // Frame iteration | // Frame iteration | ||||||
|  |  | ||||||
| // Find the first 'frame_num' frame. There may be multiple such frames in a |  | ||||||
| // fragmented frame. |  | ||||||
| static const Frame* GetFrame(const WebPDemuxer* const dmux, int frame_num) { | static const Frame* GetFrame(const WebPDemuxer* const dmux, int frame_num) { | ||||||
|   const Frame* f; |   const Frame* f; | ||||||
|   for (f = dmux->frames_; f != NULL; f = f->next_) { |   for (f = dmux->frames_; f != NULL; f = f->next_) { | ||||||
| @@ -747,22 +745,6 @@ static const Frame* GetFrame(const WebPDemuxer* const dmux, int frame_num) { | |||||||
|   return f; |   return f; | ||||||
| } | } | ||||||
|  |  | ||||||
| // Returns fragment 'fragment_num' and the total count. |  | ||||||
| // TODO(jzern): this function is no longer necessary. |  | ||||||
| static const Frame* GetFragment( |  | ||||||
|     const Frame* const frame_set, int fragment_num, int* const count) { |  | ||||||
|   const int this_frame = frame_set->frame_num_; |  | ||||||
|   const Frame* f = frame_set; |  | ||||||
|   const Frame* fragment = NULL; |  | ||||||
|   int total; |  | ||||||
|  |  | ||||||
|   for (total = 0; f != NULL && f->frame_num_ == this_frame; f = f->next_) { |  | ||||||
|     if (++total == fragment_num) fragment = f; |  | ||||||
|   } |  | ||||||
|   *count = total; |  | ||||||
|   return fragment; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| static const uint8_t* GetFramePayload(const uint8_t* const mem_buf, | static const uint8_t* GetFramePayload(const uint8_t* const mem_buf, | ||||||
|                                       const Frame* const frame, |                                       const Frame* const frame, | ||||||
|                                       size_t* const data_size) { |                                       size_t* const data_size) { | ||||||
| @@ -789,29 +771,25 @@ static const uint8_t* GetFramePayload(const uint8_t* const mem_buf, | |||||||
|  |  | ||||||
| // Create a whole 'frame' from VP8 (+ alpha) or lossless. | // Create a whole 'frame' from VP8 (+ alpha) or lossless. | ||||||
| static int SynthesizeFrame(const WebPDemuxer* const dmux, | static int SynthesizeFrame(const WebPDemuxer* const dmux, | ||||||
|                            const Frame* const first_frame, |                            const Frame* const frame, | ||||||
|                            int fragment_num, WebPIterator* const iter) { |                            WebPIterator* const iter) { | ||||||
|   const uint8_t* const mem_buf = dmux->mem_.buf_; |   const uint8_t* const mem_buf = dmux->mem_.buf_; | ||||||
|   int num_fragments; |  | ||||||
|   size_t payload_size = 0; |   size_t payload_size = 0; | ||||||
|   const Frame* const fragment = |   const uint8_t* const payload = GetFramePayload(mem_buf, frame, &payload_size); | ||||||
|       GetFragment(first_frame, fragment_num, &num_fragments); |  | ||||||
|   const uint8_t* const payload = |  | ||||||
|       GetFramePayload(mem_buf, fragment, &payload_size); |  | ||||||
|   if (payload == NULL) return 0; |   if (payload == NULL) return 0; | ||||||
|   assert(first_frame != NULL); |   assert(frame != NULL); | ||||||
|  |  | ||||||
|   iter->frame_num      = first_frame->frame_num_; |   iter->frame_num      = frame->frame_num_; | ||||||
|   iter->num_frames     = dmux->num_frames_; |   iter->num_frames     = dmux->num_frames_; | ||||||
|   iter->x_offset       = fragment->x_offset_; |   iter->x_offset       = frame->x_offset_; | ||||||
|   iter->y_offset       = fragment->y_offset_; |   iter->y_offset       = frame->y_offset_; | ||||||
|   iter->width          = fragment->width_; |   iter->width          = frame->width_; | ||||||
|   iter->height         = fragment->height_; |   iter->height         = frame->height_; | ||||||
|   iter->has_alpha      = fragment->has_alpha_; |   iter->has_alpha      = frame->has_alpha_; | ||||||
|   iter->duration       = fragment->duration_; |   iter->duration       = frame->duration_; | ||||||
|   iter->dispose_method = fragment->dispose_method_; |   iter->dispose_method = frame->dispose_method_; | ||||||
|   iter->blend_method   = fragment->blend_method_; |   iter->blend_method   = frame->blend_method_; | ||||||
|   iter->complete       = fragment->complete_; |   iter->complete       = frame->complete_; | ||||||
|   iter->fragment.bytes = payload; |   iter->fragment.bytes = payload; | ||||||
|   iter->fragment.size  = payload_size; |   iter->fragment.size  = payload_size; | ||||||
|   return 1; |   return 1; | ||||||
| @@ -827,7 +805,7 @@ static int SetFrame(int frame_num, WebPIterator* const iter) { | |||||||
|   frame = GetFrame(dmux, frame_num); |   frame = GetFrame(dmux, frame_num); | ||||||
|   if (frame == NULL) return 0; |   if (frame == NULL) return 0; | ||||||
|  |  | ||||||
|   return SynthesizeFrame(dmux, frame, 1, iter); |   return SynthesizeFrame(dmux, frame, iter); | ||||||
| } | } | ||||||
|  |  | ||||||
| int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) { | int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user