linux/drivers/media/platform/allegro-dvt/nal-hevc.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2019-2020 Pengutronix, Michael Tretter <[email protected]>
 *
 * Convert NAL units between raw byte sequence payloads (RBSP) and C structs.
 *
 * The conversion is defined in "ITU-T Rec. H.265 (02/2018) high efficiency
 * video coding". Decoder drivers may use the parser to parse RBSP from
 * encoded streams and configure the hardware, if the hardware is not able to
 * parse RBSP itself. Encoder drivers may use the generator to generate the
 * RBSP for VPS/SPS/PPS nal units and add them to the encoded stream if the
 * hardware does not generate the units.
 */

#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/v4l2-controls.h>

#include <linux/device.h>
#include <linux/export.h>
#include <linux/log2.h>

#include "nal-hevc.h"
#include "nal-rbsp.h"

/*
 * See Rec. ITU-T H.265 (02/2018) Table 7-1 - NAL unit type codes and NAL unit
 * type classes
 */
enum nal_unit_type {};

static void nal_hevc_write_start_code_prefix(struct rbsp *rbsp)
{}

static void nal_hevc_read_start_code_prefix(struct rbsp *rbsp)
{}

static void nal_hevc_write_filler_data(struct rbsp *rbsp)
{}

static void nal_hevc_read_filler_data(struct rbsp *rbsp)
{}

static void nal_hevc_rbsp_profile_tier_level(struct rbsp *rbsp,
					     struct nal_hevc_profile_tier_level *ptl)
{}

static void nal_hevc_rbsp_vps(struct rbsp *rbsp, struct nal_hevc_vps *vps)
{}

static void nal_hevc_rbsp_sub_layer_hrd_parameters(struct rbsp *rbsp,
						   struct nal_hevc_sub_layer_hrd_parameters *hrd)
{}

static void nal_hevc_rbsp_hrd_parameters(struct rbsp *rbsp,
					 struct nal_hevc_hrd_parameters *hrd)
{}

static void nal_hevc_rbsp_vui_parameters(struct rbsp *rbsp,
					 struct nal_hevc_vui_parameters *vui)
{}

static void nal_hevc_rbsp_sps(struct rbsp *rbsp, struct nal_hevc_sps *sps)
{}

static void nal_hevc_rbsp_pps(struct rbsp *rbsp, struct nal_hevc_pps *pps)
{}

/**
 * nal_hevc_write_vps() - Write PPS NAL unit into RBSP format
 * @dev: device pointer
 * @dest: the buffer that is filled with RBSP data
 * @n: maximum size of @dest in bytes
 * @vps: &struct nal_hevc_vps to convert to RBSP
 *
 * Convert @vps to RBSP data and write it into @dest.
 *
 * The size of the VPS NAL unit is not known in advance and this function will
 * fail, if @dest does not hold sufficient space for the VPS NAL unit.
 *
 * Return: number of bytes written to @dest or negative error code
 */
ssize_t nal_hevc_write_vps(const struct device *dev,
			   void *dest, size_t n, struct nal_hevc_vps *vps)
{}
EXPORT_SYMBOL_GPL();

/**
 * nal_hevc_read_vps() - Read VPS NAL unit from RBSP format
 * @dev: device pointer
 * @vps: the &struct nal_hevc_vps to fill from the RBSP data
 * @src: the buffer that contains the RBSP data
 * @n: size of @src in bytes
 *
 * Read RBSP data from @src and use it to fill @vps.
 *
 * Return: number of bytes read from @src or negative error code
 */
ssize_t nal_hevc_read_vps(const struct device *dev,
			  struct nal_hevc_vps *vps, void *src, size_t n)
{}
EXPORT_SYMBOL_GPL();

