File: avif_parse.h

package info (click to toggle)
rust-avif-parse 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 204 kB
  • sloc: ansic: 17; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,052 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

/**
 * Result of parsing an AVIF file. Contains AV1-compressed data.
 */
typedef struct avif_data_t {
  /**
   * AV1 data for color channels
   */
  const unsigned char *primary_data;
  size_t primary_size;
  /**
   * AV1 data for alpha channel (may be NULL if the image is fully opaque)
   */
  const unsigned char *alpha_data;
  size_t alpha_size;
  /**
   * 0 = normal, uncorrelated alpha channel
   * 1 = premultiplied alpha. You must divide RGB values by alpha.
   *
   * ```c
   * if (a != 0) {r = r * 255 / a}
   * ```
   */
  char premultiplied_alpha;
  void *reserved;
} avif_data_t;

/**
 * Parse AVIF image file and return results. Returns `NULL` if the file can't be parsed.
 *
 * Call `avif_data_free` on the result when done.
 */
const avif_data_t *avif_parse(const unsigned char *bytes, size_t bytes_len);

/**
 * Free all data related to `avif_data_t`
 */
void avif_data_free(const avif_data_t *data);

#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus