25 fixed(1, alignment_bit_equal_to_zero, 0);
34 fixed(1, rbsp_stop_one_bit, 1);
36 fixed(1, rbsp_alignment_zero_bit, 0);
43 uint32_t valid_type_mask)
47 fixed(1, forbidden_zero_bit, 0);
48 fixed(1, forbidden_one_bit, 1);
51 if (!(1 <<
current->nal_unit_type & valid_type_mask)) {
72 flag(processed_planes_type_flag);
73 ub(6, resolution_type);
74 ub(1, transform_type);
75 ub(2, chroma_sampling_type);
76 ub(2, base_depth_type);
77 ub(2, enhancement_depth_type);
78 flag(temporal_step_width_modifier_signalled_flag);
79 flag(predicted_residual_mode_flag);
80 flag(temporal_tile_intra_signalling_enabled_flag);
81 flag(temporal_enabled_flag);
83 flag(level1_filtering_signalled_flag);
84 ub(2, scaling_mode_level1);
85 ub(2, scaling_mode_level2);
86 ub(2, tile_dimensions_type);
87 ub(2, user_data_enabled);
88 flag(level1_depth_flag);
89 flag(chroma_step_width_flag);
91 if (
current->processed_planes_type_flag) {
93 ub(4, reserved_zeros_4bit);
95 infer(planes_type, 0);
97 if (
current->temporal_step_width_modifier_signalled_flag) {
98 ub(8, temporal_step_width_modifier);
101 if (
current->upsample_type == 4) {
102 ub(16, upsampler_coeff1);
103 ub(16, upsampler_coeff2);
104 ub(16, upsampler_coeff3);
105 ub(16, upsampler_coeff4);
108 if (
current->level1_filtering_signalled_flag) {
109 ub(4, level1_filtering_first_coefficient);
110 ub(4, level1_filtering_second_coefficient);
113 if (
current->tile_dimensions_type > 0) {
114 if (
current->tile_dimensions_type == 3) {
115 ub(16, custom_tile_width);
116 ub(16, custom_tile_height);
118 ub(5, reserved_zeros_5bit);
119 flag(compression_type_entropy_enabled_per_tile_flag);
120 ub(2, compression_type_size_per_tile);
123 if (
current->resolution_type == 63) {
124 ub(16, custom_resolution_width);
125 ub(16, custom_resolution_height);
127 if (
current->chroma_step_width_flag) {
128 ub(8, chroma_step_width_multiplier);
130 infer(chroma_step_width_multiplier, 64);
146 HEADER(
"Sequence Config");
151 flag(conformance_window_flag);
152 ub(5, reserved_zeros_5bit);
157 ub(1, reserved_zeros_1bit);
159 if (
current->conformance_window_flag == 1) {
160 mb(conf_win_left_offset);
161 mb(conf_win_right_offset);
162 mb(conf_win_top_offset);
163 mb(conf_win_bottom_offset);
184 flag(no_enhancement_bit_flag);
185 if (
current->no_enhancement_bit_flag == 0) {
186 ub(3, quant_matrix_mode);
187 flag(dequant_offset_signalled_flag);
188 flag(picture_type_bit_flag);
189 flag(temporal_refresh_bit_flag);
190 flag(step_width_sublayer1_enabled_flag);
191 ub(15, step_width_sublayer2);
192 flag(dithering_control_flag);
195 !
current->temporal_refresh_bit_flag);
197 infer(quant_matrix_mode, 0);
198 infer(dequant_offset_signalled_flag, 0);
199 ub(4, reserved_zeros_4bit);
200 flag(picture_type_bit_flag);
201 flag(temporal_refresh_bit_flag);
202 infer(step_width_sublayer1_enabled_flag, 0);
207 flag(temporal_signalling_present_flag);
210 if (
current->picture_type_bit_flag == 1) {
211 flag(field_type_bit_flag);
212 ub(7, reserved_zeros_7bit);
215 if (
current->step_width_sublayer1_enabled_flag == 1) {
216 ub(15, step_width_sublayer1);
217 flag(level1_filtering_enabled_flag);
219 infer(level1_filtering_enabled_flag, 0);
222 if (
current->quant_matrix_mode == 2 ||
223 current->quant_matrix_mode == 3 ||
224 current->quant_matrix_mode == 5) {
225 for (
int layer_idx = 0; layer_idx < nlayers; layer_idx++)
226 ubs(8, qm_coefficient_0[layer_idx], 1, layer_idx);
229 if (
current->quant_matrix_mode == 4 ||
current->quant_matrix_mode == 5) {
230 for (
int layer_idx = 0; layer_idx < nlayers; layer_idx++)
231 ubs(8, qm_coefficient_1[layer_idx], 1, layer_idx);
234 if (
current->dequant_offset_signalled_flag) {
235 flag(dequant_offset_mode_flag);
236 ub(7, dequant_offset);
239 if (
current->dithering_control_flag == 1) {
240 ub(2, dithering_type);
241 ub(1, reserverd_zero);
242 if (
current->dithering_type != 0) {
243 ub(5, dithering_strength);
245 ub(5, reserved_zeros_5bit);
261 int nplanes, nlayers, err;
268 if (!priv->
gc || !priv->
pc)
273 for (
int plane_idx = 0; plane_idx < nplanes; plane_idx++) {
276 for (
int layer_idx = 0; layer_idx < nlayers; layer_idx++) {
277 ubs(1, surfaces_entropy_enabled_flag[plane_idx][
level_idx][layer_idx], 3, plane_idx,
level_idx, layer_idx);
283 ubs(1, temporal_surfaces_entropy_enabled_flag[plane_idx], 1, plane_idx);
284 ubs(1, temporal_surfaces_rle_only_flag[plane_idx], 1, plane_idx);
323 if (
current->payload_type == 1)
325 else if (
current->payload_type == 2)
327 else if (
current->payload_type == 4)
329 else if (
current->payload_type == 5)
335 current->payload_size = payload_size;
344 xu(8, reserved_sei_message_payload_byte[
i],
data[
i], 0, 255, 1,
i);
349 message->payload_type = sei_type;
350 message->payload_size = payload_size;
364 flag(aspect_ratio_info_present_flag);
365 if (
current->aspect_ratio_info_present_flag) {
366 ub(8, aspect_ratio_idc);
368 if (
current->aspect_ratio_idc == 255) {
373 infer(aspect_ratio_idc, 0);
376 flag(overscan_info_present_flag);
377 if (
current->overscan_info_present_flag)
378 flag(overscan_appropriate_flag);
380 infer(overscan_appropriate_flag, 0);
382 flag(video_signal_type_present_flag);
383 if (
current->video_signal_type_present_flag) {
384 u(3, video_format, 0, 5);
385 flag(video_full_range_flag);
386 flag(colour_description_present_flag);
387 if (
current->colour_description_present_flag) {
388 ub(8, colour_primaries);
390 ub(8, matrix_coefficients);
392 infer(colour_primaries, 2);
394 infer(matrix_coefficients, 2);
397 infer(video_format, 5);
398 infer(video_full_range_flag, 0);
399 infer(colour_description_present_flag, 0);
400 infer(colour_primaries, 2);
402 infer(matrix_coefficients, 2);
404 flag(chroma_loc_info_present_flag);
405 if (
current->chroma_loc_info_present_flag) {
406 ue(chroma_sample_loc_type_top_field, 0, 5);
407 ue(chroma_sample_loc_type_bottom_field, 0, 5);
409 infer(chroma_sample_loc_type_top_field, 0);
410 infer(chroma_sample_loc_type_bottom_field, 0);
423 HEADER(
"Additional Info");
425 ub(8, additional_info_type);
444 xu(8, additional_info_byte[
i],
data[
i], 0, 255, 1,
i);
462 fixed(8, filler_byte, 0xaa);
469 for (
int i = 0;
i <
current->filler_size;
i++)
470 fixed(8, filler_byte, 0xaa);
486 .payload_type =
current->payload_type,
487 .payload_size =
current->payload_size,
488 .extension_present =
current->extension_bit_length > 0,
490 int start_position, current_position, bits_written;
501 bits_written = current_position - start_position;
504 bits_written < 8 * current->payload_size) {
524 current->extension_bit_length =
528 if (
current->extension_bit_length > 0) {
530 (
current->extension_bit_length + 7) / 8);
535 xu(length, reserved_payload_extension_data,
542 fixed(1, payload_bit_equal_to_one, 1);
544 fixed(1, payload_bit_equal_to_zero, 0);
562 xu(8, payload_byte[
i],
data[
i], 0, 255, 1,
i);
577 int payload_size_type;
579 uint32_t payload_size;
586 payload_size_type =
tmp;
590 if (payload_size_type == 6) {
595 payload_size = payload_size_type;
596 if (payload_size_type == 7)
597 xmb(custom_byte_size, payload_size);
602 "Invalid process block: payload_size too large "
603 "(%"PRIu32
" bytes).\n", payload_size);
613 block->payload_type = payload_type;
614 block->payload_size = payload_size;
624 for (k = 0; k <
current->nb_blocks; k++) {
633 trace =
ctx->trace_enable;
634 ctx->trace_enable = 0;
637 for (
i = 0;
i < 2;
i++) {
643 xu(3, payload_size_type,
tmp, 0, 7, 0);
647 xmb(custom_byte_size,
block->payload_size);
650 ctx->trace_enable = trace;
674 current->nal_unit_header.nal_unit_type));
static int FUNC trailing_bits(CodedBitstreamContext *ctx, RWContext *rw, int nb_bits)
int ff_cbs_h2645_write_slice_data(CodedBitstreamContext *ctx, PutBitContext *pbc, const uint8_t *data, size_t data_size, int data_bit_start)
int ff_cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
#define allocate(name, size)
#define ue(name, range_min, range_max)
#define infer(name, value)
#define byte_alignment(rw)
#define i(width, name, range_min, range_max)
#define xu(width, name, var, range_min, range_max, subs,...)
static int FUNC vui_parameters(CodedBitstreamContext *ctx, RWContext *rw, H264RawVUI *current, H264RawSPS *sps)
static int FUNC rbsp_trailing_bits(CodedBitstreamContext *ctx, RWContext *rw)
static int FUNC nal_unit_header(CodedBitstreamContext *ctx, RWContext *rw, H264RawNALUnitHeader *current, uint32_t valid_type_mask)
#define MAX_UINT_BITS(length)
int ff_cbs_lcevc_alloc_process_block_payload(LCEVCRawProcessBlock *block, const LCEVCProcessBlockTypeDescriptor *desc)
Allocate a new payload for the given Process Block.
#define LCEVC_BLOCK_FUNC(name, args)
const LCEVCProcessBlockTypeDescriptor * ff_cbs_lcevc_process_block_find_type(CodedBitstreamContext *ctx, int payload_type)
Find the type descriptor for the given payload type.
int ff_cbs_lcevc_list_add(LCEVCRawProcessBlockList *list, int position)
Allocate a new empty Process Block in a block list at a given position.
static int FUNC process_block(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawProcessBlock *current, int nal_unit_type)
static int FUNC process_block_list(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawProcessBlockList *current, int nal_unit_type)
static int FUNC sei_payload(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawSEI *current, int payload_size)
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
static struct @346255127015250356166251341105367306144006377143 state
static struct @111144215057303131116103221376075045141373005341 current
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int(* filler)(InterplayACMContext *s, unsigned ind, unsigned col)
#define fixed(width, name, value)
#define u(width, name, range_min, range_max)
#define ubs(width, name, subs,...)
@ LCEVC_ADDITIONAL_INFO_TYPE_SEI
@ LCEVC_ADDITIONAL_INFO_TYPE_VUI
static const struct TransferCharacteristics transfer_characteristics[]
static int put_bits_count(PutBitContext *s)
void av_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
@ SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
@ SEI_TYPE_USER_DATA_UNREGISTERED
@ SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO
@ SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME
Context structure for coded bitstream operations.
LCEVCRawGlobalConfig * gc
RefStruct references.
LCEVCRawSequenceConfig * sc
RefStruct references.
LCEVCRawPictureConfig * pc
RefStruct references.
int dithering_control_flag
uint8_t temporal_enabled_flag
uint8_t temporal_signalling_present_flag
uint8_t no_enhancement_bit_flag
static AVFormatContext * ctx