Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2019-2020 Pengutronix, Michael Tretter <kernel@pengutronix.de>
0004  */
0005 
0006 #ifndef __NAL_RBSP_H__
0007 #define __NAL_RBSP_H__
0008 
0009 #include <linux/kernel.h>
0010 #include <linux/types.h>
0011 
0012 struct rbsp;
0013 
0014 struct nal_rbsp_ops {
0015     int (*rbsp_bit)(struct rbsp *rbsp, int *val);
0016     int (*rbsp_bits)(struct rbsp *rbsp, int n, unsigned int *val);
0017     int (*rbsp_uev)(struct rbsp *rbsp, unsigned int *val);
0018     int (*rbsp_sev)(struct rbsp *rbsp, int *val);
0019 };
0020 
0021 /**
0022  * struct rbsp - State object for handling a raw byte sequence payload
0023  * @data: pointer to the data of the rbsp
0024  * @size: maximum size of the data of the rbsp
0025  * @pos: current bit position inside the rbsp
0026  * @num_consecutive_zeros: number of zeros before @pos
0027  * @ops: per datatype functions for interacting with the rbsp
0028  * @error: an error occurred while handling the rbsp
0029  *
0030  * This struct is passed around the various parsing functions and tracks the
0031  * current position within the raw byte sequence payload.
0032  *
0033  * The @ops field allows to separate the operation, i.e., reading/writing a
0034  * value from/to that rbsp, from the structure of the NAL unit. This allows to
0035  * have a single function for iterating the NAL unit, while @ops has function
0036  * pointers for handling each type in the rbsp.
0037  */
0038 struct rbsp {
0039     u8 *data;
0040     size_t size;
0041     unsigned int pos;
0042     unsigned int num_consecutive_zeros;
0043     struct nal_rbsp_ops *ops;
0044     int error;
0045 };
0046 
0047 extern struct nal_rbsp_ops write;
0048 extern struct nal_rbsp_ops read;
0049 
0050 void rbsp_init(struct rbsp *rbsp, void *addr, size_t size,
0051            struct nal_rbsp_ops *ops);
0052 void rbsp_unsupported(struct rbsp *rbsp);
0053 
0054 void rbsp_bit(struct rbsp *rbsp, int *value);
0055 void rbsp_bits(struct rbsp *rbsp, int n, int *value);
0056 void rbsp_uev(struct rbsp *rbsp, unsigned int *value);
0057 void rbsp_sev(struct rbsp *rbsp, int *value);
0058 
0059 void rbsp_trailing_bits(struct rbsp *rbsp);
0060 
0061 #endif /* __NAL_RBSP_H__ */