f4f635635fb56380fb3139686a5583bf655e9446
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VLIB / P263 / p263_huffman.h
1 #ifndef _P263_HUFFMAN_H_
2 #define _P263_HUFFMAN_H_
3
4 #include <VLIB/video_huffman.h>
5
6
7 /// Macroblock type & Coded Block Pattern for Chrominance (MCBPC)
8
9 #define VLC_MCBPC_IPICTURES_NUM         9
10 #define VLC_MCBPC_IPICTURES_MAX_LENGTH  9
11
12 #define CBPC_CB(mcbpc) (((mcbpc).cbpc) & 1)
13 #define CBPC_CR(mcbpc) (((mcbpc).cbpc) & 2)
14
15 extern huffman_code_t   vlc_mcbpc_ipictures[VLC_MCBPC_IPICTURES_NUM];
16 extern huffman_tree_t*  vlc_mcbpc_ipictures_tree;
17
18 typedef struct _p263_mcbpc_t {
19   int32_t mb_type;
20   int32_t cbpc;
21 } p263_mcbpc_t;
22
23 extern p263_mcbpc_t mcbpc_ipictures[VLC_MCBPC_IPICTURES_NUM];
24
25
26 /// Coded Block Pattern for luminance (CBPY)
27
28 #define VLC_CBPY_STANDARD_NUM         16
29 #define VLC_CBPY_STANDARD_MAX_LENGTH  6
30
31 extern huffman_code_t   vlc_cbpy_standard[VLC_CBPY_STANDARD_NUM];
32 extern huffman_tree_t*  vlc_cbpy_standard_tree;
33
34 #define CBPY_MAKE( i12, i34 ) (((i34) << 2) | (i12))
35
36 #define CBPY_INTRA_Y0(cpby) ((((cbpy).intra) >> 0) & 1)
37 #define CBPY_INTRA_Y1(cpby) ((((cbpy).intra) >> 1) & 1)
38 #define CBPY_INTRA_Y2(cpby) ((((cbpy).intra) >> 2) & 1)
39 #define CBPY_INTRA_Y3(cpby) ((((cbpy).intra) >> 3) & 1)
40
41 #define CBPY_INTER_Y0(cpby) ((((cbpy).inter) >> 0) & 1)
42 #define CBPY_INTER_Y1(cpby) ((((cbpy).inter) >> 1) & 1)
43 #define CBPY_INTER_Y2(cpby) ((((cbpy).inter) >> 2) & 1)
44 #define CBPY_INTER_Y3(cpby) ((((cbpy).inter) >> 3) & 1)
45
46 typedef struct _p263_cbpy_t {
47   int32_t intra;
48   int32_t inter;
49 } p263_cbpy_t;
50
51 extern p263_cbpy_t cbpy_standard[VLC_CBPY_STANDARD_NUM - 1];
52
53
54 /// Transform Coefficient (TCOEF)
55
56 #define VLC_TCOEFF_NUM          103
57 #define VLC_TCOEFF_MAX_LENGTH   12
58 #define VLC_TCOEFF_ESCAPE       2
59
60 extern huffman_code_t   vlc_tcoeff[VLC_TCOEFF_NUM];
61 extern huffman_tree_t*  vlc_tcoeff_tree;
62
63 typedef struct _p263_tcoeff_t {
64   int32_t run;
65   int32_t level;
66   int32_t last;
67 } p263_tcoeff_t;
68
69 extern p263_tcoeff_t tcoeff[VLC_TCOEFF_NUM];
70
71
72 /// VLC table for Motion Vector Data (MVD)
73
74 #define MVD_VLC_NUM             64
75 #define MVD_VLC_MAX_LENGTH      13
76
77 extern huffman_code_t   mvd_vlc[MVD_VLC_NUM];
78 extern huffman_tree_t*  mvd_vlc_tree;
79
80 typedef struct _p263_mvd_t {
81   int32_t vector;
82   int32_t differences;
83 } p263_mvd_t;
84
85 extern p263_mvd_t mvd[MVD_VLC_NUM];
86
87 #endif // _P263_HUFFMAN_H_