From a0770727776c6d1f5ef6b5ef60d22786af50357b Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Tue, 30 Oct 2012 14:54:46 -0700 Subject: [PATCH] mux struct naming members of public structs should not have a trailing underscore. Change-Id: Ieef42e1da115bf42b0ea42159701e32bed7b9f60 --- README.mux | 2 +- examples/vwebp.c | 14 +++++----- examples/webpmux.c | 50 +++++++++++++++++----------------- src/mux/demux.c | 54 ++++++++++++++++++------------------- src/mux/muxedit.c | 62 +++++++++++++++++++++---------------------- src/mux/muxi.h | 2 +- src/mux/muxinternal.c | 24 ++++++++--------- src/mux/muxread.c | 38 +++++++++++++------------- src/webp/mux.h | 54 ++++++++++++++++++------------------- 9 files changed, 150 insertions(+), 150 deletions(-) diff --git a/README.mux b/README.mux index 965b772c..74c8e930 100644 --- a/README.mux +++ b/README.mux @@ -85,7 +85,7 @@ profile & XMP metadata. // Get data from mux in WebP RIFF format. WebPMuxAssemble(mux, &output_data); 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); diff --git a/examples/vwebp.c b/examples/vwebp.c index 90bc4a5b..f2f211d9 100644 --- a/examples/vwebp.c +++ b/examples/vwebp.c @@ -178,17 +178,17 @@ static int Decode(int* const duration) { int ok = 0; ClearPreviousPic(); - if (iter->x_offset_ != 0 || iter->y_offset_ != 0) { + if (iter->x_offset != 0 || iter->y_offset != 0) { fprintf(stderr, "Frame offsets not yet supported! Forcing offset to 0,0\n"); } 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); 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 { - *duration = iter->duration_; + *duration = iter->duration; kParams.pic = output_buffer; } return ok; @@ -288,7 +288,7 @@ int main(int argc, char *argv[]) { } if (!ExUtilReadFile(kParams.file_name, - &kParams.data.bytes_, &kParams.data.size_)) { + &kParams.data.bytes, &kParams.data.size)) { goto Error; } @@ -305,10 +305,10 @@ int main(int argc, char *argv[]) { 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); 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 { diff --git a/examples/webpmux.c b/examples/webpmux.c index 5e555b66..c2dd11d8 100644 --- a/examples/webpmux.c +++ b/examples/webpmux.c @@ -215,10 +215,10 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) { WebPMuxFrameInfo frame; err = WebPMuxGetFrame(mux, i, &frame); RETURN_IF_ERROR3("Failed to retrieve %s#%d\n", type_str, i); - printf("%3d: %8d %8d ", i, frame.x_offset_, frame.y_offset_); - if (is_anim) printf("%8d ", frame.duration_); - printf("%10zu\n", frame.bitstream_.size_); - WebPDataClear(&frame.bitstream_); + printf("%3d: %8d %8d ", i, frame.x_offset, frame.y_offset); + if (is_anim) printf("%8d ", frame.duration); + printf("%10zu\n", frame.bitstream.size); + WebPDataClear(&frame.bitstream); } } } @@ -227,21 +227,21 @@ static WebPMuxError DisplayInfo(const WebPMux* mux) { WebPData icc_profile; err = WebPMuxGetChunk(mux, "ICCP", &icc_profile); 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) { WebPData metadata; err = WebPMuxGetChunk(mux, "META", &metadata); 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))) { WebPMuxFrameInfo image; err = WebPMuxGetFrame(mux, 1, &image); 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; @@ -302,8 +302,8 @@ static int ReadFileToWebPData(const char* const filename, const uint8_t* data; size_t size; if (!ExUtilReadFile(filename, &data, &size)) return 0; - webp_data->bytes_ = data; - webp_data->size_ = size; + webp_data->bytes = data; + webp_data->size = size; return 1; } @@ -312,7 +312,7 @@ static int CreateMux(const char* const filename, WebPMux** mux) { assert(mux != NULL); if (!ReadFileToWebPData(filename, &bitstream)) return 0; *mux = WebPMuxCreate(&bitstream, 1); - free((void*)bitstream.bytes_); + free((void*)bitstream.bytes); if (*mux != NULL) return 1; fprintf(stderr, "Failed to create mux object from file %s.\n", filename); 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); 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); } 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; } 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) { 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) { - 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; const WebPChunkId id = isFrame ? WEBP_CHUNK_ANMF : WEBP_CHUNK_FRGM; WebPMuxFrameInfo info; - WebPDataInit(&info.bitstream_); + WebPDataInit(&info.bitstream); num = strtol(config->feature_.args_[0].params_, NULL, 10); if (num < 0) { @@ -706,7 +706,7 @@ static int GetFrameTile(const WebPMux* mux, ERROR_GOTO2("ERROR (%s): Could not allocate a mux object.\n", ErrorString(err), ErrGet); } - err = WebPMuxSetImage(mux_single, &info.bitstream_, 1); + err = WebPMuxSetImage(mux_single, &info.bitstream, 1); if (err != WEBP_MUX_OK) { ERROR_GOTO2("ERROR (%s): Could not create single image mux object.\n", ErrorString(err), ErrGet); @@ -715,7 +715,7 @@ static int GetFrameTile(const WebPMux* mux, ok = WriteWebP(mux_single, config->output_); ErrGet: - WebPDataClear(&info.bitstream_); + WebPDataClear(&info.bitstream); WebPMuxDelete(mux_single); return ok; } @@ -787,16 +787,16 @@ static int Process(const WebPMuxConfig* config) { } else if (feature->args_[index].subtype_ == SUBTYPE_FRM) { WebPMuxFrameInfo frame; ok = ReadFileToWebPData(feature->args_[index].filename_, - &frame.bitstream_); + &frame.bitstream); if (!ok) goto Err2; ok = ParseFrameArgs(feature->args_[index].params_, &frame); if (!ok) { - WebPDataClear(&frame.bitstream_); + WebPDataClear(&frame.bitstream); ERROR_GOTO1("ERROR: Could not parse frame properties.\n", Err2); } frame.id = WEBP_CHUNK_ANMF; err = WebPMuxPushFrame(mux, &frame, 1); - WebPDataClear(&frame.bitstream_); + WebPDataClear(&frame.bitstream); if (err != WEBP_MUX_OK) { ERROR_GOTO3("ERROR (%s): Could not add a frame at index %d.\n", ErrorString(err), index, Err2); @@ -816,16 +816,16 @@ static int Process(const WebPMuxConfig* config) { for (index = 0; index < feature->arg_count_; ++index) { WebPMuxFrameInfo tile; ok = ReadFileToWebPData(feature->args_[index].filename_, - &tile.bitstream_); + &tile.bitstream); if (!ok) goto Err2; ok = ParseTileArgs(feature->args_[index].params_, &tile); if (!ok) { - WebPDataClear(&tile.bitstream_); + WebPDataClear(&tile.bitstream); ERROR_GOTO1("ERROR: Could not parse tile properties.\n", Err2); } tile.id = WEBP_CHUNK_FRGM; err = WebPMuxPushFrame(mux, &tile, 1); - WebPDataClear(&tile.bitstream_); + WebPDataClear(&tile.bitstream); if (err != WEBP_MUX_OK) { ERROR_GOTO3("ERROR (%s): Could not add a tile at index %d.\n", ErrorString(err), index, Err2); @@ -839,7 +839,7 @@ static int Process(const WebPMuxConfig* config) { ok = ReadFileToWebPData(feature->args_[0].filename_, &color_profile); if (!ok) goto Err2; err = WebPMuxSetChunk(mux, "ICCP", &color_profile, 1); - free((void*)color_profile.bytes_); + free((void*)color_profile.bytes); if (err != WEBP_MUX_OK) { ERROR_GOTO2("ERROR (%s): Could not set color profile.\n", ErrorString(err), Err2); @@ -852,7 +852,7 @@ static int Process(const WebPMuxConfig* config) { ok = ReadFileToWebPData(feature->args_[0].filename_, &metadata); if (!ok) goto Err2; err = WebPMuxSetChunk(mux, "META", &metadata, 1); - free((void*)metadata.bytes_); + free((void*)metadata.bytes); if (err != WEBP_MUX_OK) { ERROR_GOTO2("ERROR (%s): Could not set the metadata.\n", ErrorString(err), Err2); diff --git a/src/mux/demux.c b/src/mux/demux.c index 989f475c..0643cbe0 100644 --- a/src/mux/demux.c +++ b/src/mux/demux.c @@ -632,9 +632,9 @@ WebPDemuxer* WebPDemuxInternal(const WebPData* data, int allow_partial, WebPDemuxer* dmux; 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; 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); if (payload == NULL) return 0; - iter->frame_num_ = first_frame->frame_num_; - iter->num_frames_ = dmux->num_frames_; - iter->tile_num_ = tile_num; - iter->num_tiles_ = num_tiles; - iter->x_offset_ = tile->x_offset_; - iter->y_offset_ = tile->y_offset_; - iter->width_ = tile->width_; - iter->height_ = tile->height_; - iter->duration_ = tile->duration_; - iter->complete_ = tile->complete_; - iter->tile_.bytes_ = payload; - iter->tile_.size_ = payload_size; + iter->frame_num = first_frame->frame_num_; + iter->num_frames = dmux->num_frames_; + iter->tile_num = tile_num; + iter->num_tiles = num_tiles; + iter->x_offset = tile->x_offset_; + iter->y_offset = tile->y_offset_; + iter->width = tile->width_; + iter->height = tile->height_; + iter->duration = tile->duration_; + iter->complete = tile->complete_; + iter->tile.bytes = payload; + iter->tile.size = payload_size; // TODO(jzern): adjust offsets for 'FRGM's embedded in 'ANMF's return 1; } @@ -792,19 +792,19 @@ int WebPDemuxGetFrame(const WebPDemuxer* dmux, int frame, WebPIterator* iter) { int WebPDemuxNextFrame(WebPIterator* iter) { if (iter == NULL) return 0; - return SetFrame(iter->frame_num_ + 1, iter); + return SetFrame(iter->frame_num + 1, iter); } int WebPDemuxPrevFrame(WebPIterator* iter) { if (iter == NULL) return 0; - if (iter->frame_num_ <= 1) return 0; - return SetFrame(iter->frame_num_ - 1, iter); + if (iter->frame_num <= 1) return 0; + return SetFrame(iter->frame_num - 1, iter); } int WebPDemuxSelectTile(WebPIterator* iter, int tile) { if (iter != NULL && iter->private_ != NULL && tile > 0) { 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; return SynthesizeFrame(dmux, frame, tile, iter); @@ -856,10 +856,10 @@ static int SetChunk(const char fourcc[4], int chunk_num, if (chunk_num <= count) { const uint8_t* const mem_buf = dmux->mem_.buf_; const Chunk* const chunk = GetChunk(dmux, fourcc, chunk_num); - iter->chunk_.bytes_ = mem_buf + chunk->data_.offset_ + CHUNK_HEADER_SIZE; - iter->chunk_.size_ = chunk->data_.size_ - CHUNK_HEADER_SIZE; - iter->num_chunks_ = count; - iter->chunk_num_ = chunk_num; + iter->chunk.bytes = mem_buf + chunk->data_.offset_ + CHUNK_HEADER_SIZE; + iter->chunk.size = chunk->data_.size_ - CHUNK_HEADER_SIZE; + iter->num_chunks = count; + iter->chunk_num = chunk_num; return 1; } return 0; @@ -878,17 +878,17 @@ int WebPDemuxGetChunk(const WebPDemuxer* dmux, int WebPDemuxNextChunk(WebPChunkIterator* iter) { if (iter != NULL) { const char* const fourcc = - (const char*)iter->chunk_.bytes_ - CHUNK_HEADER_SIZE; - return SetChunk(fourcc, iter->chunk_num_ + 1, iter); + (const char*)iter->chunk.bytes - CHUNK_HEADER_SIZE; + return SetChunk(fourcc, iter->chunk_num + 1, iter); } return 0; } int WebPDemuxPrevChunk(WebPChunkIterator* iter) { - if (iter != NULL && iter->chunk_num_ > 1) { + if (iter != NULL && iter->chunk_num > 1) { const char* const fourcc = - (const char*)iter->chunk_.bytes_ - CHUNK_HEADER_SIZE; - return SetChunk(fourcc, iter->chunk_num_ - 1, iter); + (const char*)iter->chunk.bytes - CHUNK_HEADER_SIZE; + return SetChunk(fourcc, iter->chunk_num - 1, iter); } return 0; } diff --git a/src/mux/muxedit.c b/src/mux/muxedit.c index 3295f406..4d6999b0 100644 --- a/src/mux/muxedit.c +++ b/src/mux/muxedit.c @@ -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_LOOP, &mux->loop_); 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 // used for the chunk. - const WebPData tmp = { data->bytes_ + TAG_SIZE, data->size_ - TAG_SIZE }; - err = ChunkAssignData(&chunk, &tmp, copy_data, GetLE32(data->bytes_ + 0)); + const WebPData tmp = { data->bytes + TAG_SIZE, data->size - TAG_SIZE }; + err = ChunkAssignData(&chunk, &tmp, copy_data, GetLE32(data->bytes + 0)); if (err == WEBP_MUX_OK) 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 int ok = is_lossless ? - VP8LGetInfo(image->bytes_, image->size_, &width, &height, NULL) : - VP8GetInfo(image->bytes_, image->size_, image->size_, &width, &height); + VP8LGetInfo(image->bytes, image->size, &width, &height, NULL) : + VP8GetInfo(image->bytes, image->size, image->size, &width, &height); if (!ok) return WEBP_MUX_INVALID_ARGUMENT; 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); } - frame_tile->bytes_ = frame_tile_bytes; - frame_tile->size_ = frame_tile_size; + frame_tile->bytes = frame_tile_bytes; + frame_tile->size = frame_tile_size; return WEBP_MUX_OK; } @@ -149,8 +149,8 @@ static WebPMuxError GetImageData(const WebPData* const bitstream, WebPData* const image, WebPData* const alpha, int* const is_lossless) { WebPDataInit(alpha); // Default: no alpha. - if (bitstream->size_ < TAG_SIZE || - memcmp(bitstream->bytes_, "RIFF", TAG_SIZE)) { + if (bitstream->size < TAG_SIZE || + memcmp(bitstream->bytes, "RIFF", TAG_SIZE)) { // It is NOT webp file data. Return input data as is. *image = *bitstream; } else { @@ -166,7 +166,7 @@ static WebPMuxError GetImageData(const WebPData* const bitstream, } WebPMuxDelete(mux); } - *is_lossless = VP8LCheckSignature(image->bytes_, image->size_); + *is_lossless = VP8LCheckSignature(image->bytes, image->size); return WEBP_MUX_OK; } @@ -210,8 +210,8 @@ WebPMuxError WebPMuxSetChunk(WebPMux* mux, const char fourcc[4], const CHUNK_INDEX idx = ChunkGetIndexFromFourCC(fourcc); const uint32_t tag = ChunkGetTagFromFourCC(fourcc); WebPMuxError err; - if (mux == NULL || chunk_data == NULL || chunk_data->bytes_ == NULL || - chunk_data->size_ > MAX_CHUNK_PAYLOAD) { + if (mux == NULL || chunk_data == NULL || chunk_data->bytes == NULL || + chunk_data->size > MAX_CHUNK_PAYLOAD) { return WEBP_MUX_INVALID_ARGUMENT; } @@ -250,7 +250,7 @@ static WebPMuxError SetAlphaAndImageChunks( const int image_tag = is_lossless ? kChunks[IDX_VP8L].tag : kChunks[IDX_VP8].tag; if (err != WEBP_MUX_OK) return err; - if (alpha.bytes_ != NULL) { + if (alpha.bytes != NULL) { err = AddDataToChunkList(&alpha, copy_data, kChunks[IDX_ALPHA].tag, &wpi->alpha_); if (err != WEBP_MUX_OK) return err; @@ -264,8 +264,8 @@ WebPMuxError WebPMuxSetImage(WebPMux* mux, const WebPData* bitstream, WebPMuxError err; // Sanity checks. - if (mux == NULL || bitstream == NULL || bitstream->bytes_ == NULL || - bitstream->size_ > MAX_CHUNK_PAYLOAD) { + if (mux == NULL || bitstream == NULL || bitstream->bytes == NULL || + bitstream->size > MAX_CHUNK_PAYLOAD) { return WEBP_MUX_INVALID_ARGUMENT; } @@ -295,7 +295,7 @@ WebPMuxError WebPMuxPushFrame(WebPMux* mux, const WebPMuxFrameInfo* frame, WebPMuxImage wpi; WebPMuxError err; int is_frame; - const WebPData* const bitstream = &frame->bitstream_; + const WebPData* const bitstream = &frame->bitstream; // Sanity checks. 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; } - if (bitstream->bytes_ == NULL || bitstream->size_ > MAX_CHUNK_PAYLOAD) { + if (bitstream->bytes == NULL || bitstream->size > MAX_CHUNK_PAYLOAD) { 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 x_offset = frame->x_offset_ & ~1; // Snap offsets to even. - const int y_offset = frame->y_offset_ & ~1; - const int duration = is_frame ? frame->duration_ : 1 /* unused */; + const int x_offset = frame->x_offset & ~1; // Snap offsets to even. + const int y_offset = frame->y_offset & ~1; + const int duration = is_frame ? frame->duration : 1 /* unused */; const uint32_t tag = kChunks[is_frame ? IDX_ANMF : IDX_FRGM].tag; WebPData frame_tile; 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; assert(frame_tile_chunk != NULL); 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); - *y_offset = 2 * GetLE24(data->bytes_ + 3); - if (is_frame) *duration = 1 + GetLE24(data->bytes_ + 12); + *x_offset = 2 * GetLE24(data->bytes + 0); + *y_offset = 2 * GetLE24(data->bytes + 3); + if (is_frame) *duration = 1 + GetLE24(data->bytes + 12); return WEBP_MUX_OK; } @@ -415,8 +415,8 @@ WebPMuxError MuxGetImageWidthHeight(const WebPChunk* const image_chunk, assert(image_chunk != NULL); assert(tag == kChunks[IDX_VP8].tag || tag == kChunks[IDX_VP8L].tag); ok = (tag == kChunks[IDX_VP8].tag) ? - VP8GetInfo(data->bytes_, data->size_, data->size_, &w, &h) : - VP8LGetInfo(data->bytes_, data->size_, &w, &h, NULL); + VP8GetInfo(data->bytes, data->size, data->size, &w, &h) : + VP8LGetInfo(data->bytes, data->size, &w, &h, NULL); if (ok) { *width = w; *height = h; @@ -512,7 +512,7 @@ static WebPMuxError CreateVP8XChunk(WebPMux* const mux) { assert(mux != NULL); images = mux->images_; // First image. if (images == NULL || images->img_ == NULL || - images->img_->data_.bytes_ == NULL) { + images->img_->data_.bytes == NULL) { 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; // Set flags. - if (mux->iccp_ != NULL && mux->iccp_->data_.bytes_ != NULL) { + if (mux->iccp_ != NULL && mux->iccp_->data_.bytes != NULL) { flags |= ICCP_FLAG; } - if (mux->meta_ != NULL && mux->meta_->data_.bytes_ != NULL) { + if (mux->meta_ != NULL && mux->meta_->data_.bytes != NULL) { flags |= META_FLAG; } @@ -631,8 +631,8 @@ WebPMuxError WebPMuxAssemble(WebPMux* mux, WebPData* assembled_data) { } // Finalize. - assembled_data->bytes_ = data; - assembled_data->size_ = size; + assembled_data->bytes = data; + assembled_data->size = size; return err; } diff --git a/src/mux/muxi.h b/src/mux/muxi.h index f3d93bb0..64811624 100644 --- a/src/mux/muxi.h +++ b/src/mux/muxi.h @@ -167,7 +167,7 @@ WebPChunk* ChunkDelete(WebPChunk* const chunk); // Size of a chunk including header and padding. 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); return SizeWithPadding(data_size); } diff --git a/src/mux/muxinternal.c b/src/mux/muxinternal.c index d01f69e0..4e2e5e61 100644 --- a/src/mux/muxinternal.c +++ b/src/mux/muxinternal.c @@ -143,10 +143,10 @@ WebPMuxError ChunkAssignData(WebPChunk* chunk, const WebPData* const data, if (data != NULL) { if (copy_data) { // Copy data. - chunk->data_.bytes_ = (uint8_t*)malloc(data->size_); - if (chunk->data_.bytes_ == NULL) return WEBP_MUX_MEMORY_ERROR; - memcpy((uint8_t*)chunk->data_.bytes_, data->bytes_, data->size_); - chunk->data_.size_ = data->size_; + chunk->data_.bytes = (uint8_t*)malloc(data->size); + if (chunk->data_.bytes == NULL) return WEBP_MUX_MEMORY_ERROR; + memcpy((uint8_t*)chunk->data_.bytes, data->bytes, data->size); + chunk->data_.size = data->size; // Chunk is owner of data. 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) { - const size_t chunk_size = chunk->data_.size_; + const size_t chunk_size = chunk->data_.size; assert(chunk); assert(chunk->tag_ != NIL_TAG); PutLE32(dst + 0, chunk->tag_); PutLE32(dst + TAG_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) dst[CHUNK_HEADER_SIZE + chunk_size] = 0; // Add padding. return dst + ChunkDiskSize(chunk); @@ -230,7 +230,7 @@ void WebPDataInit(WebPData* webp_data) { void WebPDataClear(WebPData* webp_data) { if (webp_data != NULL) { - free((void*)webp_data->bytes_); + free((void*)webp_data->bytes); WebPDataInit(webp_data); } } @@ -239,11 +239,11 @@ int WebPDataCopy(const WebPData* src, WebPData* dst) { if (src == NULL || dst == NULL) return 0; WebPDataInit(dst); - if (src->bytes_ != NULL && src->size_ != 0) { - dst->bytes_ = (uint8_t*)malloc(src->size_); - if (dst->bytes_ == NULL) return 0; - memcpy((void*)dst->bytes_, src->bytes_, src->size_); - dst->size_ = src->size_; + if (src->bytes != NULL && src->size != 0) { + dst->bytes = (uint8_t*)malloc(src->size); + if (dst->bytes == NULL) return 0; + memcpy((void*)dst->bytes, src->bytes, src->size); + dst->size = src->size; } return 1; } diff --git a/src/mux/muxread.c b/src/mux/muxread.c index ce4596fb..ff10b67f 100644 --- a/src/mux/muxread.c +++ b/src/mux/muxread.c @@ -68,8 +68,8 @@ static WebPMuxError ChunkVerifyAndAssignData(WebPChunk* chunk, } // Data assignment. - chunk_data.bytes_ = data + CHUNK_HEADER_SIZE; - chunk_data.size_ = chunk_size; + chunk_data.bytes = data + CHUNK_HEADER_SIZE; + chunk_data.size = chunk_size; 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; - data = bitstream->bytes_; - size = bitstream->size_; + data = bitstream->bytes; + size = bitstream->size; if (data == NULL) return NULL; if (size < RIFF_HEADER_SIZE) return NULL; @@ -207,10 +207,10 @@ WebPMuxError WebPMuxGetFeatures(const WebPMux* mux, uint32_t* flags) { 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. - *flags = GetLE32(data.bytes_); + *flags = GetLE32(data.bytes); return WEBP_MUX_OK; } @@ -264,8 +264,8 @@ static WebPMuxError SynthesizeBitstream(const WebPMuxImage* const wpi, assert(dst == data + size); // Output. - bitstream->bytes_ = data; - bitstream->size_ = size; + bitstream->bytes = data; + bitstream->size = size; return WEBP_MUX_OK; } @@ -289,12 +289,12 @@ WebPMuxError WebPMuxGetChunk(const WebPMux* mux, const char fourcc[4], static WebPMuxError MuxGetImageInternal(const WebPMuxImage* const wpi, WebPMuxFrameInfo* const info) { // Set some defaults for unrelated fields. - info->x_offset_ = 0; - info->y_offset_ = 0; - info->duration_ = 1; + info->x_offset = 0; + info->y_offset = 0; + info->duration = 1; // Extract data for related fields. info->id = ChunkGetIdFromTag(wpi->img_->tag_); - return SynthesizeBitstream(wpi, &info->bitstream_); + return SynthesizeBitstream(wpi, &info->bitstream); } 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(). // Get frame/tile chunk. 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. - frame->x_offset_ = 2 * GetLE24(frame_tile_data->bytes_ + 0); - frame->y_offset_ = 2 * GetLE24(frame_tile_data->bytes_ + 3); - frame->duration_ = is_frame ? 1 + GetLE24(frame_tile_data->bytes_ + 12) : 1; + frame->x_offset = 2 * GetLE24(frame_tile_data->bytes + 0); + frame->y_offset = 2 * GetLE24(frame_tile_data->bytes + 3); + frame->duration = is_frame ? 1 + GetLE24(frame_tile_data->bytes + 12) : 1; frame->id = ChunkGetIdFromTag(wpi->header_->tag_); - return SynthesizeBitstream(wpi, &frame->bitstream_); + return SynthesizeBitstream(wpi, &frame->bitstream); } WebPMuxError WebPMuxGetFrame( @@ -344,8 +344,8 @@ WebPMuxError WebPMuxGetLoopCount(const WebPMux* mux, int* loop_count) { err = MuxGet(mux, IDX_LOOP, 1, &image); if (err != WEBP_MUX_OK) return err; - if (image.size_ < kChunks[WEBP_CHUNK_LOOP].size) return WEBP_MUX_BAD_DATA; - *loop_count = GetLE16(image.bytes_); + if (image.size < kChunks[WEBP_CHUNK_LOOP].size) return WEBP_MUX_BAD_DATA; + *loop_count = GetLE16(image.bytes); return WEBP_MUX_OK; } diff --git a/src/webp/mux.h b/src/webp/mux.h index 42b17a88..882e926d 100644 --- a/src/webp/mux.h +++ b/src/webp/mux.h @@ -27,7 +27,7 @@ // // Get data from mux in WebP RIFF format. // WebPMuxAssemble(mux, &output_data); // 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); // // 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 // (ICC profile, metadata) and WebP compressed image data. struct WebPData { - const uint8_t* bytes_; - size_t size_; + const uint8_t* bytes; + size_t size; }; //------------------------------------------------------------------------------ @@ -220,15 +220,15 @@ WEBP_EXTERN(WebPMuxError) WebPMuxDeleteChunk( // Encapsulates data about a single frame/tile. struct WebPMuxFrameInfo { - WebPData bitstream_; // image data: can either be a raw VP8/VP8L bitstream - // or a single-image WebP file. - int x_offset_; // x-offset of the frame. - int y_offset_; // y-offset of the frame. - int duration_; // duration of the frame (in milliseconds). + WebPData bitstream; // image data: can either be a raw VP8/VP8L bitstream + // or a single-image WebP file. + int x_offset; // x-offset of the frame. + int y_offset; // y-offset of the frame. + int duration; // duration of the frame (in milliseconds). - WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF, - // WEBP_CHUNK_FRGM or WEBP_CHUNK_IMAGE - uint32_t pad[3]; // padding for later use + WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF, + // WEBP_CHUNK_FRGM or WEBP_CHUNK_IMAGE + uint32_t pad[3]; // padding for later use }; // 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); // 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 // WebPDataClear(). // nth=0 has a special meaning - last position. @@ -424,19 +424,19 @@ WEBP_EXTERN(uint32_t) WebPDemuxGetI( // Frame iteration. struct WebPIterator { - int frame_num_; - int num_frames_; - int tile_num_; - int num_tiles_; - int x_offset_, y_offset_; // offset relative to the canvas. - int width_, height_; // dimensions of this frame or tile. - int duration_; // display duration in milliseconds. - int complete_; // true if 'tile_' contains a full frame. partial images may - // still be decoded with the WebP incremental decoder. - WebPData tile_; // The frame or tile given by 'frame_num_' and 'tile_num_'. + int frame_num; + int num_frames; + int tile_num; + int num_tiles; + int x_offset, y_offset; // offset relative to the canvas. + int width, height; // dimensions of this frame or tile. + int duration; // display duration in milliseconds. + int complete; // true if 'tile_' contains a full frame. partial images may + // still be decoded with the WebP incremental decoder. + WebPData tile; // The frame or tile given by 'frame_num_' and 'tile_num_'. uint32_t pad[4]; // padding for later use - void* private_; + void* private_; // for internal use only. }; // Retrieves frame 'frame_number' from 'dmux'. @@ -470,11 +470,11 @@ WEBP_EXTERN(void) WebPDemuxReleaseIterator(WebPIterator* iter); struct WebPChunkIterator { // The current and total number of chunks with the fourcc given to // WebPDemuxGetChunk(). - int chunk_num_; - int num_chunks_; - WebPData chunk_; // The payload of the chunk. + int chunk_num; + int num_chunks; + 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_; };