1 /* SPDX-License-Identifier: GPL-2.0 */
9 #include <linux/kernel.h>
10 #include <linux/types.h>
15 int (*rbsp_bit)(struct rbsp *rbsp, int *val);
16 int (*rbsp_bits)(struct rbsp *rbsp, int n, unsigned int *val);
17 int (*rbsp_uev)(struct rbsp *rbsp, unsigned int *val);
18 int (*rbsp_sev)(struct rbsp *rbsp, int *val);
22 * struct rbsp - State object for handling a raw byte sequence payload
23 * @data: pointer to the data of the rbsp
24 * @size: maximum size of the data of the rbsp
25 * @pos: current bit position inside the rbsp
26 * @num_consecutive_zeros: number of zeros before @pos
27 * @ops: per datatype functions for interacting with the rbsp
28 * @error: an error occurred while handling the rbsp
30 * This struct is passed around the various parsing functions and tracks the
31 * current position within the raw byte sequence payload.
33 * The @ops field allows to separate the operation, i.e., reading/writing a
34 * value from/to that rbsp, from the structure of the NAL unit. This allows to
35 * have a single function for iterating the NAL unit, while @ops has function
36 * pointers for handling each type in the rbsp.
42 unsigned int num_consecutive_zeros;
43 struct nal_rbsp_ops *ops;
47 extern struct nal_rbsp_ops write;
48 extern struct nal_rbsp_ops read;
50 void rbsp_init(struct rbsp *rbsp, void *addr, size_t size,
51 struct nal_rbsp_ops *ops);
52 void rbsp_unsupported(struct rbsp *rbsp);
54 void rbsp_bit(struct rbsp *rbsp, int *value);
55 void rbsp_bits(struct rbsp *rbsp, int n, int *value);
56 void rbsp_uev(struct rbsp *rbsp, unsigned int *value);
57 void rbsp_sev(struct rbsp *rbsp, int *value);
59 void rbsp_trailing_bits(struct rbsp *rbsp);
61 #endif /* __NAL_RBSP_H__ */