prepare experimentation with yuv444 / 422

+ add a simple rescaling function: WebPPictureRescale() for encoding
+ clean-up the memory managment around the alpha plane
+ fix some includes path by using "../webp/xxx.h" instead of "webp/xxx.h"

New flags for 'cwebp':
 -resize <width> <height>
 -444  (no effect)
 -422  (no effect)
 -400

Change-Id: I25a95f901493f939c2dd789e658493b83bd1abfa
This commit is contained in:
Pascal Massimino
2011-05-02 17:19:00 -07:00
parent 79cc49f5eb
commit 6d0e66c23e
25 changed files with 658 additions and 132 deletions

View File

@ -375,26 +375,30 @@ int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
#ifdef WEBP_EXPERIMENTAL_FEATURES
// Extensions
if (dec->pic_hdr_.colorspace_) {
const uint32_t EXT_SIZE = 4;
uint32_t ext_size;
uint8_t ext_bits;
const uint8_t* ext_bytes_end = buf - EXT_SIZE;
if (frm_hdr->partition_length_ <= EXT_SIZE) {
const size_t kTrailerSize = 8;
const uint8_t kTrailerMarker = 0x01;
uint8_t* const ext_buf = buf - kTrailerSize;
size_t size;
if (frm_hdr->partition_length_ < kTrailerSize ||
ext_buf[kTrailerSize - 1] != kTrailerMarker) {
Error:
return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
"RIFF: Inconsistent extra information.");
}
ext_size = (ext_bytes_end[0] << 16) | (ext_bytes_end[1] << 8)
| (ext_bytes_end[2]);
ext_bits = ext_bytes_end[3];
ext_bytes_end -= ext_size;
if (!(ext_bits & 0x01) || (ext_size + EXT_SIZE > frm_hdr->partition_length_)) {
return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
"RIFF: Inconsistent extra information.");
}
if (!!(ext_bits & 0x02)) { // has alpha data
dec->alpha_data_size_ = ext_size;
dec->alpha_data_ = ext_bytes_end;
// Alpha
size = (ext_buf[4] << 0) | (ext_buf[5] << 8) | (ext_buf[6] << 16);
if (frm_hdr->partition_length_ < size + kTrailerSize) {
goto Error;
}
dec->alpha_data_ = (size > 0) ? ext_buf - size : NULL;
dec->alpha_data_size_ = size;
// Layer
size = (ext_buf[0] << 0) | (ext_buf[1] << 8) | (ext_buf[2] << 16);
dec->layer_data_size_ = size;
dec->layer_data_ = NULL; // will be set later
dec->layer_colorspace_ = ext_buf[3];
}
#endif
@ -651,6 +655,14 @@ static int ParseFrame(VP8Decoder* const dec, VP8Io* io) {
}
#endif
#ifdef WEBP_EXPERIMENTAL_FEATURES
if (dec->layer_data_size_ > 0) {
if (!VP8DecodeLayer(dec)) {
return 0;
}
}
#endif
return 1;
}