[FFmpeg-devel] [PATCH v4 5/7] avcodec/hevcdec: create AVFrame side data from HEVC timecodes like H.264
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Wed Jun 24 16:43:18 EEST 2020
From: Limin Wang <lance.lmwang at gmail.com>
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
libavcodec/hevcdec.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index c9e28f5..3bdec12 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"
@@ -2808,6 +2809,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;
}
--
1.8.3.1
More information about the ffmpeg-devel
mailing list