/**
 * nal_hevc_write_sps() - Write SPS NAL unit into RBSP format
 * @dev: device pointer
 * @dest: the buffer that is filled with RBSP data
 * @n: maximum size of @dest in bytes
 * @sps: &struct nal_hevc_sps to convert to RBSP
 *
 * Convert @sps to RBSP data and write it into @dest.
 *
 * The size of the SPS NAL unit is not known in advance and this function will
 * fail, if @dest does not hold sufficient space for the SPS NAL unit.
 *
 * Return: number of bytes written to @dest or negative error code
 */
ssize_t nal_hevc_write_sps(const struct device *dev,
			   void *dest, size_t n, struct nal_hevc_sps *sps)
{}
EXPORT_SYMBOL_GPL();

/**
 * nal_hevc_read_sps() - Read SPS NAL unit from RBSP format
 * @dev: device pointer
 * @sps: the &struct nal_hevc_sps to fill from the RBSP data
 * @src: the buffer that contains the RBSP data
 * @n: size of @src in bytes
 *
 * Read RBSP data from @src and use it to fill @sps.
 *
 * Return: number of bytes read from @src or negative error code
 */
ssize_t nal_hevc_read_sps(const struct device *dev,
			  struct nal_hevc_sps *sps, void *src, size_t n)
{}
EXPORT_SYMBOL_GPL();

/**
 * nal_hevc_write_pps() - Write PPS NAL unit into RBSP format
 * @dev: device pointer
 * @dest: the buffer that is filled with RBSP data
 * @n: maximum size of @dest in bytes
 * @pps: &struct nal_hevc_pps to convert to RBSP
 *
 * Convert @pps to RBSP data and write it into @dest.
 *
 * The size of the PPS NAL unit is not known in advance and this function will
 * fail, if @dest does not hold sufficient space for the PPS NAL unit.
 *
 * Return: number of bytes written to @dest or negative error code
 */
ssize_t nal_hevc_write_pps(const struct device *dev,
			   void *dest, size_t n, struct nal_hevc_pps *pps)
{}
EXPORT_SYMBOL_GPL();

/**
 * nal_hevc_read_pps() - Read PPS NAL unit from RBSP format
 * @dev: device pointer
 * @pps: the &struct nal_hevc_pps to fill from the RBSP data
 * @src: the buffer that contains the RBSP data
 * @n: size of @src in bytes
 *
 * Read RBSP data from @src and use it to fill @pps.
 *
 * Return: number of bytes read from @src or negative error code
 */
ssize_t nal_hevc_read_pps(const struct device *dev,
			  struct nal_hevc_pps *pps, void *src, size_t n)
{}
EXPORT_SYMBOL_GPL();

/**
 * nal_hevc_write_filler() - Write filler data RBSP
 * @dev: device pointer
 * @dest: buffer to fill with filler data
 * @n: size of the buffer to fill with filler data
 *
 * Write a filler data RBSP to @dest with a size of @n bytes and return the
 * number of written filler data bytes.
 *
 * Use this function to generate dummy data in an RBSP data stream that can be
 * safely ignored by hevc decoders.
 *
 * The RBSP format of the filler data is specified in Rec. ITU-T H.265
 * (02/2018) 7.3.2.8 Filler data RBSP syntax.
 *
 * Return: number of filler data bytes (including marker) or negative error
 */
ssize_t nal_hevc_write_filler(const struct device *dev, void *dest, size_t n)
{}
EXPORT_SYMBOL_GPL();

/**
 * nal_hevc_read_filler() - Read filler data RBSP
 * @dev: device pointer
 * @src: buffer with RBSP data that is read
 * @n: maximum size of src that shall be read
 *
 * Read a filler data RBSP from @src up to a maximum size of @n bytes and
 * return the size of the filler data in bytes including the marker.
 *
 * This function is used to parse filler data and skip the respective bytes in
 * the RBSP data.
 *
 * The RBSP format of the filler data is specified in Rec. ITU-T H.265
 * (02/2018) 7.3.2.8 Filler data RBSP syntax.
 *
 * Return: number of filler data bytes (including marker) or negative error
 */
ssize_t nal_hevc_read_filler(const struct device *dev, void *src, size_t n)
{}
EXPORT_SYMBOL_GPL();