• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015 Google Inc. All Rights Reserved.
2 //
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
5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree.
8 // -----------------------------------------------------------------------------
9 //
10 
11 #ifndef WEBP_EXTRAS_EXTRAS_H_
12 #define WEBP_EXTRAS_EXTRAS_H_
13 
14 #include "webp/types.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include "webp/encode.h"
21 
22 #define WEBP_EXTRAS_ABI_VERSION 0x0002    // MAJOR(8b) + MINOR(8b)
23 
24 //------------------------------------------------------------------------------
25 
26 // Returns the version number of the extras library, packed in hexadecimal using
27 // 8bits for each of major/minor/revision. E.g: v2.5.7 is 0x020507.
28 WEBP_EXTERN int WebPGetExtrasVersion(void);
29 
30 //------------------------------------------------------------------------------
31 // Ad-hoc colorspace importers.
32 
33 // Import luma sample (gray scale image) into 'picture'. The 'picture'
34 // width and height must be set prior to calling this function.
35 WEBP_EXTERN int WebPImportGray(const uint8_t* gray, WebPPicture* picture);
36 
37 // Import rgb sample in RGB565 packed format into 'picture'. The 'picture'
38 // width and height must be set prior to calling this function.
39 WEBP_EXTERN int WebPImportRGB565(const uint8_t* rgb565, WebPPicture* pic);
40 
41 // Import rgb sample in RGB4444 packed format into 'picture'. The 'picture'
42 // width and height must be set prior to calling this function.
43 WEBP_EXTERN int WebPImportRGB4444(const uint8_t* rgb4444, WebPPicture* pic);
44 
45 // Import a color mapped image. The number of colors is less or equal to
46 // MAX_PALETTE_SIZE. 'pic' must have been initialized. Its content, if any,
47 // will be discarded. Returns 'false' in case of error, or if indexed[] contains
48 // invalid indices.
49 WEBP_EXTERN int
50 WebPImportColorMappedARGB(const uint8_t* indexed, int indexed_stride,
51                           const uint32_t palette[], int palette_size,
52                           WebPPicture* pic);
53 
54 // Convert the ARGB content of 'pic' from associated to unassociated.
55 // 'pic' can be for instance the result of calling of some WebPPictureImportXXX
56 // functions, with pic->use_argb set to 'true'. It is assumed (and not checked)
57 // that the pre-multiplied r/g/b values as less or equal than the alpha value.
58 // Return false in case of error (invalid parameter, ...).
59 WEBP_EXTERN int WebPUnmultiplyARGB(WebPPicture* pic);
60 
61 //------------------------------------------------------------------------------
62 
63 // Parse a bitstream, search for VP8 (lossy) header and report a
64 // rough estimation of the quality factor used for compressing the bitstream.
65 // If the bitstream is in lossless format, the special value '101' is returned.
66 // Otherwise (lossy bitstream), the returned value is in the range [0..100].
67 // Any error (invalid bitstream, animated WebP, incomplete header, etc.)
68 // will return a value of -1.
69 WEBP_EXTERN int VP8EstimateQuality(const uint8_t* const data, size_t size);
70 
71 //------------------------------------------------------------------------------
72 
73 #ifdef __cplusplus
74 }    // extern "C"
75 #endif
76 
77 #endif  // WEBP_EXTRAS_EXTRAS_H_
78