27 #include "libavutil/imgutils.h"
31 16, 16, 16, 16, 17, 18, 21, 24,
32 16, 16, 16, 16, 17, 19, 22, 25,
33 16, 16, 17, 18, 20, 22, 25, 29,
34 16, 16, 18, 21, 24, 27, 31, 36,
35 17, 17, 20, 24, 30, 35, 41, 47,
36 18, 19, 22, 27, 35, 44, 54, 65,
37 21, 22, 25, 31, 41, 54, 70, 88,
38 24, 25, 29,36, 47, 65, 88, 115
42 16, 16, 16, 16, 17, 18, 20, 24,
43 16, 16, 16, 17, 18, 20, 24, 25,
44 16, 16, 17, 18, 20, 24, 25, 28,
45 16, 17, 18, 20, 24, 25, 28, 33,
46 17, 18, 20, 24, 25, 28, 33, 41,
47 18, 20, 24, 25, 28, 33, 41, 54,
48 20, 24, 25, 28, 33, 41, 54, 71,
49 24, 25, 28, 33, 41, 54, 71, 91
73 const HEVCSPS *sps,
int is_slice_header)
90 int delta_rps, abs_delta_rps;
94 if (is_slice_header) {
98 "in slice header RPS: %d > %d.\n", delta_idx,
108 delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps;
115 if (used || use_delta_flag) {
116 if (i < rps_ridx->num_delta_pocs)
117 delta_poc = delta_rps + rps_ridx->
delta_poc[i];
119 delta_poc = delta_rps;
137 for (k = i-1 ; k >= 0; k--) {
139 if (delta_poc < tmp ) {
163 unsigned int prev, nb_positive_pics;
183 for (i = 0; i < nb_positive_pics; i++) {
202 for (i = 0; i < 32; i++)
216 for (i = 0; i < max_num_sub_layers - 1; i++) {
220 if (max_num_sub_layers - 1 > 0)
221 for (i = max_num_sub_layers - 1; i < 8; i++)
223 for (i = 0; i < max_num_sub_layers - 1; i++) {
228 for (j = 0; j < 32; j++)
253 for (i = 0; i < nb_cpb; i++) {
257 if (subpic_params_present) {
268 int nal_params_present = 0, vcl_params_present = 0;
269 int subpic_params_present = 0;
272 if (common_inf_present) {
276 if (nal_params_present || vcl_params_present) {
279 if (subpic_params_present) {
289 if (subpic_params_present)
298 for (i = 0; i < max_sublayers; i++) {
314 if (nal_params_present)
316 if (vcl_params_present)
399 int common_inf_present = 1;
430 vui->
sar = vui_sar[sar_idx];
431 else if (sar_idx == 255) {
476 "discarding vui default display window, "
477 "original values are l:%u r:%u t:%u b:%u\n",
519 for (matrixId = 0; matrixId < 6; matrixId++) {
521 memset(sl->
sl[0][matrixId], 16, 16);
522 sl->
sl_dc[0][matrixId] = 16;
523 sl->
sl_dc[1][matrixId] = 16;
544 uint8_t scaling_list_pred_mode_flag[4][6];
545 int32_t scaling_list_dc_coef[2][6];
547 int size_id, matrix_id, i, pos,
delta;
548 for (size_id = 0; size_id < 4; size_id++)
549 for (matrix_id = 0; matrix_id < ((size_id == 3) ? 2 : 6); matrix_id++) {
550 scaling_list_pred_mode_flag[size_id][matrix_id] =
get_bits1(gb);
551 if (!scaling_list_pred_mode_flag[size_id][matrix_id]) {
556 if (matrix_id - delta < 0) {
558 "Invalid delta in scaling list data: %d.\n", delta);
562 memcpy(sl->
sl[size_id][matrix_id],
563 sl->
sl[size_id][matrix_id - delta],
564 size_id > 0 ? 64 : 16);
566 sl->
sl_dc[size_id - 2][matrix_id] = sl->
sl_dc[size_id - 2][matrix_id -
delta];
571 int32_t scaling_list_delta_coef;
574 coef_num =
FFMIN(64, (1 << (4 + (size_id << 1))));
576 scaling_list_dc_coef[size_id - 2][matrix_id] =
get_se_golomb(gb) + 8;
577 next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
578 sl->
sl_dc[size_id - 2][matrix_id] = next_coef;
580 for (i = 0; i < coef_num; i++) {
587 next_coef = (next_coef + scaling_list_delta_coef + 256 ) % 256;
588 sl->
sl[size_id][matrix_id][pos] = next_coef;
602 int log2_diff_max_min_transform_block_size;
603 int bit_depth_chroma,
start, vui_present, sublayer_ordering_info;
670 "discarding sps conformance window, "
671 "original values are l:%u r:%u t:%u b:%u\n",
687 if (bit_depth_chroma != sps->
bit_depth) {
689 "Luma bit depth (%d) is different from chroma bit depth (%d), this is unsupported.\n",
751 if (!sublayer_ordering_info) {
752 for (i = 0; i <
start; i++){
796 "PCM bit depth (%d) is greater than normal bit depth (%d)\n",
845 "chroma samples to preserve alignment.\n",
914 "cropped wxh: %dx%d; pix_fmt: %s.\n",
965 int pic_area_in_ctbs, pic_area_in_min_cbs, pic_area_in_min_tbs;
966 int log2_diff_ctb_min_tb_size;
967 int i, j, x,
y, ctb_addr_rs, tile_id;
1217 for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) {
1218 int tb_x = ctb_addr_rs % sps->
ctb_width;
1219 int tb_y = ctb_addr_rs / sps->
ctb_width;
1225 if (tb_x < pps->col_bd[i + 1]) {
1232 if (tb_y < pps->row_bd[i + 1]) {
1238 for (i = 0; i < tile_x; i++ )
1240 for (i = 0; i < tile_y; i++ )
1244 tb_x - pps->
col_bd[tile_x];
1252 for (y = pps->
row_bd[j]; y < pps->row_bd[j + 1]; y++)
1253 for (x = pps->
col_bd[i]; x < pps->col_bd[i + 1]; x++)
1270 int ctb_addr_rs = sps->
ctb_width * tb_y + tb_x;
1275 val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
1284 int tb_x = x >> log2_diff_ctb_min_tb_size;
1285 int tb_y = y >> log2_diff_ctb_min_tb_size;
1286 int ctb_addr_rs = sps->
ctb_width * tb_y + tb_x;
1288 (log2_diff_ctb_min_tb_size * 2);
1289 for (i = 0; i < log2_diff_ctb_min_tb_size; i++) {
1291 val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0);
VPS * vps_list[MAX_VPS_COUNT]
unsigned int log2_min_cb_size
const char const char void * val
int min_spatial_segmentation_idc
static int decode_profile_tier_level(HEVCLocalContext *lc, PTL *ptl, int max_num_sub_layers)
#define AVERROR_PATCHWELCOME
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
int sub_layer_profile_idc[MAX_SUB_LAYERS]
#define CODEC_FLAG_UNALIGNED
Allow decoders to produce frames with data planes that are not aligned to CPU requirements (e...
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.
#define CODEC_FLAG2_IGNORE_CROP
Discard cropping information from SPS.
int vps_num_ticks_poc_diff_one
vps_num_ticks_poc_diff_one_minus1 + 1
uint8_t weighted_bipred_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.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
uint8_t seq_loop_filter_across_slices_enabled_flag
uint8_t cabac_init_present_flag
int chroma_loc_info_present_flag
int * ctb_addr_ts_to_rs
CtbAddrTSToRS.
int num_ref_idx_l0_default_active
num_ref_idx_l0_default_active_minus1 + 1
static const AVRational vui_sar[]
int vps_num_hrd_parameters
int * row_height
RowHeight.
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.
uint8_t entropy_coding_sync_enabled_flag
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const uint8_t ff_hevc_diag_scan4x4_y[16]
int log2_parallel_merge_level
log2_parallel_merge_level_minus2 + 2
int restricted_ref_pic_lists_flag
unsigned int log2_max_trafo_size
uint8_t sub_layer_profile_present_flag[MAX_SUB_LAYERS]
int * min_cb_addr_zs
MinCbAddrZS.
static const uint8_t default_scaling_list_inter[]
uint8_t sub_layer_profile_compatibility_flags[MAX_SUB_LAYERS][32]
int overscan_info_present_flag
uint32_t vps_num_units_in_tick
#define MAX_LOG2_CTB_SIZE
int num_ref_idx_l1_default_active
num_ref_idx_l1_default_active_minus1 + 1
unsigned int log2_min_pcm_cb_size
int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header)
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.
int frame_field_info_present_flag
int pps_scaling_list_data_present_flag
struct HEVCSPS::@63 temporal_layer[MAX_SUB_LAYERS]
unsigned int vps_num_reorder_pics[MAX_SUB_LAYERS]
uint8_t sub_layer_tier_flag[MAX_SUB_LAYERS]
static void decode_hrd(HEVCContext *s, int common_inf_present, int max_sublayers)
uint8_t loop_filter_disable_flag
static void decode_sublayer_hrd(HEVCContext *s, int nb_cpb, int subpic_params_present)
int bitstream_restriction_flag
uint8_t transquant_bypass_enable_flag
const uint8_t ff_hevc_diag_scan8x8_y[64]
uint8_t vps_temporal_id_nesting_flag
unsigned int vps_max_dec_pic_buffering[MAX_SUB_LAYERS]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
unsigned int log2_max_poc_lsb
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int vps_sub_layer_ordering_info_present_flag
int vui_timing_info_present_flag
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
unsigned int log2_ctb_size
uint8_t vps_poc_proportional_to_timing_flag
int vui_poc_proportional_to_timing_flag
uint8_t general_tier_flag
unsigned int vps_max_latency_increase[MAX_SUB_LAYERS]
#define MAX_SHORT_TERM_RPS_COUNT
int motion_vectors_over_pic_boundaries_flag
uint8_t tiles_enabled_flag
#define FF_ARRAY_ELEMS(a)
uint8_t lists_modification_present_flag
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...
uint8_t * data
The data buffer.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
int max_transform_hierarchy_depth_inter
uint8_t vps_timing_info_present_flag
int num_tile_columns
num_tile_columns_minus1 + 1
int * column_width
ColumnWidth.
AVBufferRef * sps_list[MAX_SPS_COUNT]
int max_bits_per_min_cu_denom
uint8_t cu_qp_delta_enabled_flag
uint8_t used_by_curr_pic_lt_sps_flag[32]
uint8_t sign_data_hiding_flag
uint8_t output_flag_present_flag
int log2_max_mv_length_vertical
const uint8_t ff_hevc_diag_scan8x8_x[64]
int max_bytes_per_pic_denom
static int scaling_list_data(HEVCContext *s, ScalingList *sl)
int overscan_appropriate_flag
static void set_default_scaling_list_data(ScalingList *sl)
AVBufferRef * pps_list[MAX_PPS_COUNT]
const uint8_t ff_hevc_diag_scan4x4_x[16]
uint8_t constrained_intra_pred_flag
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int sps_id
seq_parameter_set_id
uint8_t pic_slice_level_chroma_qp_offsets_present_flag
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
int colour_description_present_flag
uint8_t sub_layer_level_present_flag[MAX_SUB_LAYERS]
enum AVPixelFormat pix_fmt
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
uint8_t transform_skip_enabled_flag
uint8_t uniform_spacing_flag
int * ctb_addr_rs_to_ts
CtbAddrRSToTS.
unsigned int log2_min_pu_size
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int log2_max_mv_length_horizontal
int num_extra_slice_header_bits
#define AV_EF_EXPLODE
abort decoding on minor error detection
uint8_t loop_filter_across_tiles_enabled_flag
int general_profile_compatibility_flag[32]
uint8_t pps_extension_flag
uint8_t num_long_term_ref_pics_sps
uint32_t vui_num_units_in_tick
uint8_t deblocking_filter_control_present_flag
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
uint8_t sps_temporal_mvp_enabled_flag
int chroma_sample_loc_type_bottom_field
int num_tile_rows
num_tile_rows_minus1 + 1
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
static void skip_bits(GetBitContext *s, int n)
rational number numerator/denominator
#define AV_PIX_FMT_YUV420P9
static void hevc_pps_free(void *opaque, uint8_t *data)
unsigned int log2_min_tb_size
#define MAX_SUB_LAYERS
7.4.2.1
uint16_t lt_ref_pic_poc_lsb_sps[32]
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[]
int tc_offset
tc_offset_div2 * 2
uint8_t transfer_characteristic
int default_display_window_flag
HEVCLocalContext * HEVClc
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
int general_profile_space
int sub_layer_profile_space[MAX_SUB_LAYERS]
int neutra_chroma_indication_flag
int * tile_pos_rs
TilePosRS.
static void decode_vui(HEVCContext *s, HEVCSPS *sps)
A reference to a data buffer.
int max_transform_hierarchy_depth_intra
coded frame dimension in various units
uint8_t weighted_pred_flag
uint8_t slice_header_extension_present_flag
int video_full_range_flag
int ff_hevc_decode_nal_sps(HEVCContext *s)
int vps_max_sub_layers
vps_max_temporal_layers_minus1 + 1
uint8_t sps_strong_intra_smoothing_enable_flag
#define AVERROR_INVALIDDATA
int ff_hevc_decode_nal_pps(HEVCContext *s)
int ff_hevc_decode_nal_vps(HEVCContext *s)
#define AV_PIX_FMT_YUV420P10
uint8_t long_term_ref_pics_present_flag
int vui_hrd_parameters_present_flag
int diff_cu_qp_delta_depth
int video_signal_type_present_flag
uint8_t deblocking_filter_override_enabled_flag
int beta_offset
beta_offset_div2 * 2
int * min_tb_addr_zs
MinTbAddrZS.
int sub_layer_level_idc[MAX_SUB_LAYERS]
int vps_num_layer_sets
vps_num_layer_sets_minus1 + 1
int tiles_fixed_structure_flag
uint8_t separate_colour_plane_flag
output (i.e. cropped) values
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define FF_DEBUG_BITSTREAM
uint8_t dependent_slice_segments_enabled_flag