Home | History | Annotate | Download | only in demux

Lines Matching refs:frame

43 typedef struct Frame {
50 int is_fragment_; // this is a frame fragment (and not a full frame).
51 int frame_num_; // the referent frame number for use in assembling fragments.
54 struct Frame* next_;
55 } Frame;
71 Frame* frames_;
72 Frame** frames_tail_;
184 // Add a frame to the end of the list, ensuring the last frame is complete.
186 static int AddFrame(WebPDemuxer* const dmux, Frame* const frame) {
187 const Frame* const last_frame = *dmux->frames_tail_;
190 *dmux->frames_tail_ = frame;
191 frame->next_ = NULL;
192 dmux->frames_tail_ = &frame->next_;
196 // Store image bearing chunks to 'frame'.
198 MemBuffer* const mem, Frame* const frame) {
223 frame->img_components_[1].offset_ = chunk_start_offset;
224 frame->img_components_[1].size_ = chunk_size;
225 frame->has_alpha_ = 1;
226 frame->frame_num_ = frame_num;
251 frame->img_components_[0].offset_ = chunk_start_offset;
252 frame->img_components_[0].size_ = chunk_size;
253 frame->width_ = features.width;
254 frame->height_ = features.height;
255 frame->has_alpha_ |= features.has_alpha;
256 frame->frame_num_ = frame_num;
257 frame->complete_ = (status == PARSE_OK);
281 // Creates a new Frame if 'actual_size' is within bounds and 'mem' contains
283 // Returns PARSE_OK on success with *frame pointing to the new Frame.
287 Frame** frame) {
292 *frame = (Frame*)WebPSafeCalloc(1ULL, sizeof(**frame));
293 return (*frame == NULL) ? PARSE_ERROR : PARSE_OK;
305 Frame* frame;
307 NewFrame(mem, ANMF_CHUNK_SIZE, frame_chunk_size, &frame);
310 frame->x_offset_ = 2 * ReadLE24s(mem);
311 frame->y_offset_ = 2 * ReadLE24s(mem);
312 frame->width_ = 1 + ReadLE24s(mem);
313 frame->height_ = 1 + ReadLE24s(mem);
314 frame->duration_ = ReadLE24s(mem);
316 frame->dispose_method_ =
318 frame->blend_method_ = (bits & 2) ? WEBP_MUX_NO_BLEND : WEBP_MUX_BLEND;
319 if (frame->width_ * (uint64_t)frame->height_ >= MAX_IMAGE_AREA) {
320 WebPSafeFree(frame);
324 // Store a frame only if the animation flag is set there is some data for
325 // this frame is available.
326 status = StoreFrame(dmux->num_frames_ + 1, anmf_payload_size, mem, frame);
327 if (status != PARSE_ERROR && is_animation && frame->frame_num_ > 0) {
328 added_frame = AddFrame(dmux, frame);
336 if (!added_frame) WebPSafeFree(frame);
345 const int frame_num = 1; // All fragments belong to the 1st (and only) frame.
350 Frame* frame;
352 NewFrame(mem, FRGM_CHUNK_SIZE, fragment_chunk_size, &frame);
355 frame->is_fragment_ = 1;
356 frame->x_offset_ = 2 * ReadLE24s(mem);
357 frame->y_offset_ = 2 * ReadLE24s(mem);
361 status = StoreFrame(frame_num, frgm_payload_size, mem, frame);
362 if (status != PARSE_ERROR && is_fragmented && frame->frame_num_ > 0) {
363 added_fragment = AddFrame(dmux, frame);
371 if (!added_fragment) WebPSafeFree(frame);
422 Frame* frame;
430 frame = (Frame*)WebPSafeCalloc(1ULL, sizeof(*frame));
431 if (frame == NULL) return PARSE_ERROR;
433 // For the single image case we allow parsing of a partial frame, but we need
435 status = StoreFrame(1, CHUNK_HEADER_SIZE, &dmux->mem_, frame);
439 if (!has_alpha && frame->img_components_[1].size_ > 0) {
440 frame->img_components_[1].offset_ = 0;
441 frame->img_components_[1].size_ = 0;
442 frame->has_alpha_ = 0;
445 // Use the frame width/height as the canvas values for non-vp8x files.
447 if (!dmux->is_ext_format_ && frame->width_ > 0 && frame->height_ > 0) {
449 dmux->canvas_width_ = frame->width_;
450 dmux->canvas_height_ = frame->height_;
451 dmux->feature_flags_ |= frame->has_alpha_ ? ALPHA_FLAG : 0;
453 if (!AddFrame(dmux, frame)) {
454 status = PARSE_ERROR; // last frame was left incomplete
461 if (!image_added) WebPSafeFree(frame);
597 const Frame* const frame = dmux->frames_;
601 if (dmux->state_ == WEBP_DEMUX_DONE && frame == NULL) return 0;
603 if (frame->width_ <= 0 || frame->height_ <= 0) return 0;
611 static int CheckFrameBounds(const Frame* const frame, int exact,
614 if (frame->x_offset_ != 0 || frame->y_offset_ != 0) {
617 if (frame->width_ != canvas_width || frame->height_ != canvas_height) {
621 if (frame->x_offset_ < 0 || frame->y_offset_ < 0) return 0;
622 if (frame->width_ + frame->x_offset_ > canvas_width) return 0;
623 if (frame->height_ + frame->y_offset_ > canvas_height) return 0;
631 const Frame* f = dmux->frames_;
646 // Check frame properties and if the image is composed of fragments that
665 // There shouldn't be a partial frame in a complete file.
758 Frame* f;
762 Frame* const cur_frame = f;
791 // Frame iteration
793 // Find the first 'frame_num' frame. There may be multiple such frames in a
794 // fragmented frame.
795 static const Frame* GetFrame(const WebPDemuxer* const dmux, int frame_num) {
796 const Frame* f;
804 static const Frame* GetFragment(
805 const Frame* const frame_set, int fragment_num, int* const count) {
807 const Frame* f = frame_set;
808 const Frame* fragment = NULL;
819 const Frame* const frame,
822 if (frame != NULL) {
823 const ChunkData* const image = frame->img_components_;
824 const ChunkData* const alpha = frame->img_components_ + 1;
842 // Create a whole 'frame' from VP8 (+ alpha) or lossless.
844 const Frame* const first_frame,
849 const Frame* const fragment =
876 const Frame* frame;
882 frame = GetFrame(dmux, frame_num);
883 if (frame == NULL) return 0;
885 return SynthesizeFrame(dmux, frame, 1, iter);
888 int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) {
893 return SetFrame(frame, iter);
910 const Frame* const frame = GetFrame(dmux, iter->frame_num);
911 if (frame == NULL) return 0;
913 return SynthesizeFrame(dmux, frame, fragment_num, iter);