Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/libwebp/webp/mux.h

Issue 2651883004: libwebp-0.6.0-rc1 (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libwebp/webp/format_constants.h ('k') | third_party/libwebp/webp/mux_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 Google Inc. All Rights Reserved. 1 // Copyright 2011 Google Inc. All Rights Reserved.
2 // 2 //
3 // Use of this source code is governed by a BSD-style license 3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the COPYING file in the root of the source 4 // that can be found in the COPYING file in the root of the source
5 // tree. An additional intellectual property rights grant can be found 5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may 6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree. 7 // be found in the AUTHORS file in the root of the source tree.
8 // ----------------------------------------------------------------------------- 8 // -----------------------------------------------------------------------------
9 // 9 //
10 // RIFF container manipulation and encoding for WebP images. 10 // RIFF container manipulation and encoding for WebP images.
11 // 11 //
12 // Authors: Urvang (urvang@google.com) 12 // Authors: Urvang (urvang@google.com)
13 // Vikas (vikasa@google.com) 13 // Vikas (vikasa@google.com)
14 14
15 #ifndef WEBP_WEBP_MUX_H_ 15 #ifndef WEBP_WEBP_MUX_H_
16 #define WEBP_WEBP_MUX_H_ 16 #define WEBP_WEBP_MUX_H_
17 17
18 #include "./mux_types.h" 18 #include "./mux_types.h"
19 19
20 #ifdef __cplusplus 20 #ifdef __cplusplus
21 extern "C" { 21 extern "C" {
22 #endif 22 #endif
23 23
24 #define WEBP_MUX_ABI_VERSION 0x0106 // MAJOR(8b) + MINOR(8b) 24 #define WEBP_MUX_ABI_VERSION 0x0107 // MAJOR(8b) + MINOR(8b)
25 25
26 //------------------------------------------------------------------------------ 26 //------------------------------------------------------------------------------
27 // Mux API 27 // Mux API
28 // 28 //
29 // This API allows manipulation of WebP container images containing features 29 // This API allows manipulation of WebP container images containing features
30 // like color profile, metadata, animation and fragmented images. 30 // like color profile, metadata, animation.
31 // 31 //
32 // Code Example#1: Create a WebPMux object with image data, color profile and 32 // Code Example#1: Create a WebPMux object with image data, color profile and
33 // XMP metadata. 33 // XMP metadata.
34 /* 34 /*
35 int copy_data = 0; 35 int copy_data = 0;
36 WebPMux* mux = WebPMuxNew(); 36 WebPMux* mux = WebPMuxNew();
37 // ... (Prepare image data). 37 // ... (Prepare image data).
38 WebPMuxSetImage(mux, &image, copy_data); 38 WebPMuxSetImage(mux, &image, copy_data);
39 // ... (Prepare ICCP color profile data). 39 // ... (Prepare ICCP color profile data).
40 WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data); 40 WebPMuxSetChunk(mux, "ICCP", &icc_profile, copy_data);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 WEBP_MUX_OK = 1, 74 WEBP_MUX_OK = 1,
75 WEBP_MUX_NOT_FOUND = 0, 75 WEBP_MUX_NOT_FOUND = 0,
76 WEBP_MUX_INVALID_ARGUMENT = -1, 76 WEBP_MUX_INVALID_ARGUMENT = -1,
77 WEBP_MUX_BAD_DATA = -2, 77 WEBP_MUX_BAD_DATA = -2,
78 WEBP_MUX_MEMORY_ERROR = -3, 78 WEBP_MUX_MEMORY_ERROR = -3,
79 WEBP_MUX_NOT_ENOUGH_DATA = -4 79 WEBP_MUX_NOT_ENOUGH_DATA = -4
80 } WebPMuxError; 80 } WebPMuxError;
81 81
82 // IDs for different types of chunks. 82 // IDs for different types of chunks.
83 typedef enum WebPChunkId { 83 typedef enum WebPChunkId {
84 WEBP_CHUNK_VP8X, // VP8X 84 WEBP_CHUNK_VP8X, // VP8X
85 WEBP_CHUNK_ICCP, // ICCP 85 WEBP_CHUNK_ICCP, // ICCP
86 WEBP_CHUNK_ANIM, // ANIM 86 WEBP_CHUNK_ANIM, // ANIM
87 WEBP_CHUNK_ANMF, // ANMF 87 WEBP_CHUNK_ANMF, // ANMF
88 WEBP_CHUNK_FRGM, // FRGM 88 WEBP_CHUNK_DEPRECATED, // (deprecated from FRGM)
89 WEBP_CHUNK_ALPHA, // ALPH 89 WEBP_CHUNK_ALPHA, // ALPH
90 WEBP_CHUNK_IMAGE, // VP8/VP8L 90 WEBP_CHUNK_IMAGE, // VP8/VP8L
91 WEBP_CHUNK_EXIF, // EXIF 91 WEBP_CHUNK_EXIF, // EXIF
92 WEBP_CHUNK_XMP, // XMP 92 WEBP_CHUNK_XMP, // XMP
93 WEBP_CHUNK_UNKNOWN, // Other chunks. 93 WEBP_CHUNK_UNKNOWN, // Other chunks.
94 WEBP_CHUNK_NIL 94 WEBP_CHUNK_NIL
95 } WebPChunkId; 95 } WebPChunkId;
96 96
97 //------------------------------------------------------------------------------ 97 //------------------------------------------------------------------------------
98 98
99 // Returns the version number of the mux library, packed in hexadecimal using 99 // Returns the version number of the mux library, packed in hexadecimal using
100 // 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507. 100 // 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
101 WEBP_EXTERN(int) WebPGetMuxVersion(void); 101 WEBP_EXTERN(int) WebPGetMuxVersion(void);
102 102
103 //------------------------------------------------------------------------------ 103 //------------------------------------------------------------------------------
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // NULL - In case of invalid data or memory error. 135 // NULL - In case of invalid data or memory error.
136 static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream, 136 static WEBP_INLINE WebPMux* WebPMuxCreate(const WebPData* bitstream,
137 int copy_data) { 137 int copy_data) {
138 return WebPMuxCreateInternal(bitstream, copy_data, WEBP_MUX_ABI_VERSION); 138 return WebPMuxCreateInternal(bitstream, copy_data, WEBP_MUX_ABI_VERSION);
139 } 139 }
140 140
141 //------------------------------------------------------------------------------ 141 //------------------------------------------------------------------------------
142 // Non-image chunks. 142 // Non-image chunks.
143 143
144 // Note: Only non-image related chunks should be managed through chunk APIs. 144 // Note: Only non-image related chunks should be managed through chunk APIs.
145 // (Image related chunks are: "ANMF", "FRGM", "VP8 ", "VP8L" and "ALPH"). 145 // (Image related chunks are: "ANMF", "VP8 ", "VP8L" and "ALPH").
146 // To add, get and delete images, use WebPMuxSetImage(), WebPMuxPushFrame(), 146 // To add, get and delete images, use WebPMuxSetImage(), WebPMuxPushFrame(),
147 // WebPMuxGetFrame() and WebPMuxDeleteFrame(). 147 // WebPMuxGetFrame() and WebPMuxDeleteFrame().
148 148
149 // Adds a chunk with id 'fourcc' and data 'chunk_data' in the mux object. 149 // Adds a chunk with id 'fourcc' and data 'chunk_data' in the mux object.
150 // Any existing chunk(s) with the same id will be removed. 150 // Any existing chunk(s) with the same id will be removed.
151 // Parameters: 151 // Parameters:
152 // mux - (in/out) object to which the chunk is to be added 152 // mux - (in/out) object to which the chunk is to be added
153 // fourcc - (in) a character array containing the fourcc of the given chunk; 153 // fourcc - (in) a character array containing the fourcc of the given chunk;
154 // e.g., "ICCP", "XMP ", "EXIF" etc. 154 // e.g., "ICCP", "XMP ", "EXIF" etc.
155 // chunk_data - (in) the chunk data to be added 155 // chunk_data - (in) the chunk data to be added
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // WEBP_MUX_INVALID_ARGUMENT - if mux or fourcc is NULL 188 // WEBP_MUX_INVALID_ARGUMENT - if mux or fourcc is NULL
189 // or if fourcc corresponds to an image chunk. 189 // or if fourcc corresponds to an image chunk.
190 // WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given fourcc. 190 // WEBP_MUX_NOT_FOUND - If mux does not contain a chunk with the given fourcc.
191 // WEBP_MUX_OK - on success. 191 // WEBP_MUX_OK - on success.
192 WEBP_EXTERN(WebPMuxError) WebPMuxDeleteChunk( 192 WEBP_EXTERN(WebPMuxError) WebPMuxDeleteChunk(
193 WebPMux* mux, const char fourcc[4]); 193 WebPMux* mux, const char fourcc[4]);
194 194
195 //------------------------------------------------------------------------------ 195 //------------------------------------------------------------------------------
196 // Images. 196 // Images.
197 197
198 // Encapsulates data about a single frame/fragment. 198 // Encapsulates data about a single frame.
199 struct WebPMuxFrameInfo { 199 struct WebPMuxFrameInfo {
200 WebPData bitstream; // image data: can be a raw VP8/VP8L bitstream 200 WebPData bitstream; // image data: can be a raw VP8/VP8L bitstream
201 // or a single-image WebP file. 201 // or a single-image WebP file.
202 int x_offset; // x-offset of the frame. 202 int x_offset; // x-offset of the frame.
203 int y_offset; // y-offset of the frame. 203 int y_offset; // y-offset of the frame.
204 int duration; // duration of the frame (in milliseconds). 204 int duration; // duration of the frame (in milliseconds).
205 205
206 WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF, 206 WebPChunkId id; // frame type: should be one of WEBP_CHUNK_ANMF
207 // WEBP_CHUNK_FRGM or WEBP_CHUNK_IMAGE 207 // or WEBP_CHUNK_IMAGE
208 WebPMuxAnimDispose dispose_method; // Disposal method for the frame. 208 WebPMuxAnimDispose dispose_method; // Disposal method for the frame.
209 WebPMuxAnimBlend blend_method; // Blend operation for the frame. 209 WebPMuxAnimBlend blend_method; // Blend operation for the frame.
210 uint32_t pad[1]; // padding for later use 210 uint32_t pad[1]; // padding for later use
211 }; 211 };
212 212
213 // Sets the (non-animated and non-fragmented) image in the mux object. 213 // Sets the (non-animated) image in the mux object.
214 // Note: Any existing images (including frames/fragments) will be removed. 214 // Note: Any existing images (including frames) will be removed.
215 // Parameters: 215 // Parameters:
216 // mux - (in/out) object in which the image is to be set 216 // mux - (in/out) object in which the image is to be set
217 // bitstream - (in) can be a raw VP8/VP8L bitstream or a single-image 217 // bitstream - (in) can be a raw VP8/VP8L bitstream or a single-image
218 // WebP file (non-animated and non-fragmented) 218 // WebP file (non-animated)
219 // copy_data - (in) value 1 indicates given data WILL be copied to the mux 219 // copy_data - (in) value 1 indicates given data WILL be copied to the mux
220 // object and value 0 indicates data will NOT be copied. 220 // object and value 0 indicates data will NOT be copied.
221 // Returns: 221 // Returns:
222 // WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL. 222 // WEBP_MUX_INVALID_ARGUMENT - if mux is NULL or bitstream is NULL.
223 // WEBP_MUX_MEMORY_ERROR - on memory allocation error. 223 // WEBP_MUX_MEMORY_ERROR - on memory allocation error.
224 // WEBP_MUX_OK - on success. 224 // WEBP_MUX_OK - on success.
225 WEBP_EXTERN(WebPMuxError) WebPMuxSetImage( 225 WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(
226 WebPMux* mux, const WebPData* bitstream, int copy_data); 226 WebPMux* mux, const WebPData* bitstream, int copy_data);
227 227
228 // Adds a frame at the end of the mux object. 228 // Adds a frame at the end of the mux object.
229 // Notes: (1) frame.id should be one of WEBP_CHUNK_ANMF or WEBP_CHUNK_FRGM 229 // Notes: (1) frame.id should be WEBP_CHUNK_ANMF
230 // (2) For setting a non-animated non-fragmented image, use 230 // (2) For setting a non-animated image, use WebPMuxSetImage() instead.
231 // WebPMuxSetImage() instead.
232 // (3) Type of frame being pushed must be same as the frames in mux. 231 // (3) Type of frame being pushed must be same as the frames in mux.
233 // (4) As WebP only supports even offsets, any odd offset will be snapped 232 // (4) As WebP only supports even offsets, any odd offset will be snapped
234 // to an even location using: offset &= ~1 233 // to an even location using: offset &= ~1
235 // Parameters: 234 // Parameters:
236 // mux - (in/out) object to which the frame is to be added 235 // mux - (in/out) object to which the frame is to be added
237 // frame - (in) frame data. 236 // frame - (in) frame data.
238 // copy_data - (in) value 1 indicates given data WILL be copied to the mux 237 // copy_data - (in) value 1 indicates given data WILL be copied to the mux
239 // object and value 0 indicates data will NOT be copied. 238 // object and value 0 indicates data will NOT be copied.
240 // Returns: 239 // Returns:
241 // WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL 240 // WEBP_MUX_INVALID_ARGUMENT - if mux or frame is NULL
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // enc - (in/out) object to be deleted 520 // enc - (in/out) object to be deleted
522 WEBP_EXTERN(void) WebPAnimEncoderDelete(WebPAnimEncoder* enc); 521 WEBP_EXTERN(void) WebPAnimEncoderDelete(WebPAnimEncoder* enc);
523 522
524 //------------------------------------------------------------------------------ 523 //------------------------------------------------------------------------------
525 524
526 #ifdef __cplusplus 525 #ifdef __cplusplus
527 } // extern "C" 526 } // extern "C"
528 #endif 527 #endif
529 528
530 #endif /* WEBP_WEBP_MUX_H_ */ 529 #endif /* WEBP_WEBP_MUX_H_ */
OLDNEW
« no previous file with comments | « third_party/libwebp/webp/format_constants.h ('k') | third_party/libwebp/webp/mux_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698