Commit 7a206564 authored by Mark Thompson's avatar Mark Thompson

cbs_h265: Add a lot more SEI parsing support

Supports both prefix and suffix SEI, decoding all of the common SEI
types and some more obscure ones.  Most of this is tested by the
existing tests in fate.
parent 529debc9
......@@ -490,8 +490,23 @@ static void cbs_h265_free_slice(void *unit, uint8_t *content)
static void cbs_h265_free_sei_payload(H265RawSEIPayload *payload)
{
switch (payload->payload_type) {
case HEVC_SEI_TYPE_BUFFERING_PERIOD:
case HEVC_SEI_TYPE_PICTURE_TIMING:
case HEVC_SEI_TYPE_PAN_SCAN_RECT:
case HEVC_SEI_TYPE_RECOVERY_POINT:
case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS:
case HEVC_SEI_TYPE_DECODED_PICTURE_HASH:
case HEVC_SEI_TYPE_TIME_CODE:
case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO:
case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
break;
case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
av_buffer_unref(&payload->payload.user_data_registered.data_ref);
break;
case HEVC_SEI_TYPE_USER_DATA_UNREGISTERED:
av_buffer_unref(&payload->payload.user_data_unregistered.data_ref);
break;
default:
av_buffer_unref(&payload->payload.other.data_ref);
......@@ -1029,6 +1044,7 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx,
break;
case HEVC_NAL_SEI_PREFIX:
case HEVC_NAL_SEI_SUFFIX:
{
err = ff_cbs_alloc_unit_content(ctx, unit, sizeof(H265RawSEI),
&cbs_h265_free_sei);
......@@ -1036,7 +1052,8 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext *ctx,
if (err < 0)
return err;
err = cbs_h265_read_sei(ctx, &gbc, unit->content);
err = cbs_h265_read_sei(ctx, &gbc, unit->content,
unit->type == HEVC_NAL_SEI_PREFIX);
if (err < 0)
return err;
......@@ -1318,8 +1335,10 @@ static int cbs_h265_write_nal_unit(CodedBitstreamContext *ctx,
break;
case HEVC_NAL_SEI_PREFIX:
case HEVC_NAL_SEI_SUFFIX:
{
err = cbs_h265_write_sei(ctx, pbc, unit->content);
err = cbs_h265_write_sei(ctx, pbc, unit->content,
unit->type == HEVC_NAL_SEI_PREFIX);
if (err < 0)
return err;
......
......@@ -548,6 +548,120 @@ typedef struct H265RawSlice {
AVBufferRef *data_ref;
} H265RawSlice;
typedef struct H265RawSEIBufferingPeriod {
uint8_t bp_seq_parameter_set_id;
uint8_t irap_cpb_params_present_flag;
uint32_t cpb_delay_offset;
uint32_t dpb_delay_offset;
uint8_t concatenation_flag;
uint32_t au_cpb_removal_delay_delta_minus1;
uint32_t nal_initial_cpb_removal_delay[HEVC_MAX_CPB_CNT];
uint32_t nal_initial_cpb_removal_offset[HEVC_MAX_CPB_CNT];
uint32_t nal_initial_alt_cpb_removal_delay[HEVC_MAX_CPB_CNT];
uint32_t nal_initial_alt_cpb_removal_offset[HEVC_MAX_CPB_CNT];
uint32_t vcl_initial_cpb_removal_delay[HEVC_MAX_CPB_CNT];
uint32_t vcl_initial_cpb_removal_offset[HEVC_MAX_CPB_CNT];
uint32_t vcl_initial_alt_cpb_removal_delay[HEVC_MAX_CPB_CNT];
uint32_t vcl_initial_alt_cpb_removal_offset[HEVC_MAX_CPB_CNT];
uint8_t use_alt_cpb_params_flag;
} H265RawSEIBufferingPeriod;
typedef struct H265RawSEIPicTiming {
uint8_t pic_struct;
uint8_t source_scan_type;
uint8_t duplicate_flag;
uint32_t au_cpb_removal_delay_minus1;
uint32_t pic_dpb_output_delay;
uint32_t pic_dpb_output_du_delay;
uint16_t num_decoding_units_minus1;
uint8_t du_common_cpb_removal_delay_flag;
uint32_t du_common_cpb_removal_delay_increment_minus1;
uint16_t num_nalus_in_du_minus1[HEVC_MAX_SLICE_SEGMENTS];
uint32_t du_cpb_removal_delay_increment_minus1[HEVC_MAX_SLICE_SEGMENTS];
} H265RawSEIPicTiming;
typedef struct H265RawSEIPanScanRect {
uint32_t pan_scan_rect_id;
uint8_t pan_scan_rect_cancel_flag;
uint8_t pan_scan_cnt_minus1;
int32_t pan_scan_rect_left_offset[3];
int32_t pan_scan_rect_right_offset[3];
int32_t pan_scan_rect_top_offset[3];
int32_t pan_scan_rect_bottom_offset[3];
uint16_t pan_scan_rect_persistence_flag;
} H265RawSEIPanScanRect;
typedef struct H265RawSEIUserDataRegistered {
uint8_t itu_t_t35_country_code;
uint8_t itu_t_t35_country_code_extension_byte;
uint8_t *data;
size_t data_length;
AVBufferRef *data_ref;
} H265RawSEIUserDataRegistered;
typedef struct H265RawSEIUserDataUnregistered {
uint8_t uuid_iso_iec_11578[16];
uint8_t *data;
size_t data_length;
AVBufferRef *data_ref;
} H265RawSEIUserDataUnregistered;
typedef struct H265RawSEIRecoveryPoint {
int16_t recovery_poc_cnt;
uint8_t exact_match_flag;
uint8_t broken_link_flag;
} H265RawSEIRecoveryPoint;
typedef struct H265RawSEIDisplayOrientation {
uint8_t display_orientation_cancel_flag;
uint8_t hor_flip;
uint8_t ver_flip;
uint16_t anticlockwise_rotation;
uint16_t display_orientation_repetition_period;
uint8_t display_orientation_persistence_flag;
} H265RawSEIDisplayOrientation;
typedef struct H265RawSEIActiveParameterSets {
uint8_t active_video_parameter_set_id;
uint8_t self_contained_cvs_flag;
uint8_t no_parameter_set_update_flag;
uint8_t num_sps_ids_minus1;
uint8_t active_seq_parameter_set_id[HEVC_MAX_SPS_COUNT];
uint8_t layer_sps_idx[HEVC_MAX_LAYERS];
} H265RawSEIActiveParameterSets;
typedef struct H265RawSEIDecodedPictureHash {
uint8_t hash_type;
uint8_t picture_md5[3][16];
uint16_t picture_crc[3];
uint32_t picture_checksum[3];
} H265RawSEIDecodedPictureHash;
typedef struct H265RawSEITimeCode {
uint8_t num_clock_ts;
uint8_t clock_timestamp_flag[3];
uint8_t units_field_based_flag[3];
uint8_t counting_type[3];
uint8_t full_timestamp_flag[3];
uint8_t discontinuity_flag[3];
uint8_t cnt_dropped_flag[3];
uint16_t n_frames[3];
uint8_t seconds_value[3];
uint8_t minutes_value[3];
uint8_t hours_value[3];
uint8_t seconds_flag[3];
uint8_t minutes_flag[3];
uint8_t hours_flag[3];
uint8_t time_offset_length[3];
uint32_t time_offset_value[3];
} H265RawSEITimeCode;
typedef struct H265RawSEIMasteringDisplayColourVolume {
uint16_t display_primaries_x[3];
uint16_t display_primaries_y[3];
......@@ -562,12 +676,28 @@ typedef struct H265RawSEIContentLightLevelInfo {
uint16_t max_pic_average_light_level;
} H265RawSEIContentLightLevelInfo;
typedef struct H265RawSEIAlternativeTransferCharacteristics {
uint8_t preferred_transfer_characteristics;
} H265RawSEIAlternativeTransferCharacteristics;
typedef struct H265RawSEIPayload {
uint32_t payload_type;
uint32_t payload_size;
union {
H265RawSEIBufferingPeriod buffering_period;
H265RawSEIPicTiming pic_timing;
H265RawSEIPanScanRect pan_scan_rect;
H265RawSEIUserDataRegistered user_data_registered;
H265RawSEIUserDataUnregistered user_data_unregistered;
H265RawSEIRecoveryPoint recovery_point;
H265RawSEIDisplayOrientation display_orientation;
H265RawSEIActiveParameterSets active_parameter_sets;
H265RawSEIDecodedPictureHash decoded_picture_hash;
H265RawSEITimeCode time_code;
H265RawSEIMasteringDisplayColourVolume mastering_display;
H265RawSEIContentLightLevelInfo content_light_level;
H265RawSEIAlternativeTransferCharacteristics
alternative_transfer_characteristics;
struct {
uint8_t *data;
size_t data_length;
......
This diff is collapsed.
......@@ -143,6 +143,9 @@ enum {
// A.4.1: table A.6 allows at most 20 tile columns for any level.
HEVC_MAX_TILE_COLUMNS = 20,
// A.4.2: table A.6 allows at most 600 slice segments for any level.
HEVC_MAX_SLICE_SEGMENTS = 600,
// 7.4.7.1: in the worst case (tiles_enabled_flag and
// entropy_coding_sync_enabled_flag are both set), entry points can be
// placed at the beginning of every Ctb row in every tile, giving an
......
......@@ -52,6 +52,7 @@ typedef enum {
HEVC_SEI_TYPE_DECODED_PICTURE_HASH = 132,
HEVC_SEI_TYPE_SCALABLE_NESTING = 133,
HEVC_SEI_TYPE_REGION_REFRESH_INFO = 134,
HEVC_SEI_TYPE_TIME_CODE = 136,
HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO = 137,
HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO = 144,
HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment