mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-25 21:28:22 +01:00
mux struct naming
members of public structs should not have a trailing underscore. Change-Id: Ieef42e1da115bf42b0ea42159701e32bed7b9f60
This commit is contained in:
parent
6c66dde80f
commit
a077072777
@ -85,7 +85,7 @@ profile & XMP metadata.
|
|||||||
// Get data from mux in WebP RIFF format.
|
// Get data from mux in WebP RIFF format.
|
||||||
WebPMuxAssemble(mux, &output_data);
|
WebPMuxAssemble(mux, &output_data);
|
||||||
WebPMuxDelete(mux);
|
WebPMuxDelete(mux);
|
||||||
// ... (Consume output_data; e.g. write output_data.bytes_ to file).
|
// ... (Consume output_data; e.g. write output_data.bytes to file).
|
||||||
WebPDataClear(&output_data);
|
WebPDataClear(&output_data);
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,17 +178,17 @@ static int Decode(int* const duration) {
|
|||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
|
||||||
ClearPreviousPic();
|
ClearPreviousPic();
|
||||||
if (iter->x_offset_ != 0 || iter->y_offset_ != 0) {
|
if (iter->x_offset != 0 || iter->y_offset != 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Frame offsets not yet supported! Forcing offset to 0,0\n");
|
"Frame offsets not yet supported! Forcing offset to 0,0\n");
|
||||||
}
|
}
|
||||||
output_buffer->colorspace = MODE_RGBA;
|
output_buffer->colorspace = MODE_RGBA;
|
||||||
ok = (WebPDecode(iter->tile_.bytes_, iter->tile_.size_,
|
ok = (WebPDecode(iter->tile.bytes, iter->tile.size,
|
||||||
config) == VP8_STATUS_OK);
|
config) == VP8_STATUS_OK);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
fprintf(stderr, "Decoding of frame #%d failed!\n", iter->frame_num_);
|
fprintf(stderr, "Decoding of frame #%d failed!\n", iter->frame_num);
|
||||||
} else {
|
} else {
|
||||||
*duration = iter->duration_;
|
*duration = iter->duration;
|
||||||
kParams.pic = output_buffer;
|
kParams.pic = output_buffer;
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
@ -288,7 +288,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ExUtilReadFile(kParams.file_name,
|
if (!ExUtilReadFile(kParams.file_name,
|
||||||
&kParams.data.bytes_, &kParams.data.size_)) {
|
&kParams.data.bytes, &kParams.data.size)) {
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,10 +305,10 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
if (!WebPDemuxGetFrame(kParams.dmux, 1, &kParams.frameiter)) goto Error;
|
if (!WebPDemuxGetFrame(kParams.dmux, 1, &kParams.frameiter)) goto Error;
|
||||||
|
|
||||||
kParams.has_animation = (kParams.frameiter.num_frames_ > 1);
|
kParams.has_animation = (kParams.frameiter.num_frames > 1);
|
||||||
kParams.loop_count = (int)WebPDemuxGetI(kParams.dmux, WEBP_FF_LOOP_COUNT);
|
kParams.loop_count = (int)WebPDemuxGetI(kParams.dmux, WEBP_FF_LOOP_COUNT);
|
||||||
printf("VP8X: Found %d images in file (loop count = %d)\n",
|
printf("VP8X: Found %d images in file (loop count = %d)\n",
|
||||||
kParams.frameiter.num_frames_, kParams.loop_count);
|
kParams.frameiter.num_frames, kParams.loop_count);
|
||||||
|
|
||||||
// Decode first frame
|
// Decode first frame
|
||||||
{
|
{
|
||||||
|
@ -215,10 +215,10 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
|
|||||||
WebPMuxFrameInfo frame;
|
WebPMuxFrameInfo frame;
|
||||||
err = WebPMuxGetFrame(mux, i, &frame);
|
err = WebPMuxGetFrame(mux, i, &frame);
|
||||||
RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i);
|
RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i);
|
||||||
printf("%3d: %8d %8d ", i, frame.x_offset_, frame.y_offset_);
|
printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset);
|
||||||
if (is_anim) printf("%8d ", frame.duration_);
|
if (is_anim) printf("%8d ", frame.duration);
|
||||||
printf("%10zu\n", frame.bitstream_.size_);
|
printf("%10zu\n", frame.bitstream.size);
|
||||||
WebPDataClear(&frame.bitstream_);
|
WebPDataClear(&frame.bitstream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,21 +227,21 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) {
|
|||||||
WebPData icc_profile;
|
WebPData icc_profile;
|
||||||
err = WebPMuxGetChunk(mux, "ICCP", &icc_profile);
|
err = WebPMuxGetChunk(mux, "ICCP", &icc_profile);
|
||||||
RETURN_IF_ERROR("Failed to retrieve the color profile\n");
|
RETURN_IF_ERROR("Failed to retrieve the color profile\n");
|
||||||
printf("Size of the color profile data: %zu\n", icc_profile.size_);
|
printf("Size of the color profile data: %zu\n", icc_profile.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag & META_FLAG) {
|
if (flag & META_FLAG) {
|
||||||
WebPData metadata;
|
WebPData metadata;
|
||||||
err = WebPMuxGetChunk(mux, "META", &metadata);
|
err = WebPMuxGetChunk(mux, "META", &metadata);
|
||||||
RETURN_IF_ERROR("Failed to retrieve the metadata\n");
|
RETURN_IF_ERROR("Failed to retrieve the metadata\n");
|
||||||
printf("Size of the metadata: %zu\n", metadata.size_);
|
printf("Size of the metadata: %zu\n", metadata.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((flag & ALPHA_FLAG) && !(flag & (ANIMATION_FLAG | TILE_FLAG))) {
|
if ((flag & ALPHA_FLAG) && !(flag & (ANIMATION_FLAG | TILE_FLAG))) {
|
||||||
WebPMuxFrameInfo image;
|
WebPMuxFrameInfo image;
|
||||||
err = WebPMuxGetFrame(mux, 1, &image);
|
err = WebPMuxGetFrame(mux, 1, &image);
|
||||||
RETURN_IF_ERROR("Failed to retrieve the image\n");
|
RETURN_IF_ERROR("Failed to retrieve the image\n");
|
||||||
printf("Size of the image (with alpha): %zu\n", image.bitstream_.size_);
|
printf("Size of the image (with alpha): %zu\n", image.bitstream.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return WEBP_MUX_OK;
|
return WEBP_MUX_OK;
|
||||||
@ -302,8 +302,8 @@ static int ReadFileToWebPData(const char* const filename,
|
|||||||
const uint8_t* data;
|
const uint8_t* data;
|
||||||
size_t size;
|
size_t size;
|
||||||
if (!ExUtilReadFile(filename, &data, &size)) return 0;
|
if (!ExUtilReadFile(filename, &data, &size)) return 0;
|
||||||
webp_data->bytes_ = data;
|
webp_data->bytes = data;
|
||||||
webp_data->size_ = size;
|
webp_data->size = size;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ static int CreateMux(const char* const filename, WebPMux** mux) {
|
|||||||
assert(mux != NULL);
|
assert(mux != NULL);
|
||||||
if (!ReadFileToWebPData(filename, &bitstream)) return 0;
|
if (!ReadFileToWebPData(filename, &bitstream)) return 0;
|
||||||
*mux = WebPMuxCreate(&bitstream, 1);
|
*mux = WebPMuxCreate(&bitstream, 1);
|
||||||
free((void*)bitstream.bytes_);
|
free((void*)bitstream.bytes);
|
||||||
if (*mux != NULL) return 1;
|
if (*mux != NULL) return 1;
|
||||||
fprintf(stderr, "Failed to create mux object from file %s.\n", filename);
|
fprintf(stderr, "Failed to create mux object from file %s.\n", filename);
|
||||||
return 0;
|
return 0;
|
||||||
@ -325,10 +325,10 @@ static int WriteData(const char* filename, const WebPData* const webpdata) {
|
|||||||
fprintf(stderr, "Error opening output WebP file %s!\n", filename);
|
fprintf(stderr, "Error opening output WebP file %s!\n", filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (fwrite(webpdata->bytes_, webpdata->size_, 1, fout) != 1) {
|
if (fwrite(webpdata->bytes, webpdata->size, 1, fout) != 1) {
|
||||||
fprintf(stderr, "Error writing file %s!\n", filename);
|
fprintf(stderr, "Error writing file %s!\n", filename);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Saved file %s (%zu bytes)\n", filename, webpdata->size_);
|
fprintf(stderr, "Saved file %s (%zu bytes)\n", filename, webpdata->size);
|
||||||
ok = 1;
|
ok = 1;
|
||||||
}
|
}
|
||||||
if (fout != stdout) fclose(fout);
|
if (fout != stdout) fclose(fout);
|
||||||
@ -350,11 +350,11 @@ static int WriteWebP(WebPMux* const mux, const char* filename) {
|
|||||||
|
|
||||||
static int ParseFrameArgs(const char* args, WebPMuxFrameInfo* const info) {
|
static int ParseFrameArgs(const char* args, WebPMuxFrameInfo* const info) {
|
||||||
return (sscanf(args, "+%d+%d+%d",
|
return (sscanf(args, "+%d+%d+%d",
|
||||||
&info->x_offset_, &info->y_offset_, &info->duration_) == 3);
|
&info->x_offset, &info->y_offset, &info->duration) == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ParseTileArgs(const char* args, WebPMuxFrameInfo* const info) {
|
static int ParseTileArgs(const char* args, WebPMuxFrameInfo* const info) {
|
||||||
return (sscanf(args, "+%d+%d", &info->x_offset_, &info->y_offset_) == 2);
|
return (sscanf(args, "+%d+%d", &info->x_offset, &info->y_offset) == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@ -686,7 +686,7 @@ static int GetFrameTile(const WebPMux* mux,
|
|||||||
int ok = 1;
|
int ok = 1;
|
||||||
const WebPChunkId id = isFrame ? WEBP_CHUNK_ANMF : WEBP_CHUNK_FRGM;
|
const WebPChunkId id = isFrame ? WEBP_CHUNK_ANMF : WEBP_CHUNK_FRGM;
|
||||||
WebPMuxFrameInfo info;
|
WebPMuxFrameInfo info;
|
||||||
WebPDataInit(&info.bitstream_);
|
WebPDataInit(&info.bitstream);
|
||||||
|
|
||||||
num = strtol(config->feature_.args_[0].params_, NULL, 10);
|
num = strtol(config->feature_.args_[0].params_, NULL, 10);
|
||||||
if (num < 0) {
|
if (num < 0) {
|
||||||
@ -706,7 +706,7 @@ static int GetFrameTile(const WebPMux* mux,
|
|||||||
ERROR_GOTO2("ERROR (%s): Could not allocate a mux object.\n",
|
ERROR_GOTO2("ERROR (%s): Could not allocate a mux object.\n",
|
||||||
ErrorString(err), ErrGet);
|
ErrorString(err), ErrGet);
|
||||||
}
|
}
|
||||||
err = WebPMuxSetImage(mux_single, &info.bitstream_, 1);
|
err = WebPMuxSetImage(mux_single, &info.bitstream, 1);
|
||||||
if (err != WEBP_MUX_OK) {
|
if (err != WEBP_MUX_OK) {
|
||||||
ERROR_GOTO2("ERROR (%s): Could not create single image mux object.\n",
|
ERROR_GOTO2("ERROR (%s): Could not create single image mux object.\n",
|
||||||
ErrorString(err), ErrGet);
|
ErrorString(err), ErrGet);
|
||||||
@ -715,7 +715,7 @@ static int GetFrameTile(const WebPMux* mux,
|
|||||||
ok = WriteWebP(mux_single, config->output_);
|
ok = WriteWebP(mux_single, config->output_);
|
||||||
|
|
||||||
ErrGet:
|
ErrGet:
|
||||||
WebPDataClear(&info.bitstream_);
|
WebPDataClear(&info.bitstream);
|
||||||
WebPMuxDelete(mux_single);
|
WebPMuxDelete(mux_single);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
@ -787,16 +787,16 @@ static int Process(const WebPMuxConfig* config) {
|
|||||||
} else if (feature->args_[index].subtype_ == SUBTYPE_FRM) {
|
} else if (feature->args_[index].subtype_ == SUBTYPE_FRM) {
|
||||||
WebPMuxFrameInfo frame;
|
WebPMuxFrameInfo frame;
|
||||||
ok = ReadFileToWebPData(feature->args_[index].filename_,
|
ok = ReadFileToWebPData(feature->args_[index].filename_,
|
||||||
&frame.bitstream_);
|
&frame.bitstream);
|
||||||
if (!ok) goto Err2;
|
if (!ok) goto Err2;
|
||||||
ok = ParseFrameArgs(feature->args_[index].params_, &frame);
|
ok = ParseFrameArgs(feature->args_[index].params_, &frame);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
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_ANMF;
|
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) {
|
||||||
ERROR_GOTO3("ERROR (%s): Could not add a frame at index %d.\n",
|
ERROR_GOTO3("ERROR (%s): Could not add a frame at index %d.\n",
|
||||||
ErrorString(err), index, Err2);
|
ErrorString(err), index, Err2);
|
||||||
@ -816,16 +816,16 @@ static int Process(const WebPMuxConfig* config) {
|
|||||||
for (index = 0; index < feature->arg_count_; ++index) {
|
for (index = 0; index < feature->arg_count_; ++index) {
|
||||||
WebPMuxFrameInfo tile;
|
WebPMuxFrameInfo tile;
|
||||||
ok = ReadFileToWebPData(feature->args_[index].filename_,
|
ok = ReadFileToWebPData(feature->args_[index].filename_,
|
||||||
&tile.bitstream_);
|
&tile.bitstream);
|
||||||
if (!ok) goto Err2;
|
if (!ok) goto Err2;
|
||||||
ok = ParseTileArgs(feature->args_[index].params_, &tile);
|
ok = ParseTileArgs(feature->args_[index].params_, &tile);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
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_FRGM;
|
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) {
|
||||||
ERROR_GOTO3("ERROR (%s): Could not add a tile at index %d.\n",
|
ERROR_GOTO3("ERROR (%s): Could not add a tile at index %d.\n",
|
||||||
ErrorString(err), index, Err2);
|
ErrorString(err), index, Err2);
|
||||||
@ -839,7 +839,7 @@ static int Process(const WebPMuxConfig* config) {
|
|||||||
ok = ReadFileToWebPData(feature->args_[0].filename_, &color_profile);
|
ok = ReadFileToWebPData(feature->args_[0].filename_, &color_profile);
|
||||||
if (!ok) goto Err2;
|
if (!ok) goto Err2;
|
||||||
err = WebPMuxSetChunk(mux, "ICCP", &color_profile, 1);
|
err = WebPMuxSetChunk(mux, "ICCP", &color_profile, 1);
|
||||||
free((void*)color_profile.bytes_);
|
free((void*)color_profile.bytes);
|
||||||
if (err != WEBP_MUX_OK) {
|
if (err != WEBP_MUX_OK) {
|
||||||
ERROR_GOTO2("ERROR (%s): Could not set color profile.\n",
|
ERROR_GOTO2("ERROR (%s): Could not set color profile.\n",
|
||||||
ErrorString(err), Err2);
|
ErrorString(err), Err2);
|
||||||
@ -852,7 +852,7 @@ static int Process(const WebPMuxConfig* config) {
|
|||||||
ok = ReadFileToWebPData(feature->args_[0].filename_, &metadata);
|
ok = ReadFileToWebPData(feature->args_[0].filename_, &metadata);
|
||||||
if (!ok) goto Err2;
|
if (!ok) goto Err2;
|
||||||
err = WebPMuxSetChunk(mux, "META", &metadata, 1);
|
err = WebPMuxSetChunk(mux, "META", &metadata, 1);
|
||||||
free((void*)metadata.bytes_);
|
free((void*)metadata.bytes);
|
||||||
if (err != WEBP_MUX_OK) {
|
if (err != WEBP_MUX_OK) {
|
||||||
ERROR_GOTO2("ERROR (%s): Could not set the metadata.\n",
|
ERROR_GOTO2("ERROR (%s): Could not set the metadata.\n",
|
||||||
ErrorString(err), Err2);
|
ErrorString(err), Err2);
|
||||||
|
@ -632,9 +632,9 @@ WebPDemuxer* WebPDemuxInternal(const WebPData* data, int allow_partial,
|
|||||||
WebPDemuxer* dmux;
|
WebPDemuxer* dmux;
|
||||||
|
|
||||||
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DEMUX_ABI_VERSION)) return NULL;
|
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DEMUX_ABI_VERSION)) return NULL;
|
||||||
if (data == NULL || data->bytes_ == NULL || data->size_ == 0) return NULL;
|
if (data == NULL || data->bytes == NULL || data->size == 0) return NULL;
|
||||||
|
|
||||||
if (!InitMemBuffer(&mem, data->bytes_, data->size_)) return NULL;
|
if (!InitMemBuffer(&mem, data->bytes, data->size)) return NULL;
|
||||||
if (!ReadHeader(&mem)) return NULL;
|
if (!ReadHeader(&mem)) return NULL;
|
||||||
|
|
||||||
partial = (mem.buf_size_ < mem.riff_end_);
|
partial = (mem.buf_size_ < mem.riff_end_);
|
||||||
@ -755,18 +755,18 @@ static int SynthesizeFrame(const WebPDemuxer* const dmux,
|
|||||||
const uint8_t* const payload = GetFramePayload(mem_buf, tile, &payload_size);
|
const uint8_t* const payload = GetFramePayload(mem_buf, tile, &payload_size);
|
||||||
if (payload == NULL) return 0;
|
if (payload == NULL) return 0;
|
||||||
|
|
||||||
iter->frame_num_ = first_frame->frame_num_;
|
iter->frame_num = first_frame->frame_num_;
|
||||||
iter->num_frames_ = dmux->num_frames_;
|
iter->num_frames = dmux->num_frames_;
|
||||||
iter->tile_num_ = tile_num;
|
iter->tile_num = tile_num;
|
||||||
iter->num_tiles_ = num_tiles;
|
iter->num_tiles = num_tiles;
|
||||||
iter->x_offset_ = tile->x_offset_;
|
iter->x_offset = tile->x_offset_;
|
||||||
iter->y_offset_ = tile->y_offset_;
|
iter->y_offset = tile->y_offset_;
|
||||||
iter->width_ = tile->width_;
|
iter->width = tile->width_;
|
||||||
iter->height_ = tile->height_;
|
iter->height = tile->height_;
|
||||||
iter->duration_ = tile->duration_;
|
iter->duration = tile->duration_;
|
||||||
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 'FRGM's embedded in 'ANMF's
|
// TODO(jzern): adjust offsets for 'FRGM's embedded in 'ANMF's
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -792,19 +792,19 @@ int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) {
|
|||||||
|
|
||||||
int WebPDemuxNextFrame(WebPIterator* iter) {
|
int WebPDemuxNextFrame(WebPIterator* iter) {
|
||||||
if (iter == NULL) return 0;
|
if (iter == NULL) return 0;
|
||||||
return SetFrame(iter->frame_num_ + 1, iter);
|
return SetFrame(iter->frame_num + 1, iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WebPDemuxPrevFrame(WebPIterator* iter) {
|
int WebPDemuxPrevFrame(WebPIterator* iter) {
|
||||||
if (iter == NULL) return 0;
|
if (iter == NULL) return 0;
|
||||||
if (iter->frame_num_ <= 1) return 0;
|
if (iter->frame_num <= 1) return 0;
|
||||||
return SetFrame(iter->frame_num_ - 1, iter);
|
return SetFrame(iter->frame_num - 1, iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WebPDemuxSelectTile(WebPIterator* iter, int tile) {
|
int WebPDemuxSelectTile(WebPIterator* iter, int tile) {
|
||||||
if (iter != NULL && iter->private_ != NULL && tile > 0) {
|
if (iter != NULL && iter->private_ != NULL && tile > 0) {
|
||||||
const WebPDemuxer* const dmux = (WebPDemuxer*)iter->private_;
|
const WebPDemuxer* const dmux = (WebPDemuxer*)iter->private_;
|
||||||
const Frame* const frame = GetFrame(dmux, iter->frame_num_);
|
const Frame* const frame = GetFrame(dmux, iter->frame_num);
|
||||||
if (frame == NULL) return 0;
|
if (frame == NULL) return 0;
|
||||||
|
|
||||||
return SynthesizeFrame(dmux, frame, tile, iter);
|
return SynthesizeFrame(dmux, frame, tile, iter);
|
||||||
@ -856,10 +856,10 @@ static int SetChunk(const char fourcc[4], int chunk_num,
|
|||||||
if (chunk_num <= count) {
|
if (chunk_num <= count) {
|
||||||
const uint8_t* const mem_buf = dmux->mem_.buf_;
|
const uint8_t* const mem_buf = dmux->mem_.buf_;
|
||||||
const Chunk* const chunk = GetChunk(dmux, fourcc, chunk_num);
|
const Chunk* const chunk = GetChunk(dmux, fourcc, chunk_num);
|
||||||
iter->chunk_.bytes_ = mem_buf + chunk->data_.offset_ + CHUNK_HEADER_SIZE;
|
iter->chunk.bytes = mem_buf + chunk->data_.offset_ + CHUNK_HEADER_SIZE;
|
||||||
iter->chunk_.size_ = chunk->data_.size_ - CHUNK_HEADER_SIZE;
|
iter->chunk.size = chunk->data_.size_ - CHUNK_HEADER_SIZE;
|
||||||
iter->num_chunks_ = count;
|
iter->num_chunks = count;
|
||||||
iter->chunk_num_ = chunk_num;
|
iter->chunk_num = chunk_num;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -878,17 +878,17 @@ int WebPDemuxGetChunk(const WebPDemuxer* dmux,
|
|||||||
int WebPDemuxNextChunk(WebPChunkIterator* iter) {
|
int WebPDemuxNextChunk(WebPChunkIterator* iter) {
|
||||||
if (iter != NULL) {
|
if (iter != NULL) {
|
||||||
const char* const fourcc =
|
const char* const fourcc =
|
||||||
(const char*)iter->chunk_.bytes_ - CHUNK_HEADER_SIZE;
|
(const char*)iter->chunk.bytes - CHUNK_HEADER_SIZE;
|
||||||
return SetChunk(fourcc, iter->chunk_num_ + 1, iter);
|
return SetChunk(fourcc, iter->chunk_num + 1, iter);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int WebPDemuxPrevChunk(WebPChunkIterator* iter) {
|
int WebPDemuxPrevChunk(WebPChunkIterator* iter) {
|
||||||
if (iter != NULL && iter->chunk_num_ > 1) {
|
if (iter != NULL && iter->chunk_num > 1) {
|
||||||
const char* const fourcc =
|
const char* const fourcc =
|
||||||
(const char*)iter->chunk_.bytes_ - CHUNK_HEADER_SIZE;
|
(const char*)iter->chunk.bytes - CHUNK_HEADER_SIZE;
|
||||||
return SetChunk(fourcc, iter->chunk_num_ - 1, iter);
|
return SetChunk(fourcc, iter->chunk_num - 1, iter);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -83,11 +83,11 @@ static WebPMuxError MuxSet(WebPMux* const mux, CHUNK_INDEX idx, uint32_t nth,
|
|||||||
SWITCH_ID_LIST(IDX_ICCP, &mux->iccp_);
|
SWITCH_ID_LIST(IDX_ICCP, &mux->iccp_);
|
||||||
SWITCH_ID_LIST(IDX_LOOP, &mux->loop_);
|
SWITCH_ID_LIST(IDX_LOOP, &mux->loop_);
|
||||||
SWITCH_ID_LIST(IDX_META, &mux->meta_);
|
SWITCH_ID_LIST(IDX_META, &mux->meta_);
|
||||||
if (idx == IDX_UNKNOWN && data->size_ > TAG_SIZE) {
|
if (idx == IDX_UNKNOWN && data->size > TAG_SIZE) {
|
||||||
// For raw-data unknown chunk, the first four bytes should be the tag to be
|
// For raw-data unknown chunk, the first four bytes should be the tag to be
|
||||||
// used for the chunk.
|
// used for the chunk.
|
||||||
const WebPData tmp = { data->bytes_ + TAG_SIZE, data->size_ - TAG_SIZE };
|
const WebPData tmp = { data->bytes + TAG_SIZE, data->size - TAG_SIZE };
|
||||||
err = ChunkAssignData(&chunk, &tmp, copy_data, GetLE32(data->bytes_ + 0));
|
err = ChunkAssignData(&chunk, &tmp, copy_data, GetLE32(data->bytes + 0));
|
||||||
if (err == WEBP_MUX_OK)
|
if (err == WEBP_MUX_OK)
|
||||||
err = ChunkSetNth(&chunk, &mux->unknown_, nth);
|
err = ChunkSetNth(&chunk, &mux->unknown_, nth);
|
||||||
}
|
}
|
||||||
@ -118,8 +118,8 @@ static WebPMuxError CreateFrameTileData(const WebPData* const image,
|
|||||||
const size_t frame_tile_size = kChunks[is_frame ? IDX_ANMF : IDX_FRGM].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) :
|
||||||
VP8GetInfo(image->bytes_, image->size_, image->size_, &width, &height);
|
VP8GetInfo(image->bytes, image->size, image->size, &width, &height);
|
||||||
if (!ok) return WEBP_MUX_INVALID_ARGUMENT;
|
if (!ok) return WEBP_MUX_INVALID_ARGUMENT;
|
||||||
|
|
||||||
assert(width > 0 && height > 0 && duration > 0);
|
assert(width > 0 && height > 0 && duration > 0);
|
||||||
@ -137,8 +137,8 @@ static WebPMuxError CreateFrameTileData(const WebPData* const image,
|
|||||||
PutLE24(frame_tile_bytes + 12, duration - 1);
|
PutLE24(frame_tile_bytes + 12, duration - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_tile->bytes_ = frame_tile_bytes;
|
frame_tile->bytes = frame_tile_bytes;
|
||||||
frame_tile->size_ = frame_tile_size;
|
frame_tile->size = frame_tile_size;
|
||||||
return WEBP_MUX_OK;
|
return WEBP_MUX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +149,8 @@ static WebPMuxError GetImageData(const WebPData* const bitstream,
|
|||||||
WebPData* const image, WebPData* const alpha,
|
WebPData* const image, WebPData* const alpha,
|
||||||
int* const is_lossless) {
|
int* const is_lossless) {
|
||||||
WebPDataInit(alpha); // Default: no alpha.
|
WebPDataInit(alpha); // Default: no alpha.
|
||||||
if (bitstream->size_ < TAG_SIZE ||
|
if (bitstream->size < TAG_SIZE ||
|
||||||
memcmp(bitstream->bytes_, "RIFF", TAG_SIZE)) {
|
memcmp(bitstream->bytes, "RIFF", TAG_SIZE)) {
|
||||||
// It is NOT webp file data. Return input data as is.
|
// It is NOT webp file data. Return input data as is.
|
||||||
*image = *bitstream;
|
*image = *bitstream;
|
||||||
} else {
|
} else {
|
||||||
@ -166,7 +166,7 @@ static WebPMuxError GetImageData(const WebPData* const bitstream,
|
|||||||
}
|
}
|
||||||
WebPMuxDelete(mux);
|
WebPMuxDelete(mux);
|
||||||
}
|
}
|
||||||
*is_lossless = VP8LCheckSignature(image->bytes_, image->size_);
|
*is_lossless = VP8LCheckSignature(image->bytes, image->size);
|
||||||
return WEBP_MUX_OK;
|
return WEBP_MUX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,8 +210,8 @@ WebPMuxError WebPMuxSetChunk(WebPMux* mux, const char fourcc[4],
|
|||||||
const CHUNK_INDEX idx = ChunkGetIndexFromFourCC(fourcc);
|
const CHUNK_INDEX idx = ChunkGetIndexFromFourCC(fourcc);
|
||||||
const uint32_t tag = ChunkGetTagFromFourCC(fourcc);
|
const uint32_t tag = ChunkGetTagFromFourCC(fourcc);
|
||||||
WebPMuxError err;
|
WebPMuxError err;
|
||||||
if (mux == NULL || chunk_data == NULL || chunk_data->bytes_ == NULL ||
|
if (mux == NULL || chunk_data == NULL || chunk_data->bytes == NULL ||
|
||||||
chunk_data->size_ > MAX_CHUNK_PAYLOAD) {
|
chunk_data->size > MAX_CHUNK_PAYLOAD) {
|
||||||
return WEBP_MUX_INVALID_ARGUMENT;
|
return WEBP_MUX_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ static WebPMuxError SetAlphaAndImageChunks(
|
|||||||
const int image_tag =
|
const int image_tag =
|
||||||
is_lossless ? kChunks[IDX_VP8L].tag : kChunks[IDX_VP8].tag;
|
is_lossless ? kChunks[IDX_VP8L].tag : kChunks[IDX_VP8].tag;
|
||||||
if (err != WEBP_MUX_OK) return err;
|
if (err != WEBP_MUX_OK) return err;
|
||||||
if (alpha.bytes_ != NULL) {
|
if (alpha.bytes != NULL) {
|
||||||
err = AddDataToChunkList(&alpha, copy_data, kChunks[IDX_ALPHA].tag,
|
err = AddDataToChunkList(&alpha, copy_data, kChunks[IDX_ALPHA].tag,
|
||||||
&wpi->alpha_);
|
&wpi->alpha_);
|
||||||
if (err != WEBP_MUX_OK) return err;
|
if (err != WEBP_MUX_OK) return err;
|
||||||
@ -264,8 +264,8 @@ WebPMuxError WebPMuxSetImage(WebPMux* mux, const WebPData* bitstream,
|
|||||||
WebPMuxError err;
|
WebPMuxError err;
|
||||||
|
|
||||||
// Sanity checks.
|
// Sanity checks.
|
||||||
if (mux == NULL || bitstream == NULL || bitstream->bytes_ == NULL ||
|
if (mux == NULL || bitstream == NULL || bitstream->bytes == NULL ||
|
||||||
bitstream->size_ > MAX_CHUNK_PAYLOAD) {
|
bitstream->size > MAX_CHUNK_PAYLOAD) {
|
||||||
return WEBP_MUX_INVALID_ARGUMENT;
|
return WEBP_MUX_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame,
|
|||||||
WebPMuxImage wpi;
|
WebPMuxImage wpi;
|
||||||
WebPMuxError err;
|
WebPMuxError err;
|
||||||
int is_frame;
|
int is_frame;
|
||||||
const WebPData* const bitstream = &frame->bitstream_;
|
const WebPData* const bitstream = &frame->bitstream;
|
||||||
|
|
||||||
// Sanity checks.
|
// Sanity checks.
|
||||||
if (mux == NULL || frame == NULL) return WEBP_MUX_INVALID_ARGUMENT;
|
if (mux == NULL || frame == NULL) return WEBP_MUX_INVALID_ARGUMENT;
|
||||||
@ -305,7 +305,7 @@ WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame,
|
|||||||
return WEBP_MUX_INVALID_ARGUMENT;
|
return WEBP_MUX_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bitstream->bytes_ == NULL || bitstream->size_ > MAX_CHUNK_PAYLOAD) {
|
if (bitstream->bytes == NULL || bitstream->size > MAX_CHUNK_PAYLOAD) {
|
||||||
return WEBP_MUX_INVALID_ARGUMENT;
|
return WEBP_MUX_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,9 +325,9 @@ WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame,
|
|||||||
|
|
||||||
{
|
{
|
||||||
const int is_lossless = (wpi.img_->tag_ == kChunks[IDX_VP8L].tag);
|
const int is_lossless = (wpi.img_->tag_ == kChunks[IDX_VP8L].tag);
|
||||||
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_ANMF : IDX_FRGM].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 ||
|
||||||
@ -398,11 +398,11 @@ static WebPMuxError GetFrameTileInfo(const WebPChunk* const frame_tile_chunk,
|
|||||||
is_frame ? ANMF_CHUNK_SIZE : FRGM_CHUNK_SIZE;
|
is_frame ? ANMF_CHUNK_SIZE : FRGM_CHUNK_SIZE;
|
||||||
assert(frame_tile_chunk != NULL);
|
assert(frame_tile_chunk != NULL);
|
||||||
assert(tag == kChunks[IDX_ANMF].tag || tag == kChunks[IDX_FRGM].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);
|
||||||
*y_offset = 2 * GetLE24(data->bytes_ + 3);
|
*y_offset = 2 * GetLE24(data->bytes + 3);
|
||||||
if (is_frame) *duration = 1 + GetLE24(data->bytes_ + 12);
|
if (is_frame) *duration = 1 + GetLE24(data->bytes + 12);
|
||||||
return WEBP_MUX_OK;
|
return WEBP_MUX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,8 +415,8 @@ WebPMuxError MuxGetImageWidthHeight(const WebPChunk* const image_chunk,
|
|||||||
assert(image_chunk != NULL);
|
assert(image_chunk != NULL);
|
||||||
assert(tag == kChunks[IDX_VP8].tag || tag == kChunks[IDX_VP8L].tag);
|
assert(tag == kChunks[IDX_VP8].tag || tag == kChunks[IDX_VP8L].tag);
|
||||||
ok = (tag == kChunks[IDX_VP8].tag) ?
|
ok = (tag == kChunks[IDX_VP8].tag) ?
|
||||||
VP8GetInfo(data->bytes_, data->size_, data->size_, &w, &h) :
|
VP8GetInfo(data->bytes, data->size, data->size, &w, &h) :
|
||||||
VP8LGetInfo(data->bytes_, data->size_, &w, &h, NULL);
|
VP8LGetInfo(data->bytes, data->size, &w, &h, NULL);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
*width = w;
|
*width = w;
|
||||||
*height = h;
|
*height = h;
|
||||||
@ -512,7 +512,7 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
|
|||||||
assert(mux != NULL);
|
assert(mux != NULL);
|
||||||
images = mux->images_; // First image.
|
images = mux->images_; // First image.
|
||||||
if (images == NULL || images->img_ == NULL ||
|
if (images == NULL || images->img_ == NULL ||
|
||||||
images->img_->data_.bytes_ == NULL) {
|
images->img_->data_.bytes == NULL) {
|
||||||
return WEBP_MUX_INVALID_ARGUMENT;
|
return WEBP_MUX_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,11 +522,11 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) {
|
|||||||
if (err != WEBP_MUX_OK && err != WEBP_MUX_NOT_FOUND) return err;
|
if (err != WEBP_MUX_OK && err != WEBP_MUX_NOT_FOUND) return err;
|
||||||
|
|
||||||
// Set flags.
|
// Set flags.
|
||||||
if (mux->iccp_ != NULL && mux->iccp_->data_.bytes_ != NULL) {
|
if (mux->iccp_ != NULL && mux->iccp_->data_.bytes != NULL) {
|
||||||
flags |= ICCP_FLAG;
|
flags |= ICCP_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mux->meta_ != NULL && mux->meta_->data_.bytes_ != NULL) {
|
if (mux->meta_ != NULL && mux->meta_->data_.bytes != NULL) {
|
||||||
flags |= META_FLAG;
|
flags |= META_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,8 +631,8 @@ WebPMuxError WebPMuxAssemble(WebPMux* mux, WebPData* assembled_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Finalize.
|
// Finalize.
|
||||||
assembled_data->bytes_ = data;
|
assembled_data->bytes = data;
|
||||||
assembled_data->size_ = size;
|
assembled_data->size = size;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ WebPChunk* ChunkDelete(WebPChunk* const chunk);
|
|||||||
|
|
||||||
// Size of a chunk including header and padding.
|
// Size of a chunk including header and padding.
|
||||||
static WEBP_INLINE size_t ChunkDiskSize(const WebPChunk* chunk) {
|
static WEBP_INLINE size_t ChunkDiskSize(const WebPChunk* chunk) {
|
||||||
const size_t data_size = chunk->data_.size_;
|
const size_t data_size = chunk->data_.size;
|
||||||
assert(data_size < MAX_CHUNK_PAYLOAD);
|
assert(data_size < MAX_CHUNK_PAYLOAD);
|
||||||
return SizeWithPadding(data_size);
|
return SizeWithPadding(data_size);
|
||||||
}
|
}
|
||||||
|
@ -143,10 +143,10 @@ WebPMuxError ChunkAssignData(WebPChunk* chunk, const WebPData* const data,
|
|||||||
if (data != NULL) {
|
if (data != NULL) {
|
||||||
if (copy_data) {
|
if (copy_data) {
|
||||||
// Copy data.
|
// Copy data.
|
||||||
chunk->data_.bytes_ = (uint8_t*)malloc(data->size_);
|
chunk->data_.bytes = (uint8_t*)malloc(data->size);
|
||||||
if (chunk->data_.bytes_ == NULL) return WEBP_MUX_MEMORY_ERROR;
|
if (chunk->data_.bytes == NULL) return WEBP_MUX_MEMORY_ERROR;
|
||||||
memcpy((uint8_t*)chunk->data_.bytes_, data->bytes_, data->size_);
|
memcpy((uint8_t*)chunk->data_.bytes, data->bytes, data->size);
|
||||||
chunk->data_.size_ = data->size_;
|
chunk->data_.size = data->size;
|
||||||
|
|
||||||
// Chunk is owner of data.
|
// Chunk is owner of data.
|
||||||
chunk->owner_ = 1;
|
chunk->owner_ = 1;
|
||||||
@ -199,13 +199,13 @@ size_t ChunksListDiskSize(const WebPChunk* chunk_list) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t* ChunkEmit(const WebPChunk* const chunk, uint8_t* dst) {
|
static uint8_t* ChunkEmit(const WebPChunk* const chunk, uint8_t* dst) {
|
||||||
const size_t chunk_size = chunk->data_.size_;
|
const size_t chunk_size = chunk->data_.size;
|
||||||
assert(chunk);
|
assert(chunk);
|
||||||
assert(chunk->tag_ != NIL_TAG);
|
assert(chunk->tag_ != NIL_TAG);
|
||||||
PutLE32(dst + 0, chunk->tag_);
|
PutLE32(dst + 0, chunk->tag_);
|
||||||
PutLE32(dst + TAG_SIZE, (uint32_t)chunk_size);
|
PutLE32(dst + TAG_SIZE, (uint32_t)chunk_size);
|
||||||
assert(chunk_size == (uint32_t)chunk_size);
|
assert(chunk_size == (uint32_t)chunk_size);
|
||||||
memcpy(dst + CHUNK_HEADER_SIZE, chunk->data_.bytes_, chunk_size);
|
memcpy(dst + CHUNK_HEADER_SIZE, chunk->data_.bytes, chunk_size);
|
||||||
if (chunk_size & 1)
|
if (chunk_size & 1)
|
||||||
dst[CHUNK_HEADER_SIZE + chunk_size] = 0; // Add padding.
|
dst[CHUNK_HEADER_SIZE + chunk_size] = 0; // Add padding.
|
||||||
return dst + ChunkDiskSize(chunk);
|
return dst + ChunkDiskSize(chunk);
|
||||||
@ -230,7 +230,7 @@ void WebPDataInit(WebPData* webp_data) {
|
|||||||
|
|
||||||
void WebPDataClear(WebPData* webp_data) {
|
void WebPDataClear(WebPData* webp_data) {
|
||||||
if (webp_data != NULL) {
|
if (webp_data != NULL) {
|
||||||
free((void*)webp_data->bytes_);
|
free((void*)webp_data->bytes);
|
||||||
WebPDataInit(webp_data);
|
WebPDataInit(webp_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,11 +239,11 @@ int WebPDataCopy(const WebPData* src, WebPData* dst) {
|
|||||||
if (src == NULL || dst == NULL) return 0;
|
if (src == NULL || dst == NULL) return 0;
|
||||||
|
|
||||||
WebPDataInit(dst);
|
WebPDataInit(dst);
|
||||||
if (src->bytes_ != NULL && src->size_ != 0) {
|
if (src->bytes != NULL && src->size != 0) {
|
||||||
dst->bytes_ = (uint8_t*)malloc(src->size_);
|
dst->bytes = (uint8_t*)malloc(src->size);
|
||||||
if (dst->bytes_ == NULL) return 0;
|
if (dst->bytes == NULL) return 0;
|
||||||
memcpy((void*)dst->bytes_, src->bytes_, src->size_);
|
memcpy((void*)dst->bytes, src->bytes, src->size);
|
||||||
dst->size_ = src->size_;
|
dst->size = src->size;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,8 @@ static WebPMuxError ChunkVerifyAndAssignData(WebPChunk* chunk,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Data assignment.
|
// Data assignment.
|
||||||
chunk_data.bytes_ = data + CHUNK_HEADER_SIZE;
|
chunk_data.bytes = data + CHUNK_HEADER_SIZE;
|
||||||
chunk_data.size_ = chunk_size;
|
chunk_data.size = chunk_size;
|
||||||
return ChunkAssignData(chunk, &chunk_data, copy_data, GetLE32(data + 0));
|
return ChunkAssignData(chunk, &chunk_data, copy_data, GetLE32(data + 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,8 +94,8 @@ WebPMux* WebPMuxCreateInternal(const WebPData* bitstream, int copy_data,
|
|||||||
}
|
}
|
||||||
if (bitstream == NULL) return NULL;
|
if (bitstream == NULL) return NULL;
|
||||||
|
|
||||||
data = bitstream->bytes_;
|
data = bitstream->bytes;
|
||||||
size = bitstream->size_;
|
size = bitstream->size;
|
||||||
|
|
||||||
if (data == NULL) return NULL;
|
if (data == NULL) return NULL;
|
||||||
if (size < RIFF_HEADER_SIZE) return NULL;
|
if (size < RIFF_HEADER_SIZE) return NULL;
|
||||||
@ -207,10 +207,10 @@ WebPMuxError WebPMuxGetFeatures(const WebPMux* mux, uint32_t* flags) {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.size_ < CHUNK_SIZE_BYTES) return WEBP_MUX_BAD_DATA;
|
if (data.size < CHUNK_SIZE_BYTES) return WEBP_MUX_BAD_DATA;
|
||||||
|
|
||||||
// All OK. Fill up flags.
|
// All OK. Fill up flags.
|
||||||
*flags = GetLE32(data.bytes_);
|
*flags = GetLE32(data.bytes);
|
||||||
return WEBP_MUX_OK;
|
return WEBP_MUX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,8 +264,8 @@ static WebPMuxError SynthesizeBitstream(const WebPMuxImage* const wpi,
|
|||||||
assert(dst == data + size);
|
assert(dst == data + size);
|
||||||
|
|
||||||
// Output.
|
// Output.
|
||||||
bitstream->bytes_ = data;
|
bitstream->bytes = data;
|
||||||
bitstream->size_ = size;
|
bitstream->size = size;
|
||||||
return WEBP_MUX_OK;
|
return WEBP_MUX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,12 +289,12 @@ WebPMuxError WebPMuxGetChunk(const WebPMux* mux, const char fourcc[4],
|
|||||||
static WebPMuxError MuxGetImageInternal(const WebPMuxImage* const wpi,
|
static WebPMuxError MuxGetImageInternal(const WebPMuxImage* const wpi,
|
||||||
WebPMuxFrameInfo* const info) {
|
WebPMuxFrameInfo* const info) {
|
||||||
// Set some defaults for unrelated fields.
|
// Set some defaults for unrelated fields.
|
||||||
info->x_offset_ = 0;
|
info->x_offset = 0;
|
||||||
info->y_offset_ = 0;
|
info->y_offset = 0;
|
||||||
info->duration_ = 1;
|
info->duration = 1;
|
||||||
// Extract data for related fields.
|
// Extract data for related fields.
|
||||||
info->id = ChunkGetIdFromTag(wpi->img_->tag_);
|
info->id = ChunkGetIdFromTag(wpi->img_->tag_);
|
||||||
return SynthesizeBitstream(wpi, &info->bitstream_);
|
return SynthesizeBitstream(wpi, &info->bitstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
static WebPMuxError MuxGetFrameTileInternal(const WebPMuxImage* const wpi,
|
static WebPMuxError MuxGetFrameTileInternal(const WebPMuxImage* const wpi,
|
||||||
@ -305,13 +305,13 @@ static WebPMuxError MuxGetFrameTileInternal(const WebPMuxImage* const wpi,
|
|||||||
assert(wpi->header_ != NULL); // Already checked by WebPMuxGetFrame().
|
assert(wpi->header_ != NULL); // Already checked by WebPMuxGetFrame().
|
||||||
// Get frame/tile chunk.
|
// Get frame/tile chunk.
|
||||||
frame_tile_data = &wpi->header_->data_;
|
frame_tile_data = &wpi->header_->data_;
|
||||||
if (frame_tile_data->size_ < kChunks[idx].size) return WEBP_MUX_BAD_DATA;
|
if (frame_tile_data->size < kChunks[idx].size) return WEBP_MUX_BAD_DATA;
|
||||||
// Extract info.
|
// Extract info.
|
||||||
frame->x_offset_ = 2 * GetLE24(frame_tile_data->bytes_ + 0);
|
frame->x_offset = 2 * GetLE24(frame_tile_data->bytes + 0);
|
||||||
frame->y_offset_ = 2 * GetLE24(frame_tile_data->bytes_ + 3);
|
frame->y_offset = 2 * GetLE24(frame_tile_data->bytes + 3);
|
||||||
frame->duration_ = is_frame ? 1 + GetLE24(frame_tile_data->bytes_ + 12) : 1;
|
frame->duration = is_frame ? 1 + GetLE24(frame_tile_data->bytes + 12) : 1;
|
||||||
frame->id = ChunkGetIdFromTag(wpi->header_->tag_);
|
frame->id = ChunkGetIdFromTag(wpi->header_->tag_);
|
||||||
return SynthesizeBitstream(wpi, &frame->bitstream_);
|
return SynthesizeBitstream(wpi, &frame->bitstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebPMuxError WebPMuxGetFrame(
|
WebPMuxError WebPMuxGetFrame(
|
||||||
@ -344,8 +344,8 @@ WebPMuxError WebPMuxGetLoopCount(const WebPMux* mux, int* loop_count) {
|
|||||||
|
|
||||||
err = MuxGet(mux, IDX_LOOP, 1, &image);
|
err = MuxGet(mux, IDX_LOOP, 1, &image);
|
||||||
if (err != WEBP_MUX_OK) return err;
|
if (err != WEBP_MUX_OK) return err;
|
||||||
if (image.size_ < kChunks[WEBP_CHUNK_LOOP].size) return WEBP_MUX_BAD_DATA;
|
if (image.size < kChunks[WEBP_CHUNK_LOOP].size) return WEBP_MUX_BAD_DATA;
|
||||||
*loop_count = GetLE16(image.bytes_);
|
*loop_count = GetLE16(image.bytes);
|
||||||
|
|
||||||
return WEBP_MUX_OK;
|
return WEBP_MUX_OK;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
// // Get data from mux in WebP RIFF format.
|
// // Get data from mux in WebP RIFF format.
|
||||||
// WebPMuxAssemble(mux, &output_data);
|
// WebPMuxAssemble(mux, &output_data);
|
||||||
// WebPMuxDelete(mux);
|
// WebPMuxDelete(mux);
|
||||||
// // ... (Consume output_data; e.g. write output_data.bytes_ to file).
|
// // ... (Consume output_data; e.g. write output_data.bytes to file).
|
||||||
// WebPDataClear(&output_data);
|
// WebPDataClear(&output_data);
|
||||||
//
|
//
|
||||||
// Code Example#2: Get image and color profile data from a WebP file.
|
// Code Example#2: Get image and color profile data from a WebP file.
|
||||||
@ -106,8 +106,8 @@ enum WebPChunkId {
|
|||||||
// Data type used to describe 'raw' data, e.g., chunk data
|
// Data type used to describe 'raw' data, e.g., chunk data
|
||||||
// (ICC profile, metadata) and WebP compressed image data.
|
// (ICC profile, metadata) and WebP compressed image data.
|
||||||
struct WebPData {
|
struct WebPData {
|
||||||
const uint8_t* bytes_;
|
const uint8_t* bytes;
|
||||||
size_t size_;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@ -220,15 +220,15 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteChunk(
|
|||||||
|
|
||||||
// Encapsulates data about a single frame/tile.
|
// Encapsulates data about a single frame/tile.
|
||||||
struct WebPMuxFrameInfo {
|
struct WebPMuxFrameInfo {
|
||||||
WebPData bitstream_; // image data: can either be a raw VP8/VP8L bitstream
|
WebPData bitstream; // image data: can either be a raw VP8/VP8L bitstream
|
||||||
// or a single-image WebP file.
|
// or a single-image WebP file.
|
||||||
int x_offset_; // x-offset of the frame.
|
int x_offset; // x-offset of the frame.
|
||||||
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_ANMF,
|
WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF,
|
||||||
// WEBP_CHUNK_FRGM 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
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sets the (non-animated and non-tiled) image in the mux object.
|
// Sets the (non-animated and non-tiled) image in the mux object.
|
||||||
@ -267,7 +267,7 @@ WEBP_EXTERN(WebPMuxError) WebPMuxPushFrame(
|
|||||||
WebPMux* mux, const WebPMuxFrameInfo* frame, int copy_data);
|
WebPMux* mux, const WebPMuxFrameInfo* frame, int copy_data);
|
||||||
|
|
||||||
// Gets the nth frame from the mux object.
|
// Gets the nth frame from the mux object.
|
||||||
// The content of 'frame->bitstream_' is allocated using malloc(), and NOT
|
// The content of 'frame->bitstream' is allocated using malloc(), and NOT
|
||||||
// owned by the 'mux' object. It MUST be deallocated by the caller by calling
|
// owned by the 'mux' object. It MUST be deallocated by the caller by calling
|
||||||
// WebPDataClear().
|
// WebPDataClear().
|
||||||
// nth=0 has a special meaning - last position.
|
// nth=0 has a special meaning - last position.
|
||||||
@ -424,19 +424,19 @@ WEBP_EXTERN(uint32_t) WebPDemuxGetI(
|
|||||||
// Frame iteration.
|
// Frame iteration.
|
||||||
|
|
||||||
struct WebPIterator {
|
struct WebPIterator {
|
||||||
int frame_num_;
|
int frame_num;
|
||||||
int num_frames_;
|
int num_frames;
|
||||||
int tile_num_;
|
int tile_num;
|
||||||
int num_tiles_;
|
int num_tiles;
|
||||||
int x_offset_, y_offset_; // offset relative to the canvas.
|
int x_offset, y_offset; // offset relative to the canvas.
|
||||||
int width_, height_; // dimensions of this frame or tile.
|
int width, height; // dimensions of this frame or tile.
|
||||||
int duration_; // display duration in milliseconds.
|
int duration; // display duration in milliseconds.
|
||||||
int complete_; // true if 'tile_' contains a full frame. partial images may
|
int complete; // true if 'tile_' contains a full frame. partial images may
|
||||||
// still be decoded with the WebP incremental decoder.
|
// still be decoded with the WebP incremental decoder.
|
||||||
WebPData tile_; // The frame or tile given by 'frame_num_' and 'tile_num_'.
|
WebPData tile; // The frame or tile given by 'frame_num_' and 'tile_num_'.
|
||||||
|
|
||||||
uint32_t pad[4]; // padding for later use
|
uint32_t pad[4]; // padding for later use
|
||||||
void* private_;
|
void* private_; // for internal use only.
|
||||||
};
|
};
|
||||||
|
|
||||||
// Retrieves frame 'frame_number' from 'dmux'.
|
// Retrieves frame 'frame_number' from 'dmux'.
|
||||||
@ -470,11 +470,11 @@ WEBP_EXTERN(void) WebPDemuxReleaseIterator(WebPIterator* iter);
|
|||||||
struct WebPChunkIterator {
|
struct WebPChunkIterator {
|
||||||
// The current and total number of chunks with the fourcc given to
|
// The current and total number of chunks with the fourcc given to
|
||||||
// WebPDemuxGetChunk().
|
// WebPDemuxGetChunk().
|
||||||
int chunk_num_;
|
int chunk_num;
|
||||||
int num_chunks_;
|
int num_chunks;
|
||||||
WebPData chunk_; // The payload of the chunk.
|
WebPData chunk; // The payload of the chunk.
|
||||||
|
|
||||||
uint32_t pad[6]; // padding for later use
|
uint32_t pad[6]; // padding for later use
|
||||||
void* private_;
|
void* private_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user