Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: third_party/libwebp/dec/idec.c

Issue 12942006: libwebp: update snapshot to v0.3.0-rc6 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: local webkit layout expectations Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 Google Inc. All Rights Reserved. 1 // Copyright 2011 Google Inc. All Rights Reserved.
2 // 2 //
3 // This code is licensed under the same terms as WebM: 3 // This code is licensed under the same terms as WebM:
4 // Software License Agreement: http://www.webmproject.org/license/software/ 4 // Software License Agreement: http://www.webmproject.org/license/software/
5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/
6 // ----------------------------------------------------------------------------- 6 // -----------------------------------------------------------------------------
7 // 7 //
8 // Incremental decoding 8 // Incremental decoding
9 // 9 //
10 // Author: somnath@google.com (Somnath Banerjee) 10 // Author: somnath@google.com (Somnath Banerjee)
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 SaveContext(dec, token_br, &context); 418 SaveContext(dec, token_br, &context);
419 419
420 if (!VP8DecodeMB(dec, token_br)) { 420 if (!VP8DecodeMB(dec, token_br)) {
421 RestoreContext(&context, dec, token_br); 421 RestoreContext(&context, dec, token_br);
422 // We shouldn't fail when MAX_MB data was available 422 // We shouldn't fail when MAX_MB data was available
423 if (dec->num_parts_ == 1 && MemDataSize(&idec->mem_) > MAX_MB_SIZE) { 423 if (dec->num_parts_ == 1 && MemDataSize(&idec->mem_) > MAX_MB_SIZE) {
424 return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR); 424 return IDecError(idec, VP8_STATUS_BITSTREAM_ERROR);
425 } 425 }
426 return VP8_STATUS_SUSPENDED; 426 return VP8_STATUS_SUSPENDED;
427 } 427 }
428 // Reconstruct and emit samples.
428 VP8ReconstructBlock(dec); 429 VP8ReconstructBlock(dec);
429 // Store data and save block's filtering params
430 VP8StoreBlock(dec);
431 430
432 // Release buffer only if there is only one partition 431 // Release buffer only if there is only one partition
433 if (dec->num_parts_ == 1) { 432 if (dec->num_parts_ == 1) {
434 idec->mem_.start_ = token_br->buf_ - idec->mem_.buf_; 433 idec->mem_.start_ = token_br->buf_ - idec->mem_.buf_;
435 assert(idec->mem_.start_ <= idec->mem_.end_); 434 assert(idec->mem_.start_ <= idec->mem_.end_);
436 } 435 }
437 } 436 }
438 if (!VP8ProcessRow(dec, io)) { 437 if (!VP8ProcessRow(dec, io)) {
439 return IDecError(idec, VP8_STATUS_USER_ABORT); 438 return IDecError(idec, VP8_STATUS_USER_ABORT);
440 } 439 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 ClearMemBuffer(&idec->mem_); 588 ClearMemBuffer(&idec->mem_);
590 WebPFreeDecBuffer(&idec->output_); 589 WebPFreeDecBuffer(&idec->output_);
591 free(idec); 590 free(idec);
592 } 591 }
593 592
594 //------------------------------------------------------------------------------ 593 //------------------------------------------------------------------------------
595 // Wrapper toward WebPINewDecoder 594 // Wrapper toward WebPINewDecoder
596 595
597 WebPIDecoder* WebPINewRGB(WEBP_CSP_MODE mode, uint8_t* output_buffer, 596 WebPIDecoder* WebPINewRGB(WEBP_CSP_MODE mode, uint8_t* output_buffer,
598 size_t output_buffer_size, int output_stride) { 597 size_t output_buffer_size, int output_stride) {
598 const int is_external_memory = (output_buffer != NULL);
599 WebPIDecoder* idec; 599 WebPIDecoder* idec;
600
600 if (mode >= MODE_YUV) return NULL; 601 if (mode >= MODE_YUV) return NULL;
602 if (!is_external_memory) { // Overwrite parameters to sane values.
603 output_buffer_size = 0;
604 output_stride = 0;
605 } else { // A buffer was passed. Validate the other params.
606 if (output_stride == 0 || output_buffer_size == 0) {
607 return NULL; // invalid parameter.
608 }
609 }
601 idec = WebPINewDecoder(NULL); 610 idec = WebPINewDecoder(NULL);
602 if (idec == NULL) return NULL; 611 if (idec == NULL) return NULL;
603 idec->output_.colorspace = mode; 612 idec->output_.colorspace = mode;
604 idec->output_.is_external_memory = 1; 613 idec->output_.is_external_memory = is_external_memory;
605 idec->output_.u.RGBA.rgba = output_buffer; 614 idec->output_.u.RGBA.rgba = output_buffer;
606 idec->output_.u.RGBA.stride = output_stride; 615 idec->output_.u.RGBA.stride = output_stride;
607 idec->output_.u.RGBA.size = output_buffer_size; 616 idec->output_.u.RGBA.size = output_buffer_size;
608 return idec; 617 return idec;
609 } 618 }
610 619
611 WebPIDecoder* WebPINewYUVA(uint8_t* luma, size_t luma_size, int luma_stride, 620 WebPIDecoder* WebPINewYUVA(uint8_t* luma, size_t luma_size, int luma_stride,
612 uint8_t* u, size_t u_size, int u_stride, 621 uint8_t* u, size_t u_size, int u_stride,
613 uint8_t* v, size_t v_size, int v_stride, 622 uint8_t* v, size_t v_size, int v_stride,
614 uint8_t* a, size_t a_size, int a_stride) { 623 uint8_t* a, size_t a_size, int a_stride) {
615 WebPIDecoder* const idec = WebPINewDecoder(NULL); 624 const int is_external_memory = (luma != NULL);
625 WebPIDecoder* idec;
626 WEBP_CSP_MODE colorspace;
627
628 if (!is_external_memory) { // Overwrite parameters to sane values.
fbarchard 2013/03/22 18:56:44 2 spaces before //
jzern 2013/03/22 19:10:36 minimum. horizontal whitespace is allowed if it ad
629 luma_size = u_size = v_size = a_size = 0;
630 luma_stride = u_stride = v_stride = a_stride = 0;
631 u = v = a = NULL;
632 colorspace = MODE_YUVA;
fbarchard 2013/03/22 18:56:44 planar YUV with alpha? i may want to support this
jzern 2013/03/22 19:10:36 Just a full plane (WxH) of alpha [0, 255] here
633 } else { // A luma buffer was passed. Validate the other parameters.
634 if (u == NULL || v == NULL) return NULL;
635 if (luma_size == 0 || u_size == 0 || v_size == 0) return NULL;
636 if (luma_stride == 0 || u_stride == 0 || v_stride == 0) return NULL;
637 if (a != NULL) {
638 if (a_size == 0 || a_stride == 0) return NULL;
639 }
640 colorspace = (a == NULL) ? MODE_YUV : MODE_YUVA;
641 }
642
643 idec = WebPINewDecoder(NULL);
616 if (idec == NULL) return NULL; 644 if (idec == NULL) return NULL;
617 idec->output_.colorspace = (a == NULL) ? MODE_YUV : MODE_YUVA; 645
618 idec->output_.is_external_memory = 1; 646 idec->output_.colorspace = colorspace;
647 idec->output_.is_external_memory = is_external_memory;
619 idec->output_.u.YUVA.y = luma; 648 idec->output_.u.YUVA.y = luma;
620 idec->output_.u.YUVA.y_stride = luma_stride; 649 idec->output_.u.YUVA.y_stride = luma_stride;
621 idec->output_.u.YUVA.y_size = luma_size; 650 idec->output_.u.YUVA.y_size = luma_size;
622 idec->output_.u.YUVA.u = u; 651 idec->output_.u.YUVA.u = u;
623 idec->output_.u.YUVA.u_stride = u_stride; 652 idec->output_.u.YUVA.u_stride = u_stride;
624 idec->output_.u.YUVA.u_size = u_size; 653 idec->output_.u.YUVA.u_size = u_size;
625 idec->output_.u.YUVA.v = v; 654 idec->output_.u.YUVA.v = v;
626 idec->output_.u.YUVA.v_stride = v_stride; 655 idec->output_.u.YUVA.v_stride = v_stride;
627 idec->output_.u.YUVA.v_size = v_size; 656 idec->output_.u.YUVA.v_size = v_size;
628 idec->output_.u.YUVA.a = a; 657 idec->output_.u.YUVA.a = a;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 idec->io_.setup = setup; 805 idec->io_.setup = setup;
777 idec->io_.teardown = teardown; 806 idec->io_.teardown = teardown;
778 idec->io_.opaque = user_data; 807 idec->io_.opaque = user_data;
779 808
780 return 1; 809 return 1;
781 } 810 }
782 811
783 #if defined(__cplusplus) || defined(c_plusplus) 812 #if defined(__cplusplus) || defined(c_plusplus)
784 } // extern "C" 813 } // extern "C"
785 #endif 814 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698