add lossless incremental decoding support

* We don't need to change DecodeAlpha, since incremental
decoding is not useful for Alpha (we already decode
progressively along the RGB)
* Similarly, we don't do incremental decoding for level>0 planes:
   the metadata don't turn into visible pixel (only the ones in level0), so...
(No visible speed change)

Change-Id: I2fd4b9ba227561a7dbede647686584b752be7baa
This commit is contained in:
Pascal Massimino
2014-09-24 09:38:52 +02:00
parent d4471637ef
commit f060dfc422
5 changed files with 96 additions and 39 deletions

View File

@ -13,6 +13,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "./color_cache.h"
#include "../utils/utils.h"
@ -27,6 +28,7 @@ int VP8LColorCacheInit(VP8LColorCache* const cc, int hash_bits) {
sizeof(*cc->colors_));
if (cc->colors_ == NULL) return 0;
cc->hash_shift_ = 32 - hash_bits;
cc->hash_bits_ = hash_bits;
return 1;
}
@ -37,3 +39,11 @@ void VP8LColorCacheClear(VP8LColorCache* const cc) {
}
}
void VP8LColorCacheCopy(const VP8LColorCache* const src,
VP8LColorCache* const dst) {
assert(src != NULL);
assert(dst != NULL);
assert(src->hash_bits_ == dst->hash_bits_);
memcpy(dst->colors_, src->colors_,
(1 << dst->hash_bits_) * sizeof(*dst->colors_));
}

View File

@ -24,7 +24,8 @@ extern "C" {
// Main color cache struct.
typedef struct {
uint32_t *colors_; // color entries
int hash_shift_; // Hash shift: 32 - hash_bits.
int hash_shift_; // Hash shift: 32 - hash_bits_.
int hash_bits_;
} VP8LColorCache;
static const uint32_t kHashMul = 0x1e35a7bd;
@ -58,6 +59,9 @@ static WEBP_INLINE int VP8LColorCacheContains(const VP8LColorCache* const cc,
// Returns false in case of memory error.
int VP8LColorCacheInit(VP8LColorCache* const color_cache, int hash_bits);
void VP8LColorCacheCopy(const VP8LColorCache* const src,
VP8LColorCache* const dst);
// Delete the memory associated to color cache.
void VP8LColorCacheClear(VP8LColorCache* const color_cache);