Rename some chunks:

TILE --> FRGM and FRM --> ANMF

Change-Id: I752f90b950413501aecb021a8f57882da0e01484
This commit is contained in:
Urvang Joshi 2012-10-30 12:14:10 -07:00
parent 3bb4bbeb60
commit 92f8059ce4
8 changed files with 54 additions and 54 deletions

View File

@ -191,7 +191,7 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
if ((flag & ANIMATION_FLAG) || (flag & TILE_FLAG)) { if ((flag & ANIMATION_FLAG) || (flag & TILE_FLAG)) {
const int is_anim = !!(flag & ANIMATION_FLAG); const int is_anim = !!(flag & ANIMATION_FLAG);
const WebPChunkId id = is_anim ? WEBP_CHUNK_FRAME : WEBP_CHUNK_TILE; const WebPChunkId id = is_anim ? WEBP_CHUNK_ANMF : WEBP_CHUNK_FRGM;
const char* const type_str = is_anim ? "frame" : "tile"; const char* const type_str = is_anim ? "frame" : "tile";
int nFrames; int nFrames;
@ -684,7 +684,7 @@ static int GetFrameTile(const WebPMux* mux,
WebPMux* mux_single = NULL; WebPMux* mux_single = NULL;
long num = 0; long num = 0;
int ok = 1; int ok = 1;
const WebPChunkId id = isFrame ? WEBP_CHUNK_FRAME : WEBP_CHUNK_TILE; const WebPChunkId id = isFrame ? WEBP_CHUNK_ANMF : WEBP_CHUNK_FRGM;
WebPMuxFrameInfo info; WebPMuxFrameInfo info;
WebPDataInit(&info.bitstream_); WebPDataInit(&info.bitstream_);
@ -794,7 +794,7 @@ static int Process(const WebPMuxConfig* config) {
WebPDataClear(&frame.bitstream_); WebPDataClear(&frame.bitstream_);
ERROR_GOTO1("ERROR: Could not parse frame properties.\n", Err2); ERROR_GOTO1("ERROR: Could not parse frame properties.\n", Err2);
} }
frame.id = WEBP_CHUNK_FRAME; frame.id = WEBP_CHUNK_ANMF;
err = WebPMuxPushFrame(mux, &frame, 1); err = WebPMuxPushFrame(mux, &frame, 1);
WebPDataClear(&frame.bitstream_); WebPDataClear(&frame.bitstream_);
if (err != WEBP_MUX_OK) { if (err != WEBP_MUX_OK) {
@ -823,7 +823,7 @@ static int Process(const WebPMuxConfig* config) {
WebPDataClear(&tile.bitstream_); WebPDataClear(&tile.bitstream_);
ERROR_GOTO1("ERROR: Could not parse tile properties.\n", Err2); ERROR_GOTO1("ERROR: Could not parse tile properties.\n", Err2);
} }
tile.id = WEBP_CHUNK_TILE; tile.id = WEBP_CHUNK_FRGM;
err = WebPMuxPushFrame(mux, &tile, 1); err = WebPMuxPushFrame(mux, &tile, 1);
WebPDataClear(&tile.bitstream_); WebPDataClear(&tile.bitstream_);
if (err != WEBP_MUX_OK) { if (err != WEBP_MUX_OK) {

View File

@ -39,7 +39,7 @@ typedef struct Frame {
int x_offset_, y_offset_; int x_offset_, y_offset_;
int width_, height_; int width_, height_;
int duration_; int duration_;
int is_tile_; // this is an image fragment from a 'TILE'. int is_tile_; // this is an image fragment from a tile.
int frame_num_; // the referent frame number for use in assembling tiles. int frame_num_; // the referent frame number for use in assembling tiles.
int complete_; // img_components_ contains a full image. int complete_; // img_components_ contains a full image.
ChunkData img_components_[2]; // 0=VP8{,L} 1=ALPH ChunkData img_components_[2]; // 0=VP8{,L} 1=ALPH
@ -285,7 +285,7 @@ static ParseStatus NewFrame(const MemBuffer* const mem,
return (*frame == NULL) ? PARSE_ERROR : PARSE_OK; return (*frame == NULL) ? PARSE_ERROR : PARSE_OK;
} }
// Parse a 'FRM ' chunk and any image bearing chunks that immediately follow. // Parse a 'ANMF' chunk and any image bearing chunks that immediately follow.
// 'frame_chunk_size' is the previously validated, padded chunk size. // 'frame_chunk_size' is the previously validated, padded chunk size.
static ParseStatus ParseFrame( static ParseStatus ParseFrame(
WebPDemuxer* const dmux, uint32_t frame_chunk_size) { WebPDemuxer* const dmux, uint32_t frame_chunk_size) {
@ -295,7 +295,7 @@ static ParseStatus ParseFrame(
MemBuffer* const mem = &dmux->mem_; MemBuffer* const mem = &dmux->mem_;
Frame* frame; Frame* frame;
ParseStatus status = ParseStatus status =
NewFrame(mem, min_size, FRAME_CHUNK_SIZE, frame_chunk_size, &frame); NewFrame(mem, min_size, ANMF_CHUNK_SIZE, frame_chunk_size, &frame);
if (status != PARSE_OK) return status; if (status != PARSE_OK) return status;
frame->x_offset_ = 2 * GetLE24s(mem); frame->x_offset_ = 2 * GetLE24s(mem);
@ -303,7 +303,7 @@ static ParseStatus ParseFrame(
frame->width_ = 1 + GetLE24s(mem); frame->width_ = 1 + GetLE24s(mem);
frame->height_ = 1 + GetLE24s(mem); frame->height_ = 1 + GetLE24s(mem);
frame->duration_ = 1 + GetLE24s(mem); frame->duration_ = 1 + GetLE24s(mem);
Skip(mem, frame_chunk_size - FRAME_CHUNK_SIZE); // skip any trailing data. Skip(mem, frame_chunk_size - ANMF_CHUNK_SIZE); // skip any trailing data.
if (frame->width_ * (uint64_t)frame->height_ >= MAX_IMAGE_AREA) { if (frame->width_ * (uint64_t)frame->height_ >= MAX_IMAGE_AREA) {
return PARSE_ERROR; return PARSE_ERROR;
} }
@ -324,7 +324,7 @@ static ParseStatus ParseFrame(
return status; return status;
} }
// Parse a 'TILE' chunk and any image bearing chunks that immediately follow. // Parse a 'FRGM' chunk and any image bearing chunks that immediately follow.
// 'tile_chunk_size' is the previously validated, padded chunk size. // 'tile_chunk_size' is the previously validated, padded chunk size.
static ParseStatus ParseTile(WebPDemuxer* const dmux, static ParseStatus ParseTile(WebPDemuxer* const dmux,
uint32_t tile_chunk_size) { uint32_t tile_chunk_size) {
@ -334,13 +334,13 @@ static ParseStatus ParseTile(WebPDemuxer* const dmux,
MemBuffer* const mem = &dmux->mem_; MemBuffer* const mem = &dmux->mem_;
Frame* frame; Frame* frame;
ParseStatus status = ParseStatus status =
NewFrame(mem, min_size, TILE_CHUNK_SIZE, tile_chunk_size, &frame); NewFrame(mem, min_size, FRGM_CHUNK_SIZE, tile_chunk_size, &frame);
if (status != PARSE_OK) return status; if (status != PARSE_OK) return status;
frame->is_tile_ = 1; frame->is_tile_ = 1;
frame->x_offset_ = 2 * GetLE24s(mem); frame->x_offset_ = 2 * GetLE24s(mem);
frame->y_offset_ = 2 * GetLE24s(mem); frame->y_offset_ = 2 * GetLE24s(mem);
Skip(mem, tile_chunk_size - TILE_CHUNK_SIZE); // skip any trailing data. Skip(mem, tile_chunk_size - FRGM_CHUNK_SIZE); // skip any trailing data.
// Store a (potentially partial) tile only if the tile flag is set // Store a (potentially partial) tile only if the tile flag is set
// and the tile contains some data. // and the tile contains some data.
@ -501,11 +501,11 @@ static ParseStatus ParseVP8X(WebPDemuxer* const dmux) {
} }
break; break;
} }
case MKFOURCC('F', 'R', 'M', ' '): { case MKFOURCC('A', 'N', 'M', 'F'): {
status = ParseFrame(dmux, chunk_size_padded); status = ParseFrame(dmux, chunk_size_padded);
break; break;
} }
case MKFOURCC('T', 'I', 'L', 'E'): { case MKFOURCC('F', 'R', 'G', 'M'): {
if (dmux->num_frames_ == 0) dmux->num_frames_ = 1; if (dmux->num_frames_ == 0) dmux->num_frames_ = 1;
status = ParseTile(dmux, chunk_size_padded); status = ParseTile(dmux, chunk_size_padded);
break; break;
@ -576,7 +576,7 @@ static int IsValidExtendedFormat(const WebPDemuxer* const dmux) {
int frame_count = 0, tile_count = 0; int frame_count = 0, tile_count = 0;
// Check frame properties and if the image is composed of tiles that each // Check frame properties and if the image is composed of tiles that each
// fragment came from a 'TILE'. // fragment came from a tile.
for (; f != NULL && f->frame_num_ == cur_frame_set; f = f->next_) { for (; f != NULL && f->frame_num_ == cur_frame_set; f = f->next_) {
const ChunkData* const image = f->img_components_; const ChunkData* const image = f->img_components_;
const ChunkData* const alpha = f->img_components_ + 1; const ChunkData* const alpha = f->img_components_ + 1;
@ -767,7 +767,7 @@ static int SynthesizeFrame(const WebPDemuxer* const dmux,
iter->complete_ = tile->complete_; iter->complete_ = tile->complete_;
iter->tile_.bytes_ = payload; iter->tile_.bytes_ = payload;
iter->tile_.size_ = payload_size; iter->tile_.size_ = payload_size;
// TODO(jzern): adjust offsets for 'TILE's embedded in 'FRM 's // TODO(jzern): adjust offsets for 'FRGM's embedded in 'ANMF's
return 1; return 1;
} }

View File

@ -115,7 +115,7 @@ static WebPMuxError CreateFrameTileData(const WebPData* const image,
int width; int width;
int height; int height;
uint8_t* frame_tile_bytes; uint8_t* frame_tile_bytes;
const size_t frame_tile_size = kChunks[is_frame ? IDX_FRAME : IDX_TILE].size; const size_t frame_tile_size = kChunks[is_frame ? IDX_ANMF : IDX_FRGM].size;
const int ok = is_lossless ? const int ok = is_lossless ?
VP8LGetInfo(image->bytes_, image->size_, &width, &height, NULL) : VP8LGetInfo(image->bytes_, image->size_, &width, &height, NULL) :
@ -300,8 +300,8 @@ WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame,
// Sanity checks. // Sanity checks.
if (mux == NULL || frame == NULL) return WEBP_MUX_INVALID_ARGUMENT; if (mux == NULL || frame == NULL) return WEBP_MUX_INVALID_ARGUMENT;
is_frame = (frame->id == WEBP_CHUNK_FRAME); is_frame = (frame->id == WEBP_CHUNK_ANMF);
if (!(is_frame || (frame->id == WEBP_CHUNK_TILE))) { if (!(is_frame || (frame->id == WEBP_CHUNK_FRGM))) {
return WEBP_MUX_INVALID_ARGUMENT; return WEBP_MUX_INVALID_ARGUMENT;
} }
@ -328,7 +328,7 @@ WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame,
const int x_offset = frame->x_offset_ & ~1; // Snap offsets to even. const int x_offset = frame->x_offset_ & ~1; // Snap offsets to even.
const int y_offset = frame->y_offset_ & ~1; const int y_offset = frame->y_offset_ & ~1;
const int duration = is_frame ? frame->duration_ : 1 /* unused */; const int duration = is_frame ? frame->duration_ : 1 /* unused */;
const uint32_t tag = kChunks[is_frame ? IDX_FRAME : IDX_TILE].tag; const uint32_t tag = kChunks[is_frame ? IDX_ANMF : IDX_FRGM].tag;
WebPData frame_tile; WebPData frame_tile;
if (x_offset < 0 || x_offset >= MAX_POSITION_OFFSET || if (x_offset < 0 || x_offset >= MAX_POSITION_OFFSET ||
y_offset < 0 || y_offset >= MAX_POSITION_OFFSET || y_offset < 0 || y_offset >= MAX_POSITION_OFFSET ||
@ -392,12 +392,12 @@ static WebPMuxError GetFrameTileInfo(const WebPChunk* const frame_tile_chunk,
int* const x_offset, int* const y_offset, int* const x_offset, int* const y_offset,
int* const duration) { int* const duration) {
const uint32_t tag = frame_tile_chunk->tag_; const uint32_t tag = frame_tile_chunk->tag_;
const int is_frame = (tag == kChunks[IDX_FRAME].tag); const int is_frame = (tag == kChunks[IDX_ANMF].tag);
const WebPData* const data = &frame_tile_chunk->data_; const WebPData* const data = &frame_tile_chunk->data_;
const size_t expected_data_size = const size_t expected_data_size =
is_frame ? FRAME_CHUNK_SIZE : TILE_CHUNK_SIZE; is_frame ? ANMF_CHUNK_SIZE : FRGM_CHUNK_SIZE;
assert(frame_tile_chunk != NULL); assert(frame_tile_chunk != NULL);
assert(tag == kChunks[IDX_FRAME].tag || tag == kChunks[IDX_TILE].tag); assert(tag == kChunks[IDX_ANMF].tag || tag == kChunks[IDX_FRGM].tag);
if (data->size_ != expected_data_size) return WEBP_MUX_INVALID_ARGUMENT; if (data->size_ != expected_data_size) return WEBP_MUX_INVALID_ARGUMENT;
*x_offset = 2 * GetLE24(data->bytes_ + 0); *x_offset = 2 * GetLE24(data->bytes_ + 0);
@ -433,7 +433,7 @@ static WebPMuxError GetImageInfo(const WebPMuxImage* const wpi,
const WebPChunk* const image_chunk = wpi->img_; const WebPChunk* const image_chunk = wpi->img_;
const WebPChunk* const frame_tile_chunk = wpi->header_; const WebPChunk* const frame_tile_chunk = wpi->header_;
// Get offsets and duration from FRM/TILE chunk. // Get offsets and duration from ANMF/FRGM chunk.
const WebPMuxError err = const WebPMuxError err =
GetFrameTileInfo(frame_tile_chunk, x_offset, y_offset, duration); GetFrameTileInfo(frame_tile_chunk, x_offset, y_offset, duration);
if (err != WEBP_MUX_OK) return err; if (err != WEBP_MUX_OK) return err;
@ -531,10 +531,10 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
} }
if (images->header_ != NULL) { if (images->header_ != NULL) {
if (images->header_->tag_ == kChunks[IDX_TILE].tag) { if (images->header_->tag_ == kChunks[IDX_FRGM].tag) {
// This is a tiled image. // This is a tiled image.
flags |= TILE_FLAG; flags |= TILE_FLAG;
} else if (images->header_->tag_ == kChunks[IDX_FRAME].tag) { } else if (images->header_->tag_ == kChunks[IDX_ANMF].tag) {
// This is an image with animation. // This is an image with animation.
flags |= ANIMATION_FLAG; flags |= ANIMATION_FLAG;
} }
@ -591,7 +591,7 @@ WebPMuxError WebPMuxAssemble(WebPMux* mux, WebPData* assembled_data) {
err = WebPMuxNumChunks(mux, kChunks[IDX_LOOP].id, &num_loop_chunks); err = WebPMuxNumChunks(mux, kChunks[IDX_LOOP].id, &num_loop_chunks);
if (err != WEBP_MUX_OK) return err; if (err != WEBP_MUX_OK) return err;
if (num_loop_chunks >= 1) { if (num_loop_chunks >= 1) {
err = WebPMuxNumChunks(mux, kChunks[IDX_FRAME].id, &num_frames); err = WebPMuxNumChunks(mux, kChunks[IDX_ANMF].id, &num_frames);
if (err != WEBP_MUX_OK) return err; if (err != WEBP_MUX_OK) return err;
if (num_frames == 0) { if (num_frames == 0) {
err = DeleteLoopCount(mux); err = DeleteLoopCount(mux);

View File

@ -31,16 +31,16 @@ struct WebPChunk {
uint32_t tag_; uint32_t tag_;
int owner_; // True if *data_ memory is owned internally. int owner_; // True if *data_ memory is owned internally.
// VP8X, Loop, and other internally created chunks // VP8X, Loop, and other internally created chunks
// like frame/tile are always owned. // like ANMF/FRGM are always owned.
WebPData data_; WebPData data_;
WebPChunk* next_; WebPChunk* next_;
}; };
// MuxImage object. Store a full webp image (including frame/tile chunk, alpha // MuxImage object. Store a full WebP image (including ANMF/FRGM chunk, ALPH
// chunk and VP8/VP8L chunk), // chunk and VP8/VP8L chunk),
typedef struct WebPMuxImage WebPMuxImage; typedef struct WebPMuxImage WebPMuxImage;
struct WebPMuxImage { struct WebPMuxImage {
WebPChunk* header_; // Corresponds to WEBP_CHUNK_FRAME/WEBP_CHUNK_TILE. WebPChunk* header_; // Corresponds to WEBP_CHUNK_ANMF/WEBP_CHUNK_FRGM.
WebPChunk* alpha_; // Corresponds to WEBP_CHUNK_ALPHA. WebPChunk* alpha_; // Corresponds to WEBP_CHUNK_ALPHA.
WebPChunk* img_; // Corresponds to WEBP_CHUNK_IMAGE. WebPChunk* img_; // Corresponds to WEBP_CHUNK_IMAGE.
int is_partial_; // True if only some of the chunks are filled. int is_partial_; // True if only some of the chunks are filled.
@ -66,8 +66,8 @@ typedef enum {
IDX_VP8X = 0, IDX_VP8X = 0,
IDX_ICCP, IDX_ICCP,
IDX_LOOP, IDX_LOOP,
IDX_FRAME, IDX_ANMF,
IDX_TILE, IDX_FRGM,
IDX_ALPHA, IDX_ALPHA,
IDX_VP8, IDX_VP8,
IDX_VP8L, IDX_VP8L,
@ -205,8 +205,8 @@ int MuxImageCount(const WebPMuxImage* wpi_list, WebPChunkId id);
// Check if given ID corresponds to an image related chunk. // Check if given ID corresponds to an image related chunk.
static WEBP_INLINE int IsWPI(WebPChunkId id) { static WEBP_INLINE int IsWPI(WebPChunkId id) {
switch (id) { switch (id) {
case WEBP_CHUNK_FRAME: case WEBP_CHUNK_ANMF:
case WEBP_CHUNK_TILE: case WEBP_CHUNK_FRGM:
case WEBP_CHUNK_ALPHA: case WEBP_CHUNK_ALPHA:
case WEBP_CHUNK_IMAGE: return 1; case WEBP_CHUNK_IMAGE: return 1;
default: return 0; default: return 0;
@ -218,8 +218,8 @@ static WEBP_INLINE WebPChunk** MuxImageGetListFromId(
const WebPMuxImage* const wpi, WebPChunkId id) { const WebPMuxImage* const wpi, WebPChunkId id) {
assert(wpi != NULL); assert(wpi != NULL);
switch (id) { switch (id) {
case WEBP_CHUNK_FRAME: case WEBP_CHUNK_ANMF:
case WEBP_CHUNK_TILE: return (WebPChunk**)&wpi->header_; case WEBP_CHUNK_FRGM: return (WebPChunk**)&wpi->header_;
case WEBP_CHUNK_ALPHA: return (WebPChunk**)&wpi->alpha_; case WEBP_CHUNK_ALPHA: return (WebPChunk**)&wpi->alpha_;
case WEBP_CHUNK_IMAGE: return (WebPChunk**)&wpi->img_; case WEBP_CHUNK_IMAGE: return (WebPChunk**)&wpi->img_;
default: return NULL; default: return NULL;

View File

@ -23,8 +23,8 @@ const ChunkInfo kChunks[] = {
{ MKFOURCC('V', 'P', '8', 'X'), WEBP_CHUNK_VP8X, VP8X_CHUNK_SIZE }, { MKFOURCC('V', 'P', '8', 'X'), WEBP_CHUNK_VP8X, VP8X_CHUNK_SIZE },
{ MKFOURCC('I', 'C', 'C', 'P'), WEBP_CHUNK_ICCP, UNDEFINED_CHUNK_SIZE }, { MKFOURCC('I', 'C', 'C', 'P'), WEBP_CHUNK_ICCP, UNDEFINED_CHUNK_SIZE },
{ MKFOURCC('L', 'O', 'O', 'P'), WEBP_CHUNK_LOOP, LOOP_CHUNK_SIZE }, { MKFOURCC('L', 'O', 'O', 'P'), WEBP_CHUNK_LOOP, LOOP_CHUNK_SIZE },
{ MKFOURCC('F', 'R', 'M', ' '), WEBP_CHUNK_FRAME, FRAME_CHUNK_SIZE }, { MKFOURCC('A', 'N', 'M', 'F'), WEBP_CHUNK_ANMF, ANMF_CHUNK_SIZE },
{ MKFOURCC('T', 'I', 'L', 'E'), WEBP_CHUNK_TILE, TILE_CHUNK_SIZE }, { MKFOURCC('F', 'R', 'G', 'M'), WEBP_CHUNK_FRGM, FRGM_CHUNK_SIZE },
{ MKFOURCC('A', 'L', 'P', 'H'), WEBP_CHUNK_ALPHA, UNDEFINED_CHUNK_SIZE }, { MKFOURCC('A', 'L', 'P', 'H'), WEBP_CHUNK_ALPHA, UNDEFINED_CHUNK_SIZE },
{ MKFOURCC('V', 'P', '8', ' '), WEBP_CHUNK_IMAGE, UNDEFINED_CHUNK_SIZE }, { MKFOURCC('V', 'P', '8', ' '), WEBP_CHUNK_IMAGE, UNDEFINED_CHUNK_SIZE },
{ MKFOURCC('V', 'P', '8', 'L'), WEBP_CHUNK_IMAGE, UNDEFINED_CHUNK_SIZE }, { MKFOURCC('V', 'P', '8', 'L'), WEBP_CHUNK_IMAGE, UNDEFINED_CHUNK_SIZE },
@ -400,8 +400,8 @@ size_t MuxImageListDiskSize(const WebPMuxImage* wpi_list) {
uint8_t* MuxImageEmit(const WebPMuxImage* const wpi, uint8_t* dst) { uint8_t* MuxImageEmit(const WebPMuxImage* const wpi, uint8_t* dst) {
// Ordering of chunks to be emitted is strictly as follows: // Ordering of chunks to be emitted is strictly as follows:
// 1. Frame/Tile chunk (if present). // 1. ANMF/FRGM chunk (if present).
// 2. Alpha chunk (if present). // 2. ALPH chunk (if present).
// 3. VP8/VP8L chunk. // 3. VP8/VP8L chunk.
assert(wpi); assert(wpi);
if (wpi->header_ != NULL) dst = ChunkEmit(wpi->header_, dst); if (wpi->header_ != NULL) dst = ChunkEmit(wpi->header_, dst);
@ -454,8 +454,8 @@ WebPChunk** MuxGetChunkListFromId(const WebPMux* mux, WebPChunkId id) {
WebPMuxError MuxValidateForImage(const WebPMux* const mux) { WebPMuxError MuxValidateForImage(const WebPMux* const mux) {
const int num_images = MuxImageCount(mux->images_, WEBP_CHUNK_IMAGE); const int num_images = MuxImageCount(mux->images_, WEBP_CHUNK_IMAGE);
const int num_frames = MuxImageCount(mux->images_, WEBP_CHUNK_FRAME); const int num_frames = MuxImageCount(mux->images_, WEBP_CHUNK_ANMF);
const int num_tiles = MuxImageCount(mux->images_, WEBP_CHUNK_TILE); const int num_tiles = MuxImageCount(mux->images_, WEBP_CHUNK_FRGM);
if (num_images == 0) { if (num_images == 0) {
// No images in mux. // No images in mux.
@ -526,7 +526,7 @@ WebPMuxError MuxValidate(const WebPMux* const mux) {
// At most one loop chunk. // At most one loop chunk.
err = ValidateChunk(mux, IDX_LOOP, NO_FLAG, flags, 1, &num_loop_chunks); err = ValidateChunk(mux, IDX_LOOP, NO_FLAG, flags, 1, &num_loop_chunks);
if (err != WEBP_MUX_OK) return err; if (err != WEBP_MUX_OK) return err;
err = ValidateChunk(mux, IDX_FRAME, NO_FLAG, flags, -1, &num_frames); err = ValidateChunk(mux, IDX_ANMF, NO_FLAG, flags, -1, &num_frames);
if (err != WEBP_MUX_OK) return err; if (err != WEBP_MUX_OK) return err;
{ {
@ -540,7 +540,7 @@ WebPMuxError MuxValidate(const WebPMux* const mux) {
} }
// Tiling: TILE_FLAG and tile chunk(s) are consistent. // Tiling: TILE_FLAG and tile chunk(s) are consistent.
err = ValidateChunk(mux, IDX_TILE, TILE_FLAG, flags, -1, &num_tiles); err = ValidateChunk(mux, IDX_FRGM, TILE_FLAG, flags, -1, &num_tiles);
if (err != WEBP_MUX_OK) return err; if (err != WEBP_MUX_OK) return err;
// Verify either VP8X chunk is present OR there is only one elem in // Verify either VP8X chunk is present OR there is only one elem in

View File

@ -237,7 +237,7 @@ static WebPMuxError SynthesizeBitstream(const WebPMuxImage* const wpi,
const int need_vp8x = (wpi->alpha_ != NULL); const int need_vp8x = (wpi->alpha_ != NULL);
const size_t vp8x_size = need_vp8x ? CHUNK_HEADER_SIZE + VP8X_CHUNK_SIZE : 0; const size_t vp8x_size = need_vp8x ? CHUNK_HEADER_SIZE + VP8X_CHUNK_SIZE : 0;
const size_t alpha_size = need_vp8x ? ChunkDiskSize(wpi->alpha_) : 0; const size_t alpha_size = need_vp8x ? ChunkDiskSize(wpi->alpha_) : 0;
// Note: No need to output FRM/TILE chunk for a single image. // Note: No need to output ANMF/FRGM chunk for a single image.
const size_t size = RIFF_HEADER_SIZE + vp8x_size + alpha_size + const size_t size = RIFF_HEADER_SIZE + vp8x_size + alpha_size +
ChunkDiskSize(wpi->img_); ChunkDiskSize(wpi->img_);
uint8_t* const data = (uint8_t*)malloc(size); uint8_t* const data = (uint8_t*)malloc(size);
@ -299,8 +299,8 @@ static WebPMuxError MuxGetImageInternal(const WebPMuxImage* const wpi,
static WebPMuxError MuxGetFrameTileInternal(const WebPMuxImage* const wpi, static WebPMuxError MuxGetFrameTileInternal(const WebPMuxImage* const wpi,
WebPMuxFrameInfo* const frame) { WebPMuxFrameInfo* const frame) {
const int is_frame = (wpi->header_->tag_ == kChunks[IDX_FRAME].tag); const int is_frame = (wpi->header_->tag_ == kChunks[IDX_ANMF].tag);
const CHUNK_INDEX idx = is_frame ? IDX_FRAME : IDX_TILE; const CHUNK_INDEX idx = is_frame ? IDX_ANMF : IDX_FRGM;
const WebPData* frame_tile_data; const WebPData* frame_tile_data;
assert(wpi->header_ != NULL); // Already checked by WebPMuxGetFrame(). assert(wpi->header_ != NULL); // Already checked by WebPMuxGetFrame().
// Get frame/tile chunk. // Get frame/tile chunk.

View File

@ -65,9 +65,9 @@ typedef enum {
#define CHUNK_SIZE_BYTES 4 // Size needed to store chunk's size. #define CHUNK_SIZE_BYTES 4 // Size needed to store chunk's size.
#define CHUNK_HEADER_SIZE 8 // Size of a chunk header. #define CHUNK_HEADER_SIZE 8 // Size of a chunk header.
#define RIFF_HEADER_SIZE 12 // Size of the RIFF header ("RIFFnnnnWEBP"). #define RIFF_HEADER_SIZE 12 // Size of the RIFF header ("RIFFnnnnWEBP").
#define FRAME_CHUNK_SIZE 15 // Size of a FRM chunk. #define ANMF_CHUNK_SIZE 15 // Size of a ANMF chunk.
#define LOOP_CHUNK_SIZE 2 // Size of a LOOP chunk. #define LOOP_CHUNK_SIZE 2 // Size of a LOOP chunk.
#define TILE_CHUNK_SIZE 6 // Size of a TILE chunk. #define FRGM_CHUNK_SIZE 6 // Size of a FRGM chunk.
#define VP8X_CHUNK_SIZE 10 // Size of a VP8X chunk. #define VP8X_CHUNK_SIZE 10 // Size of a VP8X chunk.
#define TILING_FLAG_BIT 0x01 // Set if tiles are possibly used. #define TILING_FLAG_BIT 0x01 // Set if tiles are possibly used.

View File

@ -94,8 +94,8 @@ enum WebPChunkId {
WEBP_CHUNK_VP8X, // VP8X WEBP_CHUNK_VP8X, // VP8X
WEBP_CHUNK_ICCP, // ICCP WEBP_CHUNK_ICCP, // ICCP
WEBP_CHUNK_LOOP, // LOOP WEBP_CHUNK_LOOP, // LOOP
WEBP_CHUNK_FRAME, // FRM WEBP_CHUNK_ANMF, // ANMF
WEBP_CHUNK_TILE, // TILE WEBP_CHUNK_FRGM, // FRGM
WEBP_CHUNK_ALPHA, // ALPH WEBP_CHUNK_ALPHA, // ALPH
WEBP_CHUNK_IMAGE, // VP8/VP8L WEBP_CHUNK_IMAGE, // VP8/VP8L
WEBP_CHUNK_META, // META WEBP_CHUNK_META, // META
@ -165,7 +165,7 @@ static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream,
// Non-image chunks. // Non-image chunks.
// Note: Only non-image related chunks should be managed through chunk APIs. // Note: Only non-image related chunks should be managed through chunk APIs.
// (Image related chunks are: "FRM ", "TILE", "VP8 ", "VP8L" and "ALPH"). // (Image related chunks are: "ANMF", "FRGM", "VP8 ", "VP8L" and "ALPH").
// To add, get and delete images, use APIs WebPMuxSetImage(), // To add, get and delete images, use APIs WebPMuxSetImage(),
// WebPMuxPushFrame(), WebPMuxGetFrame() and WebPMuxDeleteFrame(). // WebPMuxPushFrame(), WebPMuxGetFrame() and WebPMuxDeleteFrame().
@ -226,8 +226,8 @@ struct WebPMuxFrameInfo {
int y_offset_; // y-offset of the frame. int y_offset_; // y-offset of the frame.
int duration_; // duration of the frame (in milliseconds). int duration_; // duration of the frame (in milliseconds).
WebPChunkId id; // frame type: should be one of WEBP_CHUNK_FRAME, WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF,
// WEBP_CHUNK_TILE or WEBP_CHUNK_IMAGE // WEBP_CHUNK_FRGM or WEBP_CHUNK_IMAGE
uint32_t pad[3]; // padding for later use uint32_t pad[3]; // padding for later use
}; };
@ -247,7 +247,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(
WebPMux* mux, const WebPData* bitstream, int copy_data); WebPMux* mux, const WebPData* bitstream, int copy_data);
// Adds a frame at the end of the mux object. // Adds a frame at the end of the mux object.
// Notes: (1) frame.id should be one of WEBP_CHUNK_FRAME or WEBP_CHUNK_TILE // Notes: (1) frame.id should be one of WEBP_CHUNK_ANMF or WEBP_CHUNK_FRGM
// (2) For setting a non-animated non-tiled image, use WebPMuxSetImage() // (2) For setting a non-animated non-tiled image, use WebPMuxSetImage()
// instead. // instead.
// (3) Type of frame being pushed must be same as the frames in mux. // (3) Type of frame being pushed must be same as the frames in mux.