mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avcodec/hevc_sei: support HEVC timecode decode
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
This commit is contained in:
parent
acca2aecb0
commit
78f787c2e7
@ -306,6 +306,53 @@ static int decode_nal_sei_alternative_transfer(HEVCSEIAlternativeTransfer *s, Ge
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int decode_nal_sei_timecode(HEVCSEITimeCode *s, GetBitContext *gb)
|
||||
{
|
||||
s->num_clock_ts = get_bits(gb, 2);
|
||||
|
||||
for (int i = 0; i < s->num_clock_ts; i++) {
|
||||
s->clock_timestamp_flag[i] = get_bits(gb, 1);
|
||||
|
||||
if (s->clock_timestamp_flag[i]) {
|
||||
s->units_field_based_flag[i] = get_bits(gb, 1);
|
||||
s->counting_type[i] = get_bits(gb, 5);
|
||||
s->full_timestamp_flag[i] = get_bits(gb, 1);
|
||||
s->discontinuity_flag[i] = get_bits(gb, 1);
|
||||
s->cnt_dropped_flag[i] = get_bits(gb, 1);
|
||||
|
||||
s->n_frames[i] = get_bits(gb, 9);
|
||||
|
||||
if (s->full_timestamp_flag[i]) {
|
||||
s->seconds_value[i] = av_clip(get_bits(gb, 6), 0, 59);
|
||||
s->minutes_value[i] = av_clip(get_bits(gb, 6), 0, 59);
|
||||
s->hours_value[i] = av_clip(get_bits(gb, 5), 0, 23);
|
||||
} else {
|
||||
s->seconds_flag[i] = get_bits(gb, 1);
|
||||
if (s->seconds_flag[i]) {
|
||||
s->seconds_value[i] = av_clip(get_bits(gb, 6), 0, 59);
|
||||
s->minutes_flag[i] = get_bits(gb, 1);
|
||||
if (s->minutes_flag[i]) {
|
||||
s->minutes_value[i] = av_clip(get_bits(gb, 6), 0, 59);
|
||||
s->hours_flag[i] = get_bits(gb, 1);
|
||||
if (s->hours_flag[i]) {
|
||||
s->hours_value[i] = av_clip(get_bits(gb, 5), 0, 23);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s->time_offset_length[i] = get_bits(gb, 5);
|
||||
if (s->time_offset_length[i] > 0) {
|
||||
s->time_offset_value[i] = get_bits(gb, s->time_offset_length[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s->present = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s,
|
||||
const HEVCParamSets *ps, int type, int size)
|
||||
{
|
||||
@ -330,6 +377,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEI *s,
|
||||
return decode_nal_sei_user_data_unregistered(&s->unregistered, gb, size);
|
||||
case HEVC_SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
|
||||
return decode_nal_sei_alternative_transfer(&s->alternative_transfer, gb);
|
||||
case HEVC_SEI_TYPE_TIME_CODE:
|
||||
return decode_nal_sei_timecode(&s->timecode, gb);
|
||||
default:
|
||||
av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
|
||||
skip_bits_long(gb, 8 * size);
|
||||
|
@ -115,6 +115,26 @@ typedef struct HEVCSEIAlternativeTransfer {
|
||||
int preferred_transfer_characteristics;
|
||||
} HEVCSEIAlternativeTransfer;
|
||||
|
||||
typedef struct HEVCSEITimeCode {
|
||||
int present;
|
||||
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];
|
||||
int32_t time_offset_value[3];
|
||||
} HEVCSEITimeCode;
|
||||
|
||||
typedef struct HEVCSEI {
|
||||
HEVCSEIPictureHash picture_hash;
|
||||
HEVCSEIFramePacking frame_packing;
|
||||
@ -126,6 +146,7 @@ typedef struct HEVCSEI {
|
||||
HEVCSEIContentLight content_light;
|
||||
int active_seq_parameter_set_id;
|
||||
HEVCSEIAlternativeTransfer alternative_transfer;
|
||||
HEVCSEITimeCode timecode;
|
||||
} HEVCSEI;
|
||||
|
||||
struct HEVCParamSets;
|
||||
|
Loading…
Reference in New Issue
Block a user