Support for "Do not blend" in mux and demux libraries

Change-Id: I9566a8e2d059fe1ebd9ca99c7e13311bf3f8f281
This commit is contained in:
Urvang Joshi
2013-08-09 14:09:31 -07:00
parent f486aaa9f8
commit 6284854bd5
7 changed files with 39 additions and 9 deletions

View File

@ -116,7 +116,9 @@ static WebPMuxError CreateFrameFragmentData(
PutLE24(frame_frgm_bytes + 6, width - 1);
PutLE24(frame_frgm_bytes + 9, height - 1);
PutLE24(frame_frgm_bytes + 12, info->duration);
frame_frgm_bytes[15] = (info->dispose_method & 1);
frame_frgm_bytes[15] =
(info->blend_method == WEBP_MUX_NO_BLEND ? 2 : 0) |
(info->dispose_method == WEBP_MUX_DISPOSE_BACKGROUND ? 1 : 0);
}
frame_frgm->bytes = frame_frgm_bytes;
@ -310,7 +312,8 @@ WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame,
tmp.y_offset &= ~1;
if (!is_frame) { // Reset unused values.
tmp.duration = 1;
tmp.dispose_method = 0;
tmp.dispose_method = WEBP_MUX_DISPOSE_NONE;
tmp.blend_method = WEBP_MUX_BLEND;
}
if (tmp.x_offset < 0 || tmp.x_offset >= MAX_POSITION_OFFSET ||
tmp.y_offset < 0 || tmp.y_offset >= MAX_POSITION_OFFSET ||

View File

@ -426,6 +426,8 @@ static WebPMuxError MuxGetImageInternal(const WebPMuxImage* const wpi,
info->x_offset = 0;
info->y_offset = 0;
info->duration = 1;
info->dispose_method = WEBP_MUX_DISPOSE_NONE;
info->blend_method = WEBP_MUX_BLEND;
// Extract data for related fields.
info->id = ChunkGetIdFromTag(wpi->img_->tag_);
return SynthesizeBitstream(wpi, &info->bitstream);
@ -446,10 +448,17 @@ static WebPMuxError MuxGetFrameFragmentInternal(const WebPMuxImage* const wpi,
// Extract info.
frame->x_offset = 2 * GetLE24(frame_frgm_data->bytes + 0);
frame->y_offset = 2 * GetLE24(frame_frgm_data->bytes + 3);
frame->duration = is_frame ? GetLE24(frame_frgm_data->bytes + 12) : 1;
frame->dispose_method =
is_frame ? (WebPMuxAnimDispose)(frame_frgm_data->bytes[15] & 1)
: WEBP_MUX_DISPOSE_NONE;
if (is_frame) {
const uint8_t bits = frame_frgm_data->bytes[15];
frame->duration = GetLE24(frame_frgm_data->bytes + 12);
frame->dispose_method =
(bits & 1) ? WEBP_MUX_DISPOSE_BACKGROUND : WEBP_MUX_DISPOSE_NONE;
frame->blend_method = (bits & 2) ? WEBP_MUX_NO_BLEND : WEBP_MUX_BLEND;
} else { // Defaults for unused values.
frame->duration = 1;
frame->dispose_method = WEBP_MUX_DISPOSE_NONE;
frame->blend_method = WEBP_MUX_BLEND;
}
frame->id = ChunkGetIdFromTag(wpi->header_->tag_);
return SynthesizeBitstream(wpi, &frame->bitstream);
}