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

@ -9,6 +9,7 @@
//
// Author: Skal (pascal.massimino@gmail.com)
#include <assert.h>
#include <stdlib.h>
#include "vp8enci.h"
@ -72,19 +73,29 @@ static int CompressAlpha(const uint8_t* data, size_t data_size,
#endif /* WEBP_EXPERIMENTAL_FEATURES */
int VP8EncProcessAlpha(VP8Encoder* enc) {
void VP8EncInitAlpha(VP8Encoder* enc) {
enc->has_alpha_ = (enc->pic_->a != NULL);
enc->alpha_data_ = NULL;
enc->alpha_data_size_ = 0;
}
void VP8EncCodeAlphaBlock(VP8EncIterator* it) {
(void)it;
// Nothing for now. We just ZLIB-compress in the end.
}
int VP8EncFinishAlpha(VP8Encoder* enc) {
if (enc->has_alpha_) {
#ifdef WEBP_EXPERIMENTAL_FEATURES
if (enc->pic_->a) {
const WebPPicture* pic = enc->pic_;
assert(pic->a);
if (!CompressAlpha(pic->a, pic->width * pic->height,
&enc->alpha_data_, &enc->alpha_data_size_,
enc->config_->alpha_compression)) {
return 0;
}
#endif
}
#endif /* WEBP_EXPERIMENTAL_FEATURES */
return 1;
}
@ -92,6 +103,7 @@ void VP8EncDeleteAlpha(VP8Encoder* enc) {
free(enc->alpha_data_);
enc->alpha_data_ = NULL;
enc->alpha_data_size_ = 0;
enc->has_alpha_ = 0;
}
#if defined(__cplusplus) || defined(c_plusplus)