Decoder: handle fragments case correctly too.

Exit early from ParseHeaderInternal() in case of fragmented image too.

Change-Id: I3e24be2c869cc2d87c43b705257f21be81127dbd
This commit is contained in:
Urvang Joshi 2013-07-18 19:04:54 -07:00
parent faa4b07eda
commit 6df743a33e

View File

@ -313,12 +313,14 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
{ {
uint32_t flags = 0; uint32_t flags = 0;
int animation_present; int animation_present;
int fragments_present;
status = ParseVP8X(&data, &data_size, &found_vp8x, status = ParseVP8X(&data, &data_size, &found_vp8x,
&canvas_width, &canvas_height, &flags); &canvas_width, &canvas_height, &flags);
if (status != VP8_STATUS_OK) { if (status != VP8_STATUS_OK) {
return status; // Wrong VP8X / insufficient data. return status; // Wrong VP8X / insufficient data.
} }
animation_present = !!(flags & ANIMATION_FLAG); animation_present = !!(flags & ANIMATION_FLAG);
fragments_present = !!(flags & FRAGMENTS_FLAG);
if (!found_riff && found_vp8x) { if (!found_riff && found_vp8x) {
// Note: This restriction may be removed in the future, if it becomes // Note: This restriction may be removed in the future, if it becomes
// necessary to send VP8X chunk to the decoder. // necessary to send VP8X chunk to the decoder.
@ -327,7 +329,8 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
if (has_alpha != NULL) *has_alpha = !!(flags & ALPHA_FLAG); if (has_alpha != NULL) *has_alpha = !!(flags & ALPHA_FLAG);
if (has_animation != NULL) *has_animation = animation_present; if (has_animation != NULL) *has_animation = animation_present;
if (found_vp8x && animation_present && headers == NULL) { if (found_vp8x && (animation_present || fragments_present) &&
headers == NULL) {
if (width != NULL) *width = canvas_width; if (width != NULL) *width = canvas_width;
if (height != NULL) *height = canvas_height; if (height != NULL) *height = canvas_height;
return VP8_STATUS_OK; // Just return features from VP8X header. return VP8_STATUS_OK; // Just return features from VP8X header.
@ -374,7 +377,7 @@ static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
return VP8_STATUS_BITSTREAM_ERROR; return VP8_STATUS_BITSTREAM_ERROR;
} }
} }
// Validates image size coherency. TODO(urvang): what about FRGM? // Validates image size coherency.
if (found_vp8x) { if (found_vp8x) {
if (canvas_width != image_width || canvas_height != image_height) { if (canvas_width != image_width || canvas_height != image_height) {
return VP8_STATUS_BITSTREAM_ERROR; return VP8_STATUS_BITSTREAM_ERROR;