1
2
3
4
5
6
7 #ifndef CODEC_FWHT_H
8 #define CODEC_FWHT_H
9
10 #include <linux/types.h>
11 #include <linux/bitops.h>
12 #include <asm/byteorder.h>
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 #define FWHT_MAGIC1 0x4f4f4f4f
57 #define FWHT_MAGIC2 0xffffffff
58
59 #define FWHT_VERSION 3
60
61
62 #define FWHT_FL_IS_INTERLACED BIT(0)
63
64 #define FWHT_FL_IS_BOTTOM_FIRST BIT(1)
65
66 #define FWHT_FL_IS_ALTERNATE BIT(2)
67
68
69
70
71 #define FWHT_FL_IS_BOTTOM_FIELD BIT(3)
72
73 #define FWHT_FL_LUMA_IS_UNCOMPRESSED BIT(4)
74 #define FWHT_FL_CB_IS_UNCOMPRESSED BIT(5)
75 #define FWHT_FL_CR_IS_UNCOMPRESSED BIT(6)
76 #define FWHT_FL_CHROMA_FULL_HEIGHT BIT(7)
77 #define FWHT_FL_CHROMA_FULL_WIDTH BIT(8)
78 #define FWHT_FL_ALPHA_IS_UNCOMPRESSED BIT(9)
79 #define FWHT_FL_I_FRAME BIT(10)
80
81
82 #define FWHT_FL_COMPONENTS_NUM_MSK GENMASK(18, 16)
83 #define FWHT_FL_COMPONENTS_NUM_OFFSET 16
84
85 #define FWHT_FL_PIXENC_MSK GENMASK(20, 19)
86 #define FWHT_FL_PIXENC_OFFSET 19
87 #define FWHT_FL_PIXENC_YUV (1 << FWHT_FL_PIXENC_OFFSET)
88 #define FWHT_FL_PIXENC_RGB (2 << FWHT_FL_PIXENC_OFFSET)
89 #define FWHT_FL_PIXENC_HSV (3 << FWHT_FL_PIXENC_OFFSET)
90
91
92
93
94
95
96 #define vic_round_dim(dim, div) (round_up((dim) / (div), 8) * (div))
97
98 struct fwht_cframe_hdr {
99 u32 magic1;
100 u32 magic2;
101 __be32 version;
102 __be32 width, height;
103 __be32 flags;
104 __be32 colorspace;
105 __be32 xfer_func;
106 __be32 ycbcr_enc;
107 __be32 quantization;
108 __be32 size;
109 };
110
111 struct fwht_cframe {
112 u16 i_frame_qp;
113 u16 p_frame_qp;
114 __be16 *rlc_data;
115 s16 coeffs[8 * 8];
116 s16 de_coeffs[8 * 8];
117 s16 de_fwht[8 * 8];
118 u32 size;
119 };
120
121 struct fwht_raw_frame {
122 unsigned int width_div;
123 unsigned int height_div;
124 unsigned int luma_alpha_step;
125 unsigned int chroma_step;
126 unsigned int components_num;
127 u8 *buf;
128 u8 *luma, *cb, *cr, *alpha;
129 };
130
131 #define FWHT_FRAME_PCODED BIT(0)
132 #define FWHT_FRAME_UNENCODED BIT(1)
133 #define FWHT_LUMA_UNENCODED BIT(2)
134 #define FWHT_CB_UNENCODED BIT(3)
135 #define FWHT_CR_UNENCODED BIT(4)
136 #define FWHT_ALPHA_UNENCODED BIT(5)
137
138 u32 fwht_encode_frame(struct fwht_raw_frame *frm,
139 struct fwht_raw_frame *ref_frm,
140 struct fwht_cframe *cf,
141 bool is_intra, bool next_is_intra,
142 unsigned int width, unsigned int height,
143 unsigned int stride, unsigned int chroma_stride);
144 bool fwht_decode_frame(struct fwht_cframe *cf, u32 hdr_flags,
145 unsigned int components_num, unsigned int width,
146 unsigned int height, const struct fwht_raw_frame *ref,
147 unsigned int ref_stride, unsigned int ref_chroma_stride,
148 struct fwht_raw_frame *dst, unsigned int dst_stride,
149 unsigned int dst_chroma_stride);
150 #endif