1 | /* |
2 | * 1394-Based Digital Camera Control Library |
3 | * |
4 | * Utilities |
5 | * |
6 | * Written by Damien Douxchamps <ddouxchamps@users.sf.net> |
7 | * |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Lesser General Public |
10 | * License as published by the Free Software Foundation; either |
11 | * version 2.1 of the License, or (at your option) any later version. |
12 | * |
13 | * This library is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. |
17 | * |
18 | * You should have received a copy of the GNU Lesser General Public |
19 | * License along with this library; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | */ |
22 | |
23 | #ifndef __DC1394_UTILS_H__ |
24 | #define __DC1394_UTILS_H__ |
25 | |
26 | /*! \file dc1394/utils.h |
27 | \brief Utility functions |
28 | \author Damien Douxchamps: coding |
29 | \author Peter Antoniac: documentation maintainer |
30 | |
31 | More details soon |
32 | */ |
33 | |
34 | #ifdef __cplusplus |
35 | extern "C" { |
36 | #endif |
37 | |
38 | /** |
39 | * Returns the image width and height (in pixels) corresponding to a video mode. Works for scalable and non-scalable video modes. |
40 | */ |
41 | dc1394error_t dc1394_get_image_size_from_video_mode(dc1394camera_t *camera, dc1394video_mode_t video_mode, uint32_t *width, uint32_t *height); |
42 | |
43 | /** |
44 | * Returns the given framerate as a float. |
45 | */ |
46 | dc1394error_t dc1394_framerate_as_float(dc1394framerate_t framerate_enum, float *framerate); |
47 | |
48 | /** |
49 | * Returns the number of bits per pixel for a certain color coding. This is the size of the data sent on the bus, the effective |
50 | * data depth may vary. Example: RGB16 is 16, YUV411 is 8, YUV422 is 8. |
51 | */ |
52 | dc1394error_t dc1394_get_color_coding_data_depth(dc1394color_coding_t color_coding, uint32_t * bits); |
53 | |
54 | /** |
55 | * Returns the bit-space used by a pixel. This is different from the data depth! For instance, RGB16 has a bit space of 48 bits, |
56 | * YUV422 is 16bits and YU411 is 12bits. |
57 | */ |
58 | dc1394error_t dc1394_get_color_coding_bit_size(dc1394color_coding_t color_coding, uint32_t* bits); |
59 | |
60 | /** |
61 | * Returns the color coding from the video mode. Works with scalable image formats too. |
62 | */ |
63 | dc1394error_t dc1394_get_color_coding_from_video_mode(dc1394camera_t *camera, dc1394video_mode_t video_mode, dc1394color_coding_t *color_coding); |
64 | |
65 | /** |
66 | * Tells whether the color mode is color or monochrome |
67 | */ |
68 | dc1394error_t dc1394_is_color(dc1394color_coding_t color_mode, dc1394bool_t *is_color); |
69 | |
70 | /** |
71 | * Tells whether the video mode is scalable or not. |
72 | */ |
73 | dc1394bool_t dc1394_is_video_mode_scalable(dc1394video_mode_t video_mode); |
74 | |
75 | /** |
76 | * Tells whether the video mode is "still image" or not ("still image" is currently not supported by any cameras on the market) |
77 | */ |
78 | dc1394bool_t dc1394_is_video_mode_still_image(dc1394video_mode_t video_mode); |
79 | |
80 | /** |
81 | * Tells whether two IDs refer to the same physical camera unit. |
82 | */ |
83 | dc1394bool_t dc1394_is_same_camera(dc1394camera_id_t id1, dc1394camera_id_t id2); |
84 | |
85 | /** |
86 | * Returns a descriptive name for a feature |
87 | */ |
88 | const char * dc1394_feature_get_string(dc1394feature_t feature); |
89 | |
90 | /** |
91 | * Returns a descriptive string for an error code |
92 | */ |
93 | const char * dc1394_error_get_string(dc1394error_t error); |
94 | |
95 | /** |
96 | * Calculates the CRC16 checksum of a memory region. Useful to verify the CRC of an image buffer, for instance. |
97 | */ |
98 | uint16_t dc1394_checksum_crc16 (const uint8_t* buffer, uint32_t buffer_size); |
99 | |
100 | #ifdef __cplusplus |
101 | } |
102 | #endif |
103 | |
104 | #endif /* _DC1394_UTILS_H */ |
105 | |
106 | |