Home | History | Annotate | Download | only in demux

Lines Matching defs:Frame

43 typedef struct Frame {
53 struct Frame* next_;
54 } Frame;
70 Frame* frames_;
71 Frame** frames_tail_;
183 // Add a frame to the end of the list, ensuring the last frame is complete.
185 static int AddFrame(WebPDemuxer* const dmux, Frame* const frame) {
186 const Frame* const last_frame = *dmux->frames_tail_;
189 *dmux->frames_tail_ = frame;
190 frame->next_ = NULL;
191 dmux->frames_tail_ = &frame->next_;
198 Frame* const frame) {
199 frame->img_components_[0].offset_ = start_offset;
200 frame->img_components_[0].size_ = size;
201 frame->width_ = features->width;
202 frame->height_ = features->height;
203 frame->has_alpha_ |= features->has_alpha;
204 frame->frame_num_ = frame_num;
205 frame->complete_ = complete;
208 // Store image bearing chunks to 'frame'.
210 MemBuffer* const mem, Frame* const frame) {
235 frame->img_components_[1].offset_ = chunk_start_offset;
236 frame->img_components_[1].size_ = chunk_size;
237 frame->has_alpha_ = 1;
238 frame->frame_num_ = frame_num;
264 status == PARSE_OK, &features, frame);
288 // Creates a new Frame if 'actual_size' is within bounds and 'mem' contains
290 // Returns PARSE_OK on success with *frame pointing to the new Frame.
294 Frame** frame) {
299 *frame = (Frame*)WebPSafeCalloc(1ULL, sizeof(**frame));
300 return (*frame == NULL) ? PARSE_ERROR : PARSE_OK;
312 Frame* frame;
314 NewFrame(mem, ANMF_CHUNK_SIZE, frame_chunk_size, &frame);
317 frame->x_offset_ = 2 * ReadLE24s(mem);
318 frame->y_offset_ = 2 * ReadLE24s(mem);
319 frame->width_ = 1 + ReadLE24s(mem);
320 frame->height_ = 1 + ReadLE24s(mem);
321 frame->duration_ = ReadLE24s(mem);
323 frame->dispose_method_ =
325 frame->blend_method_ = (bits & 2) ? WEBP_MUX_NO_BLEND : WEBP_MUX_BLEND;
326 if (frame->width_ * (uint64_t)frame->height_ >= MAX_IMAGE_AREA) {
327 WebPSafeFree(frame);
331 // Store a frame only if the animation flag is set there is some data for
332 // this frame is available.
333 status = StoreFrame(dmux->num_frames_ + 1, anmf_payload_size, mem, frame);
334 if (status != PARSE_ERROR && is_animation && frame->frame_num_ > 0) {
335 added_frame = AddFrame(dmux, frame);
343 if (!added_frame) WebPSafeFree(frame);
393 Frame* frame;
401 frame = (Frame*)WebPSafeCalloc(1ULL, sizeof(*frame));
402 if (frame == NULL) return PARSE_ERROR;
404 // For the single image case we allow parsing of a partial frame, but we need
406 status = StoreFrame(1, CHUNK_HEADER_SIZE, &dmux->mem_, frame);
410 if (!has_alpha && frame->img_components_[1].size_ > 0) {
411 frame->img_components_[1].offset_ = 0;
412 frame->img_components_[1].size_ = 0;
413 frame->has_alpha_ = 0;
416 // Use the frame width/height as the canvas values for non-vp8x files.
418 if (!dmux->is_ext_format_ && frame->width_ > 0 && frame->height_ > 0) {
420 dmux->canvas_width_ = frame->width_;
421 dmux->canvas_height_ = frame->height_;
422 dmux->feature_flags_ |= frame->has_alpha_ ? ALPHA_FLAG : 0;
424 if (!AddFrame(dmux, frame)) {
425 status = PARSE_ERROR; // last frame was left incomplete
432 if (!image_added) WebPSafeFree(frame);
562 const Frame* const frame = dmux->frames_;
566 if (dmux->state_ == WEBP_DEMUX_DONE && frame == NULL) return 0;
568 if (frame->width_ <= 0 || frame->height_ <= 0) return 0;
574 static int CheckFrameBounds(const Frame* const frame, int exact,
577 if (frame->x_offset_ != 0 || frame->y_offset_ != 0) {
580 if (frame->width_ != canvas_width || frame->height_ != canvas_height) {
584 if (frame->x_offset_ < 0 || frame->y_offset_ < 0) return 0;
585 if (frame->width_ + frame->x_offset_ > canvas_width) return 0;
586 if (frame->height_ + frame->y_offset_ > canvas_height) return 0;
594 const Frame* f = dmux->frames_;
607 // Check frame properties.
623 // There shouldn't be a partial frame in a complete file.
674 Frame* const frame = (Frame*)WebPSafeCalloc(1ULL, sizeof(*frame));
675 if (dmux == NULL || frame == NULL) goto Error;
678 frame);
679 if (!AddFrame(dmux, frame)) goto Error;
681 dmux->canvas_width_ = frame->width_;
682 dmux->canvas_height_ = frame->height_;
683 dmux->feature_flags_ |= frame->has_alpha_ ? ALPHA_FLAG : 0;
691 WebPSafeFree(frame);
713 // VP8/VP8L frame. Note 'allow_partial' is ignored in this case.
757 Frame* f;
761 Frame* const cur_frame = f;
790 // Frame iteration
792 static const Frame* GetFrame(const WebPDemuxer* const dmux, int frame_num) {
793 const Frame* f;
801 const Frame* const frame,
804 if (frame != NULL) {
805 const ChunkData* const image = frame->img_components_;
806 const ChunkData* const alpha = frame->img_components_ + 1;
824 // Create a whole 'frame' from VP8 (+ alpha) or lossless.
826 const Frame* const frame,
830 const uint8_t* const payload = GetFramePayload(mem_buf, frame, &payload_size);
832 assert(frame != NULL);
834 iter->frame_num = frame->frame_num_;
836 iter->x_offset = frame->x_offset_;
837 iter->y_offset = frame->y_offset_;
838 iter->width = frame->width_;
839 iter->height = frame->height_;
840 iter->has_alpha = frame->has_alpha_;
841 iter->duration = frame->duration_;
842 iter->dispose_method = frame->dispose_method_;
843 iter->blend_method = frame->blend_method_;
844 iter->complete = frame->complete_;
851 const Frame* frame;
857 frame = GetFrame(dmux, frame_num);
858 if (frame == NULL) return 0;
860 return SynthesizeFrame(dmux, frame, iter);
863 int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) {
868 return SetFrame(frame, iter);