SHOW:
|
|
- or go back to the newest paste.
1 | typedef struct zimg_image_buffer_const { | |
2 | unsigned version; | |
3 | const void *data[3]; | |
4 | ptrdiff_t stride[3]; | |
5 | unsigned mask[3]; | |
6 | } zimg_image_buffer_const; | |
7 | ||
8 | typedef union zimg_image_buffer { | |
9 | struct { | |
10 | unsigned version; | |
11 | void *data[3]; | |
12 | ptrdiff_t stride[3]; | |
13 | unsigned mask[3]; | |
14 | } m; | |
15 | ||
16 | zimg_image_buffer_const c; | |
17 | } zimg_image_buffer; | |
18 | ||
19 | typedef struct zimg_graph zimg_graph; | |
20 | ||
21 | ||
22 | // Minimum buffering mask required for input. | |
23 | unsigned zimg_graph_input_mask(const zimg_graph *graph); | |
24 | ||
25 | // Minimum buffering mask required for output. | |
26 | unsigned zimg_graph_output_mask(const zimg_graph *graph); | |
27 | ||
28 | // Other temporary data. | |
29 | size_t zimg_graph_tmp_size(const zimg_graph *graph); | |
30 | ||
31 | ||
32 | // Make line i available to the input buffer. | |
33 | typedef int (*zimg_unpack_func)(void *user, unsigned i); | |
34 | ||
35 | // Notify that line i is available in the output buffer. | |
36 | typedef int (*zimg_pack_func)(void *user, unsigned i); | |
37 | ||
38 | typedef struct zimg_unpack_yuy2_context { | |
39 | unsigned version; | |
40 | zimg_image_buffer *buf; // same as argument to graph_traverse | |
41 | const void *packed_plane; | |
42 | ptrdiff_t packed_stride; | |
43 | } zimg_unpack_yuy2_context; | |
44 | ||
45 | typedef struct zimg_pack_yuy2_context { | |
46 | unsigned version; | |
47 | zimg_image_buffer_const *buf; // same as argument to graph_traverse | |
48 | void *packed_plane; | |
49 | - | ptrdiff_tpacked_stride; |
49 | + | |
50 | } zimg_pack_yuy2_context; | |
51 | ||
52 | ||
53 | typedef struct zimg_unpack_rgb32_context { | |
54 | unsigned version; | |
55 | zimg_image_buffer *buf; // same as argument to graph_traverse | |
56 | const void *packed_plane; | |
57 | ptrdiff_t packed_stride; | |
58 | ||
59 | void *alpha_plane; // dumps alpha here | |
60 | ptrdiff_t alpha_stride; | |
61 | } zimg_unpack_rgb_context; | |
62 | ||
63 | typedef struct zimg_pack_rgb32_context { | |
64 | unsigned version; | |
65 | zimg_image_buffer_const *buf; // same as argument to graph_traverse | |
66 | void *packed_plane; | |
67 | ptrdiff_t packed_stride; | |
68 | ||
69 | const void *alpha_plane; // reinterleaves alpha from here (must be planar) | |
70 | ptrdiff_t alpha_stride; | |
71 | } zimg_pack_rgb_context; | |
72 | ||
73 | ||
74 | // use zimg_unpack/pack_yuy2_context | |
75 | int zimg_unpack_yuy2(void *user, unsigned i); | |
76 | int zimg_pack_yuy2(void *user, unsigned i); | |
77 | ||
78 | // use zimg_unpack/pack_rgb_context | |
79 | int zimg_unpack_rgb32(void *user, unsigned i); | |
80 | int zimg_pack_rgb32(void *user, unsigned i); | |
81 | int zimg_unpack_rgb24(void *user, unsigned i); | |
82 | int zimg_pack_rgb24(void *user, unsigned i); | |
83 | ||
84 | // To run on a fully allocated planar image: | |
85 | // zimg_graph_traverse(g, src_buf, dst, tmp, 0, 0, 0, 0); | |
86 | // To convert YUY2 to RGB32: | |
87 | // zimg_unpack_yuy2_context unpack_yuy2 = { ZIMG_API_VERSION, src_mutable, yuy2_ptr, yuy2_stride }; | |
88 | // zimg_pack_rgb_context pack_rgb = { ZIMG_API_VERSION, dst, rgb32_ptr, rgb32_stride, 0, 0 }; | |
89 | // zimg_graph_traverse(g, &src_mutable->c, dst, tmp, &zimg_unpack_yuy2, &unpack_yuy2, &zimg_pack_rgb32, &pack_rgb); | |
90 | ||
91 | void zimg_graph_traverse(const zimg_graph *graph, const zimg_image_buffer_const *src, const zimg_image_buffer *dst, | |
92 | void *tmp, zimg_unpack_func unpack_cb, void *unpack_priv, zimg_pack_func pack_cb, void *pack_priv); |