• Home
  • Raw
  • Download

Lines Matching refs:idec

95 static int NeedCompressedAlpha(const WebPIDecoder* const idec) {  in NeedCompressedAlpha()  argument
96 if (idec->state_ == STATE_WEBP_HEADER) { in NeedCompressedAlpha()
101 if (idec->is_lossless_) { in NeedCompressedAlpha()
104 const VP8Decoder* const dec = (VP8Decoder*)idec->dec_; in NeedCompressedAlpha()
110 static void DoRemap(WebPIDecoder* const idec, ptrdiff_t offset) { in DoRemap() argument
111 MemBuffer* const mem = &idec->mem_; in DoRemap()
115 idec->io_.data = new_base; in DoRemap()
116 idec->io_.data_size = MemDataSize(mem); in DoRemap()
118 if (idec->dec_ != NULL) { in DoRemap()
119 if (!idec->is_lossless_) { in DoRemap()
120 VP8Decoder* const dec = (VP8Decoder*)idec->dec_; in DoRemap()
139 if (NeedCompressedAlpha(idec)) { in DoRemap()
156 VP8LDecoder* const dec = (VP8LDecoder*)idec->dec_; in DoRemap()
164 static int AppendToMemBuffer(WebPIDecoder* const idec, in AppendToMemBuffer() argument
166 VP8Decoder* const dec = (VP8Decoder*)idec->dec_; in AppendToMemBuffer()
167 MemBuffer* const mem = &idec->mem_; in AppendToMemBuffer()
168 const int need_compressed_alpha = NeedCompressedAlpha(idec); in AppendToMemBuffer()
199 DoRemap(idec, mem->buf_ + mem->start_ - old_start); in AppendToMemBuffer()
203 static int RemapMemBuffer(WebPIDecoder* const idec, in RemapMemBuffer() argument
205 MemBuffer* const mem = &idec->mem_; in RemapMemBuffer()
215 DoRemap(idec, mem->buf_ + mem->start_ - old_start); in RemapMemBuffer()
246 static VP8StatusCode FinishDecoding(WebPIDecoder* const idec) { in FinishDecoding() argument
247 const WebPDecoderOptions* const options = idec->params_.options; in FinishDecoding()
248 WebPDecBuffer* const output = idec->params_.output; in FinishDecoding()
250 idec->state_ = STATE_DONE; in FinishDecoding()
277 static VP8StatusCode IDecError(WebPIDecoder* const idec, VP8StatusCode error) { in IDecError() argument
278 if (idec->state_ == STATE_VP8_DATA) { in IDecError()
279 VP8Io* const io = &idec->io_; in IDecError()
284 idec->state_ = STATE_ERROR; in IDecError()
288 static void ChangeState(WebPIDecoder* const idec, DecState new_state, in ChangeState() argument
290 MemBuffer* const mem = &idec->mem_; in ChangeState()
291 idec->state_ = new_state; in ChangeState()
294 idec->io_.data = mem->buf_ + mem->start_; in ChangeState()
295 idec->io_.data_size = MemDataSize(mem); in ChangeState()
299 static VP8StatusCode DecodeWebPHeaders(WebPIDecoder* const idec) { in DecodeWebPHeaders() argument
300 MemBuffer* const mem = &idec->mem_; in DecodeWebPHeaders()
313 return IDecError(idec, status); in DecodeWebPHeaders()
316 idec->chunk_size_ = headers.compressed_size; in DecodeWebPHeaders()
317 idec->is_lossless_ = headers.is_lossless; in DecodeWebPHeaders()
318 if (!idec->is_lossless_) { in DecodeWebPHeaders()
323 idec->dec_ = dec; in DecodeWebPHeaders()
326 ChangeState(idec, STATE_VP8_HEADER, headers.offset); in DecodeWebPHeaders()
332 idec->dec_ = dec; in DecodeWebPHeaders()
333 ChangeState(idec, STATE_VP8L_HEADER, headers.offset); in DecodeWebPHeaders()
338 static VP8StatusCode DecodeVP8FrameHeader(WebPIDecoder* const idec) { in DecodeVP8FrameHeader() argument
339 const uint8_t* data = idec->mem_.buf_ + idec->mem_.start_; in DecodeVP8FrameHeader()
340 const size_t curr_size = MemDataSize(&idec->mem_); in DecodeVP8FrameHeader()
348 if (!VP8GetInfo(data, curr_size, idec->chunk_size_, &width, &height)) { in DecodeVP8FrameHeader()
349 return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR); in DecodeVP8FrameHeader()
353 idec->mem_.part0_size_ = (bits >> 5) + VP8_FRAME_HEADER_SIZE; in DecodeVP8FrameHeader()
355 idec->io_.data = data; in DecodeVP8FrameHeader()
356 idec->io_.data_size = curr_size; in DecodeVP8FrameHeader()
357 idec->state_ = STATE_VP8_PARTS0; in DecodeVP8FrameHeader()
362 static VP8StatusCode CopyParts0Data(WebPIDecoder* const idec) { in CopyParts0Data() argument
363 VP8Decoder* const dec = (VP8Decoder*)idec->dec_; in CopyParts0Data()
366 MemBuffer* const mem = &idec->mem_; in CopyParts0Data()
367 assert(!idec->is_lossless_); in CopyParts0Data()
390 static VP8StatusCode DecodePartition0(WebPIDecoder* const idec) { in DecodePartition0() argument
391 VP8Decoder* const dec = (VP8Decoder*)idec->dec_; in DecodePartition0()
392 VP8Io* const io = &idec->io_; in DecodePartition0()
393 const WebPDecParams* const params = &idec->params_; in DecodePartition0()
397 if (MemDataSize(&idec->mem_) < idec->mem_.part0_size_) { in DecodePartition0()
408 return IDecError(idec, status); in DecodePartition0()
415 return IDecError(idec, dec->status_); in DecodePartition0()
422 dec->status_ = CopyParts0Data(idec); in DecodePartition0()
424 return IDecError(idec, dec->status_); in DecodePartition0()
429 return IDecError(idec, dec->status_); in DecodePartition0()
434 idec->state_ = STATE_VP8_DATA; in DecodePartition0()
437 return IDecError(idec, dec->status_); in DecodePartition0()
443 static VP8StatusCode DecodeRemaining(WebPIDecoder* const idec) { in DecodeRemaining() argument
444 VP8Decoder* const dec = (VP8Decoder*)idec->dec_; in DecodeRemaining()
445 VP8Io* const io = &idec->io_; in DecodeRemaining()
449 if (idec->last_mb_y_ != dec->mb_y_) { in DecodeRemaining()
454 return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR); in DecodeRemaining()
456 idec->last_mb_y_ = dec->mb_y_; in DecodeRemaining()
465 if (dec->num_parts_ == 1 && MemDataSize(&idec->mem_) > MAX_MB_SIZE) { in DecodeRemaining()
466 return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR); in DecodeRemaining()
473 idec->mem_.start_ = token_br->buf_ - idec->mem_.buf_; in DecodeRemaining()
474 assert(idec->mem_.start_ <= idec->mem_.end_); in DecodeRemaining()
481 return IDecError(idec, VP8_STATUS_USER_ABORT); in DecodeRemaining()
486 return IDecError(idec, VP8_STATUS_USER_ABORT); in DecodeRemaining()
489 return FinishDecoding(idec); in DecodeRemaining()
492 static VP8StatusCode ErrorStatusLossless(WebPIDecoder* const idec, in ErrorStatusLossless() argument
497 return IDecError(idec, status); in ErrorStatusLossless()
500 static VP8StatusCode DecodeVP8LHeader(WebPIDecoder* const idec) { in DecodeVP8LHeader() argument
501 VP8Io* const io = &idec->io_; in DecodeVP8LHeader()
502 VP8LDecoder* const dec = (VP8LDecoder*)idec->dec_; in DecodeVP8LHeader()
503 const WebPDecParams* const params = &idec->params_; in DecodeVP8LHeader()
505 size_t curr_size = MemDataSize(&idec->mem_); in DecodeVP8LHeader()
506 assert(idec->is_lossless_); in DecodeVP8LHeader()
509 if (curr_size < (idec->chunk_size_ >> 3)) { in DecodeVP8LHeader()
511 return ErrorStatusLossless(idec, dec->status_); in DecodeVP8LHeader()
516 curr_size < idec->chunk_size_) { in DecodeVP8LHeader()
519 return ErrorStatusLossless(idec, dec->status_); in DecodeVP8LHeader()
525 return IDecError(idec, dec->status_); in DecodeVP8LHeader()
528 idec->state_ = STATE_VP8L_DATA; in DecodeVP8LHeader()
532 static VP8StatusCode DecodeVP8LData(WebPIDecoder* const idec) { in DecodeVP8LData() argument
533 VP8LDecoder* const dec = (VP8LDecoder*)idec->dec_; in DecodeVP8LData()
534 const size_t curr_size = MemDataSize(&idec->mem_); in DecodeVP8LData()
535 assert(idec->is_lossless_); in DecodeVP8LData()
538 dec->incremental_ = (curr_size < idec->chunk_size_); in DecodeVP8LData()
541 return ErrorStatusLossless(idec, dec->status_); in DecodeVP8LData()
545 : FinishDecoding(idec); in DecodeVP8LData()
549 static VP8StatusCode IDecode(WebPIDecoder* idec) { in IDecode() argument
552 if (idec->state_ == STATE_WEBP_HEADER) { in IDecode()
553 status = DecodeWebPHeaders(idec); in IDecode()
555 if (idec->dec_ == NULL) { in IDecode()
559 if (idec->state_ == STATE_VP8_HEADER) { in IDecode()
560 status = DecodeVP8FrameHeader(idec); in IDecode()
562 if (idec->state_ == STATE_VP8_PARTS0) { in IDecode()
563 status = DecodePartition0(idec); in IDecode()
565 if (idec->state_ == STATE_VP8_DATA) { in IDecode()
566 status = DecodeRemaining(idec); in IDecode()
568 if (idec->state_ == STATE_VP8L_HEADER) { in IDecode()
569 status = DecodeVP8LHeader(idec); in IDecode()
571 if (idec->state_ == STATE_VP8L_DATA) { in IDecode()
572 status = DecodeVP8LData(idec); in IDecode()
581 WebPIDecoder* idec = (WebPIDecoder*)WebPSafeCalloc(1ULL, sizeof(*idec)); in WebPINewDecoder() local
582 if (idec == NULL) { in WebPINewDecoder()
586 idec->state_ = STATE_WEBP_HEADER; in WebPINewDecoder()
587 idec->chunk_size_ = 0; in WebPINewDecoder()
589 idec->last_mb_y_ = -1; in WebPINewDecoder()
591 InitMemBuffer(&idec->mem_); in WebPINewDecoder()
592 WebPInitDecBuffer(&idec->output_); in WebPINewDecoder()
593 VP8InitIo(&idec->io_); in WebPINewDecoder()
595 WebPResetDecParams(&idec->params_); in WebPINewDecoder()
596 idec->params_.output = (output_buffer != NULL) ? output_buffer in WebPINewDecoder()
597 : &idec->output_; in WebPINewDecoder()
598 WebPInitCustomIo(&idec->params_, &idec->io_); // Plug the I/O functions. in WebPINewDecoder()
600 return idec; in WebPINewDecoder()
605 WebPIDecoder* idec; in WebPIDecode() local
614 idec = WebPINewDecoder(config ? &config->output : NULL); in WebPIDecode()
615 if (idec == NULL) { in WebPIDecode()
620 idec->params_.options = &config->options; in WebPIDecode()
622 return idec; in WebPIDecode()
625 void WebPIDelete(WebPIDecoder* idec) { in WebPIDelete() argument
626 if (idec == NULL) return; in WebPIDelete()
627 if (idec->dec_ != NULL) { in WebPIDelete()
628 if (!idec->is_lossless_) { in WebPIDelete()
629 if (idec->state_ == STATE_VP8_DATA) { in WebPIDelete()
631 VP8ExitCritical((VP8Decoder*)idec->dec_, &idec->io_); in WebPIDelete()
633 VP8Delete((VP8Decoder*)idec->dec_); in WebPIDelete()
635 VP8LDelete((VP8LDecoder*)idec->dec_); in WebPIDelete()
638 ClearMemBuffer(&idec->mem_); in WebPIDelete()
639 WebPFreeDecBuffer(&idec->output_); in WebPIDelete()
640 WebPSafeFree(idec); in WebPIDelete()
649 WebPIDecoder* idec; in WebPINewRGB() local
660 idec = WebPINewDecoder(NULL); in WebPINewRGB()
661 if (idec == NULL) return NULL; in WebPINewRGB()
662 idec->output_.colorspace = mode; in WebPINewRGB()
663 idec->output_.is_external_memory = is_external_memory; in WebPINewRGB()
664 idec->output_.u.RGBA.rgba = output_buffer; in WebPINewRGB()
665 idec->output_.u.RGBA.stride = output_stride; in WebPINewRGB()
666 idec->output_.u.RGBA.size = output_buffer_size; in WebPINewRGB()
667 return idec; in WebPINewRGB()
675 WebPIDecoder* idec; in WebPINewYUVA() local
693 idec = WebPINewDecoder(NULL); in WebPINewYUVA()
694 if (idec == NULL) return NULL; in WebPINewYUVA()
696 idec->output_.colorspace = colorspace; in WebPINewYUVA()
697 idec->output_.is_external_memory = is_external_memory; in WebPINewYUVA()
698 idec->output_.u.YUVA.y = luma; in WebPINewYUVA()
699 idec->output_.u.YUVA.y_stride = luma_stride; in WebPINewYUVA()
700 idec->output_.u.YUVA.y_size = luma_size; in WebPINewYUVA()
701 idec->output_.u.YUVA.u = u; in WebPINewYUVA()
702 idec->output_.u.YUVA.u_stride = u_stride; in WebPINewYUVA()
703 idec->output_.u.YUVA.u_size = u_size; in WebPINewYUVA()
704 idec->output_.u.YUVA.v = v; in WebPINewYUVA()
705 idec->output_.u.YUVA.v_stride = v_stride; in WebPINewYUVA()
706 idec->output_.u.YUVA.v_size = v_size; in WebPINewYUVA()
707 idec->output_.u.YUVA.a = a; in WebPINewYUVA()
708 idec->output_.u.YUVA.a_stride = a_stride; in WebPINewYUVA()
709 idec->output_.u.YUVA.a_size = a_size; in WebPINewYUVA()
710 return idec; in WebPINewYUVA()
724 static VP8StatusCode IDecCheckStatus(const WebPIDecoder* const idec) { in IDecCheckStatus() argument
725 assert(idec); in IDecCheckStatus()
726 if (idec->state_ == STATE_ERROR) { in IDecCheckStatus()
729 if (idec->state_ == STATE_DONE) { in IDecCheckStatus()
735 VP8StatusCode WebPIAppend(WebPIDecoder* idec, in WebPIAppend() argument
738 if (idec == NULL || data == NULL) { in WebPIAppend()
741 status = IDecCheckStatus(idec); in WebPIAppend()
746 if (!CheckMemBufferMode(&idec->mem_, MEM_MODE_APPEND)) { in WebPIAppend()
750 if (!AppendToMemBuffer(idec, data, data_size)) { in WebPIAppend()
753 return IDecode(idec); in WebPIAppend()
756 VP8StatusCode WebPIUpdate(WebPIDecoder* idec, in WebPIUpdate() argument
759 if (idec == NULL || data == NULL) { in WebPIUpdate()
762 status = IDecCheckStatus(idec); in WebPIUpdate()
767 if (!CheckMemBufferMode(&idec->mem_, MEM_MODE_MAP)) { in WebPIUpdate()
771 if (!RemapMemBuffer(idec, data, data_size)) { in WebPIUpdate()
774 return IDecode(idec); in WebPIUpdate()
779 static const WebPDecBuffer* GetOutputBuffer(const WebPIDecoder* const idec) { in GetOutputBuffer() argument
780 if (idec == NULL || idec->dec_ == NULL) { in GetOutputBuffer()
783 if (idec->state_ <= STATE_VP8_PARTS0) { in GetOutputBuffer()
786 return idec->params_.output; in GetOutputBuffer()
789 const WebPDecBuffer* WebPIDecodedArea(const WebPIDecoder* idec, in WebPIDecodedArea() argument
792 const WebPDecBuffer* const src = GetOutputBuffer(idec); in WebPIDecodedArea()
797 if (height != NULL) *height = idec->params_.last_y; in WebPIDecodedArea()
805 uint8_t* WebPIDecGetRGB(const WebPIDecoder* idec, int* last_y, in WebPIDecGetRGB() argument
807 const WebPDecBuffer* const src = GetOutputBuffer(idec); in WebPIDecGetRGB()
813 if (last_y != NULL) *last_y = idec->params_.last_y; in WebPIDecGetRGB()
821 uint8_t* WebPIDecGetYUVA(const WebPIDecoder* idec, int* last_y, in WebPIDecGetYUVA() argument
825 const WebPDecBuffer* const src = GetOutputBuffer(idec); in WebPIDecGetYUVA()
831 if (last_y != NULL) *last_y = idec->params_.last_y; in WebPIDecGetYUVA()
844 int WebPISetIOHooks(WebPIDecoder* const idec, in WebPISetIOHooks() argument
849 if (idec == NULL || idec->state_ > STATE_WEBP_HEADER) { in WebPISetIOHooks()
853 idec->io_.put = put; in WebPISetIOHooks()
854 idec->io_.setup = setup; in WebPISetIOHooks()
855 idec->io_.teardown = teardown; in WebPISetIOHooks()
856 idec->io_.opaque = user_data; in WebPISetIOHooks()