webpinfo: handle alpha flag mismatch

Throw a warning for false positive vp8x alpha flag;
throw an error for false negative vp8x alpha flag.

BUG=webp:330

Change-Id: I3933588c9d6d76ecaf515517f7506dea299af638
This commit is contained in:
hui su 2017-05-23 10:25:38 -07:00
parent 7caef29b86
commit af6deaffa0

View File

@ -998,6 +998,14 @@ static WebPInfoStatus Validate(const WebPInfo* const webp_info) {
const int exif = !!(webp_info->feature_flags_ & EXIF_FLAG);
const int xmp = !!(webp_info->feature_flags_ & XMP_FLAG);
const int animation = !!(webp_info->feature_flags_ & ANIMATION_FLAG);
const int alpha = !!(webp_info->feature_flags_ & ALPHA_FLAG);
if (!alpha && webp_info->has_alpha_) {
LOG_ERROR("Unexpected alpha data detected.");
return WEBP_INFO_PARSE_ERROR;
}
if (alpha && !webp_info->has_alpha_) {
LOG_WARN("Alpha flag is set with no alpha data present.");
}
if (iccp && !webp_info->chunk_counts_[CHUNK_ICCP]) {
LOG_ERROR("Missing ICCP chunk.");
return WEBP_INFO_MISSING_DATA;