diff options
author | Limin Wang <lance.lmwang@gmail.com> | 2020-06-24 14:29:32 +0800 |
---|---|---|
committer | Limin Wang <lance.lmwang@gmail.com> | 2020-06-28 21:00:52 +0800 |
commit | 5151f6d2953d75bd26898b2bd51fe095796c07ad (patch) | |
tree | 1cc9831c41655f1accfa33180ca072ba69e4bb7c | |
parent | 78f787c2e7fdf6416866ba8ca7a5eaff7f0f8c23 (diff) | |
download | ffmpeg-5151f6d2953d75bd26898b2bd51fe095796c07ad.tar.gz |
avcodec/hevcdec: create AVFrame side data from HEVC timecodes like H.264
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
-rw-r--r-- | libavcodec/hevcdec.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index b63cba6c25..e363e68630 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -32,6 +32,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/stereo3d.h" +#include "libavutil/timecode.h" #include "bswapdsp.h" #include "bytestream.h" @@ -2817,6 +2818,29 @@ static int set_side_data(HEVCContext *s) } s->sei.unregistered.nb_buf_ref = 0; + if (s->sei.timecode.present) { + uint32_t *tc_sd; + AVFrameSideData *tcside = av_frame_new_side_data(out, AV_FRAME_DATA_S12M_TIMECODE, + sizeof(uint32_t) * 4); + if (!tcside) + return AVERROR(ENOMEM); + + tc_sd = (uint32_t*)tcside->data; + tc_sd[0] = s->sei.timecode.num_clock_ts; + + for (int i = 0; i < tc_sd[0]; i++) { + int drop = s->sei.timecode.cnt_dropped_flag[i]; + int hh = s->sei.timecode.hours_value[i]; + int mm = s->sei.timecode.minutes_value[i]; + int ss = s->sei.timecode.seconds_value[i]; + int ff = s->sei.timecode.n_frames[i]; + + tc_sd[i + 1] = av_timecode_get_smpte(s->avctx->framerate, drop, hh, mm, ss, ff); + } + + s->sei.timecode.num_clock_ts = 0; + } + return 0; } |