Go to the documentation of this file.
30 #define MAX_SPATIAL_SEGMENTATION 4096 // max. value of u(12) field
136 unsigned int max_sub_layers_minus1)
151 for (
i = 0;
i < max_sub_layers_minus1;
i++) {
152 sub_layer_profile_present_flag[
i] =
get_bits1(gb);
153 sub_layer_level_present_flag[
i] =
get_bits1(gb);
156 if (max_sub_layers_minus1 > 0)
157 for (
i = max_sub_layers_minus1;
i < 8;
i++)
160 for (
i = 0;
i < max_sub_layers_minus1;
i++) {
161 if (sub_layer_profile_present_flag[
i]) {
178 if (sub_layer_level_present_flag[
i])
184 unsigned int cpb_cnt_minus1,
185 uint8_t sub_pic_hrd_params_present_flag)
189 for (
i = 0;
i <= cpb_cnt_minus1;
i++) {
193 if (sub_pic_hrd_params_present_flag) {
203 unsigned int max_sub_layers_minus1)
206 uint8_t sub_pic_hrd_params_present_flag = 0;
207 uint8_t nal_hrd_parameters_present_flag = 0;
208 uint8_t vcl_hrd_parameters_present_flag = 0;
210 if (cprms_present_flag) {
211 nal_hrd_parameters_present_flag =
get_bits1(gb);
212 vcl_hrd_parameters_present_flag =
get_bits1(gb);
214 if (nal_hrd_parameters_present_flag ||
215 vcl_hrd_parameters_present_flag) {
216 sub_pic_hrd_params_present_flag =
get_bits1(gb);
218 if (sub_pic_hrd_params_present_flag)
233 if (sub_pic_hrd_params_present_flag)
245 for (
i = 0;
i <= max_sub_layers_minus1;
i++) {
246 unsigned int cpb_cnt_minus1 = 0;
247 uint8_t low_delay_hrd_flag = 0;
248 uint8_t fixed_pic_rate_within_cvs_flag = 0;
249 uint8_t fixed_pic_rate_general_flag =
get_bits1(gb);
251 if (!fixed_pic_rate_general_flag)
252 fixed_pic_rate_within_cvs_flag =
get_bits1(gb);
254 if (fixed_pic_rate_within_cvs_flag)
259 if (!low_delay_hrd_flag) {
261 if (cpb_cnt_minus1 > 31)
265 if (nal_hrd_parameters_present_flag)
267 sub_pic_hrd_params_present_flag);
269 if (vcl_hrd_parameters_present_flag)
271 sub_pic_hrd_params_present_flag);
288 unsigned int max_sub_layers_minus1)
290 unsigned int min_spatial_segmentation_idc;
355 min_spatial_segmentation_idc);
374 unsigned int vps_max_sub_layers_minus1;
383 vps_max_sub_layers_minus1 =
get_bits(gb, 3);
394 vps_max_sub_layers_minus1 + 1);
410 int i, j, k, num_coeffs;
412 for (
i = 0;
i < 4;
i++)
413 for (j = 0; j < (
i == 3 ? 2 : 6); j++)
417 num_coeffs =
FFMIN(64, 1 << (4 + (
i << 1)));
422 for (k = 0; k < num_coeffs; k++)
428 unsigned int num_rps,
435 if (rps_idx >= num_rps)
441 num_delta_pocs[rps_idx] = 0;
462 for (
i = 0;
i <= num_delta_pocs[rps_idx - 1];
i++) {
463 uint8_t use_delta_flag = 0;
464 uint8_t used_by_curr_pic_flag =
get_bits1(gb);
465 if (!used_by_curr_pic_flag)
468 if (used_by_curr_pic_flag || use_delta_flag)
469 num_delta_pocs[rps_idx]++;
475 if ((num_positive_pics + (uint64_t)num_negative_pics) * 2 >
get_bits_left(gb))
478 num_delta_pocs[rps_idx] = num_negative_pics + num_positive_pics;
480 for (
i = 0;
i < num_negative_pics;
i++) {
485 for (
i = 0;
i < num_positive_pics;
i++) {
497 unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;
502 sps_max_sub_layers_minus1 =
get_bits (gb, 3);
513 sps_max_sub_layers_minus1 + 1);
541 i =
get_bits1(gb) ? 0 : sps_max_sub_layers_minus1;
542 for (;
i <= sps_max_sub_layers_minus1;
i++)
571 for (
i = 0;
i < num_short_term_ref_pic_sets;
i++) {
572 int ret =
parse_rps(gb,
i, num_short_term_ref_pic_sets, num_delta_pocs);
579 if (num_long_term_ref_pics_sps > 31
U)
581 for (
i = 0;
i < num_long_term_ref_pics_sps;
i++) {
582 int len =
FFMIN(log2_max_pic_order_cnt_lsb_minus4 + 4, 16);
601 uint8_t tiles_enabled_flag, entropy_coding_sync_enabled_flag;
640 entropy_coding_sync_enabled_flag =
get_bits1(gb);
642 if (entropy_coding_sync_enabled_flag && tiles_enabled_flag)
644 else if (entropy_coding_sync_enabled_flag)
646 else if (tiles_enabled_flag)
669 uint8_t nal_type,
int ps_array_completeness,
673 uint16_t numNalus =
array->numNalus;
683 array->nalUnit [numNalus] = nal_buf;
684 array->nalUnitLength[numNalus] = nal_size;
685 array->NAL_unit_type = nal_type;
695 array->array_completeness = ps_array_completeness;
701 int ps_array_completeness,
729 ps_array_completeness,
730 &hvcc->
arrays[array_idx]);
781 uint16_t vps_count, sps_count, pps_count;
848 if (
array->numNalus == 0)
852 j,
array->array_completeness);
854 j,
array->NAL_unit_type);
857 for (
unsigned k = 0; k <
array->numNalus; k++)
859 "nalUnitLength[%u][%u]: %"PRIu16
"\n",
860 j, k,
array->nalUnitLength[k]);
947 if (!
array->numNalus)
955 array->NAL_unit_type & 0x3f);
960 for (
unsigned j = 0; j <
array->numNalus; j++) {
966 array->nalUnitLength[j]);
974 int size,
int filter_ps,
int *ps_count)
976 int num_ps = 0,
ret = 0;
977 uint8_t *buf, *end, *start =
NULL;
992 while (end - buf > 4) {
994 uint8_t
type = (buf[4] >> 1) & 0x3f;
1022 int *
size,
int filter_ps,
int *ps_count)
1043 int size,
int ps_array_completeness)
1046 uint8_t *buf, *end, *start;
1052 }
else if (*
data == 1) {
1070 while (end - buf > 4) {
1072 uint8_t
type = (buf[4] >> 1) & 0x3f;
1077 static const uint8_t array_idx_to_type[] =
1081 if (
type == array_idx_to_type[
i]) {
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 void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type)
static int get_se_golomb_long(GetBitContext *gb)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
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
static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, uint8_t nal_type, int ps_array_completeness, HVCCNALUnitArray *array)
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.
#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.
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)
uint8_t * ff_nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len, uint32_t *dst_len, int header_len)
uint32_t general_profile_compatibility_flags
static int skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag, unsigned int max_sub_layers_minus1)
@ HEVC_MAX_SHORT_TERM_REF_PIC_SETS
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 unsigned int get_bits1(GetBitContext *s)
HVCCNALUnitArray arrays[NB_ARRAYS]
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
void avio_w8(AVIOContext *s, int b)
uint8_t lengthSizeMinusOne
static void skip_timing_info(GetBitContext *gb)
uint8_t bitDepthLumaMinus8
int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
static int hvcc_parse_pps(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc)
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, declarative SEI NAL units) to the provided AVIOContext.
#define i(width, name, range_min, range_max)
uint32_t profile_compatibility_flags
static void hvcc_update_ptl(HEVCDecoderConfigurationRecord *hvcc, HVCCProfileTierLevel *ptl)
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 void skip_sub_layer_hrd_parameters(GetBitContext *gb, unsigned int cpb_cnt_minus1, uint8_t sub_pic_hrd_params_present_flag)
static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc)
uint8_t array_completeness
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
static int hvcc_parse_sps(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc)
void avio_wb16(AVIOContext *s, unsigned int val)
static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, int ps_array_completeness, HEVCDecoderConfigurationRecord *hvcc, unsigned array_idx)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int hvcc_parse_vps(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc)
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 general_profile_space
static void hvcc_parse_ptl(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc, unsigned int max_sub_layers_minus1)