// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2019-2020 Pengutronix, Michael Tretter <kernel@pengutronix.de> * * 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.
*/
rbsp_uev(rbsp, &pps->pps_pic_parameter_set_id);
rbsp_uev(rbsp, &pps->pps_seq_parameter_set_id);
rbsp_bit(rbsp, &pps->dependent_slice_segments_enabled_flag);
rbsp_bit(rbsp, &pps->output_flag_present_flag);
rbsp_bits(rbsp, 3, &pps->num_extra_slice_header_bits);
rbsp_bit(rbsp, &pps->sign_data_hiding_enabled_flag);
rbsp_bit(rbsp, &pps->cabac_init_present_flag);
rbsp_uev(rbsp, &pps->num_ref_idx_l0_default_active_minus1);
rbsp_uev(rbsp, &pps->num_ref_idx_l1_default_active_minus1);
rbsp_sev(rbsp, &pps->init_qp_minus26);
rbsp_bit(rbsp, &pps->constrained_intra_pred_flag);
rbsp_bit(rbsp, &pps->transform_skip_enabled_flag);
rbsp_bit(rbsp, &pps->cu_qp_delta_enabled_flag); if (pps->cu_qp_delta_enabled_flag)
rbsp_uev(rbsp, &pps->diff_cu_qp_delta_depth);
rbsp_sev(rbsp, &pps->pps_cb_qp_offset);
rbsp_sev(rbsp, &pps->pps_cr_qp_offset);
rbsp_bit(rbsp, &pps->pps_slice_chroma_qp_offsets_present_flag);
rbsp_bit(rbsp, &pps->weighted_pred_flag);
rbsp_bit(rbsp, &pps->weighted_bipred_flag);
rbsp_bit(rbsp, &pps->transquant_bypass_enabled_flag);
rbsp_bit(rbsp, &pps->tiles_enabled_flag);
rbsp_bit(rbsp, &pps->entropy_coding_sync_enabled_flag); if (pps->tiles_enabled_flag) {
rbsp_uev(rbsp, &pps->num_tile_columns_minus1);
rbsp_uev(rbsp, &pps->num_tile_rows_minus1);
rbsp_bit(rbsp, &pps->uniform_spacing_flag); if (!pps->uniform_spacing_flag) { for (i = 0; i < pps->num_tile_columns_minus1; i++)
rbsp_uev(rbsp, &pps->column_width_minus1[i]); for (i = 0; i < pps->num_tile_rows_minus1; i++)
rbsp_uev(rbsp, &pps->row_height_minus1[i]);
}
rbsp_bit(rbsp, &pps->loop_filter_across_tiles_enabled_flag);
}
rbsp_bit(rbsp, &pps->pps_loop_filter_across_slices_enabled_flag);
rbsp_bit(rbsp, &pps->deblocking_filter_control_present_flag); if (pps->deblocking_filter_control_present_flag) {
rbsp_bit(rbsp, &pps->deblocking_filter_override_enabled_flag);
rbsp_bit(rbsp, &pps->pps_deblocking_filter_disabled_flag); if (!pps->pps_deblocking_filter_disabled_flag) {
rbsp_sev(rbsp, &pps->pps_beta_offset_div2);
rbsp_sev(rbsp, &pps->pps_tc_offset_div2);
}
}
rbsp_bit(rbsp, &pps->pps_scaling_list_data_present_flag); if (pps->pps_scaling_list_data_present_flag)
rbsp_unsupported(rbsp);
rbsp_bit(rbsp, &pps->lists_modification_present_flag);
rbsp_uev(rbsp, &pps->log2_parallel_merge_level_minus2);
rbsp_bit(rbsp, &pps->slice_segment_header_extension_present_flag);
rbsp_bit(rbsp, &pps->pps_extension_present_flag); if (pps->pps_extension_present_flag) {
rbsp_bit(rbsp, &pps->pps_range_extension_flag);
rbsp_bit(rbsp, &pps->pps_multilayer_extension_flag);
rbsp_bit(rbsp, &pps->pps_3d_extension_flag);
rbsp_bit(rbsp, &pps->pps_scc_extension_flag);
rbsp_bits(rbsp, 4, &pps->pps_extension_4bits);
} if (pps->pps_range_extension_flag)
rbsp_unsupported(rbsp); if (pps->pps_multilayer_extension_flag)
rbsp_unsupported(rbsp); if (pps->pps_3d_extension_flag)
rbsp_unsupported(rbsp); if (pps->pps_scc_extension_flag)
rbsp_unsupported(rbsp); if (pps->pps_extension_4bits)
rbsp_unsupported(rbsp);
}
/** * 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(conststruct device *dev, void *dest, size_t n, struct nal_hevc_vps *vps)
{ struct rbsp rbsp; unsignedint forbidden_zero_bit = 0; unsignedint nal_unit_type = VPS_NUT; unsignedint nuh_layer_id = 0; unsignedint nuh_temporal_id_plus1 = 1;
/** * 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(conststruct device *dev, struct nal_hevc_vps *vps, void *src, size_t n)
{ struct rbsp rbsp; unsignedint forbidden_zero_bit; unsignedint nal_unit_type; unsignedint nuh_layer_id; unsignedint nuh_temporal_id_plus1;
/** * 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(conststruct device *dev, void *dest, size_t n, struct nal_hevc_sps *sps)
{ struct rbsp rbsp; unsignedint forbidden_zero_bit = 0; unsignedint nal_unit_type = SPS_NUT; unsignedint nuh_layer_id = 0; unsignedint nuh_temporal_id_plus1 = 1;
/** * 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(conststruct device *dev, struct nal_hevc_sps *sps, void *src, size_t n)
{ struct rbsp rbsp; unsignedint forbidden_zero_bit; unsignedint nal_unit_type; unsignedint nuh_layer_id; unsignedint nuh_temporal_id_plus1;
/** * 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(conststruct device *dev, void *dest, size_t n, struct nal_hevc_pps *pps)
{ struct rbsp rbsp; unsignedint forbidden_zero_bit = 0; unsignedint nal_unit_type = PPS_NUT; unsignedint nuh_layer_id = 0; unsignedint nuh_temporal_id_plus1 = 1;
/** * 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(conststruct device *dev, struct nal_hevc_pps *pps, void *src, size_t n)
{ struct rbsp rbsp; unsignedint forbidden_zero_bit; unsignedint nal_unit_type; unsignedint nuh_layer_id; unsignedint nuh_temporal_id_plus1;
/** * 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(conststruct device *dev, void *dest, size_t n)
{ struct rbsp rbsp; unsignedint forbidden_zero_bit = 0; unsignedint nal_unit_type = FD_NUT; unsignedint nuh_layer_id = 0; unsignedint nuh_temporal_id_plus1 = 1;
/** * 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(conststruct device *dev, void *src, size_t n)
{ struct rbsp rbsp; unsignedint forbidden_zero_bit; unsignedint nal_unit_type; unsignedint nuh_layer_id; unsignedint nuh_temporal_id_plus1;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.