ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VLIB / video_huffman.h
1 #ifndef _VIDEO_HUFFMAN_H_
2 #define _VIDEO_HUFFMAN_H_
3
4 #include <VP_Os/vp_os_types.h>
5 #include <VLIB/video_controller.h>
6
7 # pragma pack (1)
8
9 typedef struct _huffman_code_t {
10   int32_t index;
11   union {
12     struct {
13       uint8_t   length;
14       uint32_t  vlc:24;
15     };
16     int32_t code;
17   };
18 } huffman_code_t;
19
20 # pragma pack () // resets packsize to default value
21
22 typedef struct _huffman_tree_data_t {
23   huffman_code_t* code;
24   int32_t         weight;
25 } huffman_tree_data_t;
26
27 typedef struct _huffman_tree_t {
28   int32_t num_used_codes;
29   int32_t num_max_codes;
30   int32_t max_code_length;
31
32   huffman_tree_data_t data[];
33 } huffman_tree_t;
34
35 huffman_tree_t* huffman_alloc( int32_t num_max_codes, int32_t max_code_length );
36 void huffman_free( huffman_tree_t* tree );
37
38 C_RESULT huffman_add_codes( huffman_tree_t* tree, huffman_code_t* codes, int32_t num_codes );
39 C_RESULT huffman_sort_codes( huffman_tree_t* tree );
40
41 C_RESULT huffman_check_code( huffman_tree_t* tree, uint32_t code, uint32_t length );
42 int32_t  huffman_stream_code( huffman_tree_t* tree, video_stream_t* stream );
43
44 #endif // _VIDEO_HUFFMAN_H_