Debian Codegraph @

libmmxnow/include/mmxnow.h

raw symbols SCIP
1 #ifndef MMXNOW_H
2 #define MMXNOW_H
3
4 #include <inttypes.h>
5 /*
6 * General interface for mmxnow library
7 *
8 * call mmxnow_create with flags - choose whatever implementation
9 * you wish to use (probably should match your CPU capabilities)
10 */
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 enum
16 {
17 // shuld be in order of prefered usage
18 MMXNOW_K7 = 1,
19 MMXNOW_MMX = 2,
20 MMXNOW_MMX2 = 4,
21 MMXNOW_3DNOW = 8,
22 MMXNOW_SSE = 16,
23 MMXNOW_SSE2 = 32,
24 };
25
26 enum
27 {
28 MMXNOW_TAGEND, /* marks taglist end */
29
30 MMXNOW_MEMCPY, /* for larger memory blocks */
31 MMXNOW_MEMSET,
32
33 /* image conversion methods */
34 /* converts just few lines per call (usually just one)
35 * depends on the convertor function and its context
36 * parameters -
37 * struct { int w; uint8_t* dst[16]; uint8_t* src[16]; }
38 *
39 * e.g. rgb conversion just w, dst[0] & src[0] would be used
40 */
41
42 /* planar YV12 */
43 MMXNOW_YV12_TO_BGR15 = 1000,
44 MMXNOW_YV12_TO_BGR16,
45 MMXNOW_YV12_TO_BGR24,
46 MMXNOW_YV12_TO_BGR32,
47
48 MMXNOW_BGR15_TO_YV12,
49 MMXNOW_BGR16_TO_YV12,
50 MMXNOW_BGR24_TO_YV12,
51 MMXNOW_BGR32_TO_YV12,
52
53 /* packed YUY2 */
54 MMXNOW_YUY2_TO_BGR15,
55 MMXNOW_YUY2_TO_BGR16,
56 MMXNOW_YUY2_TO_BGR24,
57 MMXNOW_YUY2_TO_BGR32,
58
59 MMXNOW_BGR15_TO_YUY2,
60 MMXNOW_BGR16_TO_YUY2,
61 MMXNOW_BGR24_TO_YUY2,
62 MMXNOW_BGR32_TO_YUY2,
63
64 /* 3 byte YUV */
65 MMXNOW_BGR15_TO_YUV,
66 MMXNOW_BGR16_TO_YUV,
67 MMXNOW_BGR24_TO_YUV,
68 MMXNOW_BGR32_TO_YUV,
69
70 MMXNOW_YUV_TO_BGR15,
71 MMXNOW_YUV_TO_BGR16,
72 MMXNOW_YUV_TO_BGR24,
73 MMXNOW_YUV_TO_BGR32,
74
75 /* all RGB conversions */
76 MMXNOW_BGR15_TO_BGR16,
77 MMXNOW_BGR15_TO_BGR24,
78 MMXNOW_BGR15_TO_BGR32,
79
80 MMXNOW_BGR16_TO_BGR15,
81 MMXNOW_BGR16_TO_BGR24,
82 MMXNOW_BGR16_TO_BGR32,
83
84 MMXNOW_BGR24_TO_BGR15,
85 MMXNOW_BGR24_TO_BGR16,
86 MMXNOW_BGR24_TO_BGR32,
87
88 MMXNOW_BGR32_TO_BGR15,
89 MMXNOW_BGR32_TO_BGR16,
90 MMXNOW_BGR32_TO_BGR24,
91
92
93 /* audio - proposition */
94 MMXNOW_AUDIO_SOMETHING = 2000,
95 };
96
97 struct mmxnow_context_t;
98 typedef struct mmxnow_context_t
99 {
100 /*
101 * address of function for given CPU flags
102 * data will be casted to the expected type
103 * user has to provide thread safety locking himself -
104 * or he could create new context for each thread
105 * but generally - its better to leave running only
106 * one MMX task - otherwice there is big speed penaly hit!
107 */
108 int (*method)(struct mmxnow_context_t*);
109 /* free static data data */
110 int (*free)(struct mmxnow_context_t*);
111
112 void* data; /* data - paramaters for function */
113 void* user; /* private data for user - e.g. -store mutex */
114 const char* name; /* text name of method - for debugging */
115 unsigned int flags; /* copy of initialization CPU flags */
116 } mmxnow_context_t;
117
118
119 /*
120 * only few calls here - so if should be simple to dlopen library in
121 * runtime and use it if its available on the system
122 */
123
124 /*
125 * get requested method - private context will be initialized when
126 * necesseary
127 */
128 mmxnow_context_t* mmxnow_create(int method, unsigned int flags);
129
130 /*
131 * when function is no longer necessary - call delete to free all
132 * allocated resources
133 */
134 void mmxnow_destroy(mmxnow_context_t* cntx);
135
136 unsigned int mmxnow_detect(void); /* not implemented yet */
137
138 /**** DATASTRUCTURES ****/
139
140 /*
141 * data structure used for image conversion
142 * many fields might not be supported by various function
143 */
144 typedef struct
145 {
146 int width, height; /* width of processed image */
147 int x, y;
148 uint8_t* plane[3]; /* Y U V */
149 int stride[3];
150 int format;
151 int bpp; /* bits per plane */
152 } mmxnow_image_t;
153
154 typedef struct { uint8_t r,g,b; } mmxnow_rgb_t;
155 typedef struct { uint8_t y,cb,cr; } mmxnow_yuv_t;
156
157 typedef struct
158 {
159 void* context; /* private data structure */
160 unsigned int supports; /* flag of supported operation
161 * e.g - support rescale, flip,
162 * bit plane conversion,...
163 */
164 mmxnow_image_t in; /* input image */
165 mmxnow_image_t out; /* output image */
166
167 int flip; /* flip image during processing */
168 int bottom_up; /* process image from bottom */
169 int reserved[20];
170 } mmxnow_image_data_t;
171
172 #ifdef __cplusplus
173 }
174 #endif
175
176 #endif /* MMXNOW_H */