32 16, 16, 16, 16, 17, 18, 21, 24,
33 16, 16, 16, 16, 17, 19, 22, 25,
34 16, 16, 17, 18, 20, 22, 25, 29,
35 16, 16, 18, 21, 24, 27, 31, 36,
36 17, 17, 20, 24, 30, 35, 41, 47,
37 18, 19, 22, 27, 35, 44, 54, 65,
38 21, 22, 25, 31, 41, 54, 70, 88,
39 24, 25, 29, 36, 47, 65, 88, 115
43 16, 16, 16, 16, 17, 18, 20, 24,
44 16, 16, 16, 17, 18, 20, 24, 25,
45 16, 16, 17, 18, 20, 24, 25, 28,
46 16, 17, 18, 20, 24, 25, 28, 33,
47 17, 18, 20, 24, 25, 28, 33, 41,
48 18, 20, 24, 25, 28, 33, 41, 54,
49 20, 24, 25, 28, 33, 41, 54, 71,
50 24, 25, 28, 33, 41, 54, 71, 91
124 int delta_rps, abs_delta_rps;
128 if (is_slice_header) {
132 "Invalid value of delta_idx in slice header RPS: %d > %d.\n",
143 delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
150 if (used || use_delta_flag) {
151 if (i < rps_ridx->num_delta_pocs)
152 delta_poc = delta_rps + rps_ridx->
delta_poc[i];
154 delta_poc = delta_rps;
172 for (k = i - 1; k >= 0; k--) {
174 if (delta_poc < tmp) {
198 unsigned int prev, nb_positive_pics;
218 for (i = 0; i < nb_positive_pics; i++) {
247 for (i = 0; i < 32; i++) {
264 PTL *ptl,
int max_num_sub_layers)
270 for (i = 0; i < max_num_sub_layers - 1; i++) {
274 if (max_num_sub_layers - 1 > 0)
275 for (i = max_num_sub_layers - 1; i < 8; i++)
277 for (i = 0; i < max_num_sub_layers - 1; i++) {
286 int subpic_params_present)
290 for (i = 0; i < nb_cpb; i++) {
294 if (subpic_params_present) {
305 int nal_params_present = 0, vcl_params_present = 0;
306 int subpic_params_present = 0;
309 if (common_inf_present) {
313 if (nal_params_present || vcl_params_present) {
316 if (subpic_params_present) {
326 if (subpic_params_present)
335 for (i = 0; i < max_sublayers; i++) {
337 unsigned int nb_cpb = 1;
351 if (nal_params_present)
353 if (vcl_params_present)
436 int common_inf_present = 1;
462 int apply_defdispwin,
HEVCSPS *sps)
473 vui->
sar = vui_sar[sar_idx];
474 else if (sar_idx == 255) {
479 "Unknown SAR index: %u.\n", sar_idx);
526 if (apply_defdispwin &&
529 "discarding vui default display window, " 530 "original values are l:%u r:%u t:%u b:%u\n",
572 for (matrixId = 0; matrixId < 6; matrixId++) {
574 memset(sl->
sl[0][matrixId], 16, 16);
575 sl->
sl_dc[0][matrixId] = 16;
576 sl->
sl_dc[1][matrixId] = 16;
596 uint8_t scaling_list_pred_mode_flag[4][6];
597 int32_t scaling_list_dc_coef[2][6];
598 int size_id, matrix_id, i, pos;
600 for (size_id = 0; size_id < 4; size_id++)
601 for (matrix_id = 0; matrix_id < (size_id == 3 ? 2 : 6); matrix_id++) {
602 scaling_list_pred_mode_flag[size_id][matrix_id] =
get_bits1(gb);
603 if (!scaling_list_pred_mode_flag[size_id][matrix_id]) {
609 if (matrix_id < delta) {
611 "Invalid delta in scaling list data: %d.\n", delta);
615 memcpy(sl->
sl[size_id][matrix_id],
616 sl->
sl[size_id][matrix_id - delta],
617 size_id > 0 ? 64 : 16);
619 sl->
sl_dc[size_id - 2][matrix_id] = sl->
sl_dc[size_id - 2][matrix_id -
delta];
622 int next_coef, coef_num;
623 int32_t scaling_list_delta_coef;
626 coef_num =
FFMIN(64, 1 << (4 + (size_id << 1)));
628 scaling_list_dc_coef[size_id - 2][matrix_id] =
get_se_golomb(gb) + 8;
629 next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
630 sl->
sl_dc[size_id - 2][matrix_id] = next_coef;
632 for (i = 0; i < coef_num; i++) {
641 next_coef = (next_coef + scaling_list_delta_coef + 256) % 256;
642 sl->
sl[size_id][matrix_id][pos] = next_coef;
665 "non-4:2:0 support is currently unspecified.\n");
686 int log2_diff_max_min_transform_block_size;
687 int bit_depth_chroma, start, vui_present, sublayer_ordering_info;
699 if (vps_list && !vps_list[sps->
vps_id]) {
739 sps->
height, 0, avctx)) < 0)
751 "discarding sps conformance window, " 752 "original values are l:%u r:%u t:%u b:%u\n",
768 if (bit_depth_chroma != sps->
bit_depth) {
770 "Luma bit depth (%d) is different from chroma bit depth (%d), " 771 "this is unsupported.\n",
814 if (!sublayer_ordering_info) {
815 for (i = 0; i < start; i++) {
860 "PCM bit depth (%d) is greater than normal bit depth (%d)\n",
899 if (apply_defdispwin) {
909 "chroma samples to preserve alignment.\n",
924 "Displaying the whole video surface.\n");
973 "max transform block size out of range: %d\n",
1008 "Parsed SPS: id %d; coded wxh: %dx%d; " 1009 "cropped wxh: %dx%d; pix_fmt: %s.\n",
1051 int pic_area_in_ctbs, pic_area_in_min_tbs;
1052 int i, j, x, y, ctb_addr_rs, tile_id;
1109 for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
1110 int tb_x = ctb_addr_rs % sps->
ctb_width;
1111 int tb_y = ctb_addr_rs / sps->
ctb_width;
1117 if (tb_x < pps->col_bd[i + 1]) {
1124 if (tb_y < pps->row_bd[i + 1]) {
1130 for (i = 0; i < tile_x; i++)
1132 for (i = 0; i < tile_y; i++)
1136 tb_x - pps->
col_bd[tile_x];
1144 for (y = pps->
row_bd[j]; y < pps->row_bd[j + 1]; y++)
1145 for (x = pps->
col_bd[i]; x < pps->col_bd[i + 1]; x++)
1160 int tb_x = x >> log2_diff;
1161 int tb_y = y >> log2_diff;
1164 for (i = 0; i < log2_diff; i++) {
1166 val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
1180 unsigned int pps_id = 0;
1198 pps->loop_filter_across_tiles_enabled_flag = 1;
1199 pps->num_tile_columns = 1;
1200 pps->num_tile_rows = 1;
1201 pps->uniform_spacing_flag = 1;
1202 pps->disable_dbf = 0;
1203 pps->beta_offset = 0;
1226 pps->dependent_slice_segments_enabled_flag =
get_bits1(gb);
1227 pps->output_flag_present_flag =
get_bits1(gb);
1228 pps->num_extra_slice_header_bits =
get_bits(gb, 3);
1230 pps->sign_data_hiding_flag =
get_bits1(gb);
1232 pps->cabac_init_present_flag =
get_bits1(gb);
1239 pps->constrained_intra_pred_flag =
get_bits1(gb);
1240 pps->transform_skip_enabled_flag =
get_bits1(gb);
1242 pps->cu_qp_delta_enabled_flag =
get_bits1(gb);
1243 pps->diff_cu_qp_delta_depth = 0;
1244 if (pps->cu_qp_delta_enabled_flag)
1248 if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) {
1255 if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) {
1261 pps->pic_slice_level_chroma_qp_offsets_present_flag =
get_bits1(gb);
1263 pps->weighted_pred_flag =
get_bits1(gb);
1264 pps->weighted_bipred_flag =
get_bits1(gb);
1266 pps->transquant_bypass_enable_flag =
get_bits1(gb);
1267 pps->tiles_enabled_flag =
get_bits1(gb);
1268 pps->entropy_coding_sync_enabled_flag =
get_bits1(gb);
1270 if (pps->tiles_enabled_flag) {
1273 if (pps->num_tile_columns == 0 ||
1274 pps->num_tile_columns >= sps->
width) {
1276 pps->num_tile_columns - 1);
1280 if (pps->num_tile_rows == 0 ||
1281 pps->num_tile_rows >= sps->
height) {
1283 pps->num_tile_rows - 1);
1288 pps->column_width =
av_malloc_array(pps->num_tile_columns,
sizeof(*pps->column_width));
1289 pps->row_height =
av_malloc_array(pps->num_tile_rows,
sizeof(*pps->row_height));
1290 if (!pps->column_width || !pps->row_height) {
1295 pps->uniform_spacing_flag =
get_bits1(gb);
1296 if (!pps->uniform_spacing_flag) {
1298 for (i = 0; i < pps->num_tile_columns - 1; i++) {
1300 sum += pps->column_width[i];
1307 pps->column_width[pps->num_tile_columns - 1] = sps->
ctb_width - sum;
1310 for (i = 0; i < pps->num_tile_rows - 1; i++) {
1312 sum += pps->row_height[i];
1319 pps->row_height[pps->num_tile_rows - 1] = sps->
ctb_height - sum;
1321 pps->loop_filter_across_tiles_enabled_flag =
get_bits1(gb);
1324 pps->seq_loop_filter_across_slices_enabled_flag =
get_bits1(gb);
1326 pps->deblocking_filter_control_present_flag =
get_bits1(gb);
1327 if (pps->deblocking_filter_control_present_flag) {
1328 pps->deblocking_filter_override_enabled_flag =
get_bits1(gb);
1330 if (!pps->disable_dbf) {
1333 if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) {
1335 pps->beta_offset/2);
1339 if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) {
1348 pps->scaling_list_data_present_flag =
get_bits1(gb);
1349 if (pps->scaling_list_data_present_flag) {
1355 pps->lists_modification_present_flag =
get_bits1(gb);
1359 pps->log2_parallel_merge_level - 2);
1364 pps->slice_header_extension_present_flag =
get_bits1(gb);
unsigned int log2_min_cb_size
int min_spatial_segmentation_idc
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
int vui_num_ticks_poc_diff_one_minus1
int max_dec_pic_buffering
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
unsigned int * row_height
RowHeight.
int vps_num_ticks_poc_diff_one
vps_num_ticks_poc_diff_one_minus1 + 1
#define MAX_LOG2_CTB_SIZE
#define FF_DEBUG_BITSTREAM
const uint8_t ff_hevc_diag_scan4x4_x[16]
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
int chroma_loc_info_present_flag
static void decode_sublayer_hrd(GetBitContext *gb, unsigned int nb_cpb, int subpic_params_present)
#define FF_ARRAY_ELEMS(a)
int * ctb_addr_ts_to_rs
CtbAddrTSToRS.
static const AVRational vui_sar[]
AVBufferRef * vps_list[MAX_VPS_COUNT]
ShortTermRPS st_rps[MAX_SHORT_TERM_RPS_COUNT]
int chroma_sample_loc_type_top_field
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int restricted_ref_pic_lists_flag
static void remove_vps(HEVCParamSets *s, int id)
unsigned int log2_max_trafo_size
uint8_t profile_compatibility_flag[32]
unsigned int num_negative_pics
uint8_t sub_layer_profile_present_flag[MAX_SUB_LAYERS]
static void remove_pps(HEVCParamSets *s, int id)
static const uint8_t default_scaling_list_inter[]
unsigned int vps_num_reorder_pics[MAX_SUB_LAYERS]
int overscan_info_present_flag
uint8_t vps_timing_info_present_flag
#define AV_CODEC_FLAG_UNALIGNED
Allow decoders to produce frames with data planes that are not aligned to CPU requirements (e...
#define FF_PROFILE_HEVC_MAIN
int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, int apply_defdispwin, AVBufferRef **vps_list, AVCodecContext *avctx)
Parse the SPS from the bitstream into the provided HEVCSPS struct.
unsigned int log2_min_pcm_cb_size
int vps_max_sub_layers
vps_max_temporal_layers_minus1 + 1
int frame_field_info_present_flag
uint8_t loop_filter_disable_flag
static int map_pixel_format(AVCodecContext *avctx, HEVCSPS *sps)
#define FF_PROFILE_HEVC_MAIN_10
int bitstream_restriction_flag
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t frame_only_constraint_flag
#define AV_CODEC_FLAG2_IGNORE_CROP
Discard cropping information from SPS.
unsigned int log2_max_poc_lsb
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int ff_hevc_decode_nal_vps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
int vui_timing_info_present_flag
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define MAX_SHORT_TERM_RPS_COUNT
unsigned int log2_ctb_size
int flags
AV_CODEC_FLAG_*.
int vui_poc_proportional_to_timing_flag
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
uint8_t vps_temporal_id_nesting_flag
int motion_vectors_over_pic_boundaries_flag
uint32_t vps_num_units_in_tick
int vps_num_layer_sets
vps_num_layer_sets_minus1 + 1
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int max_transform_hierarchy_depth_inter
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
uint8_t vps_poc_proportional_to_timing_flag
int num_tile_columns
num_tile_columns_minus1 + 1
AVBufferRef * pps_list[MAX_PPS_COUNT]
#define FF_PROFILE_HEVC_MAIN_STILL_PICTURE
int max_bits_per_min_cu_denom
static void decode_hrd(GetBitContext *gb, int common_inf_present, int max_sublayers)
uint8_t used_by_curr_pic_lt_sps_flag[32]
static void decode_profile_tier_level(GetBitContext *gb, AVCodecContext *avctx, PTLCommon *ptl)
int log2_max_mv_length_vertical
int max_bytes_per_pic_denom
int overscan_appropriate_flag
static void set_default_scaling_list_data(ScalingList *sl)
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
int colour_description_present_flag
uint8_t sub_layer_level_present_flag[MAX_SUB_LAYERS]
enum AVPixelFormat pix_fmt
uint8_t uniform_spacing_flag
static void decode_vui(GetBitContext *gb, AVCodecContext *avctx, int apply_defdispwin, HEVCSPS *sps)
int * ctb_addr_rs_to_ts
CtbAddrRSToTS.
unsigned int log2_min_pu_size
static int scaling_list_data(GetBitContext *gb, AVCodecContext *avctx, ScalingList *sl)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
int log2_max_mv_length_horizontal
uint8_t * data
The data buffer.
uint8_t num_long_term_ref_pics_sps
uint32_t vui_num_units_in_tick
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
#define AV_PIX_FMT_YUV420P10
uint8_t sps_temporal_mvp_enabled_flag
int chroma_sample_loc_type_bottom_field
int num_tile_rows
num_tile_rows_minus1 + 1
static void skip_bits(GetBitContext *s, int n)
static void parse_ptl(GetBitContext *gb, AVCodecContext *avctx, PTL *ptl, int max_num_sub_layers)
const uint8_t ff_hevc_diag_scan8x8_y[64]
rational number numerator/denominator
int vps_num_hrd_parameters
#define MAX_SUB_LAYERS
7.4.2.1
static void hevc_pps_free(void *opaque, uint8_t *data)
unsigned int log2_min_tb_size
uint16_t lt_ref_pic_poc_lsb_sps[32]
int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps)
#define AV_PIX_FMT_YUV420P9
int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, HEVCParamSets *ps, int apply_defdispwin)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
uint8_t scaling_list_enable_flag
static const uint8_t default_scaling_list_intra[]
uint8_t transfer_characteristic
int default_display_window_flag
int size
Size of data in bytes.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
unsigned int log2_diff_max_min_coding_block_size
static void * av_malloc_array(size_t nmemb, size_t size)
unsigned int log2_max_pcm_cb_size
static int setup_pps(AVCodecContext *avctx, GetBitContext *gb, HEVCPPS *pps, HEVCSPS *sps)
int neutra_chroma_indication_flag
int * tile_pos_rs
TilePosRS.
A reference to a data buffer.
int max_transform_hierarchy_depth_intra
coded frame dimension in various units
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
unsigned int * row_bd
RowBd.
unsigned int * col_bd
ColBd.
unsigned int * column_width
ColumnWidth.
int video_full_range_flag
PTLCommon sub_layer_ptl[MAX_SUB_LAYERS]
uint8_t sps_strong_intra_smoothing_enable_flag
int rps_idx_num_delta_pocs
unsigned int vps_max_dec_pic_buffering[MAX_SUB_LAYERS]
uint8_t long_term_ref_pics_present_flag
unsigned int vps_max_latency_increase[MAX_SUB_LAYERS]
int flags2
AV_CODEC_FLAG2_*.
int vui_hrd_parameters_present_flag
unsigned int right_offset
const uint8_t ff_hevc_diag_scan8x8_x[64]
struct HEVCSPS::@21 temporal_layer[MAX_SUB_LAYERS]
static void remove_sps(HEVCParamSets *s, int id)
uint8_t progressive_source_flag
int video_signal_type_present_flag
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
int * min_tb_addr_zs
MinTbAddrZS.
uint8_t non_packed_constraint_flag
int tiles_fixed_structure_flag
uint8_t interlaced_source_flag
AVBufferRef * sps_list[MAX_SPS_COUNT]
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
uint8_t separate_colour_plane_flag
output (i.e. cropped) values
const uint8_t ff_hevc_diag_scan4x4_y[16]
unsigned int bottom_offset
int vps_sub_layer_ordering_info_present_flag