xref: /aosp_15_r20/external/webp/imageio/image_dec.h (revision b2055c353e87c8814eb2b6b1b11112a1562253bd)
1 // Copyright 2016 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 //  All-in-one library to decode PNG/JPEG/WebP/TIFF/WIC input images.
11 //
12 // Author: Skal ([email protected])
13 
14 #ifndef WEBP_IMAGEIO_IMAGE_DEC_H_
15 #define WEBP_IMAGEIO_IMAGE_DEC_H_
16 
17 #include "webp/types.h"
18 
19 #ifdef HAVE_CONFIG_H
20 #include "webp/config.h"
21 #endif
22 
23 #include "./metadata.h"
24 #include "./jpegdec.h"
25 #include "./pngdec.h"
26 #include "./pnmdec.h"
27 #include "./tiffdec.h"
28 #include "./webpdec.h"
29 #include "./wicdec.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 typedef enum {
36   WEBP_PNG_FORMAT = 0,
37   WEBP_JPEG_FORMAT,
38   WEBP_TIFF_FORMAT,
39   WEBP_WEBP_FORMAT,
40   WEBP_PNM_FORMAT,
41   WEBP_UNSUPPORTED_FORMAT
42 } WebPInputFileFormat;
43 
44 // Returns a comma separated list of enabled input formats.
45 const char* WebPGetEnabledInputFileFormats(void);
46 
47 // Try to infer the image format. 'data_size' should be larger than 12.
48 // Returns WEBP_UNSUPPORTED_FORMAT if format can't be guess safely.
49 WebPInputFileFormat WebPGuessImageType(const uint8_t* const data,
50                                        size_t data_size);
51 
52 // Signature for common image-reading functions (ReadPNG, ReadJPEG, ...)
53 typedef int (*WebPImageReader)(const uint8_t* const data, size_t data_size,
54                                struct WebPPicture* const pic,
55                                int keep_alpha, struct Metadata* const metadata);
56 
57 // Return the reader associated to a given file format.
58 WebPImageReader WebPGetImageReader(WebPInputFileFormat format);
59 
60 // This function is similar to WebPGuessImageType(), but returns a
61 // suitable reader function. The returned reader is never NULL, but
62 // unknown formats will return an always-failing valid reader.
63 WebPImageReader WebPGuessImageReader(const uint8_t* const data,
64                                      size_t data_size);
65 
66 #ifdef __cplusplus
67 }    // extern "C"
68 #endif
69 
70 #endif  // WEBP_IMAGEIO_IMAGE_DEC_H_
71