• Home
  • Raw
  • Download

Lines Matching refs:dmux

84   ParseStatus (*parse)(WebPDemuxer* const dmux);
85 int (*valid)(const WebPDemuxer* const dmux);
88 static ParseStatus ParseSingleImage(WebPDemuxer* const dmux);
89 static ParseStatus ParseVP8X(WebPDemuxer* const dmux);
90 static int IsValidSimpleFormat(const WebPDemuxer* const dmux);
91 static int IsValidExtendedFormat(const WebPDemuxer* const dmux);
177 static void AddChunk(WebPDemuxer* const dmux, Chunk* const chunk) { in AddChunk() argument
178 *dmux->chunks_tail_ = chunk; in AddChunk()
180 dmux->chunks_tail_ = &chunk->next_; in AddChunk()
185 static int AddFrame(WebPDemuxer* const dmux, Frame* const frame) { in AddFrame() argument
186 const Frame* const last_frame = *dmux->frames_tail_; in AddFrame()
189 *dmux->frames_tail_ = frame; in AddFrame()
191 dmux->frames_tail_ = &frame->next_; in AddFrame()
308 WebPDemuxer* const dmux, uint32_t frame_chunk_size) { in ParseAnimationFrame() argument
309 const int is_animation = !!(dmux->feature_flags_ & ANIMATION_FLAG); in ParseAnimationFrame()
313 MemBuffer* const mem = &dmux->mem_; in ParseAnimationFrame()
337 status = StoreFrame(dmux->num_frames_ + 1, anmf_payload_size, mem, frame); in ParseAnimationFrame()
342 added_frame = AddFrame(dmux, frame); in ParseAnimationFrame()
344 ++dmux->num_frames_; in ParseAnimationFrame()
358 static int StoreChunk(WebPDemuxer* const dmux, in StoreChunk() argument
365 AddChunk(dmux, chunk); in StoreChunk()
397 static ParseStatus ParseSingleImage(WebPDemuxer* const dmux) { in ParseSingleImage() argument
399 MemBuffer* const mem = &dmux->mem_; in ParseSingleImage()
404 if (dmux->frames_ != NULL) return PARSE_ERROR; in ParseSingleImage()
413 status = StoreFrame(1, 0, &dmux->mem_, frame); in ParseSingleImage()
415 const int has_alpha = !!(dmux->feature_flags_ & ALPHA_FLAG); in ParseSingleImage()
425 if (!dmux->is_ext_format_ && frame->width_ > 0 && frame->height_ > 0) { in ParseSingleImage()
426 dmux->state_ = WEBP_DEMUX_PARSED_HEADER; in ParseSingleImage()
427 dmux->canvas_width_ = frame->width_; in ParseSingleImage()
428 dmux->canvas_height_ = frame->height_; in ParseSingleImage()
429 dmux->feature_flags_ |= frame->has_alpha_ ? ALPHA_FLAG : 0; in ParseSingleImage()
431 if (!AddFrame(dmux, frame)) { in ParseSingleImage()
435 dmux->num_frames_ = 1; in ParseSingleImage()
443 static ParseStatus ParseVP8XChunks(WebPDemuxer* const dmux) { in ParseVP8XChunks() argument
444 const int is_animation = !!(dmux->feature_flags_ & ANIMATION_FLAG); in ParseVP8XChunks()
445 MemBuffer* const mem = &dmux->mem_; in ParseVP8XChunks()
470 status = ParseSingleImage(dmux); in ParseVP8XChunks()
480 dmux->bgcolor_ = ReadLE32(mem); in ParseVP8XChunks()
481 dmux->loop_count_ = ReadLE16s(mem); in ParseVP8XChunks()
491 status = ParseAnimationFrame(dmux, chunk_size_padded); in ParseVP8XChunks()
495 store_chunk = !!(dmux->feature_flags_ & ICCP_FLAG); in ParseVP8XChunks()
499 store_chunk = !!(dmux->feature_flags_ & EXIF_FLAG); in ParseVP8XChunks()
503 store_chunk = !!(dmux->feature_flags_ & XMP_FLAG); in ParseVP8XChunks()
512 if (!StoreChunk(dmux, chunk_start_offset, in ParseVP8XChunks()
534 static ParseStatus ParseVP8X(WebPDemuxer* const dmux) { in ParseVP8X() argument
535 MemBuffer* const mem = &dmux->mem_; in ParseVP8X()
540 dmux->is_ext_format_ = 1; in ParseVP8X()
549 dmux->feature_flags_ = ReadByte(mem); in ParseVP8X()
551 dmux->canvas_width_ = 1 + ReadLE24s(mem); in ParseVP8X()
552 dmux->canvas_height_ = 1 + ReadLE24s(mem); in ParseVP8X()
553 if (dmux->canvas_width_ * (uint64_t)dmux->canvas_height_ >= MAX_IMAGE_AREA) { in ParseVP8X()
557 dmux->state_ = WEBP_DEMUX_PARSED_HEADER; in ParseVP8X()
562 return ParseVP8XChunks(dmux); in ParseVP8X()
568 static int IsValidSimpleFormat(const WebPDemuxer* const dmux) { in IsValidSimpleFormat() argument
569 const Frame* const frame = dmux->frames_; in IsValidSimpleFormat()
570 if (dmux->state_ == WEBP_DEMUX_PARSING_HEADER) return 1; in IsValidSimpleFormat()
572 if (dmux->canvas_width_ <= 0 || dmux->canvas_height_ <= 0) return 0; in IsValidSimpleFormat()
573 if (dmux->state_ == WEBP_DEMUX_DONE && frame == NULL) return 0; in IsValidSimpleFormat()
598 static int IsValidExtendedFormat(const WebPDemuxer* const dmux) { in IsValidExtendedFormat() argument
599 const int is_animation = !!(dmux->feature_flags_ & ANIMATION_FLAG); in IsValidExtendedFormat()
600 const Frame* f = dmux->frames_; in IsValidExtendedFormat()
602 if (dmux->state_ == WEBP_DEMUX_PARSING_HEADER) return 1; in IsValidExtendedFormat()
604 if (dmux->canvas_width_ <= 0 || dmux->canvas_height_ <= 0) return 0; in IsValidExtendedFormat()
605 if (dmux->loop_count_ < 0) return 0; in IsValidExtendedFormat()
606 if (dmux->state_ == WEBP_DEMUX_DONE && dmux->frames_ == NULL) return 0; in IsValidExtendedFormat()
607 if (dmux->feature_flags_ & ~ALL_VALID_FLAGS) return 0; // invalid bitstream in IsValidExtendedFormat()
630 if (dmux->state_ == WEBP_DEMUX_DONE) return 0; in IsValidExtendedFormat()
643 dmux->canvas_width_, dmux->canvas_height_)) { in IsValidExtendedFormat()
656 static void InitDemux(WebPDemuxer* const dmux, const MemBuffer* const mem) { in InitDemux() argument
657 dmux->state_ = WEBP_DEMUX_PARSING_HEADER; in InitDemux()
658 dmux->loop_count_ = 1; in InitDemux()
659 dmux->bgcolor_ = 0xFFFFFFFF; // White background by default. in InitDemux()
660 dmux->canvas_width_ = -1; in InitDemux()
661 dmux->canvas_height_ = -1; in InitDemux()
662 dmux->frames_tail_ = &dmux->frames_; in InitDemux()
663 dmux->chunks_tail_ = &dmux->chunks_; in InitDemux()
664 dmux->mem_ = *mem; in InitDemux()
679 WebPDemuxer* const dmux = (WebPDemuxer*)WebPSafeCalloc(1ULL, sizeof(*dmux)); in CreateRawImageDemuxer() local
681 if (dmux == NULL || frame == NULL) goto Error; in CreateRawImageDemuxer()
682 InitDemux(dmux, mem); in CreateRawImageDemuxer()
685 if (!AddFrame(dmux, frame)) goto Error; in CreateRawImageDemuxer()
686 dmux->state_ = WEBP_DEMUX_DONE; in CreateRawImageDemuxer()
687 dmux->canvas_width_ = frame->width_; in CreateRawImageDemuxer()
688 dmux->canvas_height_ = frame->height_; in CreateRawImageDemuxer()
689 dmux->feature_flags_ |= frame->has_alpha_ ? ALPHA_FLAG : 0; in CreateRawImageDemuxer()
690 dmux->num_frames_ = 1; in CreateRawImageDemuxer()
691 assert(IsValidSimpleFormat(dmux)); in CreateRawImageDemuxer()
692 *demuxer = dmux; in CreateRawImageDemuxer()
696 WebPSafeFree(dmux); in CreateRawImageDemuxer()
708 WebPDemuxer* dmux; in WebPDemuxInternal() local
721 status = CreateRawImageDemuxer(&mem, &dmux); in WebPDemuxInternal()
724 return dmux; in WebPDemuxInternal()
737 dmux = (WebPDemuxer*)WebPSafeCalloc(1ULL, sizeof(*dmux)); in WebPDemuxInternal()
738 if (dmux == NULL) return NULL; in WebPDemuxInternal()
739 InitDemux(dmux, &mem); in WebPDemuxInternal()
743 if (!memcmp(parser->id, GetBuffer(&dmux->mem_), TAG_SIZE)) { in WebPDemuxInternal()
744 status = parser->parse(dmux); in WebPDemuxInternal()
745 if (status == PARSE_OK) dmux->state_ = WEBP_DEMUX_DONE; in WebPDemuxInternal()
747 if (status != PARSE_ERROR && !parser->valid(dmux)) status = PARSE_ERROR; in WebPDemuxInternal()
748 if (status == PARSE_ERROR) dmux->state_ = WEBP_DEMUX_PARSE_ERROR; in WebPDemuxInternal()
752 if (state != NULL) *state = dmux->state_; in WebPDemuxInternal()
755 WebPDemuxDelete(dmux); in WebPDemuxInternal()
758 return dmux; in WebPDemuxInternal()
761 void WebPDemuxDelete(WebPDemuxer* dmux) { in WebPDemuxDelete() argument
764 if (dmux == NULL) return; in WebPDemuxDelete()
766 for (f = dmux->frames_; f != NULL;) { in WebPDemuxDelete()
771 for (c = dmux->chunks_; c != NULL;) { in WebPDemuxDelete()
776 WebPSafeFree(dmux); in WebPDemuxDelete()
781 uint32_t WebPDemuxGetI(const WebPDemuxer* dmux, WebPFormatFeature feature) { in WebPDemuxGetI() argument
782 if (dmux == NULL) return 0; in WebPDemuxGetI()
785 case WEBP_FF_FORMAT_FLAGS: return dmux->feature_flags_; in WebPDemuxGetI()
786 case WEBP_FF_CANVAS_WIDTH: return (uint32_t)dmux->canvas_width_; in WebPDemuxGetI()
787 case WEBP_FF_CANVAS_HEIGHT: return (uint32_t)dmux->canvas_height_; in WebPDemuxGetI()
788 case WEBP_FF_LOOP_COUNT: return (uint32_t)dmux->loop_count_; in WebPDemuxGetI()
789 case WEBP_FF_BACKGROUND_COLOR: return dmux->bgcolor_; in WebPDemuxGetI()
790 case WEBP_FF_FRAME_COUNT: return (uint32_t)dmux->num_frames_; in WebPDemuxGetI()
798 static const Frame* GetFrame(const WebPDemuxer* const dmux, int frame_num) { in GetFrame() argument
800 for (f = dmux->frames_; f != NULL; f = f->next_) { in GetFrame()
831 static int SynthesizeFrame(const WebPDemuxer* const dmux, in SynthesizeFrame() argument
834 const uint8_t* const mem_buf = dmux->mem_.buf_; in SynthesizeFrame()
841 iter->num_frames = dmux->num_frames_; in SynthesizeFrame()
858 const WebPDemuxer* const dmux = (WebPDemuxer*)iter->private_; in SetFrame() local
859 if (dmux == NULL || frame_num < 0) return 0; in SetFrame()
860 if (frame_num > dmux->num_frames_) return 0; in SetFrame()
861 if (frame_num == 0) frame_num = dmux->num_frames_; in SetFrame()
863 frame = GetFrame(dmux, frame_num); in SetFrame()
866 return SynthesizeFrame(dmux, frame, iter); in SetFrame()
869 int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) { in WebPDemuxGetFrame() argument
873 iter->private_ = (void*)dmux; in WebPDemuxGetFrame()
895 static int ChunkCount(const WebPDemuxer* const dmux, const char fourcc[4]) { in ChunkCount() argument
896 const uint8_t* const mem_buf = dmux->mem_.buf_; in ChunkCount()
899 for (c = dmux->chunks_; c != NULL; c = c->next_) { in ChunkCount()
906 static const Chunk* GetChunk(const WebPDemuxer* const dmux, in GetChunk() argument
908 const uint8_t* const mem_buf = dmux->mem_.buf_; in GetChunk()
911 for (c = dmux->chunks_; c != NULL; c = c->next_) { in GetChunk()
921 const WebPDemuxer* const dmux = (WebPDemuxer*)iter->private_; in SetChunk() local
924 if (dmux == NULL || fourcc == NULL || chunk_num < 0) return 0; in SetChunk()
925 count = ChunkCount(dmux, fourcc); in SetChunk()
930 const uint8_t* const mem_buf = dmux->mem_.buf_; in SetChunk()
931 const Chunk* const chunk = GetChunk(dmux, fourcc, chunk_num); in SetChunk()
941 int WebPDemuxGetChunk(const WebPDemuxer* dmux, in WebPDemuxGetChunk() argument
947 iter->private_ = (void*)dmux; in WebPDemuxGetChunk()