Go to the documentation of this file.
32 #define MAX_SPATIAL_SEGMENTATION 4096 // max. value of u(12) field
44 #define FLAG_ARRAY_COMPLETENESS (1 << 0)
45 #define FLAG_IS_NALFF (1 << 1)
46 #define FLAG_IS_LHVC (1 << 2)
152 unsigned int max_sub_layers_minus1)
167 for (
i = 0;
i < max_sub_layers_minus1;
i++) {
168 sub_layer_profile_present_flag[
i] =
get_bits1(gb);
169 sub_layer_level_present_flag[
i] =
get_bits1(gb);
172 if (max_sub_layers_minus1 > 0)
173 for (
i = max_sub_layers_minus1;
i < 8;
i++)
176 for (
i = 0;
i < max_sub_layers_minus1;
i++) {
177 if (sub_layer_profile_present_flag[
i]) {
194 if (sub_layer_level_present_flag[
i])
200 unsigned int cpb_cnt_minus1,
201 uint8_t sub_pic_hrd_params_present_flag)
205 for (
i = 0;
i <= cpb_cnt_minus1;
i++) {
209 if (sub_pic_hrd_params_present_flag) {
219 unsigned int max_sub_layers_minus1)
222 uint8_t sub_pic_hrd_params_present_flag = 0;
223 uint8_t nal_hrd_parameters_present_flag = 0;
224 uint8_t vcl_hrd_parameters_present_flag = 0;
226 if (cprms_present_flag) {
227 nal_hrd_parameters_present_flag =
get_bits1(gb);
228 vcl_hrd_parameters_present_flag =
get_bits1(gb);
230 if (nal_hrd_parameters_present_flag ||
231 vcl_hrd_parameters_present_flag) {
232 sub_pic_hrd_params_present_flag =
get_bits1(gb);
234 if (sub_pic_hrd_params_present_flag)
249 if (sub_pic_hrd_params_present_flag)
261 for (
i = 0;
i <= max_sub_layers_minus1;
i++) {
262 unsigned int cpb_cnt_minus1 = 0;
263 uint8_t low_delay_hrd_flag = 0;
264 uint8_t fixed_pic_rate_within_cvs_flag = 0;
265 uint8_t fixed_pic_rate_general_flag =
get_bits1(gb);
267 if (!fixed_pic_rate_general_flag)
268 fixed_pic_rate_within_cvs_flag =
get_bits1(gb);
270 if (fixed_pic_rate_within_cvs_flag)
275 if (!low_delay_hrd_flag) {
277 if (cpb_cnt_minus1 > 31)
281 if (nal_hrd_parameters_present_flag)
283 sub_pic_hrd_params_present_flag);
285 if (vcl_hrd_parameters_present_flag)
287 sub_pic_hrd_params_present_flag);
304 unsigned int max_sub_layers_minus1)
306 unsigned int min_spatial_segmentation_idc;
371 min_spatial_segmentation_idc);
424 int i, j, k, num_coeffs;
426 for (
i = 0;
i < 4;
i++)
427 for (j = 0; j < (
i == 3 ? 2 : 6); j++)
431 num_coeffs =
FFMIN(64, 1 << (4 + (
i << 1)));
436 for (k = 0; k < num_coeffs; k++)
442 unsigned int num_rps,
449 if (rps_idx >= num_rps)
455 num_delta_pocs[rps_idx] = 0;
476 for (
i = 0;
i <= num_delta_pocs[rps_idx - 1];
i++) {
477 uint8_t use_delta_flag = 0;
478 uint8_t used_by_curr_pic_flag =
get_bits1(gb);
479 if (!used_by_curr_pic_flag)
482 if (used_by_curr_pic_flag || use_delta_flag)
483 num_delta_pocs[rps_idx]++;
489 if ((num_positive_pics + (uint64_t)num_negative_pics) * 2 >
get_bits_left(gb))
492 num_delta_pocs[rps_idx] = num_negative_pics + num_positive_pics;
494 for (
i = 0;
i < num_negative_pics;
i++) {
499 for (
i = 0;
i < num_positive_pics;
i++) {
511 unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;
513 unsigned int sps_ext_or_max_sub_layers_minus1, multi_layer_ext_sps_flag;
515 unsigned int sps_video_parameter_set_id =
get_bits(gb, 4);
518 sps_ext_or_max_sub_layers_minus1 = 0;
519 sps_max_sub_layers_minus1 =
get_bits(gb, 3);
521 sps_ext_or_max_sub_layers_minus1 =
get_bits(gb, 3);
522 if (sps_ext_or_max_sub_layers_minus1 == 7) {
526 for (
i = 0;
i <
array->numNalus;
i++)
527 if (sps_video_parameter_set_id ==
array->nal[
i].parameter_set_id) {
534 sps_max_sub_layers_minus1 =
vps->vps_max_sub_layers_minus1;
536 sps_max_sub_layers_minus1 = sps_ext_or_max_sub_layers_minus1;
539 sps_ext_or_max_sub_layers_minus1 == 7;
550 sps_max_sub_layers_minus1 + 1);
552 if (!multi_layer_ext_sps_flag) {
559 if (multi_layer_ext_sps_flag) {
583 if (!multi_layer_ext_sps_flag) {
585 i =
get_bits1(gb) ? 0 : sps_max_sub_layers_minus1;
586 for (;
i <= sps_max_sub_layers_minus1;
i++)
598 int sps_infer_scaling_list_flag = 0;
599 if (multi_layer_ext_sps_flag)
600 sps_infer_scaling_list_flag =
get_bits1(gb);
601 if (sps_infer_scaling_list_flag)
622 for (
i = 0;
i < num_short_term_ref_pic_sets;
i++) {
623 int ret =
parse_rps(gb,
i, num_short_term_ref_pic_sets, num_delta_pocs);
630 if (num_long_term_ref_pics_sps > 31
U)
632 for (
i = 0;
i < num_long_term_ref_pics_sps;
i++) {
633 int len =
FFMIN(log2_max_pic_order_cnt_lsb_minus4 + 4, 16);
652 uint8_t tiles_enabled_flag, entropy_coding_sync_enabled_flag;
691 entropy_coding_sync_enabled_flag =
get_bits1(gb);
693 if (entropy_coding_sync_enabled_flag && tiles_enabled_flag)
695 else if (entropy_coding_sync_enabled_flag)
697 else if (tiles_enabled_flag)
707 uint8_t *nuh_layer_id)
725 uint16_t numNalus =
array->numNalus;
731 nal = &
array->nal[numNalus];
741 int flags,
unsigned array_idx)
750 uint8_t nal_type, nuh_layer_id;
765 if (!is_lhvc && nuh_layer_id > 0)
776 if (
array->numNalus == 1) {
778 array->NAL_unit_type = nal_type;
788 array->array_completeness = ps_array_completeness;
886 if (
array->numNalus == 0)
889 for (
unsigned j = 0; j <
array->numNalus; j++)
890 numNalus[
i] += !is_lhvc || (
array->nal[j].nuh_layer_id != 0);
891 numOfArrays += (numNalus[
i] > 0);
938 if (numNalus[
i] == 0)
942 j,
array->array_completeness);
944 j,
array->NAL_unit_type);
947 for (
unsigned k = 0; k <
array->numNalus; k++) {
948 if (is_lhvc &&
array->nal[k].nuh_layer_id == 0)
952 "nalUnitLength[%u][%u]: %"PRIu16
"\n",
953 j, k,
array->nal[k].nalUnitLength);
1054 array->NAL_unit_type & 0x3f);
1059 for (
unsigned j = 0; j <
array->numNalus; j++) {
1077 int size,
int filter_ps,
int *ps_count)
1079 int num_ps = 0,
ret = 0;
1080 uint8_t *buf, *end, *start =
NULL;
1095 while (end - buf > 4) {
1097 uint8_t
type = (buf[4] >> 1) & 0x3f;
1125 int *
size,
int filter_ps,
int *ps_count)
1150 static const uint8_t array_idx_to_type[] =
1154 if (
type == array_idx_to_type[
i]) {
1169 uint8_t *buf, *end, *start =
NULL;
1175 }
else if (*
data == 1) {
1215 for (
int i = 0;
i < num_arrays;
i++) {
1216 int type, num_nalus;
1221 for (
int j = 0; j < num_nalus; j++) {
1252 while (end - buf > 4) {
1254 uint8_t
type = (buf[4] >> 1) & 0x3f;
1274 int size,
int ps_array_completeness)
1281 int size,
int ps_array_completeness)
static int hvcc_parse_vps(GetBitContext *gb, HVCCNALUnit *nal, HEVCDecoderConfigurationRecord *hvcc)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int get_se_golomb_long(GetBitContext *gb)
static int hvcc_parse_nal_unit(const uint8_t *buf, uint32_t len, int type, HEVCDecoderConfigurationRecord *hvcc, int flags)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_count(const GetBitContext *s)
int ff_isom_write_lhvc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness)
Writes L-HEVC extradata (parameter sets with nuh_layer_id > 0, as a LHEVCDecoderConfigurationRecord) ...
static void hvcc_close(HEVCDecoderConfigurationRecord *hvcc)
uint8_t general_profile_idc
static void hvcc_init(HEVCDecoderConfigurationRecord *hvcc)
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void skip_scaling_list_data(GetBitContext *gb)
uint8_t numTemporalLayers
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
static int parse_rps(GetBitContext *gb, unsigned int rps_idx, unsigned int num_rps, unsigned int num_delta_pocs[HEVC_MAX_SHORT_TERM_REF_PIC_SETS])
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
static int hvcc_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size, HEVCDecoderConfigurationRecord *hvcc, int flags, unsigned array_idx)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define FF_ARRAY_ELEMS(a)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc, int flags)
#define FLAG_ARRAY_COMPLETENESS
const H265RawProfileTierLevel * ptl
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
uint64_t general_constraint_indicator_flags
static void hvcc_parse_vui(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc, unsigned int max_sub_layers_minus1)
int ff_nal_parse_units(AVIOContext *pb, const uint8_t *buf_in, int size)
uint32_t general_profile_compatibility_flags
@ HEVC_MAX_SHORT_TERM_REF_PIC_SETS
static int skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag, unsigned int max_sub_layers_minus1)
uint8_t * ff_nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len, uint32_t *dst_len, int header_len)
int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, int *size, int filter_ps, int *ps_count)
Writes Annex B formatted HEVC NAL units to a data buffer.
static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type, uint8_t *nuh_layer_id)
static unsigned int get_bits1(GetBitContext *s)
static int hvcc_parse_pps(GetBitContext *gb, HVCCNALUnit *nal, HEVCDecoderConfigurationRecord *hvcc)
HVCCNALUnitArray arrays[NB_ARRAYS]
void avio_w8(AVIOContext *s, int b)
uint8_t lengthSizeMinusOne
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
static void skip_timing_info(GetBitContext *gb)
uint8_t bitDepthLumaMinus8
int ff_nal_parse_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_wb32(AVIOContext *s, unsigned int val)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate an array through a pointer to a pointer.
uint8_t constantFrameRate
static void skip_bits1(GetBitContext *s)
uint16_t min_spatial_segmentation_idc
uint8_t bitDepthChromaMinus8
static uint64_t get_bits64(GetBitContext *s, int n)
Read 0-64 bits.
int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness)
Writes HEVC extradata (parameter sets and declarative SEI NAL units with nuh_layer_id == 0,...
#define i(width, name, range_min, range_max)
uint32_t profile_compatibility_flags
static void hvcc_update_ptl(HEVCDecoderConfigurationRecord *hvcc, HVCCProfileTierLevel *ptl)
static int hvcc_array_add_nal_unit(const uint8_t *nal_buf, uint32_t nal_size, HVCCNALUnitArray *array)
uint8_t general_tier_flag
uint8_t general_level_idc
uint8_t configurationVersion
static int array[MAX_W *MAX_W]
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
static int write_configuration_record(AVIOContext *pb, const uint8_t *data, int size, int flags)
static void skip_sub_layer_hrd_parameters(GetBitContext *gb, unsigned int cpb_cnt_minus1, uint8_t sub_pic_hrd_params_present_flag)
uint8_t array_completeness
static int hvcc_parse_sps(GetBitContext *gb, HVCCNALUnit *nal, HEVCDecoderConfigurationRecord *hvcc)
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
uint64_t constraint_indicator_flags
void avio_wb16(AVIOContext *s, unsigned int val)
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
#define MAX_SPATIAL_SEGMENTATION
static void skip_sub_layer_ordering_info(GetBitContext *gb)
int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in, int size, int filter_ps, int *ps_count)
Writes Annex B formatted HEVC NAL units to the provided AVIOContext.
uint8_t vps_max_sub_layers_minus1
uint8_t general_profile_space
static void hvcc_parse_ptl(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc, unsigned int max_sub_layers_minus1)