Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../usr/include/webp
File: mux.h
// Copyright 2011 Google Inc. All Rights Reserved.
[0] Fix | Delete
//
[1] Fix | Delete
// Use of this source code is governed by a BSD-style license
[2] Fix | Delete
// that can be found in the COPYING file in the root of the source
[3] Fix | Delete
// tree. An additional intellectual property rights grant can be found
[4] Fix | Delete
// in the file PATENTS. All contributing project authors may
[5] Fix | Delete
// be found in the AUTHORS file in the root of the source tree.
[6] Fix | Delete
// -----------------------------------------------------------------------------
[7] Fix | Delete
//
[8] Fix | Delete
// RIFF container manipulation and encoding for WebP images.
[9] Fix | Delete
//
[10] Fix | Delete
// Authors: Urvang (urvang@google.com)
[11] Fix | Delete
// Vikas (vikasa@google.com)
[12] Fix | Delete
[13] Fix | Delete
#ifndef WEBP_WEBP_MUX_H_
[14] Fix | Delete
#define WEBP_WEBP_MUX_H_
[15] Fix | Delete
[16] Fix | Delete
#include "./mux_types.h"
[17] Fix | Delete
[18] Fix | Delete
#ifdef __cplusplus
[19] Fix | Delete
extern "C" {
[20] Fix | Delete
#endif
[21] Fix | Delete
[22] Fix | Delete
#define WEBP_MUX_ABI_VERSION 0x0108 // MAJOR(8b) + MINOR(8b)
[23] Fix | Delete
[24] Fix | Delete
//------------------------------------------------------------------------------
[25] Fix | Delete
// Mux API
[26] Fix | Delete
//
[27] Fix | Delete
// This API allows manipulation of WebP container images containing features
[28] Fix | Delete
// like color profile, metadata, animation.
[29] Fix | Delete
//
[30] Fix | Delete
// Code Example#1: Create a WebPMux object with image data, color profile and
[31] Fix | Delete
// XMP metadata.
[32] Fix | Delete
/*
[33] Fix | Delete
int copy_data = 0;
[34] Fix | Delete
WebPMux* mux = WebPMuxNew();
[35] Fix | Delete
// ... (Prepare image data).
[36] Fix | Delete
WebPMuxSetImage(mux, &image, copy_data);
[37] Fix | Delete
// ... (Prepare ICCP color profile data).
[38] Fix | Delete
WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data);
[39] Fix | Delete
// ... (Prepare XMP metadata).
[40] Fix | Delete
WebPMuxSetChunk(mux, "XMP ", &xmp, copy_data);
[41] Fix | Delete
// Get data from mux in WebP RIFF format.
[42] Fix | Delete
WebPMuxAssemble(mux, &output_data);
[43] Fix | Delete
WebPMuxDelete(mux);
[44] Fix | Delete
// ... (Consume output_data; e.g. write output_data.bytes to file).
[45] Fix | Delete
WebPDataClear(&output_data);
[46] Fix | Delete
*/
[47] Fix | Delete
[48] Fix | Delete
// Code Example#2: Get image and color profile data from a WebP file.
[49] Fix | Delete
/*
[50] Fix | Delete
int copy_data = 0;
[51] Fix | Delete
// ... (Read data from file).
[52] Fix | Delete
WebPMux* mux = WebPMuxCreate(&data, copy_data);
[53] Fix | Delete
WebPMuxGetFrame(mux, 1, &image);
[54] Fix | Delete
// ... (Consume image; e.g. call WebPDecode() to decode the data).
[55] Fix | Delete
WebPMuxGetChunk(mux, "ICCP", &icc_profile);
[56] Fix | Delete
// ... (Consume icc_data).
[57] Fix | Delete
WebPMuxDelete(mux);
[58] Fix | Delete
free(data);
[59] Fix | Delete
*/
[60] Fix | Delete
[61] Fix | Delete
// Note: forward declaring enumerations is not allowed in (strict) C and C++,
[62] Fix | Delete
// the types are left here for reference.
[63] Fix | Delete
// typedef enum WebPMuxError WebPMuxError;
[64] Fix | Delete
// typedef enum WebPChunkId WebPChunkId;
[65] Fix | Delete
typedef struct WebPMux WebPMux; // main opaque object.
[66] Fix | Delete
typedef struct WebPMuxFrameInfo WebPMuxFrameInfo;
[67] Fix | Delete
typedef struct WebPMuxAnimParams WebPMuxAnimParams;
[68] Fix | Delete
typedef struct WebPAnimEncoderOptions WebPAnimEncoderOptions;
[69] Fix | Delete
[70] Fix | Delete
// Error codes
[71] Fix | Delete
typedef enum WebPMuxError {
[72] Fix | Delete
WEBP_MUX_OK = 1,
[73] Fix | Delete
WEBP_MUX_NOT_FOUND = 0,
[74] Fix | Delete
WEBP_MUX_INVALID_ARGUMENT = -1,
[75] Fix | Delete
WEBP_MUX_BAD_DATA = -2,
[76] Fix | Delete
WEBP_MUX_MEMORY_ERROR = -3,
[77] Fix | Delete
WEBP_MUX_NOT_ENOUGH_DATA = -4
[78] Fix | Delete
} WebPMuxError;
[79] Fix | Delete
[80] Fix | Delete
// IDs for different types of chunks.
[81] Fix | Delete
typedef enum WebPChunkId {
[82] Fix | Delete
WEBP_CHUNK_VP8X, // VP8X
[83] Fix | Delete
WEBP_CHUNK_ICCP, // ICCP
[84] Fix | Delete
WEBP_CHUNK_ANIM, // ANIM
[85] Fix | Delete
WEBP_CHUNK_ANMF, // ANMF
[86] Fix | Delete
WEBP_CHUNK_DEPRECATED, // (deprecated from FRGM)
[87] Fix | Delete
WEBP_CHUNK_ALPHA, // ALPH
[88] Fix | Delete
WEBP_CHUNK_IMAGE, // VP8/VP8L
[89] Fix | Delete
WEBP_CHUNK_EXIF, // EXIF
[90] Fix | Delete
WEBP_CHUNK_XMP, // XMP
[91] Fix | Delete
WEBP_CHUNK_UNKNOWN, // Other chunks.
[92] Fix | Delete
WEBP_CHUNK_NIL
[93] Fix | Delete
} WebPChunkId;
[94] Fix | Delete
[95] Fix | Delete
//------------------------------------------------------------------------------
[96] Fix | Delete
[97] Fix | Delete
// Returns the version number of the mux library, packed in hexadecimal using
[98] Fix | Delete
// 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
[99] Fix | Delete
WEBP_EXTERN int WebPGetMuxVersion(void);
[100] Fix | Delete
[101] Fix | Delete
//------------------------------------------------------------------------------
[102] Fix | Delete
// Life of a Mux object
[103] Fix | Delete
[104] Fix | Delete
// Internal, version-checked, entry point
[105] Fix | Delete
WEBP_EXTERN WebPMux* WebPNewInternal(int);
[106] Fix | Delete
[107] Fix | Delete
// Creates an empty mux object.
[108] Fix | Delete
// Returns:
[109] Fix | Delete
// A pointer to the newly created empty mux object.
[110] Fix | Delete
// Or NULL in case of memory error.
[111] Fix | Delete
static WEBP_INLINE WebPMux* WebPMuxNew(void) {
[112] Fix | Delete
return WebPNewInternal(WEBP_MUX_ABI_VERSION);
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
// Deletes the mux object.
[116] Fix | Delete
// Parameters:
[117] Fix | Delete
// mux - (in/out) object to be deleted
[118] Fix | Delete
WEBP_EXTERN void WebPMuxDelete(WebPMux* mux);
[119] Fix | Delete
[120] Fix | Delete
//------------------------------------------------------------------------------
[121] Fix | Delete
// Mux creation.
[122] Fix | Delete
[123] Fix | Delete
// Internal, version-checked, entry point
[124] Fix | Delete
WEBP_EXTERN WebPMux* WebPMuxCreateInternal(const WebPData*, int, int);
[125] Fix | Delete
[126] Fix | Delete
// Creates a mux object from raw data given in WebP RIFF format.
[127] Fix | Delete
// Parameters:
[128] Fix | Delete
// bitstream - (in) the bitstream data in WebP RIFF format
[129] Fix | Delete
// copy_data - (in) value 1 indicates given data WILL be copied to the mux
[130] Fix | Delete
// object and value 0 indicates data will NOT be copied.
[131] Fix | Delete
// Returns:
[132] Fix | Delete
// A pointer to the mux object created from given data - on success.
[133] Fix | Delete
// NULL - In case of invalid data or memory error.
[134] Fix | Delete
static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream,
[135] Fix | Delete
int copy_data) {
[136] Fix | Delete
return WebPMuxCreateInternal(bitstream, copy_data, WEBP_MUX_ABI_VERSION);
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
//------------------------------------------------------------------------------
[140] Fix | Delete
// Non-image chunks.
[141] Fix | Delete
[142] Fix | Delete
// Note: Only non-image related chunks should be managed through chunk APIs.
[143] Fix | Delete
// (Image related chunks are: "ANMF", "VP8 ", "VP8L" and "ALPH").
[144] Fix | Delete
// To add, get and delete images, use WebPMuxSetImage(), WebPMuxPushFrame(),
[145] Fix | Delete
// WebPMuxGetFrame() and WebPMuxDeleteFrame().
[146] Fix | Delete
[147] Fix | Delete
// Adds a chunk with id 'fourcc' and data 'chunk_data' in the mux object.
[148] Fix | Delete
// Any existing chunk(s) with the same id will be removed.
[149] Fix | Delete
// Parameters:
[150] Fix | Delete
// mux - (in/out) object to which the chunk is to be added
[151] Fix | Delete
// fourcc - (in) a character array containing the fourcc of the given chunk;
[152] Fix | Delete
// e.g., "ICCP", "XMP ", "EXIF" etc.
[153] Fix | Delete
// chunk_data - (in) the chunk data to be added
[154] Fix | Delete
// copy_data - (in) value 1 indicates given data WILL be copied to the mux
[155] Fix | Delete
// object and value 0 indicates data will NOT be copied.
[156] Fix | Delete
// Returns:
[157] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL
[158] Fix | Delete
// or if fourcc corresponds to an image chunk.
[159] Fix | Delete
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
[160] Fix | Delete
// WEBP_MUX_OK - on success.
[161] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxSetChunk(
[162] Fix | Delete
WebPMux* mux, const char fourcc[4], const WebPData* chunk_data,
[163] Fix | Delete
int copy_data);
[164] Fix | Delete
[165] Fix | Delete
// Gets a reference to the data of the chunk with id 'fourcc' in the mux object.
[166] Fix | Delete
// The caller should NOT free the returned data.
[167] Fix | Delete
// Parameters:
[168] Fix | Delete
// mux - (in) object from which the chunk data is to be fetched
[169] Fix | Delete
// fourcc - (in) a character array containing the fourcc of the chunk;
[170] Fix | Delete
// e.g., "ICCP", "XMP ", "EXIF" etc.
[171] Fix | Delete
// chunk_data - (out) returned chunk data
[172] Fix | Delete
// Returns:
[173] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux, fourcc or chunk_data is NULL
[174] Fix | Delete
// or if fourcc corresponds to an image chunk.
[175] Fix | Delete
// WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given id.
[176] Fix | Delete
// WEBP_MUX_OK - on success.
[177] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxGetChunk(
[178] Fix | Delete
const WebPMux* mux, const char fourcc[4], WebPData* chunk_data);
[179] Fix | Delete
[180] Fix | Delete
// Deletes the chunk with the given 'fourcc' from the mux object.
[181] Fix | Delete
// Parameters:
[182] Fix | Delete
// mux - (in/out) object from which the chunk is to be deleted
[183] Fix | Delete
// fourcc - (in) a character array containing the fourcc of the chunk;
[184] Fix | Delete
// e.g., "ICCP", "XMP ", "EXIF" etc.
[185] Fix | Delete
// Returns:
[186] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux or fourcc is NULL
[187] Fix | Delete
// or if fourcc corresponds to an image chunk.
[188] Fix | Delete
// WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given fourcc.
[189] Fix | Delete
// WEBP_MUX_OK - on success.
[190] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxDeleteChunk(
[191] Fix | Delete
WebPMux* mux, const char fourcc[4]);
[192] Fix | Delete
[193] Fix | Delete
//------------------------------------------------------------------------------
[194] Fix | Delete
// Images.
[195] Fix | Delete
[196] Fix | Delete
// Encapsulates data about a single frame.
[197] Fix | Delete
struct WebPMuxFrameInfo {
[198] Fix | Delete
WebPData bitstream; // image data: can be a raw VP8/VP8L bitstream
[199] Fix | Delete
// or a single-image WebP file.
[200] Fix | Delete
int x_offset; // x-offset of the frame.
[201] Fix | Delete
int y_offset; // y-offset of the frame.
[202] Fix | Delete
int duration; // duration of the frame (in milliseconds).
[203] Fix | Delete
[204] Fix | Delete
WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF
[205] Fix | Delete
// or WEBP_CHUNK_IMAGE
[206] Fix | Delete
WebPMuxAnimDispose dispose_method; // Disposal method for the frame.
[207] Fix | Delete
WebPMuxAnimBlend blend_method; // Blend operation for the frame.
[208] Fix | Delete
uint32_t pad[1]; // padding for later use
[209] Fix | Delete
};
[210] Fix | Delete
[211] Fix | Delete
// Sets the (non-animated) image in the mux object.
[212] Fix | Delete
// Note: Any existing images (including frames) will be removed.
[213] Fix | Delete
// Parameters:
[214] Fix | Delete
// mux - (in/out) object in which the image is to be set
[215] Fix | Delete
// bitstream - (in) can be a raw VP8/VP8L bitstream or a single-image
[216] Fix | Delete
// WebP file (non-animated)
[217] Fix | Delete
// copy_data - (in) value 1 indicates given data WILL be copied to the mux
[218] Fix | Delete
// object and value 0 indicates data will NOT be copied.
[219] Fix | Delete
// Returns:
[220] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL.
[221] Fix | Delete
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
[222] Fix | Delete
// WEBP_MUX_OK - on success.
[223] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxSetImage(
[224] Fix | Delete
WebPMux* mux, const WebPData* bitstream, int copy_data);
[225] Fix | Delete
[226] Fix | Delete
// Adds a frame at the end of the mux object.
[227] Fix | Delete
// Notes: (1) frame.id should be WEBP_CHUNK_ANMF
[228] Fix | Delete
// (2) For setting a non-animated image, use WebPMuxSetImage() instead.
[229] Fix | Delete
// (3) Type of frame being pushed must be same as the frames in mux.
[230] Fix | Delete
// (4) As WebP only supports even offsets, any odd offset will be snapped
[231] Fix | Delete
// to an even location using: offset &= ~1
[232] Fix | Delete
// Parameters:
[233] Fix | Delete
// mux - (in/out) object to which the frame is to be added
[234] Fix | Delete
// frame - (in) frame data.
[235] Fix | Delete
// copy_data - (in) value 1 indicates given data WILL be copied to the mux
[236] Fix | Delete
// object and value 0 indicates data will NOT be copied.
[237] Fix | Delete
// Returns:
[238] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL
[239] Fix | Delete
// or if content of 'frame' is invalid.
[240] Fix | Delete
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
[241] Fix | Delete
// WEBP_MUX_OK - on success.
[242] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxPushFrame(
[243] Fix | Delete
WebPMux* mux, const WebPMuxFrameInfo* frame, int copy_data);
[244] Fix | Delete
[245] Fix | Delete
// Gets the nth frame from the mux object.
[246] Fix | Delete
// The content of 'frame->bitstream' is allocated using malloc(), and NOT
[247] Fix | Delete
// owned by the 'mux' object. It MUST be deallocated by the caller by calling
[248] Fix | Delete
// WebPDataClear().
[249] Fix | Delete
// nth=0 has a special meaning - last position.
[250] Fix | Delete
// Parameters:
[251] Fix | Delete
// mux - (in) object from which the info is to be fetched
[252] Fix | Delete
// nth - (in) index of the frame in the mux object
[253] Fix | Delete
// frame - (out) data of the returned frame
[254] Fix | Delete
// Returns:
[255] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL.
[256] Fix | Delete
// WEBP_MUX_NOT_FOUND - if there are less than nth frames in the mux object.
[257] Fix | Delete
// WEBP_MUX_BAD_DATA - if nth frame chunk in mux is invalid.
[258] Fix | Delete
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
[259] Fix | Delete
// WEBP_MUX_OK - on success.
[260] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxGetFrame(
[261] Fix | Delete
const WebPMux* mux, uint32_t nth, WebPMuxFrameInfo* frame);
[262] Fix | Delete
[263] Fix | Delete
// Deletes a frame from the mux object.
[264] Fix | Delete
// nth=0 has a special meaning - last position.
[265] Fix | Delete
// Parameters:
[266] Fix | Delete
// mux - (in/out) object from which a frame is to be deleted
[267] Fix | Delete
// nth - (in) The position from which the frame is to be deleted
[268] Fix | Delete
// Returns:
[269] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL.
[270] Fix | Delete
// WEBP_MUX_NOT_FOUND - If there are less than nth frames in the mux object
[271] Fix | Delete
// before deletion.
[272] Fix | Delete
// WEBP_MUX_OK - on success.
[273] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxDeleteFrame(WebPMux* mux, uint32_t nth);
[274] Fix | Delete
[275] Fix | Delete
//------------------------------------------------------------------------------
[276] Fix | Delete
// Animation.
[277] Fix | Delete
[278] Fix | Delete
// Animation parameters.
[279] Fix | Delete
struct WebPMuxAnimParams {
[280] Fix | Delete
uint32_t bgcolor; // Background color of the canvas stored (in MSB order) as:
[281] Fix | Delete
// Bits 00 to 07: Alpha.
[282] Fix | Delete
// Bits 08 to 15: Red.
[283] Fix | Delete
// Bits 16 to 23: Green.
[284] Fix | Delete
// Bits 24 to 31: Blue.
[285] Fix | Delete
int loop_count; // Number of times to repeat the animation [0 = infinite].
[286] Fix | Delete
};
[287] Fix | Delete
[288] Fix | Delete
// Sets the animation parameters in the mux object. Any existing ANIM chunks
[289] Fix | Delete
// will be removed.
[290] Fix | Delete
// Parameters:
[291] Fix | Delete
// mux - (in/out) object in which ANIM chunk is to be set/added
[292] Fix | Delete
// params - (in) animation parameters.
[293] Fix | Delete
// Returns:
[294] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux or params is NULL.
[295] Fix | Delete
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
[296] Fix | Delete
// WEBP_MUX_OK - on success.
[297] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxSetAnimationParams(
[298] Fix | Delete
WebPMux* mux, const WebPMuxAnimParams* params);
[299] Fix | Delete
[300] Fix | Delete
// Gets the animation parameters from the mux object.
[301] Fix | Delete
// Parameters:
[302] Fix | Delete
// mux - (in) object from which the animation parameters to be fetched
[303] Fix | Delete
// params - (out) animation parameters extracted from the ANIM chunk
[304] Fix | Delete
// Returns:
[305] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux or params is NULL.
[306] Fix | Delete
// WEBP_MUX_NOT_FOUND - if ANIM chunk is not present in mux object.
[307] Fix | Delete
// WEBP_MUX_OK - on success.
[308] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxGetAnimationParams(
[309] Fix | Delete
const WebPMux* mux, WebPMuxAnimParams* params);
[310] Fix | Delete
[311] Fix | Delete
//------------------------------------------------------------------------------
[312] Fix | Delete
// Misc Utilities.
[313] Fix | Delete
[314] Fix | Delete
// Sets the canvas size for the mux object. The width and height can be
[315] Fix | Delete
// specified explicitly or left as zero (0, 0).
[316] Fix | Delete
// * When width and height are specified explicitly, then this frame bound is
[317] Fix | Delete
// enforced during subsequent calls to WebPMuxAssemble() and an error is
[318] Fix | Delete
// reported if any animated frame does not completely fit within the canvas.
[319] Fix | Delete
// * When unspecified (0, 0), the constructed canvas will get the frame bounds
[320] Fix | Delete
// from the bounding-box over all frames after calling WebPMuxAssemble().
[321] Fix | Delete
// Parameters:
[322] Fix | Delete
// mux - (in) object to which the canvas size is to be set
[323] Fix | Delete
// width - (in) canvas width
[324] Fix | Delete
// height - (in) canvas height
[325] Fix | Delete
// Returns:
[326] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux is NULL; or
[327] Fix | Delete
// width or height are invalid or out of bounds
[328] Fix | Delete
// WEBP_MUX_OK - on success.
[329] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxSetCanvasSize(WebPMux* mux,
[330] Fix | Delete
int width, int height);
[331] Fix | Delete
[332] Fix | Delete
// Gets the canvas size from the mux object.
[333] Fix | Delete
// Note: This method assumes that the VP8X chunk, if present, is up-to-date.
[334] Fix | Delete
// That is, the mux object hasn't been modified since the last call to
[335] Fix | Delete
// WebPMuxAssemble() or WebPMuxCreate().
[336] Fix | Delete
// Parameters:
[337] Fix | Delete
// mux - (in) object from which the canvas size is to be fetched
[338] Fix | Delete
// width - (out) canvas width
[339] Fix | Delete
// height - (out) canvas height
[340] Fix | Delete
// Returns:
[341] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux, width or height is NULL.
[342] Fix | Delete
// WEBP_MUX_BAD_DATA - if VP8X/VP8/VP8L chunk or canvas size is invalid.
[343] Fix | Delete
// WEBP_MUX_OK - on success.
[344] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxGetCanvasSize(const WebPMux* mux,
[345] Fix | Delete
int* width, int* height);
[346] Fix | Delete
[347] Fix | Delete
// Gets the feature flags from the mux object.
[348] Fix | Delete
// Note: This method assumes that the VP8X chunk, if present, is up-to-date.
[349] Fix | Delete
// That is, the mux object hasn't been modified since the last call to
[350] Fix | Delete
// WebPMuxAssemble() or WebPMuxCreate().
[351] Fix | Delete
// Parameters:
[352] Fix | Delete
// mux - (in) object from which the features are to be fetched
[353] Fix | Delete
// flags - (out) the flags specifying which features are present in the
[354] Fix | Delete
// mux object. This will be an OR of various flag values.
[355] Fix | Delete
// Enum 'WebPFeatureFlags' can be used to test individual flag values.
[356] Fix | Delete
// Returns:
[357] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux or flags is NULL.
[358] Fix | Delete
// WEBP_MUX_BAD_DATA - if VP8X/VP8/VP8L chunk or canvas size is invalid.
[359] Fix | Delete
// WEBP_MUX_OK - on success.
[360] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxGetFeatures(const WebPMux* mux,
[361] Fix | Delete
uint32_t* flags);
[362] Fix | Delete
[363] Fix | Delete
// Gets number of chunks with the given 'id' in the mux object.
[364] Fix | Delete
// Parameters:
[365] Fix | Delete
// mux - (in) object from which the info is to be fetched
[366] Fix | Delete
// id - (in) chunk id specifying the type of chunk
[367] Fix | Delete
// num_elements - (out) number of chunks with the given chunk id
[368] Fix | Delete
// Returns:
[369] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux, or num_elements is NULL.
[370] Fix | Delete
// WEBP_MUX_OK - on success.
[371] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxNumChunks(const WebPMux* mux,
[372] Fix | Delete
WebPChunkId id, int* num_elements);
[373] Fix | Delete
[374] Fix | Delete
// Assembles all chunks in WebP RIFF format and returns in 'assembled_data'.
[375] Fix | Delete
// This function also validates the mux object.
[376] Fix | Delete
// Note: The content of 'assembled_data' will be ignored and overwritten.
[377] Fix | Delete
// Also, the content of 'assembled_data' is allocated using malloc(), and NOT
[378] Fix | Delete
// owned by the 'mux' object. It MUST be deallocated by the caller by calling
[379] Fix | Delete
// WebPDataClear(). It's always safe to call WebPDataClear() upon return,
[380] Fix | Delete
// even in case of error.
[381] Fix | Delete
// Parameters:
[382] Fix | Delete
// mux - (in/out) object whose chunks are to be assembled
[383] Fix | Delete
// assembled_data - (out) assembled WebP data
[384] Fix | Delete
// Returns:
[385] Fix | Delete
// WEBP_MUX_BAD_DATA - if mux object is invalid.
[386] Fix | Delete
// WEBP_MUX_INVALID_ARGUMENT - if mux or assembled_data is NULL.
[387] Fix | Delete
// WEBP_MUX_MEMORY_ERROR - on memory allocation error.
[388] Fix | Delete
// WEBP_MUX_OK - on success.
[389] Fix | Delete
WEBP_EXTERN WebPMuxError WebPMuxAssemble(WebPMux* mux,
[390] Fix | Delete
WebPData* assembled_data);
[391] Fix | Delete
[392] Fix | Delete
//------------------------------------------------------------------------------
[393] Fix | Delete
// WebPAnimEncoder API
[394] Fix | Delete
//
[395] Fix | Delete
// This API allows encoding (possibly) animated WebP images.
[396] Fix | Delete
//
[397] Fix | Delete
// Code Example:
[398] Fix | Delete
/*
[399] Fix | Delete
WebPAnimEncoderOptions enc_options;
[400] Fix | Delete
WebPAnimEncoderOptionsInit(&enc_options);
[401] Fix | Delete
// Tune 'enc_options' as needed.
[402] Fix | Delete
WebPAnimEncoder* enc = WebPAnimEncoderNew(width, height, &enc_options);
[403] Fix | Delete
while(<there are more frames>) {
[404] Fix | Delete
WebPConfig config;
[405] Fix | Delete
WebPConfigInit(&config);
[406] Fix | Delete
// Tune 'config' as needed.
[407] Fix | Delete
WebPAnimEncoderAdd(enc, frame, timestamp_ms, &config);
[408] Fix | Delete
}
[409] Fix | Delete
WebPAnimEncoderAdd(enc, NULL, timestamp_ms, NULL);
[410] Fix | Delete
WebPAnimEncoderAssemble(enc, webp_data);
[411] Fix | Delete
WebPAnimEncoderDelete(enc);
[412] Fix | Delete
// Write the 'webp_data' to a file, or re-mux it further.
[413] Fix | Delete
*/
[414] Fix | Delete
[415] Fix | Delete
typedef struct WebPAnimEncoder WebPAnimEncoder; // Main opaque object.
[416] Fix | Delete
[417] Fix | Delete
// Forward declarations. Defined in encode.h.
[418] Fix | Delete
struct WebPPicture;
[419] Fix | Delete
struct WebPConfig;
[420] Fix | Delete
[421] Fix | Delete
// Global options.
[422] Fix | Delete
struct WebPAnimEncoderOptions {
[423] Fix | Delete
WebPMuxAnimParams anim_params; // Animation parameters.
[424] Fix | Delete
int minimize_size; // If true, minimize the output size (slow). Implicitly
[425] Fix | Delete
// disables key-frame insertion.
[426] Fix | Delete
int kmin;
[427] Fix | Delete
int kmax; // Minimum and maximum distance between consecutive key
[428] Fix | Delete
// frames in the output. The library may insert some key
[429] Fix | Delete
// frames as needed to satisfy this criteria.
[430] Fix | Delete
// Note that these conditions should hold: kmax > kmin
[431] Fix | Delete
// and kmin >= kmax / 2 + 1. Also, if kmax <= 0, then
[432] Fix | Delete
// key-frame insertion is disabled; and if kmax == 1,
[433] Fix | Delete
// then all frames will be key-frames (kmin value does
[434] Fix | Delete
// not matter for these special cases).
[435] Fix | Delete
int allow_mixed; // If true, use mixed compression mode; may choose
[436] Fix | Delete
// either lossy and lossless for each frame.
[437] Fix | Delete
int verbose; // If true, print info and warning messages to stderr.
[438] Fix | Delete
[439] Fix | Delete
uint32_t padding[4]; // Padding for later use.
[440] Fix | Delete
};
[441] Fix | Delete
[442] Fix | Delete
// Internal, version-checked, entry point.
[443] Fix | Delete
WEBP_EXTERN int WebPAnimEncoderOptionsInitInternal(
[444] Fix | Delete
WebPAnimEncoderOptions*, int);
[445] Fix | Delete
[446] Fix | Delete
// Should always be called, to initialize a fresh WebPAnimEncoderOptions
[447] Fix | Delete
// structure before modification. Returns false in case of version mismatch.
[448] Fix | Delete
// WebPAnimEncoderOptionsInit() must have succeeded before using the
[449] Fix | Delete
// 'enc_options' object.
[450] Fix | Delete
static WEBP_INLINE int WebPAnimEncoderOptionsInit(
[451] Fix | Delete
WebPAnimEncoderOptions* enc_options) {
[452] Fix | Delete
return WebPAnimEncoderOptionsInitInternal(enc_options, WEBP_MUX_ABI_VERSION);
[453] Fix | Delete
}
[454] Fix | Delete
[455] Fix | Delete
// Internal, version-checked, entry point.
[456] Fix | Delete
WEBP_EXTERN WebPAnimEncoder* WebPAnimEncoderNewInternal(
[457] Fix | Delete
int, int, const WebPAnimEncoderOptions*, int);
[458] Fix | Delete
[459] Fix | Delete
// Creates and initializes a WebPAnimEncoder object.
[460] Fix | Delete
// Parameters:
[461] Fix | Delete
// width/height - (in) canvas width and height of the animation.
[462] Fix | Delete
// enc_options - (in) encoding options; can be passed NULL to pick
[463] Fix | Delete
// reasonable defaults.
[464] Fix | Delete
// Returns:
[465] Fix | Delete
// A pointer to the newly created WebPAnimEncoder object.
[466] Fix | Delete
// Or NULL in case of memory error.
[467] Fix | Delete
static WEBP_INLINE WebPAnimEncoder* WebPAnimEncoderNew(
[468] Fix | Delete
int width, int height, const WebPAnimEncoderOptions* enc_options) {
[469] Fix | Delete
return WebPAnimEncoderNewInternal(width, height, enc_options,
[470] Fix | Delete
WEBP_MUX_ABI_VERSION);
[471] Fix | Delete
}
[472] Fix | Delete
[473] Fix | Delete
// Optimize the given frame for WebP, encode it and add it to the
[474] Fix | Delete
// WebPAnimEncoder object.
[475] Fix | Delete
// The last call to 'WebPAnimEncoderAdd' should be with frame = NULL, which
[476] Fix | Delete
// indicates that no more frames are to be added. This call is also used to
[477] Fix | Delete
// determine the duration of the last frame.
[478] Fix | Delete
// Parameters:
[479] Fix | Delete
// enc - (in/out) object to which the frame is to be added.
[480] Fix | Delete
// frame - (in/out) frame data in ARGB or YUV(A) format. If it is in YUV(A)
[481] Fix | Delete
// format, it will be converted to ARGB, which incurs a small loss.
[482] Fix | Delete
// timestamp_ms - (in) timestamp of this frame in milliseconds.
[483] Fix | Delete
// Duration of a frame would be calculated as
[484] Fix | Delete
// "timestamp of next frame - timestamp of this frame".
[485] Fix | Delete
// Hence, timestamps should be in non-decreasing order.
[486] Fix | Delete
// config - (in) encoding options; can be passed NULL to pick
[487] Fix | Delete
// reasonable defaults.
[488] Fix | Delete
// Returns:
[489] Fix | Delete
// On error, returns false and frame->error_code is set appropriately.
[490] Fix | Delete
// Otherwise, returns true.
[491] Fix | Delete
WEBP_EXTERN int WebPAnimEncoderAdd(
[492] Fix | Delete
WebPAnimEncoder* enc, struct WebPPicture* frame, int timestamp_ms,
[493] Fix | Delete
const struct WebPConfig* config);
[494] Fix | Delete
[495] Fix | Delete
// Assemble all frames added so far into a WebP bitstream.
[496] Fix | Delete
// This call should be preceded by a call to 'WebPAnimEncoderAdd' with
[497] Fix | Delete
// frame = NULL; if not, the duration of the last frame will be internally
[498] Fix | Delete
// estimated.
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function