remove absolute_delta_ field and syntax code

we'll always encode using absolute value, not relative ones.
    Both methods use the same number of bits, so we'll go for the
    simpler and most robust one.
    + add some extra checks about pic->u/v being NULL.

Change-Id: I98ea01a1a6b133ab3c816c0fbc50e18269bd2098
This commit is contained in:
Pascal Massimino 2011-02-27 10:22:54 -08:00
parent 0744e8420e
commit b65a3e101e
3 changed files with 7 additions and 20 deletions

View File

@ -86,24 +86,13 @@ static void PutSegmentHeader(VP8BitWriter* const bw,
int s;
VP8PutBitUniform(bw, hdr->update_map_);
if (VP8PutBitUniform(bw, update_data)) {
const int base_quant = enc->base_quant_;
const int base_strength = enc->filter_hdr_.level_;
VP8PutBitUniform(bw, hdr->absolute_delta_);
// we always use absolute values, not relative ones
VP8PutBitUniform(bw, 1); // (segment_feature_mode = 1. Paragraph 9.3.)
for (s = 0; s < NUM_MB_SEGMENTS; ++s) {
if (hdr->absolute_delta_) {
VP8PutSignedValue(bw, enc->dqm_[s].quant_, 7);
} else {
const int delta = enc->dqm_[s].quant_ - base_quant;
VP8PutSignedValue(bw, delta, 7);
}
VP8PutSignedValue(bw, enc->dqm_[s].quant_, 7);
}
for (s = 0; s < NUM_MB_SEGMENTS; ++s) {
if (hdr->absolute_delta_) {
VP8PutSignedValue(bw, enc->dqm_[s].fstrength_, 6);
} else {
const int delta = enc->dqm_[s].fstrength_ - base_strength;
VP8PutSignedValue(bw, delta, 6);
}
VP8PutSignedValue(bw, enc->dqm_[s].fstrength_, 6);
}
}
if (hdr->update_map_) {

View File

@ -159,9 +159,6 @@ typedef struct {
int num_segments_; // Actual number of segments. 1 segment only = unused.
int update_map_; // whether to update the segment map or not.
// must be 0 if there's only 1 segment.
int absolute_delta_; // if true, segments' filter strength and quantizers
// are not transmitted relatively to
// VP8FilterHeader::level_ and base_quant_
int size_; // bit-cost for transmitting the segment map
} VP8SegmentHeader;

View File

@ -55,7 +55,6 @@ static void ResetSegmentHeader(VP8Encoder* const enc) {
VP8SegmentHeader* const hdr = &enc->segment_hdr_;
hdr->num_segments_ = enc->config_->segments;
hdr->update_map_ = (hdr->num_segments_ > 1);
hdr->absolute_delta_ = 1;
hdr->size_ = 0;
}
@ -285,7 +284,9 @@ int WebPEncode(const WebPConfig* const config, WebPPicture* const pic) {
return 0; // bad params
if (!WebPValidateConfig(config))
return 0; // invalid config.
if (pic->width <= 0 || pic->height <= 0 || pic->y == NULL)
if (pic->width <= 0 || pic->height <= 0)
return 0; // invalid parameters
if (pic->y == NULL || pic->u == NULL || pic->v == NULL)
return 0; // invalid parameters
if (pic->width >= MAX_DIMENSION || pic->height >= MAX_DIMENSION)
return 0; // image is too big