30 #define MAX_SPATIAL_SEGMENTATION 4096 // max. value of u(12) field 127 unsigned int max_sub_layers_minus1)
142 for (i = 0; i < max_sub_layers_minus1; i++) {
143 sub_layer_profile_present_flag[i] =
get_bits1(gb);
144 sub_layer_level_present_flag[i] =
get_bits1(gb);
147 if (max_sub_layers_minus1 > 0)
148 for (i = max_sub_layers_minus1; i < 8; i++)
151 for (i = 0; i < max_sub_layers_minus1; i++) {
152 if (sub_layer_profile_present_flag[i]) {
169 if (sub_layer_level_present_flag[i])
175 unsigned int cpb_cnt_minus1,
176 uint8_t sub_pic_hrd_params_present_flag)
180 for (i = 0; i <= cpb_cnt_minus1; i++) {
184 if (sub_pic_hrd_params_present_flag) {
194 unsigned int max_sub_layers_minus1)
197 uint8_t sub_pic_hrd_params_present_flag = 0;
198 uint8_t nal_hrd_parameters_present_flag = 0;
199 uint8_t vcl_hrd_parameters_present_flag = 0;
201 if (cprms_present_flag) {
202 nal_hrd_parameters_present_flag =
get_bits1(gb);
203 vcl_hrd_parameters_present_flag =
get_bits1(gb);
205 if (nal_hrd_parameters_present_flag ||
206 vcl_hrd_parameters_present_flag) {
207 sub_pic_hrd_params_present_flag =
get_bits1(gb);
209 if (sub_pic_hrd_params_present_flag)
224 if (sub_pic_hrd_params_present_flag)
236 for (i = 0; i <= max_sub_layers_minus1; i++) {
237 unsigned int cpb_cnt_minus1 = 0;
238 uint8_t low_delay_hrd_flag = 0;
239 uint8_t fixed_pic_rate_within_cvs_flag = 0;
242 if (!fixed_pic_rate_general_flag)
243 fixed_pic_rate_within_cvs_flag =
get_bits1(gb);
245 if (fixed_pic_rate_within_cvs_flag)
250 if (!low_delay_hrd_flag) {
252 if (cpb_cnt_minus1 > 31)
256 if (nal_hrd_parameters_present_flag)
258 sub_pic_hrd_params_present_flag);
260 if (vcl_hrd_parameters_present_flag)
262 sub_pic_hrd_params_present_flag);
279 unsigned int max_sub_layers_minus1)
281 unsigned int min_spatial_segmentation_idc;
346 min_spatial_segmentation_idc);
365 unsigned int vps_max_sub_layers_minus1;
374 vps_max_sub_layers_minus1 =
get_bits(gb, 3);
385 vps_max_sub_layers_minus1 + 1);
401 int i, j, k, num_coeffs;
403 for (i = 0; i < 4; i++)
404 for (j = 0; j < (i == 3 ? 2 : 6); j++)
408 num_coeffs =
FFMIN(64, 1 << (4 + (i << 1)));
413 for (k = 0; k < num_coeffs; k++)
419 unsigned int num_rps,
426 if (rps_idx >= num_rps)
432 num_delta_pocs[rps_idx] = 0;
453 for (i = 0; i <= num_delta_pocs[rps_idx - 1]; i++) {
456 if (!used_by_curr_pic_flag)
459 if (used_by_curr_pic_flag || use_delta_flag)
460 num_delta_pocs[rps_idx]++;
466 if ((num_positive_pics + (uint64_t)num_negative_pics) * 2 >
get_bits_left(gb))
469 num_delta_pocs[rps_idx] = num_negative_pics + num_positive_pics;
471 for (i = 0; i < num_negative_pics; i++) {
476 for (i = 0; i < num_positive_pics; i++) {
488 unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;
493 sps_max_sub_layers_minus1 =
get_bits (gb, 3);
504 sps_max_sub_layers_minus1 + 1);
532 i =
get_bits1(gb) ? 0 : sps_max_sub_layers_minus1;
533 for (; i <= sps_max_sub_layers_minus1; i++)
562 for (i = 0; i < num_short_term_ref_pic_sets; i++) {
563 int ret =
parse_rps(gb, i, num_short_term_ref_pic_sets, num_delta_pocs);
570 if (num_long_term_ref_pics_sps > 31
U)
572 for (i = 0; i < num_long_term_ref_pics_sps; i++) {
573 int len =
FFMIN(log2_max_pic_order_cnt_lsb_minus4 + 4, 16);
592 uint8_t tiles_enabled_flag, entropy_coding_sync_enabled_flag;
631 entropy_coding_sync_enabled_flag =
get_bits1(gb);
633 if (entropy_coding_sync_enabled_flag && tiles_enabled_flag)
635 else if (entropy_coding_sync_enabled_flag)
637 else if (tiles_enabled_flag)
658 while (i < 2 && i < src_len)
659 dst[len++] = src[i++];
661 while (i + 2 < src_len)
662 if (!src[i] && !src[i + 1] && src[i + 2] == 3) {
663 dst[len++] = src[i++];
664 dst[len++] = src[i++];
667 dst[len++] = src[i++];
670 dst[len++] = src[i++];
694 uint8_t nal_type,
int ps_array_completeness,
702 for (index = 0; index < hvcc->
numOfArrays; index++)
747 int ps_array_completeness,
780 ps_array_completeness, hvcc);
839 uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
912 "nalUnitLength[%"PRIu8
"][%"PRIu16
"]: %"PRIu16
"\n",
1033 int size,
int filter_ps,
int *ps_count)
1035 int num_ps = 0, ret = 0;
1051 while (end - buf > 4) {
1081 int *
size,
int filter_ps,
int *ps_count)
1097 int size,
int ps_array_completeness)
1109 }
else if (*data == 1) {
1126 while (end - buf > 4) {
static void skip_scaling_list_data(GetBitContext *gb)
static int hvcc_parse_vps(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
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 int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc)
uint8_t general_profile_idc
uint64_t general_constraint_indicator_flags
static uint8_t * nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len, uint32_t *dst_len)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
uint32_t general_profile_compatibility_flags
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.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
static av_cold int end(AVCodecContext *avctx)
uint8_t constantFrameRate
static void skip_sub_layer_hrd_parameters(GetBitContext *gb, unsigned int cpb_cnt_minus1, uint8_t sub_pic_hrd_params_present_flag)
bitstream reader API header.
static void skip_sub_layer_ordering_info(GetBitContext *gb)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
static int hvcc_parse_pps(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc)
uint32_t profile_compatibility_flags
static int get_bits_left(GetBitContext *gb)
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...
static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type)
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
uint8_t bitDepthChromaMinus8
uint8_t general_profile_space
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 ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
uint8_t lengthSizeMinusOne
static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, uint8_t nal_type, int ps_array_completeness, HEVCDecoderConfigurationRecord *hvcc)
uint8_t general_tier_flag
static void skip_timing_info(GetBitContext *gb)
uint8_t numTemporalLayers
static void hvcc_parse_vui(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc, unsigned int max_sub_layers_minus1)
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
#define MAX_SPATIAL_SEGMENTATION
static int get_se_golomb_long(GetBitContext *gb)
Libavcodec external API header.
static void hvcc_close(HEVCDecoderConfigurationRecord *hvcc)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
void avio_w8(AVIOContext *s, int b)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static void hvcc_parse_ptl(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc, unsigned int max_sub_layers_minus1)
uint8_t bitDepthLumaMinus8
uint8_t array_completeness
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
uint8_t general_level_idc
void avio_wb16(AVIOContext *s, unsigned int val)
uint8_t configurationVersion
static int hvcc_parse_sps(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc)
static int skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag, unsigned int max_sub_layers_minus1)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
void avio_wb32(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)
static int array[MAX_W *MAX_W]
static void hvcc_init(HEVCDecoderConfigurationRecord *hvcc)
uint64_t constraint_indicator_flags
uint16_t min_spatial_segmentation_idc
static void hvcc_update_ptl(HEVCDecoderConfigurationRecord *hvcc, HVCCProfileTierLevel *ptl)