| OLD | NEW |
| 1 // Copyright 2010 Google Inc. All Rights Reserved. | 1 // Copyright 2010 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
| 4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
| 5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
| 8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 9 // | 9 // |
| 10 // Frame-reconstruction function. Memory allocation. | 10 // Frame-reconstruction function. Memory allocation. |
| 11 // | 11 // |
| 12 // Author: Skal (pascal.massimino@gmail.com) | 12 // Author: Skal (pascal.massimino@gmail.com) |
| 13 | 13 |
| 14 #include <stdlib.h> | 14 #include <stdlib.h> |
| 15 #include "./vp8i.h" | 15 #include "./vp8i_dec.h" |
| 16 #include "../utils/utils.h" | 16 #include "../utils/utils.h" |
| 17 | 17 |
| 18 //------------------------------------------------------------------------------ | 18 //------------------------------------------------------------------------------ |
| 19 // Main reconstruction function. | 19 // Main reconstruction function. |
| 20 | 20 |
| 21 static const int kScan[16] = { | 21 static const int kScan[16] = { |
| 22 0 + 0 * BPS, 4 + 0 * BPS, 8 + 0 * BPS, 12 + 0 * BPS, | 22 0 + 0 * BPS, 4 + 0 * BPS, 8 + 0 * BPS, 12 + 0 * BPS, |
| 23 0 + 4 * BPS, 4 + 4 * BPS, 8 + 4 * BPS, 12 + 4 * BPS, | 23 0 + 4 * BPS, 4 + 4 * BPS, 8 + 4 * BPS, 12 + 4 * BPS, |
| 24 0 + 8 * BPS, 4 + 8 * BPS, 8 + 8 * BPS, 12 + 8 * BPS, | 24 0 + 8 * BPS, 4 + 8 * BPS, 8 + 8 * BPS, 12 + 8 * BPS, |
| 25 0 + 12 * BPS, 4 + 12 * BPS, 8 + 12 * BPS, 12 + 12 * BPS | 25 0 + 12 * BPS, 4 + 12 * BPS, 8 + 12 * BPS, 12 + 12 * BPS |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 | 716 |
| 717 if (needed != (size_t)needed) return 0; // check for overflow | 717 if (needed != (size_t)needed) return 0; // check for overflow |
| 718 if (needed > dec->mem_size_) { | 718 if (needed > dec->mem_size_) { |
| 719 WebPSafeFree(dec->mem_); | 719 WebPSafeFree(dec->mem_); |
| 720 dec->mem_size_ = 0; | 720 dec->mem_size_ = 0; |
| 721 dec->mem_ = WebPSafeMalloc(needed, sizeof(uint8_t)); | 721 dec->mem_ = WebPSafeMalloc(needed, sizeof(uint8_t)); |
| 722 if (dec->mem_ == NULL) { | 722 if (dec->mem_ == NULL) { |
| 723 return VP8SetError(dec, VP8_STATUS_OUT_OF_MEMORY, | 723 return VP8SetError(dec, VP8_STATUS_OUT_OF_MEMORY, |
| 724 "no memory during frame initialization."); | 724 "no memory during frame initialization."); |
| 725 } | 725 } |
| 726 // down-cast is ok, thanks to WebPSafeAlloc() above. | 726 // down-cast is ok, thanks to WebPSafeMalloc() above. |
| 727 dec->mem_size_ = (size_t)needed; | 727 dec->mem_size_ = (size_t)needed; |
| 728 } | 728 } |
| 729 | 729 |
| 730 mem = (uint8_t*)dec->mem_; | 730 mem = (uint8_t*)dec->mem_; |
| 731 dec->intra_t_ = (uint8_t*)mem; | 731 dec->intra_t_ = (uint8_t*)mem; |
| 732 mem += intra_pred_mode_size; | 732 mem += intra_pred_mode_size; |
| 733 | 733 |
| 734 dec->yuv_t_ = (VP8TopSamples*)mem; | 734 dec->yuv_t_ = (VP8TopSamples*)mem; |
| 735 mem += top_size; | 735 mem += top_size; |
| 736 | 736 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 | 803 |
| 804 int VP8InitFrame(VP8Decoder* const dec, VP8Io* const io) { | 804 int VP8InitFrame(VP8Decoder* const dec, VP8Io* const io) { |
| 805 if (!InitThreadContext(dec)) return 0; // call first. Sets dec->num_caches_. | 805 if (!InitThreadContext(dec)) return 0; // call first. Sets dec->num_caches_. |
| 806 if (!AllocateMemory(dec)) return 0; | 806 if (!AllocateMemory(dec)) return 0; |
| 807 InitIo(dec, io); | 807 InitIo(dec, io); |
| 808 VP8DspInit(); // Init critical function pointers and look-up tables. | 808 VP8DspInit(); // Init critical function pointers and look-up tables. |
| 809 return 1; | 809 return 1; |
| 810 } | 810 } |
| 811 | 811 |
| 812 //------------------------------------------------------------------------------ | 812 //------------------------------------------------------------------------------ |
| OLD | NEW |